diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 00000000000..10756a01aa0 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,49 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "lpatino10", + "name": "Logan Patino", + "avatar_url": "https://avatars2.githubusercontent.com/u/8710772?v=4", + "profile": "https://www.linkedin.com/in/logan-patino/", + "contributions": [ + "code", + "design", + "bug" + ] + }, + { + "login": "mediumTaj", + "name": "Ajiemar Santiago", + "avatar_url": "https://avatars1.githubusercontent.com/u/4381558?v=4", + "profile": "https://github.com/mediumTaj", + "contributions": [ + "code", + "design", + "bug" + ] + }, + { + "login": "germanattanasio", + "name": "German Attanasio", + "avatar_url": "https://avatars3.githubusercontent.com/u/313157?v=4", + "profile": "https://germanattanasio.com", + "contributions": [ + "code", + "design", + "doc", + "test" + ] + } + ], + "contributorsPerLine": 7, + "projectName": "java-sdk", + "projectOwner": "watson-developer-cloud", + "repoType": "github", + "repoHost": "https://github.com", + "skipCi": true +} diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 78eac6a6927..24d4fd8c2f4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,29 +1,22 @@ [bumpversion] -current_version = 6.1.0 +current_version = 16.1.0 +commit = True +message = Update version numbers from {current_version} -> {new_version} +search = {current_version} +replace = {new_version} [bumpversion:file:README.md] [bumpversion:file:assistant/README.md] -[bumpversion:file:conversation/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] -search = {current_version} -replace = {new_version} +[bumpversion:file:docker/pom.xml] +[bumpversion:file:.github/workflows/deploy.yml] diff --git a/.github/.github/stale.yml b/.github/.github/stale.yml new file mode 100644 index 00000000000..6582de497e6 --- /dev/null +++ b/.github/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - bug + - feature +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 923748e6a3a..ba2daa61be4 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -34,7 +34,7 @@ This Code of Conduct applies both within project spaces and in public spaces whe ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at germanattanasio@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at loganpatino10@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f33a1283229..4736f1db669 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,27 +1,32 @@ -# Questions - -If you are having difficulties using the APIs or have a question about the IBM Watson Services, -please ask a question on [dW Answers][dw] or [Stack Overflow][stackoverflow]. - # Issues If you encounter an issue with the Java SDK, you are welcome to submit a [bug report](https://github.com/watson-developer-cloud/java-sdk/issues). Before that, please search for similar issues. It's possible somebody has encountered this issue already. +# Building and testing +This project uses [Maven] as the build tool (> v1.x). Here are some helpful commands: +```sh +cd java-sdk +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 If you want to contribute to the repository, here's a quick guide: 1. Fork the repository - 1. Create a `.config.properties` similar to [`config.properties`](https://github.com/watson-developer-cloud/java-sdk/blob/master/core/src/test/resources/config.properties). - 2. develop and test your code changes, gradle: `gradle test`. - * Run `checkstyle`: `gradle checkstyle`. 🏁 + 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: `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 4. Commit your changes: - * Use the present tense (`"Add feature"` not `"Added Feature"`) - * Use the imperative mood (`"Move cursor to…"` not `"Moves cursor to…"`) - * Include relevant Emoji from our [Emoji cheatsheet](#emoji-cheatsheet) + * Commits should follow the [Angular commit message guidelines](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines). This is because our release tool uses this format for determining release versions and generating changelogs. To make this easier, we recommend using the [Commitizen CLI](https://github.com/commitizen/cz-cli) with the `cz-conventional-changelog` adapter. 5. Push to your fork and submit a pull request to the **master** branch # Developer's Certificate of Origin 1.1 @@ -50,24 +55,6 @@ By making a contribution to this project, I certify that: maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. -## Emoji Cheatsheet - -When creating creating commits or updating the `CHANGELOG`, please **start** the commit message or update with one of the following applicable Emoji. Emoji should not be used at the start of issue or pull request titles. - -* :new: `:new:` when adding new functionality -* :bug: `:bug:` when fixing a bug -* :memo: `:memo:` when writing documentation -* :art: `:art:` when improving the format/structure of the code -* :fire: `:fire:` when removing code or files -* :racehorse: `:racehorse:` when improving performance -* :white_check_mark: `:white_check_mark:` when adding tests -* :green_heart: `:green_heart:` when fixing the CI build -* :lock: `:lock:` when dealing with security -* :crystal_ball: `:crystal_ball:` when experimenting -* :unamused: `:unamused:` when doing chore work (updating dependencies, etc…) -* :boom: `:boom:` when changing in a non-backwards-compatible way current functionality -* :shipit: `:shipit:` when creating a new release - ## Additional Resources + [General GitHub documentation](https://help.github.com/) + [GitHub pull request documentation](https://help.github.com/send-pull-requests/) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000000..3e991949e71 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,44 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+java). + +Before you open an issue, please check if a similar issue already exists or has been closed before. + +**Check service status** + +1. For service issues or 5xx errors, first, go to the [IBM Cloud status page](https://cloud.ibm.com/status?component=compare-comply%2Cdiscovery%2Cconversation%2Cwatson-vision-combined%2Cnatural-language-understanding%2Cnatural-language-classifier%2Clanguage-translator%2Cpersonality-insights%2Cspeech-to-text%2Ctext-to-speech%2Ctone-analyzer&selected=status) and check the status of the service. +1. If the service status is OK, continue with a bug report. + +--- + +**Overview** +_What is the issue? Be concise and clear._ + +**Expected behavior** +_What did you expect to happen?_ + +**Actual behavior** +_What actually happened?_ + +**How to reproduce** +_Help us to reproduce what you experienced. Include your code snippets (without credentials)_ + +**Screenshots** +_If applicable, add screenshots to help explain your problem._ + +**SDK Version** +_Please provide the SDK version here._ + +**Additional information:** +- OS: _for example, iOS_ +- Which version of `Java` are you using? + +**Additional context** +_Add any other details about the problem._ diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000000..0f47a4dc643 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+java). + +Before you open an issue, please check if a similar issue already exists or has been closed before. + +### When you open an issue for a feature request, please add as much detail as possible: + +- [ ] A descriptive title starting with the service name +- [ ] A description of the problem you're trying to solve +- [ ] A suggested solution if possible diff --git a/.github/bintray-new-version.png b/.github/bintray-new-version.png new file mode 100644 index 00000000000..76850dd9d14 Binary files /dev/null and b/.github/bintray-new-version.png differ diff --git a/.github/bintray-sync.png b/.github/bintray-sync.png new file mode 100644 index 00000000000..13e4dadb327 Binary files /dev/null and b/.github/bintray-sync.png differ diff --git a/.github/bintray-upload-files.png b/.github/bintray-upload-files.png new file mode 100644 index 00000000000..6024c834dae Binary files /dev/null and b/.github/bintray-upload-files.png differ diff --git a/.github/issue_template.md b/.github/issue_template.md index c9c2e173746..c62e3dfece2 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,4 +1,4 @@ -Remember, an issue is not the place to ask questions. You can use [Stack Overflow](http://stackoverflow.com/questions/tagged/ibm-watson) for that, or you may want to start a discussion on the [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson). +Remember, an issue is not the place to ask questions. If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+java). Before you open an issue, please check if a similar issue already exists or has been closed before. diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000000..e3e4aac1495 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,17 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 60 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security +# Label to use when marking an issue as stale +staleLabel: wontfix +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has had no + recent activity. It will be closed if no further activity occurs. Thank you + for your contributions. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false 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..44b8d64f76e --- /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.1.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.1.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 7c7f20ebaaf..220350e7b47 100644 --- a/.gitignore +++ b/.gitignore @@ -5,20 +5,62 @@ .idea .project .settings -build out target bin/ *.iml *.ipr *.iws +config.properties .config.properties .checkstyle .gradletasknamecache docs .swagger-codegen-ignore .vscode/ -conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationTest.java .swagger-codegen/VERSION *.orig -*.rej \ No newline at end of file +*.rej +compare-comply/src/test/resources/compare_comply/cloud-object-storage-credentials-input.json +compare-comply/src/test/resources/compare_comply/cloud-object-storage-credentials-output.json +secrets.tar +package-lock.json +model_result.mlmodel +.openapi-generator-ignore +.openapi-generator/ +package-lock.json +.pre-commit-config.yaml +.secrets.baseline +*.test-metadata.txt +*.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 new file mode 100644 index 00000000000..5fe2ab68c63 --- /dev/null +++ b/.releaserc @@ -0,0 +1,23 @@ +{ + "debug": true, + "branches": [ "master" ], + "tagFormat": "v${version}", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/changelog", + [ + "@semantic-release/exec", + { + "prepareCmd": "bump2version --allow-dirty --current-version ${lastRelease.version} --new-version ${nextRelease.version} patch" + } + ], + [ + "@semantic-release/git", + { + "message": "chore(release): ${nextRelease.version} release notes\n\n${nextRelease.notes}" + } + ], + "@semantic-release/github" + ] +} \ No newline at end of file diff --git a/.secrets.baseline b/.secrets.baseline new file mode 100644 index 00000000000..63e7fc50b13 --- /dev/null +++ b/.secrets.baseline @@ -0,0 +1,122 @@ +{ + "exclude": { + "files": "package-lock.json|credentials.json|^.secrets.baseline$", + "lines": null + }, + "generated_at": "2024-02-26T19:16:17Z", + "plugins_used": [ + { + "name": "AWSKeyDetector" + }, + { + "name": "ArtifactoryDetector" + }, + { + "base64_limit": 4.5, + "name": "Base64HighEntropyString" + }, + { + "name": "BasicAuthDetector" + }, + { + "name": "BoxDetector" + }, + { + "name": "CloudantDetector" + }, + { + "ghe_instance": "github.ibm.com", + "name": "GheDetector" + }, + { + "hex_limit": 3, + "name": "HexHighEntropyString" + }, + { + "name": "IbmCloudIamDetector" + }, + { + "name": "IbmCosHmacDetector" + }, + { + "name": "JwtTokenDetector" + }, + { + "keyword_exclude": null, + "name": "KeywordDetector" + }, + { + "name": "MailchimpDetector" + }, + { + "name": "PrivateKeyDetector" + }, + { + "name": "SlackDetector" + }, + { + "name": "SoftlayerDetector" + }, + { + "name": "StripeDetector" + }, + { + "name": "TwilioKeyDetector" + } + ], + "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 59c4789a68b..02a7a19eae2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,68 +1,78 @@ +--- language: java -sudo: required -dist: precise +dist: xenial +os: linux + jdk: - - oraclejdk7 - - 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/ + - "$HOME/.m2" + env: global: - - secure: S2KIWOJX35j1FczyV7JRFrFpTftb8Hmkf6C50bJh8E03IbPu7tnX2znPKBbRWcIQndO6qd5dL7+BqtXabByOzd5Slj5/NBdXPcGffsO7B0cpFQS8ngpIMAGReCXQ12PbOiO8CIk2f/20lU3L0kqcP1TaPyZYIlSwkUg98ls8p90= - - secure: eLv41LVZoRCqQehOM29RLodZ6NZhrIdLWklAkMdLGlFDEiVY5f0shaPLffpUiuv/3pg+CuQk9ffBc72m8lwTsimex9unC/WVsqQJhqQEWJEaPGL0UamV/HqHMeBQEpKiCcKHaBRHFGk7QQJVtiXvVvlbwk7Jks5giUR7+s/Q6iI= - - secure: l0dde5NSGedD6fny5aMr1ll90FYVd7IKDsZ0Kd1GWnB+iDd3rjDBwz5q6NUwN2LTqw3jWFqmqdEnGUGO3Er0rdfdtPh3K194sTK3XuCZz8GEjFvYAEDRQ59oyK8fhw60c86cWppBQ4gluLKLstm12DLkARTUvJiIsTQTnuc2YGg= - -install: true - -before_install: - - sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml + - MVN_ARGS="--settings build/.travis.settings.xml" -script: - - '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_b248e84a4806_key -iv $encrypted_b248e84a4806_iv -in config.properties.enc -out core/src/test/resources/config.properties -d || true' - - ./gradlew install -x check - - ./gradlew checkstyleMain - - ./gradlew checkstyleTest - - ./gradlew codeCoverageReport --continue - - ./gradlew docs > /dev/null # build the javadoc +stages: + - name: Build and test + - name: Semantic-Release + if: branch = master AND type = push AND fork = false + - name: Publish-Release + if: tag IS present -after_success: - - bash <(curl -s https://codecov.io/bash) +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 -deploy: - - provider: script - script: .utility/push-javadoc-to-gh-pages.sh - skip_cleanup: true - on: - repo: watson-developer-cloud/java-sdk - jdk: oraclejdk7 - tags: true + - 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" - - provider: script - script: .utility/deploy.sh - skip_cleanup: true - on: - repo: watson-developer-cloud/java-sdk - jdk: oraclejdk7 + - 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!" - - provider: releases - api_key: ${GITHUB_TOKEN_RELEASES} - file: java-sdk/build/libs/${TRAVIS_BRANCH}-jar-with-dependencies.jar - skip_cleanup: true - on: - repo: watson-developer-cloud/java-sdk - jdk: oraclejdk7 - tags: true -notifications: - email: true + - 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/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.sh b/.utility/deploy.sh deleted file mode 100755 index 336a80f9b42..00000000000 --- a/.utility/deploy.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -if [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ]; then - openssl aes-256-cbc -K $encrypted_2a8b0f951653_key -iv $encrypted_2a8b0f951653_iv -in .utility/cd/secring.gpg.enc -out .utility/cd/secring.gpg -d - ./gradlew uploadArchives -Psigning.keyId=$SIGNING_KEY -Psigning.password=$SIGNING_PASSWORD -Psigning.secretKeyRingFile=$KEYRING_PATH -PossrhUsername=$OSSRH_JIRA_USERNAME -PossrhPassword=$OSSRH_JIRA_PASSWORD -fi diff --git a/.utility/generate-api-diff.sh b/.utility/generate-api-diff.sh deleted file mode 100755 index ba0ec23c97b..00000000000 --- a/.utility/generate-api-diff.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash -# Author: Hanbin Cho (mraerok@gmail.com) -# Description: This script 1) downloads the latest java-sdk jar published in Maven Repo 2) builds the jar of current java-sdk version, then 3) generate an API diff report of the two versions. -# Assumptions -# 1. This script is placed in .utility folder of the java-sdk. -# 2. Version format is [0-9].[0-9].[0-9] - -# Step 1: Download the latest release of java-sdk published in Maven Repository. -mvn dependency:get \ - -DgroupId=com.ibm.watson.developer_cloud \ - -DartifactId=java-sdk \ - -Dversion=LATEST \ - -Dpackaging=jar \ - -Dclassifier=jar-with-dependencies \ - -Dtransitive=false - -# Step 2: Construct the filepath to the latest release of java-sdk. -LOCAL_MAVEN_REPO_PATH="${HOME}/.m2/repository" -RELEASE_JAR_BASEPATH="${LOCAL_MAVEN_REPO_PATH}/com/ibm/watson/developer_cloud/java-sdk" -pushd $RELEASE_JAR_BASEPATH -LATEST_RELEASE_VERSION=`ls | grep -d read "[0-9]\.[0-9]\.[0-9]" | sort | tail -n 1` -LATEST_RELEASE_JAR_FILENAME="java-sdk-${LATEST_RELEASE_VERSION}-jar-with-dependencies.jar" -LATEST_RELEASE_JAR_PATH="${RELEASE_JAR_BASEPATH}/${LATEST_RELEASE_VERSION}/${LATEST_RELEASE_JAR_FILENAME}" - -# Step 3: Validate the filepath to the latest release of java-sdk. -if [ ! -f $LATEST_RELEASE_JAR_PATH ]; then - echo "apidiff.sh: Latest release jar was not at its expected location at: $LATEST_RELEASE_JAR_PATH" - popd - exit 1 -fi -popd - -# Step 4: Generate a stand-alone jar of the current version of java-sdk. -./gradlew shadowJar - -# Step 5: Construct the filepath to the current version of java-sdk. -CURRENT_VERSION=`cat ../gradle.properties | grep "version=[0-9]\.[0-9]\.[0-9]" | cut -d '=' -f 2` -CURRENT_JAR_FILENAME="java-sdk-${CURRENT_VERSION}-jar-with-dependencies.jar" -CURRENT_JAR_BASEPATH="java-sdk/build/libs" -CURRENT_JAR_PATH="${CURRENT_JAR_BASEPATH}/${CURRENT_JAR_FILENAME}" - -# Step 6: Validate the filepath to the current version of java-sdk. -if [ ! -f $CURRENT_JAR_PATH ]; then - echo "apidiff.sh: Current jar was not at its expected location at: $CURRENT_JAR_PATH" - exit 1 -fi - -# Step 7: Produce an API diff between the latest release and the current version using japicmp module. -./gradlew japicmp -PoldJarPath="${LATEST_RELEASE_JAR_PATH}" -PnewJarPath="${CURRENT_JAR_PATH}" -PoldJarVersion="${LATEST_RELEASE_VERSION}" -PnewJarVersion="${CURRENT_VERSION}" diff --git a/.utility/generate_apidiff_index_html.sh b/.utility/generate_apidiff_index_html.sh deleted file mode 100755 index 3d063655604..00000000000 --- a/.utility/generate_apidiff_index_html.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash - -# based on https://odoepner.wordpress.com/2012/02/17/shell-script-to-generate-simple-index-html/ - -echo ' - - - - - - IBM Watson Developer Cloud - - - -
- -

Info - | Documentation - | API Diff - | GitHub - | Maven -

-

API Diff by version

- -
- - -' diff --git a/.utility/generate_index_html.sh b/.utility/generate_index_html.sh deleted file mode 100755 index 4c8e471ede4..00000000000 --- a/.utility/generate_index_html.sh +++ /dev/null @@ -1,41 +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 - | API Diff - | 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 8b3067ff8b2..00000000000 --- a/.utility/push-javadoc-to-gh-pages.sh +++ /dev/null @@ -1,42 +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 - - # produce API diff of the current version and the latest release - ../.utility/generate-api-diff.sh - rm -rf apidiff/ - mkdir apidiff/ - cp -f ../build/reports/java-sdk-api-diff* apidiff/ - ../.utility/generate_apidiff_index_html.sh > apidiff/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 old mode 100755 new mode 100644 index 0141a356f47..b1d7a7bb880 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,526 @@ -Moved to [https://github.com/watson-developer-cloud/java-sdk/wiki/Changelog](https://github.com/watson-developer-cloud/java-sdk/wiki/Changelog) \ No newline at end of file +# [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) + + +### Bug Fixes + +* **Discovery v1:** environment document count should use 'available' ([0567073](https://github.com/watson-developer-cloud/java-sdk/commit/0567073cc4e0ed3c83cd095ba9e0bc2c43e8925a)) + +# [8.3.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.2.1...v8.3.0) (2020-02-24) + + +### Features + +* **assistant:** generated code ([10108d9](https://github.com/watson-developer-cloud/java-sdk/commit/10108d98767413bc23dfdfc8719e58eec0b1e614)) +* **common:** generated code ([cae0d2c](https://github.com/watson-developer-cloud/java-sdk/commit/cae0d2ce1021e6354abc9a7e8b5c71d0bebd934b)) +* **compare-comply:** generated code ([e03192f](https://github.com/watson-developer-cloud/java-sdk/commit/e03192f8e4dbcc7a1d3ffc7cafac47ce1593ad0f)) +* **discovery:** generated code ([4baea9e](https://github.com/watson-developer-cloud/java-sdk/commit/4baea9eed6cefb3b2d9d8f8986b07266509101e6)) +* **examples:** generated code ([2d93247](https://github.com/watson-developer-cloud/java-sdk/commit/2d932472659bc7b53259028062bcaf857ce98b18)) +* **language-translator:** generated code ([65f5d55](https://github.com/watson-developer-cloud/java-sdk/commit/65f5d5505994a59d10a460bcfbea1c8586366572)) +* **natural-language-classifier:** generated code ([d088954](https://github.com/watson-developer-cloud/java-sdk/commit/d088954520bf9fb8be347212dbe486d629a66341)) +* **natural-language-understanding:** generated code ([5d2dd6d](https://github.com/watson-developer-cloud/java-sdk/commit/5d2dd6d75cb6c07c23dd0765b69e605e0efdd170)) +* **personality-insights:** generated code ([883b971](https://github.com/watson-developer-cloud/java-sdk/commit/883b9717c42466e050d673acbcccff90429889dd)) +* **speech-to-text:** generated code ([d3de7f1](https://github.com/watson-developer-cloud/java-sdk/commit/d3de7f1ef6c16a003f13430207ca23f4c5576789)) +* **text-to-speech:** generated code ([f4548f2](https://github.com/watson-developer-cloud/java-sdk/commit/f4548f2d436157fe43b9bcd0ab129948acc70d26)) +* **tone-analyzer:** generated code ([a753857](https://github.com/watson-developer-cloud/java-sdk/commit/a753857949d42b4a4dc3c5a4b5e6a05861128ee0)) +* **visual-recognition:** generated code ([8d16bf3](https://github.com/watson-developer-cloud/java-sdk/commit/8d16bf3fdc4c7a8715119552dc334336253baa73)) + +## [8.2.1](https://github.com/watson-developer-cloud/java-sdk/compare/v8.2.0...v8.2.1) (2020-01-18) + + +### Bug Fixes + +* **Natural Language Understanding:** Add back model parameter in CategoriesOptions which was mistake ([58111ff](https://github.com/watson-developer-cloud/java-sdk/commit/58111ff5e14dca1cea3e8eaca53404a2a6dbcb85)) + +# [8.2.0](https://github.com/watson-developer-cloud/java-sdk/compare/v8.1.0...v8.2.0) (2020-01-16) + + +### Bug Fixes + +* **Discovery v1:** Ensure collectionIds are supplied to avoid service error ([955742b](https://github.com/watson-developer-cloud/java-sdk/commit/955742b4bd41640a86c8f2eee9b89231068b0654)) +* **Discovery v2:** Ensure all required props are sent to prevent service errors ([aab26b7](https://github.com/watson-developer-cloud/java-sdk/commit/aab26b738cf8c0778afd0fda493147ea49407b75)) + + +### Features + +* **Assistant v2:** Add system prop to MessageContentSkill ([b95388a](https://github.com/watson-developer-cloud/java-sdk/commit/b95388a9196a152a1cc5d86fc5ee803a6389def2)) +* **Speech to Text:** Add endOfPhraseSilenceTime and splitTranscriptAtPhraseEnd props to CreateJobOp ([be54f7f](https://github.com/watson-developer-cloud/java-sdk/commit/be54f7fe80d7eccb8af40912905759202940715f)) +* **Speech to Text:** Add endOfUtterance prop to SpeechRecognitionResult ([42f6ec6](https://github.com/watson-developer-cloud/java-sdk/commit/42f6ec65b1536d578f7464822d94db7639a9df81)) +* **Speech to Text:** Add support for Italian and Dutch models ([6f707da](https://github.com/watson-developer-cloud/java-sdk/commit/6f707da5120a870cc6fa2d84df5f70bfb7993f23)) +* **Text to Speech:** Add Argentinean, Dutch, and Chinese voices ([62259ca](https://github.com/watson-developer-cloud/java-sdk/commit/62259ca1bead8e97bb3a037b39d0699ade5e166a)) + +# [8.1.0](https://github.com/watson-developer-cloud/java-sdk/compare/java-sdk-8.0.1...java-sdk-8.1.0) (2019-11-27) + + +### Bug Fixes + +* **Discovery:** Add GenericQueryAggregation classes ([11f04fb](https://github.com/watson-developer-cloud/java-sdk/commit/11f04fb3329781f1ffc159755086882b7805aff9)) +* **Discovery v1:** Remove incorrectly-defined title prop from QuertResult and QueryNoticesResult ([28d4f5c](https://github.com/watson-developer-cloud/java-sdk/commit/28d4f5c9d08d0ab18cfe41f28fe942b69dc76d35)) +* **Visual Recognition:** Fix incorrectly-defined errors property in Image and ImageDetails ([5ce250b](https://github.com/watson-developer-cloud/java-sdk/commit/5ce250b54fb6705636c494be5bdaf3716fd7e15b)) + + +### Features + +* **Assistant v1:** Add disambiguationOptOut prop to dialog nodes ([38c610c](https://github.com/watson-developer-cloud/java-sdk/commit/38c610c2184b84d1a8350ee30744df147fb4566e)) +* **Assistant v1:** Add offTopic prop to WorkspaceSystemSettings ([34809d3](https://github.com/watson-developer-cloud/java-sdk/commit/34809d3c5175799fca1a100dec6ecf71da411581)) +* **Assistant v1:** Add randomize and maxSuggestions props to WorkspaceSystemSettingsDisambiguation ([8db7136](https://github.com/watson-developer-cloud/java-sdk/commit/8db7136c345bcd333b648b2f506000c99a12811b)) +* **Assistant v1:** Add suggestionTextPolicy prop to WorkspaceSystemSettingsDisambiguation ([2741942](https://github.com/watson-developer-cloud/java-sdk/commit/27419420cc8b150440dbf1758a163b5e5fe3ebca)) +* **Assistant v1:** Add webhook functionality ([252f385](https://github.com/watson-developer-cloud/java-sdk/commit/252f3850fbf0b853d3cf18dda13945a1acf11237)) +* **Discovery v2:** Add custom deserializer for aggregations ([a6dec27](https://github.com/watson-developer-cloud/java-sdk/commit/a6dec27245c7675c1619763bbb874516323c8999)) +* **Discovery v2:** Add initial generation of service ([ac17067](https://github.com/watson-developer-cloud/java-sdk/commit/ac17067ea1493f1afca6d5f813980533af6b4534)) +* **Visual Recognition v4:** Add getTrainingUsage method ([14fefbd](https://github.com/watson-developer-cloud/java-sdk/commit/14fefbd74572d6dcc72e895961a50485697fa166)) +* **Visual Recognition v4:** Add THUMBNAIL size constant to GetJpegImageOptions ([ee3298d](https://github.com/watson-developer-cloud/java-sdk/commit/ee3298d46f86e172a2f92eee8debcab34c35fb47)) + +## [8.0.1](https://github.com/watson-developer-cloud/java-sdk/compare/java-sdk-8.0.0...java-sdk-8.0.1) (2019-11-12) + + +### Bug Fixes + +* Update core dependency to remove unwanted transitive dependencies ([95c759a](https://github.com/watson-developer-cloud/java-sdk/commit/95c759a625187430d09bd564ddc4f73988afbc34)) diff --git a/MIGRATION.md b/MIGRATION.md deleted file mode 100644 index 3249733f932..00000000000 --- a/MIGRATION.md +++ /dev/null @@ -1,97 +0,0 @@ -# 4.0 - -## Conversation - -- No old version dates -- just current -- All methods now take options objects, e.g.: - - ```java - MessageRequest request = new MessageRequest.Builder() - .inputText(message) - .build(); - service.message(workspaceId, request).execute(); - ``` - is now: - - ```java - MessageOptions messageOptions = new MessageOptions.Builder() - .workspaceId(workspaceId) - .input(new InputData.Builder(message).build()) - .build(); - service.message(messageOptions).execute(); - ``` -- `Context` is now a formal class that extends map. -- Many classes have been renamed - mostly dropping "Response" from classnames. - - `EntityResponse` is now `Entity` - - `ExampleResponse` is now `Example` - - `IntentResponse` is now Intent - - `WorkspaceResponse` is now `Workspace` - - _This renaming was done for simplicity and to improve consistency across SDKs going forward._ - -- Counterexample now has its own classes no longer overloaded on Example - -## Tone Analyzer - -- The method `getTone()` was replaced with: `tone()`. - - For example: - - ```java - public ServiceCall getTone(String text, ToneOptions options) - ``` - - Is now: - ```java - public ServiceCall tone(ToneOptions options) - ``` - - `tone()` example: - ```java - ToneOptions toneOptions = new ToneOptions.Builder() - .text(text) - .build(); - ToneAnalysis tone = service.tone(toneOptions).execute(); - ``` - -- The method `getToneChat()` was replaced with: `toneChat()`. - - For example: - - ```java - public ServiceCall getChatTone(ToneChatRequest options) - ``` - - Is now: - - ```java - public ServiceCall chatTone(ToneChatOptions options) { - - ``` - - `chatTone()` example: - ```java - 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(); - ``` \ No newline at end of file diff --git a/README.md b/README.md index 046e6d4f956..ab338ba30cb 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,27 @@ # Watson APIs Java SDK +[![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) +## 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) -[![Slack](https://wdc-slack-inviter.mybluemix.net/badge.svg)](https://wdc-slack-inviter.mybluemix.net) -[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/java-sdk/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.ibm.watson.developer_cloud/java-sdk) -[![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]. -
- 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) - * [API key](#api-key) - * IBM Watson Services - * [Assistant](assistant) - * [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) - * [Using a proxy](#using-a-proxy) - * [Default headers](#default-headers) - * [Sending request headers](#sending-request-headers) - * [Parsing HTTP response info](#parsing-http-response-info) - * [Specifying a service URL](#specifying-a-service-url) - * [401 unauthorized error](#401-unauthorized-error) - * [Changes for v4.0](#changes-for-v40) - * [Debug](#debug) - * [Eclipse and Intellij](#working-with-eclipse-and-intellij-idea) - * [License](#license) - * [Contributing](#contributing) - -
- ## Before you begin * You need an [IBM Cloud][ibm-cloud-onboarding] account. ## Installation ##### Maven - All the services: ```xml - com.ibm.watson.developer_cloud - java-sdk - 6.1.0 + com.ibm.watson + ibm-watson + 16.1.0 ``` @@ -67,54 +29,26 @@ Only Discovery: ```xml - com.ibm.watson.developer_cloud + com.ibm.watson discovery - 6.1.0 + 16.1.0 ``` ##### Gradle - All the services: ```gradle -'com.ibm.watson.developer_cloud:java-sdk:6.1.0' +'com.ibm.watson:ibm-watson:16.1.0' ``` Only Assistant: ```gradle -'com.ibm.watson.developer_cloud:assistant:6.1.0' +'com.ibm.watson:assistant:16.1.0' ``` -##### Development snapshots - -Snapshots of the development version are available in [Sonatype's snapshots repository][sonatype_snapshots]. - -###### Gradle - -Add repository to your project Gradle file - -```gradle -allprojects { - repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } - } -} -``` - -And then reference the snapshot version on your app module gradle -Only Speech to Text: - -```gradle -'com.ibm.watson.developer_cloud:speech-to-text:6.1.1-SNAPSHOT' -``` - -##### 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/developer_cloud). +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 @@ -133,298 +67,435 @@ 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. -- Visual Recognition uses a form of [API key](#api-key) only with instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam). +- 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). ### Getting credentials + To find out which authentication to use, view the service credentials. You find the service credentials for authentication the same way for all Watson services: -1. Go to the IBM Cloud **[Dashboard][watson-dashboard]** page. -1. Either click an existing Watson service instance or click **Create**. -1. Click **Show** to view your service credentials. -1. Copy the `url` and either `apikey` or `username` and `password`. +1. Go to the IBM Cloud [Dashboard](https://cloud.ibm.com/) page. +1. Either click an existing Watson service instance in your [resource list](https://cloud.ibm.com/resources) or click [**Create resource > AI**](https://cloud.ibm.com/catalog?category=ai) and create a service instance. +1. Click on the **Manage** item in the left nav bar of your service instance. + +On this page, you should be able to see your credentials for accessing your service instance. In your code, you can use these values in the service constructor or with a method call after instantiating your service. -### IAM +### Supplying credentials + +There are two ways to supply the credentials you found above to the SDK for authentication. + +#### Credential file (easier!) + +With a credential file, you just need to put the file in the right place and the SDK will do the work of parsing it and authenticating. You can get this file by clicking the **Download** button for the credentials in the **Manage** tab of your service instance. + +The file downloaded will be called `ibm-credentials.env`. This is the name the SDK will search for and **must** be preserved unless you want to configure the file path (more on that later). The SDK will look for your `ibm-credentials.env` file in the following places (in order): + +- Your system's home directory +- The top-level directory of the project you're using the SDK in + +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("2023-03-31"); +``` + +And that's it! + +If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services. + +If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that: + +```bash +export IBM_CREDENTIALS_FILE="" +``` + +where `` is something like `/home/user/Downloads/.env`. + +#### Manually + +If you'd prefer to set authentication values manually in your code, the SDK supports that as well. The way you'll do this depends on what type of credentials your service instance gives you. + +##### IAM Some services use token-based Identity and Access Management (IAM) authentication. IAM authentication uses a service API key to get an access token that is passed with the call. Access tokens are valid for approximately one hour and must be regenerated. 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://console.bluemix.net/docs/services/watson/getting-started-iam.html). If you want to switch to API key, override your stored IAM credentials with an IAM API key. Then call the `setIamCredentials()` method again. +- 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: -#### Supplying the IAM API key ```java -// in the constructor, letting the SDK manage the IAM token -IamOptions options = new IamOptions.Builder() - .apiKey("") - .url("") // optional - the default value is https://iam.bluemix.net/identity/token - .build(); -Discovery service = new Discovery("2017-11-07", options); +// 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 -// after instantiation, letting the SDK manage the IAM token -Discovery service = new Discovery("2017-11-07"); -IamOptions options = new IamOptions.Builder() - .apiKey("") - .build(); -service.setIamCredentials(options); +// letting the SDK manage the IAM token +Authenticator authenticator = new IamAuthenticator(""); +Discovery service = new Discovery("2023-03-31", authenticator); ``` -#### Supplying the access token +Supplying the access token: + ```java -// in the constructor, assuming control of managing IAM token -IamOptions options = new IamOptions.Builder() - .accessToken("") - .build(); -Discovery service = new Discovery("2017-11-07", options); +// assuming control of managing IAM token +Authenticator authenticator = new BearerTokenAuthenticator(""); +Discovery service = new Discovery("2023-03-31", authenticator); ``` +#### Username and password + +Builder pattern approach: + ```java -// after instantiation, assuming control of managing IAM token -Discovery service = new Discovery("2017-11-07"); -IamOptions options = new IamOptions.Builder() - .accessToken("") - .build(); -service.setIamCredentials(options); +Authenticator authenticator = new BasicAuthenticator.Builder() + .username("") + .password("") + .build(); +Discovery service = new Discovery("2023-03-31", authenticator); ``` -### Username and password +Deprecated constructor approach: ```java -// in the constructor -Discovery service = new Discovery("2017-11-07", "", ""); +Authenticator authenticator = new BasicAuthenticator("", ""); +Discovery service = new Discovery("2023-03-31", authenticator); ``` +#### ICP +Authenticating with ICP is similar to the basic username and password method, except that you need to make sure to disable SSL verification to authenticate properly. See [here](#configuring-the-http-client) for more information. + ```java -// after instantiation -Discovery service = new Discovery("2017-11-07"); -service.setUsernameAndPassword("", ""); +Authenticator authenticator = new BasicAuthenticator("", ""); +Discovery service = new Discovery("2023-03-31", authenticator); + +HttpConfigOptions options = new HttpConfigOptions.Builder() + .disableSslVerification(true) + .build(); + +service.configureClient(options); ``` -### API key +#### 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. -**Important**: This type of authentication works only with Visual Recognition instances created before May 23, 2018. Newer instances of Visual Recognition use [IAM](#iam). +Builder pattern approach: ```java -// in the constructor -VisualRecognition service = new VisualRecognition("2016-05-20", ""); +// 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 -// after instantiation -VisualRecognition service = new VisualRecognition("2016-05-20"); -service.setApiKey(""); +// letting the SDK manage the token +Authenticator authenticator = new CloudPakForDataAuthenticator( + "", + "", + "", + true, // disabling SSL verification + null, +); +Discovery service = new Discovery("2023-03-31", authenticator); +service.setServiceUrl(""); ``` -## Android - -The Android SDK utilizes the Java SDK while making some Android-specific additions. This repository can be found [here](https://github.com/watson-developer-cloud/android-sdk). It depends on [OkHttp][] and [gson][]. - -## Using a proxy +```java +// assuming control of managing the access token +Authenticator authenticator = new BearerTokenAuthenticator(""); +Discovery service = new Discovery("2023-03-31", authenticator); +service.setServiceUrl(""); +``` -Override the `configureHttpClient()` method and add the proxy using the `OkHttpClient.Builder` object. +Be sure to both disable SSL verification when authenticating and set the endpoint explicitly to the URL given in Cloud Pak for Data. -For example: +#### 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 -Assistant service = new Assistant("2018-02-16") { - @Override - protected OkHttpClient configureHttpClient() { - Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080)); - return super.configureHttpClient().newBuilder().proxy(proxy).build(); - } -}; +// 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(""); +``` -service.setUsernameAndPassword("", ""); +## Using the SDK -WorkspaceCollection workspaces = service.listWorkspaces().execute(); -System.out.println(workspaces); -``` +### Parsing responses + +No matter which method you use to make an API request (`execute()`, `enqueue()`, or `reactiveRequest()`), you'll get back an object of form `Response`, where `T` is the model representing the specific response model. -For more information see: [OkHTTPClient Proxy authentication how to?](https://stackoverflow.com/a/35567936/456564) +Here's an example of how to parse that response and get additional information beyond the response model: ```java -PersonalityInsights service = new PersonalityInsights("2016-10-19"); -String apiKey = CredentialUtils.getAPIKey(service.getName(), CredentialUtils.PLAN_STANDARD); -service.setApiKey(apiKey); +// listing our workspaces with an instance of the Assistant v1 service +Response response = service.listWorkspaces().execute(); + +// pulling out the specific API method response, which we can manipulate as usual +WorkspaceCollection collection = response.getResult(); +System.out.println("My workspaces: " + collection.getWorkspaces()); + +// grabbing headers that came back with our API response +Headers responseHeaders = response.getHeaders(); +System.out.println("Response header names: " + responseHeaders.names()); ``` -## Sending request headers +### Configuring the HTTP client -Custom headers can be passed with any request. To do so, add the header to the `ServiceCall` object before executing the request. For example, this is what it looks like to send the header `Custom-Header` along with a call to the Watson Assistant service: +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 -WorkspaceCollection workspaces = service.listWorkspaces() - .addHeader("Custom-Header", "custom_value") - .execute(); -``` +Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxyHost", 8080)); +IamAuthenticator authenticator = new IamAuthenticator(apiKey); +authenticator.setProxy(proxy); -## Parsing HTTP response info +Discovery service = new Discovery("2023-03-31", authenticator); -The basic `execute()`, `enqueue()`, and `rx()` methods make HTTP requests to your Watson service and return models based on the requested endpoint. If you would like access to some HTTP response information along with the response model, you can use the more detailed versions of those three methods: `executeWithDetails()`, `enqueueWithDetails()`, and `rxWithDetails()`. To capture the responses, use the new `Response` class, with `T` being the expected response model. +// setting configuration options +HttpConfigOptions options = new HttpConfigOptions.Builder() + .disableSslVerification(true) + .proxy(proxy) + .loggingLevel(HttpConfigOptions.LoggingLevel.BASIC) + .build(); -Here is an example of calling the Watson Assistant `listWorkspaces()` method and parsing its response model as well as the response headers: +service.configureClient(options); +``` -```java -Response response = service.listWorkspaces().executeWithDetails(); +### Making asynchronous API calls -// getting result equivalent to execute() -WorkspaceCollection workspaces = response.getResult(); +The basic, synchronous way to make API calls with this SDK is through the use of the `execute()` method. Using this method looks something like this: +```java +// make API call +Response response = service.listEnvironments().execute(); -// getting returned HTTP headers -Headers responseHeaders = response.getHeaders(); +// continue execution ``` -Note that when using `enqueueWithDetails()`, you must also implement the new `ServiceCallbackWithDetails` interface. For example: +However, if you need to perform these calls in the background, there are two other methods to do this asynchronously: `enqueue()` and `reactiveRequest()`. +#### `enqueue()` + +This method allows you to set a callback for the service response through the use of the `ServiceCallback` object. Here's an example: ```java -service.listWorkspaces().enqueueWithDetails(new ServiceCallbackWithDetails() { +// make API call in the background +service.listEnvironments().enqueue(new ServiceCallback() { @Override - public void onResponse(Response response) { - WorkspaceCollection workspaces = response.getResult(); - Headers responseHeaders = response.getHeaders(); + public void onResponse(Response response) { + System.out.println("We did it! " + response); } @Override - public void onFailure(Exception e) { } + public void onFailure(Exception e) { + System.out.println("Whoops..."); + } }); + +// continue working in the meantime! +``` + +#### `reactiveRequest()` + +If you're a fan of the [RxJava](https://github.com/ReactiveX/RxJava) library, this method lets you leverage that to allow for "reactive" programming. The method will return a `Single` which you can manipulate how you please. Example: +```java +// get stream with request +Single> observableRequest + = service.listEnvironments().reactiveRequest(); + +// make API call in the background +observableRequest + .subscribeOn(Schedulers.single()) + .subscribe(response -> System.out.println("We did it with s~t~r~e~a~m~s! " + response)); + +// continue working in the meantime! ``` -## Default headers +### Default headers Default headers can be specified at any time by using the `setDefaultHeaders(Map headers)` method. The example below sends the `X-Watson-Learning-Opt-Out` header in every request preventing Watson from using the payload to improve the service. ```java -PersonalityInsights service = new PersonalityInsights("2016-10-19"); +PersonalityInsights service = new PersonalityInsights("2017-10-13", new NoAuthAuthenticator()); Map headers = new HashMap(); -headers.put(HttpHeaders.X_WATSON_LEARNING_OPT_OUT, 1); +headers.put(WatsonHttpHeaders.X_WATSON_LEARNING_OPT_OUT, "true"); service.setDefaultHeaders(headers); // All the api calls from now on will send the default headers ``` -## Specifying a service URL +### Sending request headers -You can set the correct API endpoint for your service calling `setEndPoint()`. - -For example, if you have the Discovery service in Germany, the endpoint may be `https://gateway-fra.watsonplatform.net/discovery/api`. - -You will need to call +Custom headers can be passed with any request. To do so, add the header to the `ServiceCall` object before executing the request. For example, this is what it looks like to send the header `Custom-Header` along with a call to the Watson Assistant service: ```java -Discovery service = new Discovery("2017-11-07"); -service.sentEndPoint("https://gateway-fra.watsonplatform.net/discovery/api") +Response workspaces = service.listWorkspaces() + .addHeader("Custom-Header", "custom_value") + .execute(); ``` -## 401 unauthorized error - -Make sure you are using the service credentials and not your IBM Cloud account/password. -Check the API endpoint, you may need to update the default using `setEndPoint()`. +### Canceling requests -## Changes for v4.0 -Version 4.0 focuses on the move to programmatically-generated code for many of the services. See the [changelog](https://github.com/watson-developer-cloud/java-sdk/wiki/Changelog) for the details. This version also includes many breaking changes as a result of standardizing behavior across the new generated services. Full details on migration from previous versions can be found [here](https://github.com/watson-developer-cloud/java-sdk/wiki/Migration). +It's possible that you may want to cancel a request you make to a service. For example, you may set some timeout threshold and just want to cancel an asynchronous if it doesn't respond in time. You can do that by calling the `cancel()` method on your `ServiceCall` object. For example: -## Debug +```java +// time to consider timeout (in ms) +long timeoutThreshold = 3000; -HTTP requests can be logged by adding a `logging.properties` file to your classpath. +// storing ServiceCall object we'll use to list our Assistant v1 workspaces +ServiceCall call = service.listWorkspaces(); -```none -handlers=java.util.logging.ConsoleHandler -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 -# HTTP Logging - Basic -com.ibm.watson.developer_cloud.util.HttpLogging.level=INFO -``` +long startTime = System.currentTimeMillis(); +call.enqueue(new ServiceCallback() { + @Override + public void onResponse(Response response) { + // store the result somewhere + fakeDb.store("my-key", response.getResult()); + } -The configuration above will log only the URL and query parameters for each request. + @Override + public void onFailure(Exception e) { + System.out.println("The request failed :("); + } +}); -For example: +// keep waiting for the call to complete while we're within the timeout bounds +while ((fakeDb.retrieve("my-key") == null) && (System.currentTimeMillis() - startTime < timeoutThreshold)) { + Thread.sleep(500); +} -```none -Mar 30, 2017 7:31:22 PM okhttp3.internal.platform.Platform log -INFO: --> POST https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=false http/1.1 (923-byte body) -Mar 30, 2017 7:31:22 PM okhttp3.internal.platform.Platform log -INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=false (104ms, unknown-length body) -Mar 30, 2017 7:31:23 PM okhttp3.internal.platform.Platform log -INFO: --> POST https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=true http/1.1 (12398-byte body) -Mar 30, 2017 7:31:35 PM okhttp3.internal.platform.Platform log -INFO: <-- 200 OK https://gateway.watsonplatform.net/tradeoff-analytics/api/v1/dilemmas?generate_visualization=true (12311ms, unknown-length body) +// if we timed out and it's STILL not complete, we'll just cancel the call +if (fakeDb.retrieve("my-key") == null) { + call.cancel(); +} ``` -**Warning:** The logs generated by this logger when using the level `FINE` or `ALL` has the potential to leak sensitive information such as "Authorization" or "Cookie" headers and the contents of request and response bodies. This data should only be logged in a controlled way or in a non-production environment. +Doing so will call your `onFailure()` implementation. -## Build + test +### Transaction IDs -To build and test the project you can use [Gradle][] (version 1.x). +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. -Gradle: - -```sh -cd java-sdk -gradle jar # build jar file (build/libs/watson-developer-cloud-6.1.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) +```java +Assistant service = new Assistant("2019-02-28"); +ListWorkspacesOptions options = new ListWorkspacesOptions.Builder().build(); +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); +} 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); +} ``` -## Working with Eclipse and Intellij IDEA +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}"); -If you want to work on the code in an IDE instead of a text editor you can -easily create project files with gradle: +Map headers = new HashMap<>(); +headers.put("X-Global-Transaction-Id", ""); +service.setDefaultHeaders(headers); -```sh -gradle idea # Intellij IDEA -gradle eclipse # Eclipse +MessageOptions options = new MessageOptions.Builder(workspaceId).build(); +MessageResponse result = service.message(options).execute().getResult(); ``` -## Open source @ IBM +## FAQ -Find more open source projects on the [IBM Github Page](http://ibm.github.io/) +### Does this SDK play well with Android? -## License +It does! You should be able to plug this dependency into your Android app without any issue. In addition, we have an Android SDK meant to be used with this library that adds some Android-specific functionality, which you can find [here](https://github.com/watson-developer-cloud/android-sdk). -This library is licensed under Apache 2.0. Full license text is -available in [LICENSE](LICENSE). +### How can I contribute? -## Contributing +Great question (and please do)! You can find contributing information [here](.github/CONTRIBUTING.md). -See [CONTRIBUTING.md](.github/CONTRIBUTING.md). +### Where can I get more help with using Watson APIs? -## Code of conduct +If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+java). -See [CODE_OF_CONDUCT.md](.github/CODE_OF_CONDUCT.md). - -### Other - -If you are having difficulties using the APIs or you have a question about the IBM -Watson Services, please ask a question on -[dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson) -or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson). +### Does IBM have any other open source work? +We do :sunglasses: http://ibm.github.io/ [wdc]: https://www.ibm.com/watson/developer/ -[ibm_cloud]: https://console.bluemix.net -[watson-dashboard]: https://console.bluemix.net/dashboard/apps?category=watson -[Gradle]: http://www.gradle.org/ -[OkHttp]: http://square.github.io/okhttp/ -[gson]: https://github.com/google/gson +[ibm_cloud]: https://cloud.ibm.com [apache_maven]: http://maven.apache.org/ -[sonatype_snapshots]: https://oss.sonatype.org/content/repositories/snapshots/com/ibm/watson/developer_cloud/ -[vcap_services]: https://console.bluemix.net/docs/services/watson/getting-started-variables.html -[ibm-cloud-onboarding]: http://console.bluemix.net/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-Java +[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/v16.1.0/ibm-watson-16.1.0-jar-with-dependencies.jar + +## Contributors ✨ + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + +

Logan Patino

💻 🎨 🐛

Ajiemar Santiago

💻 🎨 🐛

German Attanasio

💻 🎨 📖 ⚠️

Kevin Kowalski

💻 🎨 🐛 📖 ⚠️ 💬️

Jeff Arn

💻 🎨 🐛 📖 ⚠️ 💬️

Angelo Paparazzi

💻 🎨 🐛 📖 ⚠️ 💬️ 🥷🏼
+ + + -[jar]: https://github.com/watson-developer-cloud/java-sdk/releases/download/java-sdk-6.1.0/java-sdk-6.1.0-jar-with-dependencies.jar +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! diff --git a/RELEASE.md b/RELEASE.md index 5e2585d03ce..02e3e8a4a07 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,66 +1,45 @@ -# Release Process +# Release process -* code: https://github.com/watson-developer-cloud/java-sdk -* maven: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22java-sdk%22 +The Java SDK has been configured so that releases should happen **automatically**. -## Guide to uploading artifacts to the Central Repository +If everything goes smoothly, commits to `master` should trigger new package versions using [semantic-release](https://github.com/semantic-release/semantic-release), which bases the release type (major, minor, patch, none) on the commit messages, which should always follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). -We use Sonatype as repository manager, it's used as the input channel for the Central Repository running the Sonatype Open Source Repository Hosting(OSSRH) service. +When new versions are released, the code is pushed to Bintray and synced to Maven Central. The packages can be found [here](https://bintray.com/ibm-cloud-sdks/ibm-cloud-sdk-repo) on Bintray and [here](https://search.maven.org/search?q=com.ibm.watson) on Maven Central. -### Prerequisites +The Javadocs for the new version should also be pushed automatically. Docs are located in the `gh-pages` branch of the repo, and that gets synced to the following GitHub Pages link: http://watson-developer-cloud.github.io/java-sdk/ -If you are not familiar with Sonatype and/or the maven release process please read the following material: +If things **don't** go smoothly, you'll need to follow some other instructions to get things in order. -* Sonatype: http://central.sonatype.org/pages/apache-maven.html -* Releasing artifacts to Sonatype: http://kirang89.github.io/blog/2013/01/20/uploading-your-jar-to-maven-central/ -* Install GPG, and create a public key. More info: http://central.sonatype.org/pages/working-with-pgp-signatures.html +## Fixing broken releases -### Release steps +### Travis timeouts - 1. Update all READMEs to include the new version number +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: - This can be done using [bumpversion]. If necessary, it can be installed with the following command: +- 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%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. - ```bash - pip install bumpversion - ``` + Bintray sync - To then update all version numbers, simply run: +- After doing this with all of the necessary packages, you can verify that things worked by checking the available versions on [Maven Central](https://search.maven.org/search?q=com.ibm.watson). This could take up to an hour. - ```bash - bumpversion major|minor|patch - ``` +### Unsuccessful Bintray deployment - 1. Perform a release deployment to OSSRH (Staging) with: +This case is much more unlikely, since integration tests don't run on `master` and builds are very unlikely to be passing in a PR but fail once it's merged. Nevertheless, if this does happen and files aren't deployed to Bintray, you'll need to follow some steps to do this manually: - ```bash - `gradle release` - ``` +- 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. +- For each package in the SDK, if the new version isn't present, you can add it by navigating to the package and adding it manually: - You will have to answer prompts for versions and tags. That will tag and commit a new version into your repository automatically. + Bintray new version -[bumpversion]: https://pypi.python.org/pypi/bumpversion +- To add the files, make sure to first generate all of the necessary artifacts locally. Check out the new release tag and generate them with the following commands (from the SDK repo): + ``` + git checkout {release tag} + ./gradlew shadowJar + ``` +- In the new version of the package on Bintray, add the files with the "Upload Files" button. Follow the file structure of previous releases to ensure everything works properly. The files to add should be in the `build/libs` folder of each local package in the SDK. -### Manually releasing + Bintray upload files -The above steps should work, but we've run into situations where the archive uploading through CI has failed because IP changes caused multiple staging repositories to be created in Sonatype, each with different pieces of the full set of artifacts. If this happens, the repositories won't be able to be closed and released on the Sonatype website. - -Uploading the archives locally with the following command solves this problem: - -```bash -./gradlew uploadArchives -Psigning.keyId= -Psigning.password= -Psigning.secretKeyRingFile= -PossrhUsername= -PossrhPassword= -``` - -The arguments should be populated with the following: -- `-Psigning.keyId`: The ID of your public key you created after following the link in the prerequisites -- `-Psigning.password`: Your password you created for making public GPG keys -- `-Psigning.secretKeyRingFile`: After creating your public key, you create your keyring file with the following command and use the absolute path to your new file: - -```bash -gpg --export-secret-keys -o .gpg -``` - -- `-PossrhUsername`: Your Sonatype username -- `-PossrhPassword`: Your Sonatype password - -Assuming this command works properly, you should be able to then log into Sonatype and close and release the repository as usual. +- Finally, be sure to sync the artifacts with Maven Central. You can look at the [Travis timeouts](#travis-timeouts) section above for more information on this. diff --git a/appscan/ASOC.sh b/appscan/ASOC.sh new file mode 100644 index 00000000000..7f681691c26 --- /dev/null +++ b/appscan/ASOC.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cd appscan +make generate-irx +make upload-file +make run-scan +cd ../ diff --git a/appscan/Configfile b/appscan/Configfile new file mode 100644 index 00000000000..39749e03f19 --- /dev/null +++ b/appscan/Configfile @@ -0,0 +1,19 @@ +# URLs to the CISO APIs +LOGIN_URL ?= 'https://appscan.ibmcloud.com/api/V2/Account/ApiKeyLogin' +UPLOAD_URL ?= 'https://appscan.ibmcloud.com/api/v2/FileUpload' +GET_APP_URL ?= 'https://appscan.ibmcloud.com/api/V2/Apps?$$$$filter=Name%20eq%20' +STATIC_SCAN_URL ?= 'https://appscan.ibmcloud.com/api/v2/Scans/StaticAnalyzer' +CREATE_APP_URL ?= 'https://appscan.ibmcloud.com/api/V2/Apps' +GET_ASSET_GROUP_URL ?= 'https://appscan.ibmcloud.com/api/V2/AssetGroups' + +APPSCAN_CLIENT_URL ?= https://appscan.ibmcloud.com/api/SCX/StaticAnalyzer/SAClientUtil?os= +OS ?= linux +APPSCAN_TOOL := $(APPSCAN_CLIENT_URL)$(OS) + +GIT_REPO ?= git@github.com:watson-developer-cloud/java-sdk.git + +PROJECT_NAME ?= java-sdk + +# Headers added to curl command +CONTENT_HEADER_JSON := --header 'Content-Type: application/json' +ACCEPT_HEADER_JSON := --header 'Accept: application/json' diff --git a/appscan/Makefile b/appscan/Makefile new file mode 100644 index 00000000000..3a39315a008 --- /dev/null +++ b/appscan/Makefile @@ -0,0 +1,69 @@ +include Configfile + +# This will configure a 32-bit architecture on top of a 64-bit linux machine +config-arch: + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 + +# Gets the ASoC Client Tool and configures it +asoc-tool: config-arch + $(eval DIR := $(shell pwd)) + curl -o $(HOME)/client.zip $(APPSCAN_TOOL) + mkdir $(HOME)/client ; mkdir $(HOME)/tool + unzip -qq $(HOME)/client.zip -d $(HOME)/client + cd $(HOME)/client ; ls | xargs -I {} sh -c "cp -r {}/* $(HOME)/tool" + rm -rf client + +# Clone repo +clone-repo: + git clone $(GIT_REPO) + +# Generates the irx file for icp-cert-manager +generate-irx: + cd $(TRAVIS_BUILD_DIR) + $(HOME)/tool/bin/appscan.sh prepare -oso + +# Login to the AppScan API +api-login: + curl -o $(HOME)/token.json -X POST $(CONTENT_HEADER_JSON) $(ACCEPT_HEADER_JSON) -d '{"KeyId":"$(ASOC_APIKEY)", "KeySecret":"$(ASOC_SECRET)"}' $(LOGIN_URL) + +# Uploads the irx file to the AppScan API +upload-file: api-login + $(eval TOKE := $(shell python getJson.py $(HOME)/token.json "Token")) + $(eval AUTH := --header 'Authorization: Bearer $(TOKE)') + $(eval FILE := fileToUpload=@$(shell pwd)/$(notdir $(shell find $(pwd) -maxdepth 2 -name '*.irx' -print))) + + curl -o $(HOME)/file.json -X POST --header 'Content-Type: multipart/form-data' $(ACCEPT_HEADER_JSON) $(AUTH) -F $(FILE) $(UPLOAD_URL) + +# Checks to see if Cert-Manager-Application already exists. +# TODO: Error with the url, will come back to this later. +get-app: + $(eval TOKE := $(shell python getJson.py $(HOME)/token.json "Token")) + $(eval AUTH := --header 'Authorization: Bearer $(TOKE)') + $(eval URL := $(GET_APP_URL)'$(APP_NAME)''') + + curl -X GET $(ACCEPT_HEADER_JSON) $(AUTH) $(URL) + +# Assume we have an existing application, then we'll simply run the static scan +run-scan: + $(eval TOKE := $(shell python getJson.py $(HOME)/token.json "Token")) + $(eval AUTH := --header 'Authorization: Bearer $(TOKE)') + $(eval FILE_ID := "$(shell python getJson.py $(HOME)/file.json "FileId")") + $(eval APP_ID := "$(shell python getJson.py app.json "Id")") + + curl -X POST $(CONTENT_HEADER_JSON) $(ACCEPT_HEADER_JSON) $(AUTH) -d '{"ARSAFileId": $(FILE_ID), "ApplicationFileId": $(FILE_ID), "ScanName": "$(TRAVIS_TAG):$(TRAVIS_JOB_NUMBER):$(TRAVIS_COMMIT)", "EnableMailNotification": false, "Locale": "en-US", "AppId": $(APP_ID), "Execute": true, "Personal": false}' $(STATIC_SCAN_URL) + +get-asset-group: + $(eval TOKE := $(shell python getJson.py $(HOME)/token.json "Token")) + $(eval AUTH := --header 'Authorization: Bearer $(TOKE)') + + curl -o asset.json -X GET $(ACCEPT_HEADER_JSON) $(AUTH) $(GET_ASSET_GROUP_URL) + +# Create the application only if the application doesn't already exist. +create-app: get-asset-group + $(eval ASSET_GROUP_ID := "$(shell python getJson.py asset.json "Id")") + $(eval TOKE := $(shell python getJson.py $(HOME)/token.json "Token")) + $(eval AUTH := --header 'Authorization: Bearer $(TOKE)') + + curl -o app.json -X POST $(CONTENT_HEADER_JSON) $(ACCEPT_HEADER_JSON) $(AUTH) -d '{"Name": $(APP_NAME), "AssetGroupId": $(ASSET_GROUP_ID), "BusinessImpact": "Unspecified"}' $(CREATE_APP_URL) \ No newline at end of file diff --git a/appscan/app.json b/appscan/app.json new file mode 100644 index 00000000000..583cd3828bb --- /dev/null +++ b/appscan/app.json @@ -0,0 +1,42 @@ +{ + "Id": "de18eee4-bb7e-4326-80dd-e0fd3f1de0bc", + "AssetGroupName": "IBM Watson and Cloud Platform", + "DateCreated": null, + "LastUpdated": null, + "LastComment": null, + "RiskRating": "Unknown", + "CreatedBy": null, + "CriticalIssues": 0, + "HighIssues": 0, + "MediumIssues": 0, + "LowIssues": 0, + "IssuesInProgress": 0, + "MaxSeverity": "Undetermined", + "RR_MaxSeverity": 0, + "NewIssues": 0, + "OpenIssues": 0, + "TotalIssues": 0, + "OverallCompliance": null, + "ComplianceStatuses": [], + "CanBeDeleted": true, + "LockedToSubscription": false, + "Name": "Watson Java SDK", + "AssetGroupId": null, + "BusinessImpact": "Unspecified", + "Url": null, + "Description": null, + "BusinessUnit": null, + "Type": null, + "Technology": null, + "TestingStatus": "NotStarted", + "Hosts": null, + "CollateralDamagePotential": "NotDefined", + "TargetDistribution": "NotDefined", + "ConfidentialityRequirement": "NotDefined", + "IntegrityRequirement": "NotDefined", + "AvailabilityRequirement": "NotDefined", + "Tester": null, + "BusinessOwner": null, + "DevelopmentContact": null, + "PreferredOfferingType": "None" + } diff --git a/appscan/getJson.py b/appscan/getJson.py new file mode 100644 index 00000000000..1fc689422f1 --- /dev/null +++ b/appscan/getJson.py @@ -0,0 +1,22 @@ +import json +import sys + +def main(): + data = load_data() + printFields(data) + +def load_data(): + data = "" + filename = sys.argv[1] + with open(filename, "r") as read: + data = json.load(read) + if isinstance(data, list): + data = data[0] + return data + +def printFields(data): + fields = sys.argv[2:] + for i in fields: + print(data[i]) + +main() diff --git a/assistant/README.md b/assistant/README.md index 868c6478cc2..f56db99efa3 100644 --- a/assistant/README.md +++ b/assistant/README.md @@ -3,59 +3,136 @@ ## Installation ##### Maven + ```xml - com.ibm.watson.developer_cloud + com.ibm.watson assistant - 6.1.0 + 16.1.0 ``` ##### Gradle + ```gradle -'com.ibm.watson.developer_cloud:assistant:6.1.0' +'com.ibm.watson:assistant:16.1.0' ``` ## Usage Use the [Assistant][assistant] service to identify intents, entities, and conduct conversations. +### Using Assistant v1 + ```java -Assistant service = new Assistant("2018-02-16"); -service.setUsernameAndPassword("", ""); +// make sure to use the Assistant v1 import! +import com.ibm.watson.assistant.v1.Assistant; -InputData input = new InputData.Builder("Hi").build(); +Authenticator authenticator = new IamAuthenticator(""); +Assistant service = new Assistant("2019-02-28", authenticator); + +MessageInput input = new MessageInput(); +input.setText("Hi"); MessageOptions options = new MessageOptions.Builder(workspaceId) .input(input) .build(); -MessageResponse response = service.message(options).execute(); +MessageResponse response = service.message(options).execute().getResult(); System.out.println(response); ``` -Moving from Node 1 to Node 2. +Maintaining context across messages: ```java +// make sure to use the Assistant v1 import! +import com.ibm.watson.assistant.v1.Assistant; + Context context = null; +MessageInput input = new MessageInput(); // first message +input.setText("First message"); MessageOptions newMessageOptions = new MessageOptions.Builder() .workspaceId("") - .input(new InputData.Builder("First message").build()) + .input(input) .context(context) .build(); -MessageResponse response = service.message(newMessageOptions).execute(); +MessageResponse response = service.message(newMessageOptions).execute().getResult(); +context = response.getContext(); // second message +input.setText("Second message"); newMessageOptions = new MessageOptions.Builder() .workspaceId("") - .input(new InputData.Builder("Second message").build()) - .context(response.getContext()) // output context from the first message + .input(input) + .context(context) // using context from the first message .build(); -response = service.message(newMessageOptions).execute(); +response = service.message(newMessageOptions).execute().getResult(); System.out.println(response); ``` -[assistant]: https://console.bluemix.net/docs/services/assistant/index.html +--- + +### Using Assistant v2 + +```java +// make sure to use the Assistant v2 import! +import com.ibm.watson.assistant.v2.Assistant; + +Authenticator authenticator = new IamAuthenticator(""); +Assistant service = new Assistant("2019-02-28", authenticator); + +MessageInput input = new MessageInput.Builder() + .text("Hi") + .build(); +MessageOptions messageOptions = new MessageOptions.Builder() + .assistantId("") + .sessionId("") + .input(input) + .build(); +MessageResponse messageResponse = service.message(messageOptions).execute().getResult(); + +System.out.println(messageResponse); +``` + +Maintaining context across messages: + +```java +// make sure to use the Assistant v2 import! +import com.ibm.watson.assistant.v2.Assistant; + +MessageContext context = new MessageContext(); + +// first message +MessageInput input = new MessageInput.Builder() + .text("First message") + .build(); +MessageOptions messageOptions = new MessageOptions.Builder() + .assistantId(assistantId) + .sessionId(sessionId) + .input(input) + .context(context) + .build(); + +MessageResponse messageResponse = service.message(messageOptions).execute().getResult(); +context = messageResponse.getContext(); + +// second message +input = new MessageInput.Builder() + .text("Second message") + .build(); +messageOptions = new MessageOptions.Builder() + .assistantId(assistantId) + .sessionId(sessionId) + .input(input) + .context(context) // using context from first message + .build(); + +messageResponse = service.message(messageOptions).execute().getResult(); + +System.out.println(messageResponse); +``` + +[assistant]: https://cloud.ibm.com/docs/assistant?topic=assistant-index diff --git a/assistant/build.gradle b/assistant/build.gradle deleted file mode 100644 index 7d4d76d802c..00000000000 --- a/assistant/build.gradle +++ /dev/null @@ -1,112 +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' - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'conversation' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Assistant Service' - url 'https://console.bluemix.net/docs/services/assistant/index.html' - - 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' - } - - 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' - } - } - } - } - } -} 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 new file mode 100644 index 00000000000..2c99bedb32f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/Assistant.java @@ -0,0 +1,2765 @@ +/* + * (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. + */ + +/* + * IBM OpenAPI SDK Code Generator Version: 3.97.0-0e90eab1-20241120-170029 + */ + +package com.ibm.watson.assistant.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.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; +import com.ibm.watson.assistant.v1.model.CreateDialogNodeOptions; +import com.ibm.watson.assistant.v1.model.CreateEntityOptions; +import com.ibm.watson.assistant.v1.model.CreateExampleOptions; +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; +import com.ibm.watson.assistant.v1.model.DeleteEntityOptions; +import com.ibm.watson.assistant.v1.model.DeleteExampleOptions; +import com.ibm.watson.assistant.v1.model.DeleteIntentOptions; +import com.ibm.watson.assistant.v1.model.DeleteSynonymOptions; +import com.ibm.watson.assistant.v1.model.DeleteUserDataOptions; +import com.ibm.watson.assistant.v1.model.DeleteValueOptions; +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.Entity; +import com.ibm.watson.assistant.v1.model.EntityCollection; +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; +import com.ibm.watson.assistant.v1.model.GetExampleOptions; +import com.ibm.watson.assistant.v1.model.GetIntentOptions; +import com.ibm.watson.assistant.v1.model.GetSynonymOptions; +import com.ibm.watson.assistant.v1.model.GetValueOptions; +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.ListAllLogsOptions; +import com.ibm.watson.assistant.v1.model.ListCounterexamplesOptions; +import com.ibm.watson.assistant.v1.model.ListDialogNodesOptions; +import com.ibm.watson.assistant.v1.model.ListEntitiesOptions; +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.ListSynonymsOptions; +import com.ibm.watson.assistant.v1.model.ListValuesOptions; +import com.ibm.watson.assistant.v1.model.ListWorkspacesOptions; +import com.ibm.watson.assistant.v1.model.LogCollection; +import com.ibm.watson.assistant.v1.model.MessageOptions; +import com.ibm.watson.assistant.v1.model.MessageResponse; +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&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. + * + *

API Version: 1.0 See: https://cloud.ibm.com/docs/assistant + */ +public class Assistant extends BaseService { + + /** Default service name used when configuring the `Assistant` client. */ + public static final String DEFAULT_SERVICE_NAME = "assistant"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.assistant.watson.cloud.ibm.com"; + + private String version; + + /** + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. + * + * @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 version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + } + + /** + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. + * + * @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 version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. + * + * @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 version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. + * + * @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 version, String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + 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 `2021-11-27`. + * + * @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. + * + *

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. + * + * @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 result of type {@link MessageResponse} + */ + public ServiceCall message(MessageOptions messageOptions) { + 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())); + } + if (messageOptions.intents() != null) { + 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())); + } + 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())); + } + if (messageOptions.output() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Identify intents and entities in multiple user utterances. + * + *

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 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("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"); + 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())); + } + 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. + * + * @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 result of type {@link WorkspaceCollection} + */ + public ServiceCall listWorkspaces() { + return listWorkspaces(null); + } + + /** + * Create workspace. + * + *

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

**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 result of type {@link Workspace} + */ + public ServiceCall createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) { + 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"); + 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()); + } + if (createWorkspaceOptions.description() != null) { + contentJson.addProperty("description", createWorkspaceOptions.description()); + } + 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())); + } + 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())); + } + 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())); + } + if (createWorkspaceOptions.entities() != null) { + 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()); + 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. + * + *

**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 result of type {@link Workspace} + */ + public ServiceCall createWorkspace() { + return createWorkspace(null); + } + + /** + * Get information about a workspace. + * + *

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 result of type {@link Workspace} + */ + public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptions) { + 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())); + } + if (getWorkspaceOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit())); + } + if (getWorkspaceOptions.sort() != null) { + builder.query("sort", String.valueOf(getWorkspaceOptions.sort())); + } + 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. + * + *

**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 result of type {@link Workspace} + */ + public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) { + 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())); + } + if (updateWorkspaceOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(updateWorkspaceOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + if (updateWorkspaceOptions.name() != null) { + contentJson.addProperty("name", updateWorkspaceOptions.name()); + } + if (updateWorkspaceOptions.description() != null) { + contentJson.addProperty("description", updateWorkspaceOptions.description()); + } + 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())); + } + 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())); + } + 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())); + } + if (updateWorkspaceOptions.entities() != null) { + contentJson.add( + "entities", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateWorkspaceOptions.entities())); + } + 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()); + } + 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()); + } + 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); + } + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + 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. + * + * @return a {@link ServiceCall} with a result of type {@link Workspace} + */ + 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); + } + + /** + * 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. + * + * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call + * @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"); + 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", String.valueOf(listIntentsOptions.sort())); + } + if (listIntentsOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create intent. + * + *

Create a new intent. + * + *

If you want to create multiple intents with a single API call, consider using the **[Update + * workspace](#update-workspace)** method instead. + * + * @param createIntentOptions the {@link CreateIntentOptions} containing the options for the call + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("intent", createIntentOptions.intent()); + if (createIntentOptions.description() != null) { + contentJson.addProperty("description", createIntentOptions.description()); + } + if (createIntentOptions.examples() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get intent. + * + *

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 result of type {@link Intent} + */ + public ServiceCall getIntent(GetIntentOptions getIntentOptions) { + 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()); + 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. + * + *

If you want to update multiple intents with a single API call, consider using the **[Update + * workspace](#update-workspace)** method instead. + * + * @param updateIntentOptions the {@link UpdateIntentOptions} containing the options for the call + * @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"); + 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())); + } + if (updateIntentOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(updateIntentOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + if (updateIntentOptions.newIntent() != null) { + contentJson.addProperty("intent", updateIntentOptions.newIntent()); + } + if (updateIntentOptions.newDescription() != null) { + contentJson.addProperty("description", updateIntentOptions.newDescription()); + } + if (updateIntentOptions.newExamples() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete intent. + * + *

Delete an intent from a workspace. + * + * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call + * @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"); + 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); + } + + /** + * List user input examples. + * + *

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 result of type {@link ExampleCollection} + */ + public ServiceCall listExamples(ListExamplesOptions listExamplesOptions) { + 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", String.valueOf(listExamplesOptions.sort())); + } + if (listExamplesOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create user input example. + * + *

Add a new user input example to an intent. + * + *

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 result of type {@link Example} + */ + public ServiceCall createExample(CreateExampleOptions createExampleOptions) { + 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())); + } + builder.bodyJson(contentJson); + 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. + * + * @param getExampleOptions the {@link GetExampleOptions} containing the options for the call + * @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"); + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update 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 + * intent](#update-intent)** method instead. + * + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + if (updateExampleOptions.newText() != null) { + contentJson.addProperty("text", updateExampleOptions.newText()); + } + if (updateExampleOptions.newMentions() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete user input example. + * + *

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 void result + */ + public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions) { + 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); + } + + /** + * List counterexamples. + * + *

List the counterexamples for a workspace. Counterexamples are examples that have been marked + * as irrelevant input. + * + * @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"); + 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", String.valueOf(listCounterexamplesOptions.sort())); + } + if (listCounterexamplesOptions.cursor() != null) { + 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()); + 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. + * + * @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"); + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get counterexample. + * + *

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 result of type {@link Counterexample} + */ + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update counterexample. + * + *

Update the text of a counterexample. Counterexamples are examples that have been marked as + * irrelevant input. + * + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + if (updateCounterexampleOptions.newText() != null) { + contentJson.addProperty("text", updateCounterexampleOptions.newText()); + } + builder.bodyJson(contentJson); + 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. + * + * @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"); + 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); + } + + /** + * List entities. + * + *

List the entities for a workspace. + * + * @param listEntitiesOptions the {@link ListEntitiesOptions} containing the options for the call + * @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"); + 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", String.valueOf(listEntitiesOptions.sort())); + } + if (listEntitiesOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create 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 + * workspace](#update-workspace)** method instead. + * + * @param createEntityOptions the {@link CreateEntityOptions} containing the options for the call + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("entity", createEntityOptions.entity()); + if (createEntityOptions.description() != null) { + contentJson.addProperty("description", createEntityOptions.description()); + } + if (createEntityOptions.metadata() != null) { + 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())); + } + builder.bodyJson(contentJson); + 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. + * + * @param getEntityOptions the {@link GetEntityOptions} containing the options for the call + * @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"); + 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()); + 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. + * + *

If you want to update multiple entities with a single API call, consider using the **[Update + * workspace](#update-workspace)** method instead. + * + * @param updateEntityOptions the {@link UpdateEntityOptions} containing the options for the call + * @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"); + 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())); + } + if (updateEntityOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(updateEntityOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + if (updateEntityOptions.newEntity() != null) { + contentJson.addProperty("entity", updateEntityOptions.newEntity()); + } + if (updateEntityOptions.newDescription() != null) { + contentJson.addProperty("description", updateEntityOptions.newDescription()); + } + if (updateEntityOptions.newMetadata() != null) { + 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())); + } + builder.bodyJson(contentJson); + 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. + * + * @param deleteEntityOptions the {@link DeleteEntityOptions} containing the options for the call + * @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"); + 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); + } + + /** + * 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. + * + * @param listMentionsOptions the {@link ListMentionsOptions} containing the options for the call + * @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"); + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List entity values. + * + *

List the values for an entity. + * + * @param listValuesOptions the {@link ListValuesOptions} containing the options for the call + * @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"); + 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", String.valueOf(listValuesOptions.sort())); + } + if (listValuesOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create entity value. + * + *

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. + * + * @param createValueOptions the {@link CreateValueOptions} containing the options for the call + * @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"); + 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())); + } + 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())); + } + if (createValueOptions.patterns() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get entity value. + * + *

Get information about an entity value. + * + * @param getValueOptions the {@link GetValueOptions} containing the options for the call + * @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"); + 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()); + 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. + * + *

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 result of type {@link Value} + */ + public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { + 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())); + } + if (updateValueOptions.includeAudit() != null) { + builder.query("include_audit", String.valueOf(updateValueOptions.includeAudit())); + } + final JsonObject contentJson = new JsonObject(); + if (updateValueOptions.newValue() != null) { + contentJson.addProperty("value", updateValueOptions.newValue()); + } + if (updateValueOptions.newMetadata() != null) { + 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())); + } + if (updateValueOptions.newPatterns() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete entity value. + * + *

Delete a value from an entity. + * + * @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call + * @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"); + 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); + } + + /** + * List entity value synonyms. + * + *

List the synonyms for an entity value. + * + * @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call + * @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"); + 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", String.valueOf(listSynonymsOptions.sort())); + } + if (listSynonymsOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create entity value synonym. + * + *

Add a new synonym to an entity value. + * + *

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. + * + * @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"); + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get entity value synonym. + * + *

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 result of type {@link Synonym} + */ + public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update entity value synonym. + * + *

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 + * entity](#update-entity)** or **[Update entity value](#update-entity-value)** method instead. + * + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + if (updateSynonymOptions.newSynonym() != null) { + contentJson.addProperty("synonym", updateSynonymOptions.newSynonym()); + } + builder.bodyJson(contentJson); + 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. + * + * @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"); + 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); + } + + /** + * List dialog nodes. + * + *

List the dialog nodes for a workspace. + * + * @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"); + 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", String.valueOf(listDialogNodesOptions.sort())); + } + if (listDialogNodesOptions.cursor() != null) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Create 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. + * + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("dialog_node", createDialogNodeOptions.dialogNode()); + if (createDialogNodeOptions.description() != null) { + contentJson.addProperty("description", createDialogNodeOptions.description()); + } + if (createDialogNodeOptions.conditions() != null) { + contentJson.addProperty("conditions", createDialogNodeOptions.conditions()); + } + if (createDialogNodeOptions.parent() != null) { + contentJson.addProperty("parent", createDialogNodeOptions.parent()); + } + if (createDialogNodeOptions.previousSibling() != null) { + contentJson.addProperty("previous_sibling", createDialogNodeOptions.previousSibling()); + } + if (createDialogNodeOptions.output() != null) { + 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())); + } + if (createDialogNodeOptions.metadata() != null) { + 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())); + } + if (createDialogNodeOptions.title() != null) { + contentJson.addProperty("title", createDialogNodeOptions.title()); + } + if (createDialogNodeOptions.type() != null) { + contentJson.addProperty("type", createDialogNodeOptions.type()); + } + if (createDialogNodeOptions.eventName() != null) { + contentJson.addProperty("event_name", createDialogNodeOptions.eventName()); + } + if (createDialogNodeOptions.variable() != null) { + contentJson.addProperty("variable", createDialogNodeOptions.variable()); + } + if (createDialogNodeOptions.actions() != null) { + contentJson.add( + "actions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(createDialogNodeOptions.actions())); + } + if (createDialogNodeOptions.digressIn() != null) { + contentJson.addProperty("digress_in", createDialogNodeOptions.digressIn()); + } + if (createDialogNodeOptions.digressOut() != null) { + contentJson.addProperty("digress_out", createDialogNodeOptions.digressOut()); + } + if (createDialogNodeOptions.digressOutSlots() != null) { + contentJson.addProperty("digress_out_slots", createDialogNodeOptions.digressOutSlots()); + } + if (createDialogNodeOptions.userLabel() != null) { + contentJson.addProperty("user_label", createDialogNodeOptions.userLabel()); + } + if (createDialogNodeOptions.disambiguationOptOut() != null) { + contentJson.addProperty( + "disambiguation_opt_out", createDialogNodeOptions.disambiguationOptOut()); + } + builder.bodyJson(contentJson); + 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. + * + * @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"); + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update dialog node. + * + *

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. + * + * @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"); + 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())); + } + final JsonObject contentJson = new JsonObject(); + if (updateDialogNodeOptions.newDialogNode() != null) { + contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode()); + } + if (updateDialogNodeOptions.newDescription() != null) { + contentJson.addProperty("description", updateDialogNodeOptions.newDescription()); + } + if (updateDialogNodeOptions.newConditions() != null) { + contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions()); + } + if (updateDialogNodeOptions.newParent() != null) { + contentJson.addProperty("parent", updateDialogNodeOptions.newParent()); + } + if (updateDialogNodeOptions.newPreviousSibling() != null) { + contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling()); + } + if (updateDialogNodeOptions.newOutput() != null) { + 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())); + } + if (updateDialogNodeOptions.newMetadata() != null) { + 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())); + } + if (updateDialogNodeOptions.newTitle() != null) { + contentJson.addProperty("title", updateDialogNodeOptions.newTitle()); + } + if (updateDialogNodeOptions.newType() != null) { + contentJson.addProperty("type", updateDialogNodeOptions.newType()); + } + if (updateDialogNodeOptions.newEventName() != null) { + contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName()); + } + if (updateDialogNodeOptions.newVariable() != null) { + contentJson.addProperty("variable", updateDialogNodeOptions.newVariable()); + } + if (updateDialogNodeOptions.newActions() != null) { + contentJson.add( + "actions", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateDialogNodeOptions.newActions())); + } + if (updateDialogNodeOptions.newDigressIn() != null) { + contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn()); + } + if (updateDialogNodeOptions.newDigressOut() != null) { + contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut()); + } + if (updateDialogNodeOptions.newDigressOutSlots() != null) { + contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots()); + } + if (updateDialogNodeOptions.newUserLabel() != null) { + contentJson.addProperty("user_label", updateDialogNodeOptions.newUserLabel()); + } + if (updateDialogNodeOptions.newDisambiguationOptOut() != null) { + contentJson.addProperty( + "disambiguation_opt_out", updateDialogNodeOptions.newDisambiguationOptOut()); + } + builder.bodyJson(contentJson); + 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. + * + * @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"); + 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); + } + + /** + * List log events in a workspace. + * + *

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

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("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", 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); + } + + /** + * List log events in all workspaces. + * + *

List the events from the logs of all workspaces in the service instance. + * + *

**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 result of type {@link LogCollection} + */ + public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOptions) { + 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("version", String.valueOf(this.version)); + builder.query("filter", String.valueOf(listAllLogsOptions.filter())); + if (listAllLogsOptions.sort() != null) { + 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", String.valueOf(listAllLogsOptions.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 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 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(), "/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("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 new file mode 100644 index 00000000000..939e5f580ac --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CaptureGroup.java @@ -0,0 +1,139 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** A recognized capture group for a pattern-based entity. */ +public class CaptureGroup extends GenericModel { + + protected String group; + protected List location; + + /** 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 with required properties. + * + * @param group the group + */ + public Builder(String group) { + this.group = group; + } + + /** + * Builds a CaptureGroup. + * + * @return the new CaptureGroup instance + */ + public CaptureGroup build() { + return new CaptureGroup(this); + } + + /** + * Adds a new element to 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"); + if (this.location == null) { + this.location = new ArrayList(); + } + this.location.add(location); + return this; + } + + /** + * Set the group. + * + * @param group the group + * @return the CaptureGroup builder + */ + public Builder group(String group) { + this.group = group; + return this; + } + + /** + * Set the location. Existing location will be replaced. + * + * @param location the location + * @return the CaptureGroup builder + */ + public Builder location(List location) { + this.location = location; + return this; + } + } + + protected CaptureGroup() {} + + protected CaptureGroup(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, "group cannot be null"); + group = builder.group; + location = builder.location; + } + + /** + * New builder. + * + * @return a CaptureGroup builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the group. + * + *

A recognized capture group for the entity. + * + * @return the group + */ + public String group() { + return group; + } + + /** + * Gets the location. + * + *

Zero-based character offsets that indicate where the entity value begins and ends in the + * input text. + * + * @return the location + */ + public List location() { + return 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 new file mode 100644 index 00000000000..6b3c1d60a6c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Context.java @@ -0,0 +1,202 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. + * + *

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 Map system; + + @SerializedName("metadata") + protected MessageContextMetadata metadata; + + public Context() { + 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 conversation ID cannot contain any of the + * following characters: `+` `=` `&&` `||` `>` `<` `!` `(` `)` `{` `}` `[` `]` `^` + * `"` `~` `*` `?` `:` `\` `/`. + * + * @return the conversationId + */ + public String getConversationId() { + return this.conversationId; + } + + /** + * Sets the conversationId. + * + * @param conversationId the new conversationId + */ + public void setConversationId(final String conversationId) { + this.conversationId = conversationId; + } + + /** + * Gets the system. + * + *

For internal use only. + * + * @return the system + */ + public Map getSystem() { + return this.system; + } + + /** + * Sets the system. + * + * @param system the new system + */ + public void setSystem(final Map system) { + this.system = system; + } + + /** + * Gets the metadata. + * + *

Metadata related to the message. + * + * @return the metadata + */ + public MessageContextMetadata getMetadata() { + return this.metadata; + } + + /** + * Sets the metadata. + * + * @param metadata the new metadata + */ + public void setMetadata(final MessageContextMetadata metadata) { + this.metadata = 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 new file mode 100644 index 00000000000..df36b2032fa --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Counterexample.java @@ -0,0 +1,122 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Counterexample. */ +public class Counterexample extends GenericModel { + + protected String text; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String text; + + /** + * 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; + } + + /** 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 Counterexample. + * + * @return the new Counterexample instance + */ + public Counterexample build() { + return new Counterexample(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the Counterexample builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected Counterexample() {} + + protected Counterexample(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + } + + /** + * New builder. + * + * @return a Counterexample builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * 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/v1/model/CounterexampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java new file mode 100644 index 00000000000..2b07cced728 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CounterexampleCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. + * + * @return the counterexamples + */ + public List getCounterexamples() { + return counterexamples; + } + + /** + * 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/v1/model/CreateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java new file mode 100644 index 00000000000..27b3a9e92d4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateCounterexampleOptions.java @@ -0,0 +1,165 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class CreateCounterexampleOptions extends GenericModel { + + protected String workspaceId; + protected String text; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param text the text + */ + public Builder(String workspaceId, String text) { + this.workspaceId = workspaceId; + this.text = text; + } + + /** + * Builds a CreateCounterexampleOptions. + * + * @return the new CreateCounterexampleOptions instance + */ + public CreateCounterexampleOptions build() { + return new CreateCounterexampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateCounterexampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the CreateCounterexampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateCounterexampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the counterexample. + * + * @param counterexample the counterexample + * @return the CreateCounterexampleOptions builder + */ + public Builder counterexample(Counterexample counterexample) { + this.text = counterexample.text(); + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + text = builder.text; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateCounterexampleOptions 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 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. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * 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/CreateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java new file mode 100644 index 00000000000..af160c90612 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateDialogNodeOptions.java @@ -0,0 +1,754 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 createDialogNode options. */ +public class CreateDialogNodeOptions 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"; + } + + protected String workspaceId; + protected String dialogNode; + protected String description; + protected String conditions; + protected String parent; + protected String previousSibling; + protected DialogNodeOutput output; + protected DialogNodeContext context; + protected Map metadata; + protected DialogNodeNextStep nextStep; + protected String title; + protected String type; + protected String eventName; + protected String variable; + protected List actions; + protected String digressIn; + protected String digressOut; + protected String digressOutSlots; + protected String userLabel; + protected Boolean disambiguationOptOut; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + 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 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; + this.description = createDialogNodeOptions.description; + this.conditions = createDialogNodeOptions.conditions; + this.parent = createDialogNodeOptions.parent; + this.previousSibling = createDialogNodeOptions.previousSibling; + this.output = createDialogNodeOptions.output; + this.context = createDialogNodeOptions.context; + this.metadata = createDialogNodeOptions.metadata; + this.nextStep = createDialogNodeOptions.nextStep; + this.title = createDialogNodeOptions.title; + this.type = createDialogNodeOptions.type; + this.eventName = createDialogNodeOptions.eventName; + this.variable = createDialogNodeOptions.variable; + this.actions = createDialogNodeOptions.actions; + this.digressIn = createDialogNodeOptions.digressIn; + this.digressOut = createDialogNodeOptions.digressOut; + this.digressOutSlots = createDialogNodeOptions.digressOutSlots; + this.userLabel = createDialogNodeOptions.userLabel; + this.disambiguationOptOut = createDialogNodeOptions.disambiguationOptOut; + this.includeAudit = createDialogNodeOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + */ + public Builder(String workspaceId, String dialogNode) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + } + + /** + * Builds a CreateDialogNodeOptions. + * + * @return the new CreateDialogNodeOptions instance + */ + public CreateDialogNodeOptions build() { + return new CreateDialogNodeOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.actions == null) { + this.actions = new ArrayList(); + } + this.actions.add(actions); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateDialogNodeOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the CreateDialogNodeOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateDialogNodeOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the conditions. + * + * @param conditions the conditions + * @return the CreateDialogNodeOptions builder + */ + public Builder conditions(String conditions) { + this.conditions = conditions; + return this; + } + + /** + * Set the parent. + * + * @param parent the parent + * @return the CreateDialogNodeOptions builder + */ + public Builder parent(String parent) { + this.parent = parent; + return this; + } + + /** + * Set the previousSibling. + * + * @param previousSibling the previousSibling + * @return the CreateDialogNodeOptions builder + */ + public Builder previousSibling(String previousSibling) { + this.previousSibling = previousSibling; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the CreateDialogNodeOptions builder + */ + public Builder output(DialogNodeOutput output) { + this.output = output; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the CreateDialogNodeOptions builder + */ + public Builder context(DialogNodeContext context) { + this.context = context; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateDialogNodeOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the nextStep. + * + * @param nextStep the nextStep + * @return the CreateDialogNodeOptions builder + */ + public Builder nextStep(DialogNodeNextStep nextStep) { + this.nextStep = nextStep; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the CreateDialogNodeOptions builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateDialogNodeOptions builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the eventName. + * + * @param eventName the eventName + * @return the CreateDialogNodeOptions builder + */ + public Builder eventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * Set the variable. + * + * @param variable the variable + * @return the CreateDialogNodeOptions 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 CreateDialogNodeOptions builder + */ + public Builder actions(List actions) { + this.actions = actions; + return this; + } + + /** + * Set the digressIn. + * + * @param digressIn the digressIn + * @return the CreateDialogNodeOptions builder + */ + public Builder digressIn(String digressIn) { + this.digressIn = digressIn; + return this; + } + + /** + * Set the digressOut. + * + * @param digressOut the digressOut + * @return the CreateDialogNodeOptions builder + */ + public Builder digressOut(String digressOut) { + this.digressOut = digressOut; + return this; + } + + /** + * Set the digressOutSlots. + * + * @param digressOutSlots the digressOutSlots + * @return the CreateDialogNodeOptions builder + */ + public Builder digressOutSlots(String digressOutSlots) { + this.digressOutSlots = digressOutSlots; + return this; + } + + /** + * Set the userLabel. + * + * @param userLabel the userLabel + * @return the CreateDialogNodeOptions builder + */ + public Builder userLabel(String userLabel) { + this.userLabel = userLabel; + return this; + } + + /** + * Set the disambiguationOptOut. + * + * @param disambiguationOptOut the disambiguationOptOut + * @return the CreateDialogNodeOptions builder + */ + public Builder disambiguationOptOut(Boolean disambiguationOptOut) { + this.disambiguationOptOut = disambiguationOptOut; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateDialogNodeOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the CreateDialogNodeOptions builder + */ + public Builder dialogNode(DialogNode dialogNode) { + this.dialogNode = dialogNode.dialogNode(); + this.description = dialogNode.description(); + this.conditions = dialogNode.conditions(); + this.parent = dialogNode.parent(); + this.previousSibling = dialogNode.previousSibling(); + this.output = dialogNode.output(); + this.context = dialogNode.context(); + this.metadata = dialogNode.metadata(); + this.nextStep = dialogNode.nextStep(); + this.title = dialogNode.title(); + this.type = dialogNode.type(); + this.eventName = dialogNode.eventName(); + this.variable = dialogNode.variable(); + this.actions = dialogNode.actions(); + this.digressIn = dialogNode.digressIn(); + this.digressOut = dialogNode.digressOut(); + this.digressOutSlots = dialogNode.digressOutSlots(); + this.userLabel = dialogNode.userLabel(); + this.disambiguationOptOut = dialogNode.disambiguationOptOut(); + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + 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; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateDialogNodeOptions 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 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 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/CreateEntity.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java new file mode 100644 index 00000000000..26146110516 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntity.java @@ -0,0 +1,250 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. */ + public static class Builder { + private String entity; + private String description; + private Map metadata; + private Boolean fuzzyMatch; + 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.values = createEntity.values; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param entity the entity + */ + public Builder(String entity) { + this.entity = entity; + } + + /** + * Builds a CreateEntity. + * + * @return the new CreateEntity instance + */ + public CreateEntity build() { + return new CreateEntity(this); + } + + /** + * Adds a new element to 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"); + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(values); + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the CreateEntity builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateEntity builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateEntity builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the fuzzyMatch. + * + * @param fuzzyMatch the fuzzyMatch + * @return the CreateEntity builder + */ + public Builder fuzzyMatch(Boolean fuzzyMatch) { + this.fuzzyMatch = fuzzyMatch; + return this; + } + + /** + * Set the values. Existing values will be replaced. + * + * @param values the values + * @return the CreateEntity builder + */ + public Builder values(List values) { + this.values = values; + return this; + } + } + + protected CreateEntity() {} + + protected CreateEntity(Builder builder) { + 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; + values = builder.values; + } + + /** + * New builder. + * + * @return a CreateEntity builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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 + * that you want to enable. (Any entity content specified with the request is ignored.). + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the description. + * + *

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

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

Whether to use fuzzy matching for the entity. + * + * @return the fuzzyMatch + */ + public Boolean fuzzyMatch() { + return fuzzyMatch; + } + + /** + * 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; + } + + /** + * Gets the values. + * + *

An array of objects describing the entity values. + * + * @return the values + */ + public List values() { + return 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 new file mode 100644 index 00000000000..b27c226a16b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateEntityOptions.java @@ -0,0 +1,278 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 createEntity options. */ +public class CreateEntityOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String description; + protected Map metadata; + protected Boolean fuzzyMatch; + protected List values; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String description; + private Map metadata; + private Boolean fuzzyMatch; + 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; + this.description = createEntityOptions.description; + this.metadata = createEntityOptions.metadata; + this.fuzzyMatch = createEntityOptions.fuzzyMatch; + this.values = createEntityOptions.values; + this.includeAudit = createEntityOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a CreateEntityOptions. + * + * @return the new CreateEntityOptions instance + */ + public CreateEntityOptions build() { + return new CreateEntityOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(values); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateEntityOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the CreateEntityOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateEntityOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateEntityOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the fuzzyMatch. + * + * @param fuzzyMatch the fuzzyMatch + * @return the CreateEntityOptions builder + */ + public Builder fuzzyMatch(Boolean fuzzyMatch) { + this.fuzzyMatch = fuzzyMatch; + return this; + } + + /** + * Set the values. Existing values will be replaced. + * + * @param values the values + * @return the CreateEntityOptions builder + */ + public Builder values(List values) { + this.values = values; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateEntityOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + description = builder.description; + metadata = builder.metadata; + fuzzyMatch = builder.fuzzyMatch; + values = builder.values; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateEntityOptions 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 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 + */ + public String entity() { + return entity; + } + + /** + * Gets the description. + * + *

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

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

Whether to use fuzzy matching for the entity. + * + * @return the fuzzyMatch + */ + public Boolean fuzzyMatch() { + return fuzzyMatch; + } + + /** + * Gets the values. + * + *

An array of objects describing the entity values. + * + * @return the values + */ + public List values() { + return values; + } + + /** + * 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/CreateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java new file mode 100644 index 00000000000..7aff2e8be35 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateExampleOptions.java @@ -0,0 +1,238 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 createExample options. */ +public class CreateExampleOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String text; + protected List mentions; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String intent; + private String text; + 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; + this.text = createExampleOptions.text; + this.mentions = createExampleOptions.mentions; + this.includeAudit = createExampleOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + * @param text the text + */ + public Builder(String workspaceId, String intent, String text) { + this.workspaceId = workspaceId; + this.intent = intent; + this.text = text; + } + + /** + * Builds a CreateExampleOptions. + * + * @return the new CreateExampleOptions instance + */ + public CreateExampleOptions build() { + return new CreateExampleOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.mentions == null) { + this.mentions = new ArrayList(); + } + this.mentions.add(mentions); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateExampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the CreateExampleOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the CreateExampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the mentions. Existing mentions will be replaced. + * + * @param mentions the mentions + * @return the CreateExampleOptions builder + */ + public Builder mentions(List mentions) { + this.mentions = mentions; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateExampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the example. + * + * @param example the example + * @return the CreateExampleOptions builder + */ + public Builder example(Example example) { + this.text = example.text(); + this.mentions = example.mentions(); + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + text = builder.text; + mentions = builder.mentions; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateExampleOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return 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. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the mentions. + * + *

An array of contextual entity mentions. + * + * @return the mentions + */ + public List mentions() { + return mentions; + } + + /** + * 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/CreateIntent.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java new file mode 100644 index 00000000000..3dae5e0730a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntent.java @@ -0,0 +1,192 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** CreateIntent. */ +public class CreateIntent extends GenericModel { + + protected String intent; + protected String description; + protected Date created; + protected Date updated; + protected List examples; + + /** Builder. */ + public static class Builder { + private String intent; + private String description; + 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.examples = createIntent.examples; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param intent the intent + */ + public Builder(String intent) { + this.intent = intent; + } + + /** + * Builds a CreateIntent. + * + * @return the new CreateIntent instance + */ + public CreateIntent build() { + return new CreateIntent(this); + } + + /** + * Adds a new element to examples. + * + * @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"); + if (this.examples == null) { + this.examples = new ArrayList(); + } + this.examples.add(example); + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the CreateIntent builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateIntent builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the examples. Existing examples will be replaced. + * + * @param examples the examples + * @return the CreateIntent builder + */ + public Builder examples(List examples) { + this.examples = examples; + return this; + } + } + + protected CreateIntent() {} + + protected CreateIntent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); + intent = builder.intent; + description = builder.description; + examples = builder.examples; + } + + /** + * New builder. + * + * @return a CreateIntent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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-`. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the description. + * + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the description + */ + public String description() { + return description; + } + + /** + * 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; + } + + /** + * Gets the examples. + * + *

An array of user input examples for the intent. + * + * @return the examples + */ + public List examples() { + return 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 new file mode 100644 index 00000000000..a1e8d20e995 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateIntentOptions.java @@ -0,0 +1,224 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 createIntent options. */ +public class CreateIntentOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String description; + protected List examples; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String intent; + private String description; + 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; + this.description = createIntentOptions.description; + this.examples = createIntentOptions.examples; + this.includeAudit = createIntentOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + */ + public Builder(String workspaceId, String intent) { + this.workspaceId = workspaceId; + this.intent = intent; + } + + /** + * Builds a CreateIntentOptions. + * + * @return the new CreateIntentOptions instance + */ + public CreateIntentOptions build() { + return new CreateIntentOptions(this); + } + + /** + * Adds a new element to examples. + * + * @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"); + if (this.examples == null) { + this.examples = new ArrayList(); + } + this.examples.add(example); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateIntentOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the CreateIntentOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateIntentOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the examples. Existing examples will be replaced. + * + * @param examples the examples + * @return the CreateIntentOptions builder + */ + public Builder examples(List examples) { + this.examples = examples; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateIntentOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + description = builder.description; + examples = builder.examples; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateIntentOptions 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 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-`. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the description. + * + *

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

An array of user input examples for the intent. + * + * @return the examples + */ + public List examples() { + return examples; + } + + /** + * 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/CreateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java new file mode 100644 index 00000000000..5f645b90845 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateSynonymOptions.java @@ -0,0 +1,223 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class CreateSynonymOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + protected String synonym; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + 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; + this.value = createSynonymOptions.value; + this.synonym = createSynonymOptions.synonym; + this.includeAudit = createSynonymOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + * @param synonym the synonym + */ + public Builder(String workspaceId, String entity, String value, String synonym) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + this.synonym = synonym; + } + + /** + * Builds a CreateSynonymOptions. + * + * @return the new CreateSynonymOptions instance + */ + public CreateSynonymOptions build() { + return new CreateSynonymOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateSynonymOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the CreateSynonymOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the CreateSynonymOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the CreateSynonymOptions builder + */ + public Builder synonym(String synonym) { + this.synonym = synonym; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateSynonymOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the CreateSynonymOptions builder + */ + public Builder synonym(Synonym synonym) { + this.synonym = synonym.synonym(); + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + synonym = builder.synonym; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateSynonymOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return 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. + * + * @return the synonym + */ + public String synonym() { + return synonym; + } + + /** + * 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/CreateValue.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java new file mode 100644 index 00000000000..75624523cf7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValue.java @@ -0,0 +1,273 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** CreateValue. */ +public class CreateValue extends GenericModel { + + /** Specifies the type of entity value. */ + public interface Type { + /** synonyms. */ + String SYNONYMS = "synonyms"; + /** patterns. */ + String PATTERNS = "patterns"; + } + + protected String value; + protected Map metadata; + protected String type; + protected List synonyms; + protected List patterns; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String value; + private Map metadata; + private String type; + private List synonyms; + private List patterns; + + /** + * 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param value the value + */ + public Builder(String value) { + this.value = value; + } + + /** + * Builds a CreateValue. + * + * @return the new CreateValue instance + */ + public CreateValue build() { + return new CreateValue(this); + } + + /** + * Adds a new element to synonyms. + * + * @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"); + if (this.synonyms == null) { + this.synonyms = new ArrayList(); + } + this.synonyms.add(synonym); + return this; + } + + /** + * Adds a new element to patterns. + * + * @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"); + if (this.patterns == null) { + this.patterns = new ArrayList(); + } + this.patterns.add(pattern); + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the CreateValue builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateValue builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateValue builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the synonyms. Existing synonyms will be replaced. + * + * @param synonyms the synonyms + * @return the CreateValue builder + */ + public Builder synonyms(List synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Set the patterns. Existing patterns will be replaced. + * + * @param patterns the patterns + * @return the CreateValue builder + */ + public Builder patterns(List patterns) { + this.patterns = patterns; + return this; + } + } + + protected CreateValue() {} + + protected CreateValue(Builder builder) { + 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; + } + + /** + * New builder. + * + * @return a CreateValue builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the metadata. + * + *

Any metadata related to the entity value. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the type. + * + *

Specifies the type of entity value. + * + * @return the type + */ + public String type() { + return 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. + * + * @return the synonyms + */ + public List synonyms() { + return 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 + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). + * + * @return the patterns + */ + public List patterns() { + return patterns; + } + + /** + * 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/v1/model/CreateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java new file mode 100644 index 00000000000..b184a4064c6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateValueOptions.java @@ -0,0 +1,334 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 createValue options. */ +public class CreateValueOptions extends GenericModel { + + /** Specifies the type of entity value. */ + public interface Type { + /** synonyms. */ + String SYNONYMS = "synonyms"; + /** patterns. */ + String PATTERNS = "patterns"; + } + + protected String workspaceId; + protected String entity; + protected String value; + protected Map metadata; + protected String type; + protected List synonyms; + protected List patterns; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + private Map metadata; + private String type; + private List synonyms; + 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; + this.value = createValueOptions.value; + this.metadata = createValueOptions.metadata; + this.type = createValueOptions.type; + this.synonyms = createValueOptions.synonyms; + this.patterns = createValueOptions.patterns; + this.includeAudit = createValueOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + */ + public Builder(String workspaceId, String entity, String value) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + } + + /** + * Builds a CreateValueOptions. + * + * @return the new CreateValueOptions instance + */ + public CreateValueOptions build() { + return new CreateValueOptions(this); + } + + /** + * Adds a new element to synonyms. + * + * @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"); + if (this.synonyms == null) { + this.synonyms = new ArrayList(); + } + this.synonyms.add(synonym); + return this; + } + + /** + * Adds a new element to patterns. + * + * @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"); + if (this.patterns == null) { + this.patterns = new ArrayList(); + } + this.patterns.add(pattern); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the CreateValueOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the CreateValueOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the CreateValueOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateValueOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the CreateValueOptions builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the synonyms. Existing synonyms will be replaced. + * + * @param synonyms the synonyms + * @return the CreateValueOptions builder + */ + public Builder synonyms(List synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Set the patterns. Existing patterns will be replaced. + * + * @param patterns the patterns + * @return the CreateValueOptions builder + */ + public Builder patterns(List patterns) { + this.patterns = patterns; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateValueOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + metadata = builder.metadata; + type = builder.type; + synonyms = builder.synonyms; + patterns = builder.patterns; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateValueOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the metadata. + * + *

Any metadata related to the entity value. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the type. + * + *

Specifies the type of entity value. + * + * @return the type + */ + public String type() { + return 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. + * + * @return the synonyms + */ + public List synonyms() { + return 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 + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). + * + * @return the patterns + */ + public List patterns() { + return patterns; + } + + /** + * 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/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 new file mode 100644 index 00000000000..baa22d73fff --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/CreateWorkspaceOptions.java @@ -0,0 +1,453 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 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 Boolean includeAudit; + + /** 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 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.includeAudit = createWorkspaceOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a CreateWorkspaceOptions. + * + * @return the new CreateWorkspaceOptions instance + */ + public CreateWorkspaceOptions build() { + return new CreateWorkspaceOptions(this); + } + + /** + * Adds a new element to dialogNodes. + * + * @param dialogNode 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(); + } + this.dialogNodes.add(dialogNode); + return this; + } + + /** + * Adds a new element to counterexamples. + * + * @param counterexample 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(); + } + this.counterexamples.add(counterexample); + return this; + } + + /** + * Adds a new element to webhooks. + * + * @param webhooks 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(); + } + this.webhooks.add(webhooks); + return this; + } + + /** + * Adds a new element to intents. + * + * @param intent 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(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity 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(); + } + this.entities.add(entity); + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateWorkspaceOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateWorkspaceOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions 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 CreateWorkspaceOptions builder + */ + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the CreateWorkspaceOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the learningOptOut. + * + * @param learningOptOut the learningOptOut + * @return the CreateWorkspaceOptions builder + */ + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; + return this; + } + + /** + * Set the systemSettings. + * + * @param systemSettings the systemSettings + * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions 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 CreateWorkspaceOptions 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 CreateWorkspaceOptions builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the CreateWorkspaceOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a CreateWorkspaceOptions 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; + } + + /** + * 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/DeleteCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java new file mode 100644 index 00000000000..bdaaa73d6a2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteCounterexampleOptions.java @@ -0,0 +1,125 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteCounterexampleOptions extends GenericModel { + + protected String workspaceId; + protected String text; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param text the text + */ + public Builder(String workspaceId, String text) { + this.workspaceId = workspaceId; + this.text = text; + } + + /** + * Builds a DeleteCounterexampleOptions. + * + * @return the new DeleteCounterexampleOptions instance + */ + public DeleteCounterexampleOptions build() { + return new DeleteCounterexampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteCounterexampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the DeleteCounterexampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + text = builder.text; + } + + /** + * New builder. + * + * @return a DeleteCounterexampleOptions 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 text. + * + *

The text of a user input counterexample (for example, `What are you wearing?`). + * + * @return the text + */ + public String text() { + return 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 new file mode 100644 index 00000000000..ddd3bc396cc --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteDialogNodeOptions.java @@ -0,0 +1,126 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteDialogNodeOptions extends GenericModel { + + protected String workspaceId; + protected String dialogNode; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + */ + public Builder(String workspaceId, String dialogNode) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + } + + /** + * Builds a DeleteDialogNodeOptions. + * + * @return the new DeleteDialogNodeOptions instance + */ + public DeleteDialogNodeOptions build() { + return new DeleteDialogNodeOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteDialogNodeOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the DeleteDialogNodeOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + dialogNode = builder.dialogNode; + } + + /** + * New builder. + * + * @return a DeleteDialogNodeOptions 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; + } +} 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 new file mode 100644 index 00000000000..d6ddd677fee --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteEntityOptions.java @@ -0,0 +1,125 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteEntityOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a DeleteEntityOptions. + * + * @return the new DeleteEntityOptions instance + */ + public DeleteEntityOptions build() { + return new DeleteEntityOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteEntityOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the DeleteEntityOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + } + + /** + * New builder. + * + * @return a DeleteEntityOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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 new file mode 100644 index 00000000000..5599e588a58 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteExampleOptions.java @@ -0,0 +1,154 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteExampleOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String text; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + * @param text the text + */ + public Builder(String workspaceId, String intent, String text) { + this.workspaceId = workspaceId; + this.intent = intent; + this.text = text; + } + + /** + * Builds a DeleteExampleOptions. + * + * @return the new DeleteExampleOptions instance + */ + public DeleteExampleOptions build() { + return new DeleteExampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteExampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the DeleteExampleOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the DeleteExampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + text = builder.text; + } + + /** + * New builder. + * + * @return a DeleteExampleOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the text. + * + *

The text of the user input example. + * + * @return the text + */ + public String text() { + return 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 new file mode 100644 index 00000000000..9394b8ae511 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteIntentOptions.java @@ -0,0 +1,125 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteIntentOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + */ + public Builder(String workspaceId, String intent) { + this.workspaceId = workspaceId; + this.intent = intent; + } + + /** + * Builds a DeleteIntentOptions. + * + * @return the new DeleteIntentOptions instance + */ + public DeleteIntentOptions build() { + return new DeleteIntentOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteIntentOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the DeleteIntentOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + } + + /** + * New builder. + * + * @return a DeleteIntentOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return 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 new file mode 100644 index 00000000000..f4bb375e6a3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteSynonymOptions.java @@ -0,0 +1,183 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteSynonymOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + protected String synonym; + + /** 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; + this.value = deleteSynonymOptions.value; + this.synonym = deleteSynonymOptions.synonym; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + * @param synonym the synonym + */ + public Builder(String workspaceId, String entity, String value, String synonym) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + this.synonym = synonym; + } + + /** + * Builds a DeleteSynonymOptions. + * + * @return the new DeleteSynonymOptions instance + */ + public DeleteSynonymOptions build() { + return new DeleteSynonymOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteSynonymOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the DeleteSynonymOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the DeleteSynonymOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the DeleteSynonymOptions builder + */ + public Builder synonym(String synonym) { + this.synonym = synonym; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + synonym = builder.synonym; + } + + /** + * New builder. + * + * @return a DeleteSynonymOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the synonym. + * + *

The text of the synonym. + * + * @return the synonym + */ + public String synonym() { + return 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 new file mode 100644 index 00000000000..c53c1735afe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/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.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; + + /** + * 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/v1/model/DeleteValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java new file mode 100644 index 00000000000..9338a62ac2e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteValueOptions.java @@ -0,0 +1,154 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteValueOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + */ + public Builder(String workspaceId, String entity, String value) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + } + + /** + * Builds a DeleteValueOptions. + * + * @return the new DeleteValueOptions instance + */ + public DeleteValueOptions build() { + return new DeleteValueOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteValueOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the DeleteValueOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the DeleteValueOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + } + + /** + * New builder. + * + * @return a DeleteValueOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return 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 new file mode 100644 index 00000000000..85d048abf77 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DeleteWorkspaceOptions.java @@ -0,0 +1,96 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteWorkspaceOptions extends GenericModel { + + protected String workspaceId; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a DeleteWorkspaceOptions. + * + * @return the new DeleteWorkspaceOptions instance + */ + public DeleteWorkspaceOptions build() { + return new DeleteWorkspaceOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the DeleteWorkspaceOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + } + + protected DeleteWorkspaceOptions() {} + + protected DeleteWorkspaceOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + } + + /** + * New builder. + * + * @return a DeleteWorkspaceOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return 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 new file mode 100644 index 00000000000..b76dcc8ca40 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNode.java @@ -0,0 +1,728 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** DialogNode. */ +public class DialogNode 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; + + /** + * 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; + this.conditions = dialogNode.conditions; + this.parent = dialogNode.parent; + this.previousSibling = dialogNode.previousSibling; + this.output = dialogNode.output; + this.context = dialogNode.context; + this.metadata = dialogNode.metadata; + this.nextStep = dialogNode.nextStep; + this.title = dialogNode.title; + this.type = dialogNode.type; + this.eventName = dialogNode.eventName; + this.variable = dialogNode.variable; + this.actions = dialogNode.actions; + this.digressIn = dialogNode.digressIn; + this.digressOut = dialogNode.digressOut; + this.digressOutSlots = dialogNode.digressOutSlots; + this.userLabel = dialogNode.userLabel; + this.disambiguationOptOut = dialogNode.disambiguationOptOut; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param dialogNode the dialogNode + */ + public Builder(String dialogNode) { + this.dialogNode = dialogNode; + } + + /** + * Builds a DialogNode. + * + * @return the new DialogNode instance + */ + public DialogNode build() { + return new DialogNode(this); + } + + /** + * Adds a new element to 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"); + if (this.actions == null) { + this.actions = new ArrayList(); + } + this.actions.add(actions); + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the DialogNode builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the DialogNode builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the conditions. + * + * @param conditions the conditions + * @return the DialogNode builder + */ + public Builder conditions(String conditions) { + this.conditions = conditions; + return this; + } + + /** + * Set the parent. + * + * @param parent the parent + * @return the DialogNode builder + */ + public Builder parent(String parent) { + this.parent = parent; + return this; + } + + /** + * Set the previousSibling. + * + * @param previousSibling the previousSibling + * @return the DialogNode builder + */ + public Builder previousSibling(String previousSibling) { + this.previousSibling = previousSibling; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the DialogNode builder + */ + public Builder output(DialogNodeOutput output) { + this.output = output; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the DialogNode builder + */ + public Builder context(DialogNodeContext context) { + this.context = context; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the DialogNode builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the nextStep. + * + * @param nextStep the nextStep + * @return the DialogNode builder + */ + public Builder nextStep(DialogNodeNextStep nextStep) { + this.nextStep = nextStep; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNode builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the DialogNode builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the eventName. + * + * @param eventName the eventName + * @return the DialogNode builder + */ + public Builder eventName(String eventName) { + this.eventName = eventName; + return this; + } + + /** + * Set the variable. + * + * @param variable the variable + * @return the DialogNode 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 DialogNode builder + */ + public Builder actions(List actions) { + this.actions = actions; + return this; + } + + /** + * Set the digressIn. + * + * @param digressIn the digressIn + * @return the DialogNode builder + */ + public Builder digressIn(String digressIn) { + this.digressIn = digressIn; + return this; + } + + /** + * Set the digressOut. + * + * @param digressOut the digressOut + * @return the DialogNode builder + */ + public Builder digressOut(String digressOut) { + this.digressOut = digressOut; + return this; + } + + /** + * Set the digressOutSlots. + * + * @param digressOutSlots the digressOutSlots + * @return the DialogNode builder + */ + public Builder digressOutSlots(String digressOutSlots) { + this.digressOutSlots = digressOutSlots; + return this; + } + + /** + * Set the userLabel. + * + * @param userLabel the userLabel + * @return the DialogNode builder + */ + public Builder userLabel(String userLabel) { + this.userLabel = userLabel; + return this; + } + + /** + * Set the disambiguationOptOut. + * + * @param disambiguationOptOut the disambiguationOptOut + * @return the DialogNode builder + */ + public Builder disambiguationOptOut(Boolean disambiguationOptOut) { + this.disambiguationOptOut = disambiguationOptOut; + return this; + } + } + + protected DialogNode() {} + + protected DialogNode(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); + 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 DialogNode 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; + } +} 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 new file mode 100644 index 00000000000..7460443db77 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeAction.java @@ -0,0 +1,223 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** DialogNodeAction. */ +public class DialogNodeAction extends GenericModel { + + /** The type of action to invoke. */ + public interface Type { + /** client. */ + String CLIENT = "client"; + /** server. */ + String SERVER = "server"; + /** cloud_function. */ + String CLOUD_FUNCTION = "cloud_function"; + /** web_action. */ + String WEB_ACTION = "web_action"; + /** webhook. */ + String WEBHOOK = "webhook"; + } + + protected String name; + protected String type; + protected Map parameters; + + @SerializedName("result_variable") + protected String resultVariable; + + protected String credentials; + + /** Builder. */ + public static class Builder { + private String name; + private String type; + private Map parameters; + 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; + this.parameters = dialogNodeAction.parameters; + this.resultVariable = dialogNodeAction.resultVariable; + this.credentials = dialogNodeAction.credentials; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param resultVariable the resultVariable + */ + public Builder(String name, String resultVariable) { + this.name = name; + this.resultVariable = resultVariable; + } + + /** + * Builds a DialogNodeAction. + * + * @return the new DialogNodeAction instance + */ + public DialogNodeAction build() { + return new DialogNodeAction(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the DialogNodeAction builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the DialogNodeAction builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the parameters. + * + * @param parameters the parameters + * @return the DialogNodeAction builder + */ + public Builder parameters(Map parameters) { + this.parameters = parameters; + return this; + } + + /** + * Set the resultVariable. + * + * @param resultVariable the resultVariable + * @return the DialogNodeAction builder + */ + public Builder resultVariable(String resultVariable) { + this.resultVariable = resultVariable; + return this; + } + + /** + * Set the credentials. + * + * @param credentials the credentials + * @return the DialogNodeAction builder + */ + public Builder credentials(String credentials) { + this.credentials = credentials; + return this; + } + } + + 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"); + name = builder.name; + type = builder.type; + parameters = builder.parameters; + resultVariable = builder.resultVariable; + credentials = builder.credentials; + } + + /** + * New builder. + * + * @return a DialogNodeAction builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

The name of the action. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the type. + * + *

The type of action to invoke. + * + * @return the type + */ + public String type() { + return type; + } + + /** + * Gets the parameters. + * + *

A map of key/value pairs to be provided to the action. + * + * @return the parameters + */ + public Map parameters() { + return parameters; + } + + /** + * Gets the resultVariable. + * + *

The location in the dialog context where the result of the action is stored. + * + * @return the resultVariable + */ + public String resultVariable() { + return resultVariable; + } + + /** + * Gets the credentials. + * + *

The name of the context variable that the client application will use to pass in credentials + * for the action. + * + * @return the credentials + */ + public String credentials() { + return 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 new file mode 100644 index 00000000000..5b138fa9802 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeCollection.java @@ -0,0 +1,52 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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.List; + +/** 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. + * + * @return the dialogNodes + */ + public List getDialogNodes() { + return dialogNodes; + } + + /** + * 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/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 new file mode 100644 index 00000000000..9ef1cafb650 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeNextStep.java @@ -0,0 +1,198 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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. + */ + public interface Behavior { + /** get_user_input. */ + String GET_USER_INPUT = "get_user_input"; + /** skip_user_input. */ + String SKIP_USER_INPUT = "skip_user_input"; + /** jump_to. */ + String JUMP_TO = "jump_to"; + /** reprompt. */ + String REPROMPT = "reprompt"; + /** skip_slot. */ + String SKIP_SLOT = "skip_slot"; + /** skip_all_slots. */ + String SKIP_ALL_SLOTS = "skip_all_slots"; + } + + /** Which part of the dialog node to process next. */ + public interface Selector { + /** condition. */ + String CONDITION = "condition"; + /** client. */ + String CLIENT = "client"; + /** user_input. */ + String USER_INPUT = "user_input"; + /** body. */ + String BODY = "body"; + } + + protected String behavior; + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String selector; + + /** 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 with required properties. + * + * @param behavior the behavior + */ + public Builder(String behavior) { + this.behavior = behavior; + } + + /** + * Builds a DialogNodeNextStep. + * + * @return the new DialogNodeNextStep instance + */ + public DialogNodeNextStep build() { + return new DialogNodeNextStep(this); + } + + /** + * Set the behavior. + * + * @param behavior the behavior + * @return the DialogNodeNextStep builder + */ + public Builder behavior(String behavior) { + this.behavior = behavior; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the DialogNodeNextStep builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the selector. + * + * @param selector the selector + * @return the DialogNodeNextStep builder + */ + public Builder selector(String selector) { + this.selector = selector; + return this; + } + } + + protected DialogNodeNextStep() {} + + protected DialogNodeNextStep(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.behavior, "behavior cannot be null"); + behavior = builder.behavior; + dialogNode = builder.dialogNode; + selector = builder.selector; + } + + /** + * New builder. + * + * @return a DialogNodeNextStep builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the behavior + */ + public String behavior() { + return behavior; + } + + /** + * Gets the dialogNode. + * + *

The unique ID of the dialog node to process next. This parameter is required if + * **behavior**=`jump_to`. + * + * @return the dialogNode + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the selector. + * + *

Which part of the dialog node to process next. + * + * @return the selector + */ + public String selector() { + return 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 new file mode 100644 index 00000000000..2f49be9ea5c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutput.java @@ -0,0 +1,220 @@ +/* + * (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.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 + * [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() {}); + } + + /** 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. + * + * @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; + } + + /** + * 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. + * + * @return the modifiers + */ + public DialogNodeOutputModifiers getModifiers() { + return this.modifiers; + } + + /** + * Sets the modifiers. + * + * @param modifiers the new modifiers + */ + public void setModifiers(final DialogNodeOutputModifiers modifiers) { + this.modifiers = 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 new file mode 100644 index 00000000000..0dcac9e1e65 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputGeneric.java @@ -0,0 +1,424 @@ +/* + * (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.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 { + @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. */ + public interface SelectionPolicy { + /** sequential. */ + String SEQUENTIAL = "sequential"; + /** random. */ + String RANDOM = "random"; + /** multiline. */ + String MULTILINE = "multiline"; + } + + /** The preferred type of control to display, if supported by the channel. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + /** 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"; + } + + @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; + + @SerializedName("message_to_user") + protected String messageToUser; + + @SerializedName("user_defined") + protected Map userDefined; + + @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. + * + * @return the responseType + */ + public String responseType() { + return responseType; + } + + /** + * Gets the values. + * + *

A list of one or more objects defining text responses. + * + * @return the values + */ + public List values() { + return values; + } + + /** + * Gets the selectionPolicy. + * + *

How a response is selected from the list, if more than one response is specified. + * + * @return the selectionPolicy + */ + public String selectionPolicy() { + return selectionPolicy; + } + + /** + * Gets the delimiter. + * + *

The delimiter to use as a separator between responses when `selection_policy`=`multiline`. + * + * @return the delimiter + */ + 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. + * + * @return the time + */ + public Long time() { + return time; + } + + /** + * Gets the typing. + * + *

Whether to send a "user is typing" event during the pause. Ignored if the channel does not + * support this event. + * + * @return the typing + */ + public Boolean typing() { + return typing; + } + + /** + * Gets the source. + * + *

The `https:` URL of the image. + * + * @return the source + */ + public String source() { + return source; + } + + /** + * Gets the title. + * + *

An optional title to show before the response. + * + * @return the title + */ + public String title() { + return title; + } + + /** + * Gets the description. + * + *

An optional description to show with the response. + * + * @return the description + */ + 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. + * + * @return the preference + */ + public String preference() { + return preference; + } + + /** + * Gets the options. + * + *

An array of objects describing the options from which the user can choose. You can include + * up to 20 options. + * + * @return the options + */ + public List options() { + return options; + } + + /** + * Gets the messageToHumanAgent. + * + *

An optional 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 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?topic=discovery-query-operators#query-operators). + * + * @return the query + */ + public String query() { + return query; + } + + /** + * Gets the queryType. + * + *

The type of the search query. + * + * @return the queryType + */ + public String queryType() { + return 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?topic=discovery-query-parameters#filter). + * + * @return the filter + */ + public String filter() { + return filter; + } + + /** + * Gets the discoveryVersion. + * + *

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 new file mode 100644 index 00000000000..03ff8da2fa9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputModifiers.java @@ -0,0 +1,87 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Options that modify how specified output is handled. */ +public class DialogNodeOutputModifiers extends GenericModel { + + protected Boolean overwrite; + + /** 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() {} + + /** + * Builds a DialogNodeOutputModifiers. + * + * @return the new DialogNodeOutputModifiers instance + */ + public DialogNodeOutputModifiers build() { + return new DialogNodeOutputModifiers(this); + } + + /** + * Set the overwrite. + * + * @param overwrite the overwrite + * @return the DialogNodeOutputModifiers builder + */ + public Builder overwrite(Boolean overwrite) { + this.overwrite = overwrite; + return this; + } + } + + protected DialogNodeOutputModifiers() {} + + protected DialogNodeOutputModifiers(Builder builder) { + overwrite = builder.overwrite; + } + + /** + * New builder. + * + * @return a DialogNodeOutputModifiers builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the overwrite + */ + public Boolean overwrite() { + return 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 new file mode 100644 index 00000000000..f5c0d073b1c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElement.java @@ -0,0 +1,125 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** DialogNodeOutputOptionsElement. */ +public class DialogNodeOutputOptionsElement extends GenericModel { + + protected String label; + protected DialogNodeOutputOptionsElementValue value; + + /** 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 with required properties. + * + * @param label the label + * @param value the value + */ + public Builder(String label, DialogNodeOutputOptionsElementValue value) { + this.label = label; + this.value = value; + } + + /** + * Builds a DialogNodeOutputOptionsElement. + * + * @return the new DialogNodeOutputOptionsElement instance + */ + public DialogNodeOutputOptionsElement build() { + return new DialogNodeOutputOptionsElement(this); + } + + /** + * Set the label. + * + * @param label the label + * @return the DialogNodeOutputOptionsElement builder + */ + public Builder label(String label) { + this.label = label; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the DialogNodeOutputOptionsElement builder + */ + public Builder value(DialogNodeOutputOptionsElementValue value) { + this.value = value; + return this; + } + } + + 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"); + label = builder.label; + value = builder.value; + } + + /** + * New builder. + * + * @return a DialogNodeOutputOptionsElement builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the label. + * + *

The user-facing label for the option. + * + * @return the label + */ + public String label() { + return 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. + * + * @return the value + */ + public DialogNodeOutputOptionsElementValue value() { + return 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 new file mode 100644 index 00000000000..c6d8c1d0372 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputOptionsElementValue.java @@ -0,0 +1,178 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** + * 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 { + + protected MessageInput input; + protected List intents; + protected List entities; + + /** 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() {} + + /** + * Builds a DialogNodeOutputOptionsElementValue. + * + * @return the new DialogNodeOutputOptionsElementValue instance + */ + public DialogNodeOutputOptionsElementValue build() { + return new DialogNodeOutputOptionsElementValue(this); + } + + /** + * Adds a new element to 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"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intents); + return this; + } + + /** + * Adds a new element to 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"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entities); + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the DialogNodeOutputOptionsElementValue builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the DialogNodeOutputOptionsElementValue 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 DialogNodeOutputOptionsElementValue builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + } + + protected DialogNodeOutputOptionsElementValue() {} + + protected DialogNodeOutputOptionsElementValue(Builder builder) { + input = builder.input; + intents = builder.intents; + entities = builder.entities; + } + + /** + * New builder. + * + * @return a DialogNodeOutputOptionsElementValue builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return input; + } + + /** + * Gets the intents. + * + *

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. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

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. + * + * @return the entities + */ + public List entities() { + return 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 new file mode 100644 index 00000000000..ba8d16b6a74 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeOutputTextValuesElement.java @@ -0,0 +1,86 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** DialogNodeOutputTextValuesElement. */ +public class DialogNodeOutputTextValuesElement extends GenericModel { + + protected String text; + + /** 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() {} + + /** + * Builds a DialogNodeOutputTextValuesElement. + * + * @return the new DialogNodeOutputTextValuesElement instance + */ + public DialogNodeOutputTextValuesElement build() { + return new DialogNodeOutputTextValuesElement(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the DialogNodeOutputTextValuesElement builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + } + + protected DialogNodeOutputTextValuesElement() {} + + protected DialogNodeOutputTextValuesElement(Builder builder) { + text = builder.text; + } + + /** + * New builder. + * + * @return a DialogNodeOutputTextValuesElement builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the text + */ + public String text() { + return 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 new file mode 100644 index 00000000000..78d92f013cd --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogNodeVisitedDetails.java @@ -0,0 +1,140 @@ +/* + * (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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** DialogNodeVisitedDetails. */ +public class DialogNodeVisitedDetails extends GenericModel { + + @SerializedName("dialog_node") + protected String dialogNode; + + protected String title; + protected String conditions; + + /** 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() {} + + /** + * Builds a DialogNodeVisitedDetails. + * + * @return the new DialogNodeVisitedDetails instance + */ + public DialogNodeVisitedDetails build() { + return new DialogNodeVisitedDetails(this); + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the DialogNodeVisitedDetails builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the title. + * + * @param title the title + * @return the DialogNodeVisitedDetails builder + */ + public Builder title(String title) { + this.title = title; + return this; + } + + /** + * Set the conditions. + * + * @param conditions the conditions + * @return the DialogNodeVisitedDetails builder + */ + public Builder conditions(String conditions) { + this.conditions = conditions; + return this; + } + } + + protected DialogNodeVisitedDetails() {} + + protected DialogNodeVisitedDetails(Builder builder) { + dialogNode = builder.dialogNode; + title = builder.title; + conditions = builder.conditions; + } + + /** + * New builder. + * + * @return a DialogNodeVisitedDetails builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the dialogNode. + * + *

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

The title of the dialog node. + * + * @return the title + */ + public String title() { + return title; + } + + /** + * Gets the conditions. + * + *

The conditions that trigger the dialog node. + * + * @return the conditions + */ + public String conditions() { + return 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 new file mode 100644 index 00000000000..30b7a68c1b9 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestion.java @@ -0,0 +1,188 @@ +/* + * (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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Map; + +/** DialogSuggestion. */ +public class DialogSuggestion extends GenericModel { + + protected String label; + protected DialogSuggestionValue value; + protected Map output; + + @SerializedName("dialog_node") + protected String dialogNode; + + /** Builder. */ + public static class Builder { + private String label; + private DialogSuggestionValue value; + 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; + this.output = dialogSuggestion.output; + this.dialogNode = dialogSuggestion.dialogNode; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param label the label + * @param value the value + */ + public Builder(String label, DialogSuggestionValue value) { + this.label = label; + this.value = value; + } + + /** + * Builds a DialogSuggestion. + * + * @return the new DialogSuggestion instance + */ + public DialogSuggestion build() { + return new DialogSuggestion(this); + } + + /** + * Set the label. + * + * @param label the label + * @return the DialogSuggestion builder + */ + public Builder label(String label) { + this.label = label; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the DialogSuggestion builder + */ + public Builder value(DialogSuggestionValue value) { + this.value = value; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the DialogSuggestion builder + */ + public Builder output(Map output) { + this.output = output; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the DialogSuggestion builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + } + + 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"); + label = builder.label; + value = builder.value; + output = builder.output; + dialogNode = builder.dialogNode; + } + + /** + * New builder. + * + * @return a DialogSuggestion builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the label + */ + public String label() { + return 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. + * + *

**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 + */ + public DialogSuggestionValue value() { + return value; + } + + /** + * Gets the output. + * + *

The dialog output that will be returned from the Watson Assistant service if the user + * selects the corresponding option. + * + * @return the output + */ + public Map output() { + return output; + } + + /** + * Gets the dialogNode. + * + *

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 + */ + 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 new file mode 100644 index 00000000000..3c5e1530df1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/DialogSuggestionValue.java @@ -0,0 +1,175 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** + * 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 { + + protected MessageInput input; + protected List intents; + protected List entities; + + /** 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() {} + + /** + * Builds a DialogSuggestionValue. + * + * @return the new DialogSuggestionValue instance + */ + public DialogSuggestionValue build() { + return new DialogSuggestionValue(this); + } + + /** + * Adds a new element to 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"); + if (this.intents == null) { + this.intents = new ArrayList(); + } + this.intents.add(intents); + return this; + } + + /** + * Adds a new element to 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"); + if (this.entities == null) { + this.entities = new ArrayList(); + } + this.entities.add(entities); + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the DialogSuggestionValue builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the DialogSuggestionValue 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 DialogSuggestionValue builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + } + + protected DialogSuggestionValue() {} + + protected DialogSuggestionValue(Builder builder) { + input = builder.input; + intents = builder.intents; + entities = builder.entities; + } + + /** + * New builder. + * + * @return a DialogSuggestionValue builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return input; + } + + /** + * Gets the intents. + * + *

An array of intents to be sent along with the user input. + * + * @return the intents + */ + public List intents() { + return intents; + } + + /** + * Gets the entities. + * + *

An array of entities to be sent along with the user input. + * + * @return the entities + */ + public List entities() { + return 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 new file mode 100644 index 00000000000..c753e9cb885 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Entity.java @@ -0,0 +1,118 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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 + * that you want to enable. (Any entity content specified with the request is ignored.). + * + * @return the entity + */ + public String getEntity() { + return entity; + } + + /** + * Gets the description. + * + *

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

Any metadata related to the entity. + * + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /** + * Gets the fuzzyMatch. + * + *

Whether to use fuzzy matching for the entity. + * + * @return the fuzzyMatch + */ + public Boolean isFuzzyMatch() { + return fuzzyMatch; + } + + /** + * 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 values. + * + *

An array of objects describing the entity values. + * + * @return the values + */ + public List getValues() { + return 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 new file mode 100644 index 00000000000..744c50c0a00 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * 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/v1/model/EntityMention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java new file mode 100644 index 00000000000..a381eb16e49 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMention.java @@ -0,0 +1,61 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the intent. + * + *

The name of the intent. + * + * @return the intent + */ + public String getIntent() { + return intent; + } + + /** + * Gets the location. + * + *

An array of zero-based character offsets that indicate where the entity mentions begin and + * end in the input text. + * + * @return the location + */ + public List getLocation() { + return 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 new file mode 100644 index 00000000000..8d31644fb15 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/EntityMentionCollection.java @@ -0,0 +1,49 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the examples + */ + public List getExamples() { + return examples; + } + + /** + * 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/v1/model/Example.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java new file mode 100644 index 00000000000..422e3a5cbea --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Example.java @@ -0,0 +1,165 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Example. */ +public class Example extends GenericModel { + + protected String text; + protected List mentions; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String text; + private List mentions; + + /** + * 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; + } + + /** 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 Example. + * + * @return the new Example instance + */ + public Example build() { + return new Example(this); + } + + /** + * Adds a new element to 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"); + if (this.mentions == null) { + this.mentions = new ArrayList(); + } + this.mentions.add(mentions); + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the Example builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the mentions. Existing mentions will be replaced. + * + * @param mentions the mentions + * @return the Example builder + */ + public Builder mentions(List mentions) { + this.mentions = mentions; + return this; + } + } + + protected Example() {} + + protected Example(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + mentions = builder.mentions; + } + + /** + * New builder. + * + * @return a Example builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the mentions. + * + *

An array of contextual entity mentions. + * + * @return the mentions + */ + public List mentions() { + return mentions; + } + + /** + * 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/v1/model/ExampleCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java new file mode 100644 index 00000000000..1b8e27a8fca --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ExampleCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. + * + * @return the examples + */ + public List getExamples() { + return examples; + } + + /** + * 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/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 new file mode 100644 index 00000000000..d97e00dff21 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetCounterexampleOptions.java @@ -0,0 +1,152 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetCounterexampleOptions extends GenericModel { + + protected String workspaceId; + protected String text; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param text the text + */ + public Builder(String workspaceId, String text) { + this.workspaceId = workspaceId; + this.text = text; + } + + /** + * Builds a GetCounterexampleOptions. + * + * @return the new GetCounterexampleOptions instance + */ + public GetCounterexampleOptions build() { + return new GetCounterexampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetCounterexampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the GetCounterexampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetCounterexampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + text = builder.text; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetCounterexampleOptions 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 text. + * + *

The text of a user input counterexample (for example, `What are you wearing?`). + * + * @return the text + */ + public String text() { + return text; + } + + /** + * 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/GetDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java new file mode 100644 index 00000000000..3787e207644 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetDialogNodeOptions.java @@ -0,0 +1,153 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetDialogNodeOptions extends GenericModel { + + protected String workspaceId; + protected String dialogNode; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + */ + public Builder(String workspaceId, String dialogNode) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + } + + /** + * Builds a GetDialogNodeOptions. + * + * @return the new GetDialogNodeOptions instance + */ + public GetDialogNodeOptions build() { + return new GetDialogNodeOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetDialogNodeOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the GetDialogNodeOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetDialogNodeOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + dialogNode = builder.dialogNode; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetDialogNodeOptions 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 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/GetEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java new file mode 100644 index 00000000000..a1176c282a5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetEntityOptions.java @@ -0,0 +1,180 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetEntityOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected Boolean export; + protected Boolean includeAudit; + + /** 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; + this.export = getEntityOptions.export; + this.includeAudit = getEntityOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a GetEntityOptions. + * + * @return the new GetEntityOptions instance + */ + public GetEntityOptions build() { + return new GetEntityOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetEntityOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the GetEntityOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the GetEntityOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetEntityOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + export = builder.export; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetEntityOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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/GetExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java new file mode 100644 index 00000000000..416bb3a5801 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetExampleOptions.java @@ -0,0 +1,181 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetExampleOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String text; + protected Boolean includeAudit; + + /** 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; + this.text = getExampleOptions.text; + this.includeAudit = getExampleOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + * @param text the text + */ + public Builder(String workspaceId, String intent, String text) { + this.workspaceId = workspaceId; + this.intent = intent; + this.text = text; + } + + /** + * Builds a GetExampleOptions. + * + * @return the new GetExampleOptions instance + */ + public GetExampleOptions build() { + return new GetExampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetExampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the GetExampleOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the GetExampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetExampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + text = builder.text; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetExampleOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the text. + * + *

The text of the user input example. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * 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/GetIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java new file mode 100644 index 00000000000..358b9fbcc13 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetIntentOptions.java @@ -0,0 +1,180 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetIntentOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected Boolean export; + protected Boolean includeAudit; + + /** 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; + this.export = getIntentOptions.export; + this.includeAudit = getIntentOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + */ + public Builder(String workspaceId, String intent) { + this.workspaceId = workspaceId; + this.intent = intent; + } + + /** + * Builds a GetIntentOptions. + * + * @return the new GetIntentOptions instance + */ + public GetIntentOptions build() { + return new GetIntentOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetIntentOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the GetIntentOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the GetIntentOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetIntentOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + export = builder.export; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetIntentOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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/GetSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java new file mode 100644 index 00000000000..4bb883c447b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetSynonymOptions.java @@ -0,0 +1,210 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetSynonymOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + protected String synonym; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + 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; + this.value = getSynonymOptions.value; + this.synonym = getSynonymOptions.synonym; + this.includeAudit = getSynonymOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + * @param synonym the synonym + */ + public Builder(String workspaceId, String entity, String value, String synonym) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + this.synonym = synonym; + } + + /** + * Builds a GetSynonymOptions. + * + * @return the new GetSynonymOptions instance + */ + public GetSynonymOptions build() { + return new GetSynonymOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetSynonymOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the GetSynonymOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the GetSynonymOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the GetSynonymOptions builder + */ + public Builder synonym(String synonym) { + this.synonym = synonym; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetSynonymOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + synonym = builder.synonym; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetSynonymOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the synonym. + * + *

The text of the synonym. + * + * @return the synonym + */ + public String synonym() { + return synonym; + } + + /** + * 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/GetValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java new file mode 100644 index 00000000000..004815013fb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetValueOptions.java @@ -0,0 +1,209 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class GetValueOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + protected Boolean export; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + 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; + this.value = getValueOptions.value; + this.export = getValueOptions.export; + this.includeAudit = getValueOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + */ + public Builder(String workspaceId, String entity, String value) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + } + + /** + * Builds a GetValueOptions. + * + * @return the new GetValueOptions instance + */ + public GetValueOptions build() { + return new GetValueOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetValueOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the GetValueOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the GetValueOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the GetValueOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetValueOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + export = builder.export; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a GetValueOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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/GetWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java new file mode 100644 index 00000000000..636698cf092 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/GetWorkspaceOptions.java @@ -0,0 +1,189 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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. + */ + public interface Sort { + /** stable. */ + String STABLE = "stable"; + } + + protected String workspaceId; + protected Boolean export; + protected Boolean includeAudit; + protected String sort; + + /** 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; + this.includeAudit = getWorkspaceOptions.includeAudit; + this.sort = getWorkspaceOptions.sort; + } + + /** 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 GetWorkspaceOptions. + * + * @return the new GetWorkspaceOptions instance + */ + public GetWorkspaceOptions build() { + return new GetWorkspaceOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the GetWorkspaceOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the GetWorkspaceOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the GetWorkspaceOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the GetWorkspaceOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + } + + protected GetWorkspaceOptions() {} + + protected GetWorkspaceOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + export = builder.export; + includeAudit = builder.includeAudit; + sort = builder.sort; + } + + /** + * New builder. + * + * @return a GetWorkspaceOptions 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 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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. 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 + */ + public String sort() { + return 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 new file mode 100644 index 00000000000..c9d78bf9a3d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Intent.java @@ -0,0 +1,88 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Intent. */ +public class Intent extends GenericModel { + + protected String intent; + protected String description; + protected Date created; + 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-`. + * + * @return the intent + */ + public String getIntent() { + return intent; + } + + /** + * Gets the description. + * + *

The description of the intent. This string cannot contain carriage return, newline, or tab + * characters. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * 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 examples. + * + *

An array of user input examples for the intent. + * + * @return the examples + */ + public List getExamples() { + return 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 new file mode 100644 index 00000000000..aff2659db5b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/IntentCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. + * + * @return the intents + */ + public List getIntents() { + return intents; + } + + /** + * 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/v1/model/ListAllLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java new file mode 100644 index 00000000000..f230f37b470 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListAllLogsOptions.java @@ -0,0 +1,179 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class ListAllLogsOptions extends GenericModel { + + protected String filter; + protected String sort; + protected Long pageLimit; + protected String cursor; + + /** 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; + this.pageLimit = listAllLogsOptions.pageLimit; + this.cursor = listAllLogsOptions.cursor; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param filter the filter + */ + public Builder(String filter) { + this.filter = filter; + } + + /** + * Builds a ListAllLogsOptions. + * + * @return the new ListAllLogsOptions instance + */ + public ListAllLogsOptions build() { + return new ListAllLogsOptions(this); + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the ListAllLogsOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListAllLogsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListAllLogsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = pageLimit; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListAllLogsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + } + + protected ListAllLogsOptions() {} + + protected ListAllLogsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.filter, "filter cannot be null"); + filter = builder.filter; + sort = builder.sort; + pageLimit = builder.pageLimit; + cursor = builder.cursor; + } + + /** + * New builder. + * + * @return a ListAllLogsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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`. 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 + */ + public String filter() { + return 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 (`-`). + * + * @return the sort + */ + public String sort() { + return sort; + } + + /** + * Gets the pageLimit. + * + *

The number of records to return in each page of results. + * + * @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/v1/model/ListCounterexamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java new file mode 100644 index 00000000000..923a6cf0e28 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListCounterexamplesOptions.java @@ -0,0 +1,241 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** text. */ + String TEXT = "text"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ListCounterexamplesOptions. + * + * @return the new ListCounterexamplesOptions instance + */ + public ListCounterexamplesOptions build() { + return new ListCounterexamplesOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListCounterexamplesOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListCounterexamplesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListCounterexamplesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListCounterexamplesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListCounterexamplesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListCounterexamplesOptions() {} + + protected ListCounterexamplesOptions(Builder builder) { + 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; + } + + /** + * New builder. + * + * @return a ListCounterexamplesOptions 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 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 counterexamples 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/v1/model/ListDialogNodesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java new file mode 100644 index 00000000000..e0e379f240d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListDialogNodesOptions.java @@ -0,0 +1,241 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** dialog_node. */ + String DIALOG_NODE = "dialog_node"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ListDialogNodesOptions. + * + * @return the new ListDialogNodesOptions instance + */ + public ListDialogNodesOptions build() { + return new ListDialogNodesOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListDialogNodesOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListDialogNodesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListDialogNodesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListDialogNodesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListDialogNodesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListDialogNodesOptions() {} + + protected ListDialogNodesOptions(Builder builder) { + 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; + } + + /** + * New builder. + * + * @return a ListDialogNodesOptions 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 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 dialog nodes 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/v1/model/ListEntitiesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java new file mode 100644 index 00000000000..5bde74c0b60 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListEntitiesOptions.java @@ -0,0 +1,269 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** entity. */ + String ENTITY = "entity"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected Boolean export; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ListEntitiesOptions. + * + * @return the new ListEntitiesOptions instance + */ + public ListEntitiesOptions build() { + return new ListEntitiesOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListEntitiesOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the ListEntitiesOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListEntitiesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListEntitiesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListEntitiesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListEntitiesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListEntitiesOptions() {} + + protected ListEntitiesOptions(Builder builder) { + 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; + } + + /** + * New builder. + * + * @return a ListEntitiesOptions 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 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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 entities 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/v1/model/ListExamplesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java new file mode 100644 index 00000000000..cb9c4d04abe --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListExamplesOptions.java @@ -0,0 +1,270 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** text. */ + String TEXT = "text"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected String intent; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + */ + public Builder(String workspaceId, String intent) { + this.workspaceId = workspaceId; + this.intent = intent; + } + + /** + * Builds a ListExamplesOptions. + * + * @return the new ListExamplesOptions instance + */ + public ListExamplesOptions build() { + return new ListExamplesOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListExamplesOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the ListExamplesOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListExamplesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListExamplesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListExamplesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListExamplesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListExamplesOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * 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 examples 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/v1/model/ListIntentsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java new file mode 100644 index 00000000000..a022fe595f4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListIntentsOptions.java @@ -0,0 +1,269 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** intent. */ + String INTENT = "intent"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected Boolean export; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ListIntentsOptions. + * + * @return the new ListIntentsOptions instance + */ + public ListIntentsOptions build() { + return new ListIntentsOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListIntentsOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the ListIntentsOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListIntentsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListIntentsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListIntentsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListIntentsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListIntentsOptions() {} + + protected ListIntentsOptions(Builder builder) { + 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; + } + + /** + * New builder. + * + * @return a ListIntentsOptions 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 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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 intents 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/v1/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java new file mode 100644 index 00000000000..92e26d0d00f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListLogsOptions.java @@ -0,0 +1,205 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class ListLogsOptions extends GenericModel { + + protected String workspaceId; + protected String sort; + protected String filter; + protected Long pageLimit; + protected String cursor; + + /** Builder. */ + public static class Builder { + private String workspaceId; + 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.workspaceId = listLogsOptions.workspaceId; + 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 workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a ListLogsOptions. + * + * @return the new ListLogsOptions instance + */ + public ListLogsOptions build() { + return new ListLogsOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListLogsOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + 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.workspaceId, "workspaceId cannot be empty"); + workspaceId = builder.workspaceId; + 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 workspaceId. + * + *

Unique identifier of the workspace. + * + * @return the workspaceId + */ + public String workspaceId() { + return 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 (`-`). + * + * @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/v1/model/ListMentionsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java new file mode 100644 index 00000000000..b2a5de946ec --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListMentionsOptions.java @@ -0,0 +1,180 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listMentions options. */ +public class ListMentionsOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected Boolean export; + protected Boolean includeAudit; + + /** 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; + this.export = listMentionsOptions.export; + this.includeAudit = listMentionsOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a ListMentionsOptions. + * + * @return the new ListMentionsOptions instance + */ + public ListMentionsOptions build() { + return new ListMentionsOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListMentionsOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the ListMentionsOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the ListMentionsOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListMentionsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + export = builder.export; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListMentionsOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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/ListSynonymsOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java new file mode 100644 index 00000000000..3c794bbbe0a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListSynonymsOptions.java @@ -0,0 +1,299 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** synonym. */ + String SYNONYM = "synonym"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected String entity; + protected String value; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + */ + public Builder(String workspaceId, String entity, String value) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + } + + /** + * Builds a ListSynonymsOptions. + * + * @return the new ListSynonymsOptions instance + */ + public ListSynonymsOptions build() { + return new ListSynonymsOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListSynonymsOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the ListSynonymsOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the ListSynonymsOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListSynonymsOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListSynonymsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListSynonymsOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListSynonymsOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListSynonymsOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * 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 entity value synonyms 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/v1/model/ListValuesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java new file mode 100644 index 00000000000..93d4ed90e18 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListValuesOptions.java @@ -0,0 +1,298 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + public interface Sort { + /** value. */ + String VALUE = "value"; + /** updated. */ + String UPDATED = "updated"; + } + + protected String workspaceId; + protected String entity; + protected Boolean export; + protected Long pageLimit; + protected Boolean includeCount; + protected String sort; + protected String cursor; + protected Boolean includeAudit; + + /** 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 with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a ListValuesOptions. + * + * @return the new ListValuesOptions instance + */ + public ListValuesOptions build() { + return new ListValuesOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the ListValuesOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the ListValuesOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the export. + * + * @param export the export + * @return the ListValuesOptions builder + */ + public Builder export(Boolean export) { + this.export = export; + return this; + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListValuesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListValuesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListValuesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListValuesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + export = builder.export; + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListValuesOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the export + */ + public Boolean export() { + return export; + } + + /** + * 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 entity values 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/v1/model/ListWorkspacesOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java new file mode 100644 index 00000000000..14521421214 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ListWorkspacesOptions.java @@ -0,0 +1,204 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +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 (`-`). + */ + 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 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() {} + + /** + * Builds a ListWorkspacesOptions. + * + * @return the new ListWorkspacesOptions instance + */ + public ListWorkspacesOptions build() { + return new ListWorkspacesOptions(this); + } + + /** + * Set the pageLimit. + * + * @param pageLimit the pageLimit + * @return the ListWorkspacesOptions builder + */ + public Builder pageLimit(long pageLimit) { + this.pageLimit = 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. + * + * @param sort the sort + * @return the ListWorkspacesOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + + /** + * Set the cursor. + * + * @param cursor the cursor + * @return the ListWorkspacesOptions builder + */ + public Builder cursor(String cursor) { + this.cursor = cursor; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the ListWorkspacesOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected ListWorkspacesOptions() {} + + protected ListWorkspacesOptions(Builder builder) { + pageLimit = builder.pageLimit; + includeCount = builder.includeCount; + sort = builder.sort; + cursor = builder.cursor; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a ListWorkspacesOptions 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 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/v1/model/Log.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java new file mode 100644 index 00000000000..60faa6695c8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Log.java @@ -0,0 +1,118 @@ +/* + * (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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the request + */ + public MessageRequest getRequest() { + return request; + } + + /** + * Gets the response. + * + *

The response sent by the workspace, including the output text, detected intents and + * entities, and context. + * + * @return the response + */ + public MessageResponse getResponse() { + return response; + } + + /** + * Gets the logId. + * + *

A unique identifier for the logged event. + * + * @return the logId + */ + public String getLogId() { + return logId; + } + + /** + * 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 workspaceId. + * + *

The unique identifier of the workspace where the request was made. + * + * @return the workspaceId + */ + public String getWorkspaceId() { + return workspaceId; + } + + /** + * Gets the language. + * + *

The language of the workspace where the message request was made. + * + * @return the language + */ + public String getLanguage() { + return 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 new file mode 100644 index 00000000000..741d5a7db9d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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/v1/model/LogMessage.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java new file mode 100644 index 00000000000..6bfac0d0157 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogMessage.java @@ -0,0 +1,189 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class LogMessage extends GenericModel { + + /** The severity of the log message. */ + public interface Level { + /** info. */ + String INFO = "info"; + /** error. */ + String ERROR = "error"; + /** warn. */ + String WARN = "warn"; + } + + protected String level; + protected String msg; + protected String code; + protected LogMessageSource source; + + /** 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 with required properties. + * + * @param level the level + * @param msg the msg + * @param code the code + */ + public Builder(String level, String msg, String code) { + this.level = level; + this.msg = msg; + this.code = code; + } + + /** + * Builds a LogMessage. + * + * @return the new LogMessage instance + */ + public LogMessage build() { + return new LogMessage(this); + } + + /** + * Set the level. + * + * @param level the level + * @return the LogMessage builder + */ + public Builder level(String level) { + this.level = level; + return this; + } + + /** + * Set the msg. + * + * @param msg the msg + * @return the LogMessage builder + */ + 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.code, "code cannot be null"); + level = builder.level; + msg = builder.msg; + code = builder.code; + source = builder.source; + } + + /** + * New builder. + * + * @return a LogMessage builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the level. + * + *

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

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 new file mode 100644 index 00000000000..1abfdc2cf6f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/LogPagination.java @@ -0,0 +1,67 @@ +/* + * (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.v1.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/v1/model/Mention.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java new file mode 100644 index 00000000000..f7dc287904a --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Mention.java @@ -0,0 +1,142 @@ +/* + * (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.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** A mention of a contextual entity. */ +public class Mention extends GenericModel { + + protected String entity; + protected List location; + + /** 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 with required properties. + * + * @param entity the entity + * @param location the location + */ + public Builder(String entity, List location) { + this.entity = entity; + this.location = location; + } + + /** + * Builds a Mention. + * + * @return the new Mention instance + */ + public Mention build() { + return new Mention(this); + } + + /** + * Adds a new element to 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"); + if (this.location == null) { + this.location = new ArrayList(); + } + this.location.add(location); + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the Mention builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the location. Existing location will be replaced. + * + * @param location the location + * @return the Mention builder + */ + public Builder location(List location) { + this.location = location; + return this; + } + } + + 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"); + entity = builder.entity; + location = builder.location; + } + + /** + * New builder. + * + * @return a Mention builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the location. + * + *

An array of zero-based character offsets that indicate where the entity mentions begin and + * end in the input text. + * + * @return the location + */ + public List location() { + return 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 new file mode 100644 index 00000000000..c661adf3aab --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageContextMetadata.java @@ -0,0 +1,123 @@ +/* + * (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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Metadata related to the message. */ +public class MessageContextMetadata extends GenericModel { + + protected String deployment; + + @SerializedName("user_id") + protected String userId; + + /** 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() {} + + /** + * Builds a MessageContextMetadata. + * + * @return the new MessageContextMetadata instance + */ + public MessageContextMetadata build() { + return new MessageContextMetadata(this); + } + + /** + * Set the deployment. + * + * @param deployment the deployment + * @return the MessageContextMetadata builder + */ + public Builder deployment(String deployment) { + this.deployment = deployment; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageContextMetadata builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + } + + protected MessageContextMetadata() {} + + protected MessageContextMetadata(Builder builder) { + deployment = builder.deployment; + userId = builder.userId; + } + + /** + * New builder. + * + * @return a MessageContextMetadata builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the deployment. + * + *

A label identifying the deployment environment, used for filtering log data. This string + * cannot contain carriage return, newline, or tab characters. + * + * @return the deployment + */ + public String deployment() { + return 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 + * 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 + */ + public String userId() { + return 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 new file mode 100644 index 00000000000..af19308b244 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageInput.java @@ -0,0 +1,237 @@ +/* + * (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.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() {}); + } + + /** 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. + * + * @return the text + */ + public String getText() { + return this.text; + } + + /** + * Sets the text. + * + * @param text the new text + */ + 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 new file mode 100644 index 00000000000..7f7ea15a2cd --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageOptions.java @@ -0,0 +1,367 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 message options. */ +public class MessageOptions extends GenericModel { + + protected String workspaceId; + protected MessageInput input; + protected List intents; + protected List entities; + protected Boolean alternateIntents; + protected Context context; + protected OutputData output; + protected String userId; + protected Boolean nodesVisitedDetails; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private MessageInput input; + private List intents; + private List entities; + 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; + this.intents = messageOptions.intents; + this.entities = messageOptions.entities; + 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 with required properties. + * + * @param workspaceId the workspaceId + */ + public Builder(String workspaceId) { + this.workspaceId = workspaceId; + } + + /** + * Builds a MessageOptions. + * + * @return the new MessageOptions instance + */ + public MessageOptions build() { + return new MessageOptions(this); + } + + /** + * Adds a new element to intents. + * + * @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"); + 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 MessageOptions 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; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the MessageOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageOptions builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the MessageOptions 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 MessageOptions builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the alternateIntents. + * + * @param alternateIntents the alternateIntents + * @return the MessageOptions builder + */ + public Builder alternateIntents(Boolean alternateIntents) { + this.alternateIntents = alternateIntents; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageOptions builder + */ + public Builder context(Context context) { + this.context = context; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the MessageOptions builder + */ + public Builder output(OutputData output) { + this.output = 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. + * + * @param nodesVisitedDetails the nodesVisitedDetails + * @return the MessageOptions builder + */ + public Builder nodesVisitedDetails(Boolean nodesVisitedDetails) { + this.nodesVisitedDetails = nodesVisitedDetails; + return this; + } + + /** + * Set the messageRequest. + * + * @param messageRequest the messageRequest + * @return the MessageOptions builder + */ + public Builder messageRequest(MessageRequest messageRequest) { + this.input = messageRequest.input(); + this.intents = messageRequest.intents(); + this.entities = messageRequest.entities(); + 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"); + workspaceId = builder.workspaceId; + input = builder.input; + intents = builder.intents; + entities = builder.entities; + alternateIntents = builder.alternateIntents; + context = builder.context; + output = builder.output; + userId = builder.userId; + nodesVisitedDetails = builder.nodesVisitedDetails; + } + + /** + * New builder. + * + * @return a MessageOptions 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 input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return 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. + * + * @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 alternateIntents. + * + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. + * + * @return the alternateIntents + */ + public Boolean alternateIntents() { + return alternateIntents; + } + + /** + * Gets the context. + * + *

State information for the conversation. To maintain state, include the context from the + * previous response. + * + * @return the context + */ + public Context context() { + return 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. + * + * @return the output + */ + 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. + * + * @return the nodesVisitedDetails + */ + public Boolean nodesVisitedDetails() { + return 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 new file mode 100644 index 00000000000..13907a4831e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageRequest.java @@ -0,0 +1,304 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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.List; + +/** 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; + + @SerializedName("user_id") + protected String userId; + + /** Builder. */ + public static class Builder { + private MessageInput input; + private List intents; + private List entities; + private Boolean alternateIntents; + private Context context; + private OutputData output; + 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; + this.entities = messageRequest.entities; + this.alternateIntents = messageRequest.alternateIntents; + this.context = messageRequest.context; + this.output = messageRequest.output; + this.userId = messageRequest.userId; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a MessageRequest. + * + * @return the new MessageRequest instance + */ + public MessageRequest build() { + return new MessageRequest(this); + } + + /** + * Adds a new element to intents. + * + * @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"); + 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 MessageRequest 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; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageRequest builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the intents. Existing intents will be replaced. + * + * @param intents the intents + * @return the MessageRequest 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 MessageRequest builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the alternateIntents. + * + * @param alternateIntents the alternateIntents + * @return the MessageRequest builder + */ + public Builder alternateIntents(Boolean alternateIntents) { + this.alternateIntents = alternateIntents; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageRequest builder + */ + public Builder context(Context context) { + this.context = context; + return this; + } + + /** + * Set the output. + * + * @param output the output + * @return the MessageRequest builder + */ + public Builder output(OutputData output) { + this.output = output; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageRequest builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + } + + protected MessageRequest() {} + + protected MessageRequest(Builder builder) { + input = builder.input; + intents = builder.intents; + entities = builder.entities; + alternateIntents = builder.alternateIntents; + context = builder.context; + output = builder.output; + userId = builder.userId; + } + + /** + * New builder. + * + * @return a MessageRequest builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput input() { + return 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. + * + * @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 alternateIntents. + * + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. + * + * @return the alternateIntents + */ + public Boolean alternateIntents() { + return alternateIntents; + } + + /** + * Gets the context. + * + *

State information for the conversation. To maintain state, include the context from the + * previous response. + * + * @return the context + */ + public Context context() { + return 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. + * + * @return the output + */ + public OutputData output() { + return output; + } + + /** + * Gets the actions. + * + *

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 new file mode 100644 index 00000000000..bbee4e58033 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/MessageResponse.java @@ -0,0 +1,140 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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.List; + +/** + * 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. + * + * @return the input + */ + public MessageInput getInput() { + return input; + } + + /** + * 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 alternateIntents. + * + *

Whether to return more than one intent. A value of `true` indicates that all matching + * intents are returned. + * + * @return the alternateIntents + */ + public Boolean isAlternateIntents() { + return alternateIntents; + } + + /** + * Gets the context. + * + *

State information for the conversation. To maintain state, include the context from the + * previous response. + * + * @return the context + */ + public Context getContext() { + return 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. + * + * @return the output + */ + public OutputData getOutput() { + return output; + } + + /** + * 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 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 new file mode 100644 index 00000000000..94bb544239c --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/OutputData.java @@ -0,0 +1,317 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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.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. + * + *

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("generic") + protected List generic; + + public OutputData() { + 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. + * + * @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 logMessages. + * + *

An array of up to 50 messages logged with the request. + * + * @return the logMessages + */ + public List getLogMessages() { + return this.logMessages; + } + + /** + * Sets the logMessages. + * + * @param logMessages the new logMessages + */ + public void setLogMessages(final List logMessages) { + this.logMessages = logMessages; + } + + /** + * 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/Pagination.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Pagination.java new file mode 100644 index 00000000000..e0f8b841fa2 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/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.v1.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/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 new file mode 100644 index 00000000000..52aacfbebd0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntity.java @@ -0,0 +1,337 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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 List groups; + protected RuntimeEntityInterpretation interpretation; + protected List alternatives; + protected RuntimeEntityRole role; + + /** Builder. */ + public static class Builder { + private String entity; + private List location; + private String value; + private Double confidence; + 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.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 with required properties. + * + * @param entity the entity + * @param value the value + */ + public Builder(String entity, String value) { + this.entity = entity; + this.value = value; + } + + /** + * Builds a RuntimeEntity. + * + * @return the new RuntimeEntity instance + */ + public RuntimeEntity build() { + return new RuntimeEntity(this); + } + + /** + * Adds a new element to 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"); + if (this.location == null) { + this.location = new ArrayList(); + } + this.location.add(location); + return this; + } + + /** + * Adds a new element to 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"); + if (this.groups == null) { + this.groups = new ArrayList(); + } + this.groups.add(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. + * + * @param entity the entity + * @return the RuntimeEntity builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the location. Existing location will be replaced. + * + * @param location the location + * @return the RuntimeEntity builder + */ + public Builder location(List location) { + this.location = location; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the RuntimeEntity builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the confidence. + * + * @param confidence the confidence + * @return the RuntimeEntity builder + */ + public Builder confidence(Double confidence) { + this.confidence = confidence; + return this; + } + + /** + * Set the groups. Existing groups will be replaced. + * + * @param groups the groups + * @return the RuntimeEntity builder + */ + public Builder groups(List groups) { + this.groups = groups; + return this; + } + + /** + * Set the interpretation. + * + * @param interpretation the interpretation + * @return the RuntimeEntity builder + */ + public Builder interpretation(RuntimeEntityInterpretation interpretation) { + this.interpretation = 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. + * + * @param role the role + * @return the RuntimeEntity builder + */ + public Builder role(RuntimeEntityRole role) { + this.role = role; + 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.value, "value cannot be null"); + entity = builder.entity; + location = builder.location; + value = builder.value; + confidence = builder.confidence; + groups = builder.groups; + interpretation = builder.interpretation; + alternatives = builder.alternatives; + role = builder.role; + } + + /** + * New builder. + * + * @return a RuntimeEntity builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the entity. + * + *

An entity detected in the input. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the location + */ + public List location() { + return location; + } + + /** + * 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; + } + + /** + * Gets the groups. + * + *

The recognized capture groups for the entity, as defined by the entity pattern. + * + * @return the groups + */ + public List groups() { + return groups; + } + + /** + * Gets the interpretation. + * + *

An object containing detailed information about the entity recognized in the user input. + * + *

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 + */ + 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. + * + * @return the role + */ + public RuntimeEntityRole role() { + return 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 new file mode 100644 index 00000000000..a4e654279bf --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityInterpretation.java @@ -0,0 +1,837 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** RuntimeEntityInterpretation. */ +public class RuntimeEntityInterpretation extends GenericModel { + + /** + * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` + * entity. + */ + public interface Granularity { + /** day. */ + String DAY = "day"; + /** fortnight. */ + String FORTNIGHT = "fortnight"; + /** hour. */ + String HOUR = "hour"; + /** instant. */ + String INSTANT = "instant"; + /** minute. */ + String MINUTE = "minute"; + /** month. */ + String MONTH = "month"; + /** quarter. */ + String QUARTER = "quarter"; + /** second. */ + String SECOND = "second"; + /** week. */ + String WEEK = "week"; + /** weekend. */ + String WEEKEND = "weekend"; + /** year. */ + String YEAR = "year"; + } + + @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. */ + public static class Builder { + private String calendarType; + private String datetimeLink; + private String festival; + private String granularity; + private String rangeLink; + private String rangeModifier; + private Double relativeDay; + private Double relativeMonth; + private Double relativeWeek; + private Double relativeWeekend; + private Double relativeYear; + private Double specificDay; + private String specificDayOfWeek; + private Double specificMonth; + private Double specificQuarter; + private Double specificYear; + private Double numericValue; + private String subtype; + private String partOfDay; + private Double relativeHour; + private Double relativeMinute; + private Double relativeSecond; + private Double specificHour; + private Double specificMinute; + 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; + this.festival = runtimeEntityInterpretation.festival; + this.granularity = runtimeEntityInterpretation.granularity; + this.rangeLink = runtimeEntityInterpretation.rangeLink; + this.rangeModifier = runtimeEntityInterpretation.rangeModifier; + this.relativeDay = runtimeEntityInterpretation.relativeDay; + this.relativeMonth = runtimeEntityInterpretation.relativeMonth; + this.relativeWeek = runtimeEntityInterpretation.relativeWeek; + this.relativeWeekend = runtimeEntityInterpretation.relativeWeekend; + this.relativeYear = runtimeEntityInterpretation.relativeYear; + this.specificDay = runtimeEntityInterpretation.specificDay; + this.specificDayOfWeek = runtimeEntityInterpretation.specificDayOfWeek; + this.specificMonth = runtimeEntityInterpretation.specificMonth; + this.specificQuarter = runtimeEntityInterpretation.specificQuarter; + this.specificYear = runtimeEntityInterpretation.specificYear; + this.numericValue = runtimeEntityInterpretation.numericValue; + this.subtype = runtimeEntityInterpretation.subtype; + this.partOfDay = runtimeEntityInterpretation.partOfDay; + this.relativeHour = runtimeEntityInterpretation.relativeHour; + this.relativeMinute = runtimeEntityInterpretation.relativeMinute; + this.relativeSecond = runtimeEntityInterpretation.relativeSecond; + this.specificHour = runtimeEntityInterpretation.specificHour; + this.specificMinute = runtimeEntityInterpretation.specificMinute; + this.specificSecond = runtimeEntityInterpretation.specificSecond; + this.timezone = runtimeEntityInterpretation.timezone; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a RuntimeEntityInterpretation. + * + * @return the new RuntimeEntityInterpretation instance + */ + public RuntimeEntityInterpretation build() { + return new RuntimeEntityInterpretation(this); + } + + /** + * Set the calendarType. + * + * @param calendarType the calendarType + * @return the RuntimeEntityInterpretation builder + */ + public Builder calendarType(String calendarType) { + this.calendarType = calendarType; + return this; + } + + /** + * Set the datetimeLink. + * + * @param datetimeLink the datetimeLink + * @return the RuntimeEntityInterpretation builder + */ + public Builder datetimeLink(String datetimeLink) { + this.datetimeLink = datetimeLink; + return this; + } + + /** + * Set the festival. + * + * @param festival the festival + * @return the RuntimeEntityInterpretation builder + */ + public Builder festival(String festival) { + this.festival = festival; + return this; + } + + /** + * Set the granularity. + * + * @param granularity the granularity + * @return the RuntimeEntityInterpretation builder + */ + public Builder granularity(String granularity) { + this.granularity = granularity; + return this; + } + + /** + * Set the rangeLink. + * + * @param rangeLink the rangeLink + * @return the RuntimeEntityInterpretation builder + */ + public Builder rangeLink(String rangeLink) { + this.rangeLink = rangeLink; + return this; + } + + /** + * Set the rangeModifier. + * + * @param rangeModifier the rangeModifier + * @return the RuntimeEntityInterpretation builder + */ + public Builder rangeModifier(String rangeModifier) { + this.rangeModifier = rangeModifier; + return this; + } + + /** + * Set the relativeDay. + * + * @param relativeDay the relativeDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeDay(Double relativeDay) { + this.relativeDay = relativeDay; + return this; + } + + /** + * Set the relativeMonth. + * + * @param relativeMonth the relativeMonth + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeMonth(Double relativeMonth) { + this.relativeMonth = relativeMonth; + return this; + } + + /** + * Set the relativeWeek. + * + * @param relativeWeek the relativeWeek + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeWeek(Double relativeWeek) { + this.relativeWeek = relativeWeek; + return this; + } + + /** + * Set the relativeWeekend. + * + * @param relativeWeekend the relativeWeekend + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeWeekend(Double relativeWeekend) { + this.relativeWeekend = relativeWeekend; + return this; + } + + /** + * Set the relativeYear. + * + * @param relativeYear the relativeYear + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeYear(Double relativeYear) { + this.relativeYear = relativeYear; + return this; + } + + /** + * Set the specificDay. + * + * @param specificDay the specificDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificDay(Double specificDay) { + this.specificDay = specificDay; + return this; + } + + /** + * Set the specificDayOfWeek. + * + * @param specificDayOfWeek the specificDayOfWeek + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificDayOfWeek(String specificDayOfWeek) { + this.specificDayOfWeek = specificDayOfWeek; + return this; + } + + /** + * Set the specificMonth. + * + * @param specificMonth the specificMonth + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificMonth(Double specificMonth) { + this.specificMonth = specificMonth; + return this; + } + + /** + * Set the specificQuarter. + * + * @param specificQuarter the specificQuarter + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificQuarter(Double specificQuarter) { + this.specificQuarter = specificQuarter; + return this; + } + + /** + * Set the specificYear. + * + * @param specificYear the specificYear + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificYear(Double specificYear) { + this.specificYear = specificYear; + return this; + } + + /** + * Set the numericValue. + * + * @param numericValue the numericValue + * @return the RuntimeEntityInterpretation builder + */ + public Builder numericValue(Double numericValue) { + this.numericValue = numericValue; + return this; + } + + /** + * Set the subtype. + * + * @param subtype the subtype + * @return the RuntimeEntityInterpretation builder + */ + public Builder subtype(String subtype) { + this.subtype = subtype; + return this; + } + + /** + * Set the partOfDay. + * + * @param partOfDay the partOfDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder partOfDay(String partOfDay) { + this.partOfDay = partOfDay; + return this; + } + + /** + * Set the relativeHour. + * + * @param relativeHour the relativeHour + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeHour(Double relativeHour) { + this.relativeHour = relativeHour; + return this; + } + + /** + * Set the relativeMinute. + * + * @param relativeMinute the relativeMinute + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeMinute(Double relativeMinute) { + this.relativeMinute = relativeMinute; + return this; + } + + /** + * Set the relativeSecond. + * + * @param relativeSecond the relativeSecond + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeSecond(Double relativeSecond) { + this.relativeSecond = relativeSecond; + return this; + } + + /** + * Set the specificHour. + * + * @param specificHour the specificHour + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificHour(Double specificHour) { + this.specificHour = specificHour; + return this; + } + + /** + * Set the specificMinute. + * + * @param specificMinute the specificMinute + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificMinute(Double specificMinute) { + this.specificMinute = specificMinute; + return this; + } + + /** + * Set the specificSecond. + * + * @param specificSecond the specificSecond + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificSecond(Double specificSecond) { + this.specificSecond = specificSecond; + return this; + } + + /** + * Set the timezone. + * + * @param timezone the timezone + * @return the RuntimeEntityInterpretation builder + */ + public Builder timezone(String timezone) { + this.timezone = timezone; + return this; + } + } + + protected RuntimeEntityInterpretation() {} + + protected RuntimeEntityInterpretation(Builder builder) { + calendarType = builder.calendarType; + datetimeLink = builder.datetimeLink; + festival = builder.festival; + granularity = builder.granularity; + rangeLink = builder.rangeLink; + rangeModifier = builder.rangeModifier; + relativeDay = builder.relativeDay; + relativeMonth = builder.relativeMonth; + relativeWeek = builder.relativeWeek; + relativeWeekend = builder.relativeWeekend; + relativeYear = builder.relativeYear; + specificDay = builder.specificDay; + specificDayOfWeek = builder.specificDayOfWeek; + specificMonth = builder.specificMonth; + specificQuarter = builder.specificQuarter; + specificYear = builder.specificYear; + numericValue = builder.numericValue; + subtype = builder.subtype; + partOfDay = builder.partOfDay; + relativeHour = builder.relativeHour; + relativeMinute = builder.relativeMinute; + relativeSecond = builder.relativeSecond; + specificHour = builder.specificHour; + specificMinute = builder.specificMinute; + specificSecond = builder.specificSecond; + timezone = builder.timezone; + } + + /** + * New builder. + * + * @return a RuntimeEntityInterpretation builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the calendarType. + * + *

The calendar used to represent a recognized date (for example, `Gregorian`). + * + * @return the calendarType + */ + public String calendarType() { + return 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). + * + * @return the datetimeLink + */ + public String datetimeLink() { + return 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. + * + * @return the festival + */ + public String festival() { + return festival; + } + + /** + * Gets the granularity. + * + *

The precision or duration of a time range specified by a recognized `@sys-time` or + * `@sys-date` entity. + * + * @return the granularity + */ + public String granularity() { + return 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`). + * + * @return the rangeLink + */ + public String rangeLink() { + return 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`). + * + * @return the rangeModifier + */ + public String rangeModifier() { + return 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`). + * + * @return the relativeDay + */ + public Double relativeDay() { + return 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`). + * + * @return the relativeMonth + */ + public Double relativeMonth() { + return 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). + * + * @return the relativeWeek + */ + public Double relativeWeek() { + return 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`). + * + * @return the relativeWeekend + */ + public Double relativeWeekend() { + return 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`). + * + * @return the relativeYear + */ + public Double relativeYear() { + return 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`.). + * + * @return the specificDay + */ + public Double specificDay() { + return specificDay; + } + + /** + * Gets the specificDayOfWeek. + * + *

A recognized mention of a specific day of the week as a lowercase string (for example, + * `monday`). + * + * @return the specificDayOfWeek + */ + public String specificDayOfWeek() { + return specificDayOfWeek; + } + + /** + * Gets the specificMonth. + * + *

A recognized mention of a specific month, represented numerically (for example, `7` for + * `July`). + * + * @return the specificMonth + */ + public Double specificMonth() { + return specificMonth; + } + + /** + * Gets the specificQuarter. + * + *

A recognized mention of a specific quarter, represented numerically (for example, `3` for + * `the third quarter`). + * + * @return the specificQuarter + */ + public Double specificQuarter() { + return specificQuarter; + } + + /** + * Gets the specificYear. + * + *

A recognized mention of a specific year (for example, `2016`). + * + * @return the specificYear + */ + public Double specificYear() { + return specificYear; + } + + /** + * Gets the numericValue. + * + *

A recognized numeric value, represented as an integer or double. + * + * @return the numericValue + */ + public Double numericValue() { + return numericValue; + } + + /** + * Gets the subtype. + * + *

The type of numeric value recognized in the user input (`integer` or `rational`). + * + * @return the subtype + */ + public String subtype() { + return 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`). + * + * @return the partOfDay + */ + public String partOfDay() { + return 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`). + * + * @return the relativeHour + */ + public Double relativeHour() { + return 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`). + * + * @return the relativeMinute + */ + public Double relativeMinute() { + return 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`). + * + * @return the relativeSecond + */ + public Double relativeSecond() { + return relativeSecond; + } + + /** + * Gets the specificHour. + * + *

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

A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 + * AM`.). + * + * @return the specificMinute + */ + public Double specificMinute() { + return specificMinute; + } + + /** + * Gets the specificSecond. + * + *

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

A recognized time zone mentioned as part of a time value (for example, `EST`). + * + * @return the timezone + */ + public String timezone() { + return 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 new file mode 100644 index 00000000000..9ffe6b84276 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeEntityRole.java @@ -0,0 +1,105 @@ +/* + * (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 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. */ + public interface Type { + /** date_from. */ + String DATE_FROM = "date_from"; + /** date_to. */ + String DATE_TO = "date_to"; + /** number_from. */ + String NUMBER_FROM = "number_from"; + /** number_to. */ + String NUMBER_TO = "number_to"; + /** time_from. */ + String TIME_FROM = "time_from"; + /** time_to. */ + String TIME_TO = "time_to"; + } + + protected String type; + + /** 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() {} + + /** + * Builds a RuntimeEntityRole. + * + * @return the new RuntimeEntityRole instance + */ + public RuntimeEntityRole build() { + return new RuntimeEntityRole(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the RuntimeEntityRole builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + } + + protected RuntimeEntityRole() {} + + protected RuntimeEntityRole(Builder builder) { + type = builder.type; + } + + /** + * New builder. + * + * @return a RuntimeEntityRole builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

The relationship of the entity to the range. + * + * @return the type + */ + public String type() { + return 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 new file mode 100644 index 00000000000..c60fd8effc7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeIntent.java @@ -0,0 +1,122 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class RuntimeIntent extends GenericModel { + + protected String intent; + protected Double confidence; + + /** 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 with required properties. + * + * @param intent the intent + */ + public Builder(String intent) { + this.intent = intent; + } + + /** + * Builds a RuntimeIntent. + * + * @return the new RuntimeIntent instance + */ + public RuntimeIntent build() { + return new RuntimeIntent(this); + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the RuntimeIntent builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the confidence. + * + * @param confidence the confidence + * @return the RuntimeIntent builder + */ + public Builder confidence(Double confidence) { + this.confidence = confidence; + return this; + } + } + + protected RuntimeIntent() {} + + protected RuntimeIntent(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.intent, "intent cannot be null"); + intent = builder.intent; + confidence = builder.confidence; + } + + /** + * New builder. + * + * @return a RuntimeIntent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the intent. + * + *

The name of the recognized intent. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the confidence. + * + *

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; + } +} 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 new file mode 100644 index 00000000000..c9d96256a51 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/RuntimeResponseGeneric.java @@ -0,0 +1,352 @@ +/* + * (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.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 { + @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. */ + public interface Preference { + /** dropdown. */ + String DROPDOWN = "dropdown"; + /** button. */ + String BUTTON = "button"; + } + + @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; + + @SerializedName("message_to_user") + protected String messageToUser; + + @SerializedName("user_defined") + protected Map userDefined; + + @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. + * + * @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 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. + * + * @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 `https:` 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 response. + * + * @return the description + */ + 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. + * + * @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 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 **title** property of + * the relevant node or the **topic** property of the dialog node response. + * + * @return the topic + */ + public String topic() { + return topic; + } + + /** + * Gets the dialogNode. + * + *

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 + */ + public String dialogNode() { + return dialogNode; + } + + /** + * Gets the suggestions. + * + *

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 new file mode 100644 index 00000000000..6860d79e61e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Synonym.java @@ -0,0 +1,122 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Synonym. */ +public class Synonym extends GenericModel { + + protected String synonym; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String synonym; + + /** + * 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param synonym the synonym + */ + public Builder(String synonym) { + this.synonym = synonym; + } + + /** + * Builds a Synonym. + * + * @return the new Synonym instance + */ + public Synonym build() { + return new Synonym(this); + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the Synonym builder + */ + public Builder synonym(String synonym) { + this.synonym = synonym; + return this; + } + } + + protected Synonym() {} + + protected Synonym(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.synonym, "synonym cannot be null"); + synonym = builder.synonym; + } + + /** + * New builder. + * + * @return a Synonym builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the synonym + */ + public String synonym() { + return synonym; + } + + /** + * 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/v1/model/SynonymCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java new file mode 100644 index 00000000000..54f547936b8 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/SynonymCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** SynonymCollection. */ +public class SynonymCollection extends GenericModel { + + protected List synonyms; + protected Pagination pagination; + + protected SynonymCollection() {} + + /** + * Gets the synonyms. + * + *

An array of synonyms. + * + * @return the synonyms + */ + public List getSynonyms() { + return synonyms; + } + + /** + * 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/v1/model/UpdateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java new file mode 100644 index 00000000000..accef10adc3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateCounterexampleOptions.java @@ -0,0 +1,180 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class UpdateCounterexampleOptions extends GenericModel { + + protected String workspaceId; + protected String text; + protected String newText; + protected Boolean includeAudit; + + /** 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; + this.newText = updateCounterexampleOptions.newText; + this.includeAudit = updateCounterexampleOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param text the text + */ + public Builder(String workspaceId, String text) { + this.workspaceId = workspaceId; + this.text = text; + } + + /** + * Builds a UpdateCounterexampleOptions. + * + * @return the new UpdateCounterexampleOptions instance + */ + public UpdateCounterexampleOptions build() { + return new UpdateCounterexampleOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateCounterexampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the UpdateCounterexampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the newText. + * + * @param newText the newText + * @return the UpdateCounterexampleOptions builder + */ + public Builder newText(String newText) { + this.newText = newText; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateCounterexampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + text = builder.text; + newText = builder.newText; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateCounterexampleOptions 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 text. + * + *

The text of a user input counterexample (for example, `What are you wearing?`). + * + * @return the text + */ + public String text() { + return 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. + * + * @return the newText + */ + public String newText() { + return newText; + } + + /** + * 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/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 new file mode 100644 index 00000000000..a0a29569b51 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateDialogNodeOptions.java @@ -0,0 +1,752 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 updateDialogNode options. */ +public class UpdateDialogNodeOptions extends GenericModel { + + /** How the dialog node is processed. */ + public interface NewType { + /** 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 NewEventName { + /** 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 NewDigressIn { + /** 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 NewDigressOut { + /** 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 NewDigressOutSlots { + /** not_allowed. */ + String NOT_ALLOWED = "not_allowed"; + /** allow_returning. */ + String ALLOW_RETURNING = "allow_returning"; + /** allow_all. */ + String ALLOW_ALL = "allow_all"; + } + + protected String workspaceId; + protected String dialogNode; + protected String newDialogNode; + protected String newDescription; + protected String newConditions; + protected String newParent; + protected String newPreviousSibling; + protected DialogNodeOutput newOutput; + protected DialogNodeContext newContext; + protected Map newMetadata; + protected DialogNodeNextStep newNextStep; + protected String newTitle; + protected String newType; + protected String newEventName; + protected String newVariable; + protected List newActions; + protected String newDigressIn; + protected String newDigressOut; + protected String newDigressOutSlots; + protected String newUserLabel; + protected Boolean newDisambiguationOptOut; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String dialogNode; + private String newDialogNode; + private String newDescription; + private String newConditions; + private String newParent; + private String newPreviousSibling; + private DialogNodeOutput newOutput; + private DialogNodeContext newContext; + private Map newMetadata; + private DialogNodeNextStep newNextStep; + private String newTitle; + private String newType; + private String newEventName; + private String newVariable; + private List newActions; + private String newDigressIn; + private String newDigressOut; + private String newDigressOutSlots; + private String newUserLabel; + 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; + this.newDialogNode = updateDialogNodeOptions.newDialogNode; + this.newDescription = updateDialogNodeOptions.newDescription; + this.newConditions = updateDialogNodeOptions.newConditions; + this.newParent = updateDialogNodeOptions.newParent; + this.newPreviousSibling = updateDialogNodeOptions.newPreviousSibling; + this.newOutput = updateDialogNodeOptions.newOutput; + this.newContext = updateDialogNodeOptions.newContext; + this.newMetadata = updateDialogNodeOptions.newMetadata; + this.newNextStep = updateDialogNodeOptions.newNextStep; + this.newTitle = updateDialogNodeOptions.newTitle; + this.newType = updateDialogNodeOptions.newType; + this.newEventName = updateDialogNodeOptions.newEventName; + this.newVariable = updateDialogNodeOptions.newVariable; + this.newActions = updateDialogNodeOptions.newActions; + this.newDigressIn = updateDialogNodeOptions.newDigressIn; + this.newDigressOut = updateDialogNodeOptions.newDigressOut; + this.newDigressOutSlots = updateDialogNodeOptions.newDigressOutSlots; + this.newUserLabel = updateDialogNodeOptions.newUserLabel; + this.newDisambiguationOptOut = updateDialogNodeOptions.newDisambiguationOptOut; + this.includeAudit = updateDialogNodeOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param dialogNode the dialogNode + */ + public Builder(String workspaceId, String dialogNode) { + this.workspaceId = workspaceId; + this.dialogNode = dialogNode; + } + + /** + * Builds a UpdateDialogNodeOptions. + * + * @return the new UpdateDialogNodeOptions instance + */ + public UpdateDialogNodeOptions build() { + return new UpdateDialogNodeOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.newActions == null) { + this.newActions = new ArrayList(); + } + this.newActions.add(newActions); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateDialogNodeOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the dialogNode. + * + * @param dialogNode the dialogNode + * @return the UpdateDialogNodeOptions builder + */ + public Builder dialogNode(String dialogNode) { + this.dialogNode = dialogNode; + return this; + } + + /** + * Set the newDialogNode. + * + * @param newDialogNode the newDialogNode + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDialogNode(String newDialogNode) { + this.newDialogNode = newDialogNode; + return this; + } + + /** + * Set the newDescription. + * + * @param newDescription the newDescription + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDescription(String newDescription) { + this.newDescription = newDescription; + return this; + } + + /** + * Set the newConditions. + * + * @param newConditions the newConditions + * @return the UpdateDialogNodeOptions builder + */ + public Builder newConditions(String newConditions) { + this.newConditions = newConditions; + return this; + } + + /** + * Set the newParent. + * + * @param newParent the newParent + * @return the UpdateDialogNodeOptions builder + */ + public Builder newParent(String newParent) { + this.newParent = newParent; + return this; + } + + /** + * Set the newPreviousSibling. + * + * @param newPreviousSibling the newPreviousSibling + * @return the UpdateDialogNodeOptions builder + */ + public Builder newPreviousSibling(String newPreviousSibling) { + this.newPreviousSibling = newPreviousSibling; + return this; + } + + /** + * Set the newOutput. + * + * @param newOutput the newOutput + * @return the UpdateDialogNodeOptions builder + */ + public Builder newOutput(DialogNodeOutput newOutput) { + this.newOutput = newOutput; + return this; + } + + /** + * Set the newContext. + * + * @param newContext the newContext + * @return the UpdateDialogNodeOptions builder + */ + public Builder newContext(DialogNodeContext newContext) { + this.newContext = newContext; + return this; + } + + /** + * Set the newMetadata. + * + * @param newMetadata the newMetadata + * @return the UpdateDialogNodeOptions builder + */ + public Builder newMetadata(Map newMetadata) { + this.newMetadata = newMetadata; + return this; + } + + /** + * Set the newNextStep. + * + * @param newNextStep the newNextStep + * @return the UpdateDialogNodeOptions builder + */ + public Builder newNextStep(DialogNodeNextStep newNextStep) { + this.newNextStep = newNextStep; + return this; + } + + /** + * Set the newTitle. + * + * @param newTitle the newTitle + * @return the UpdateDialogNodeOptions builder + */ + public Builder newTitle(String newTitle) { + this.newTitle = newTitle; + return this; + } + + /** + * Set the newType. + * + * @param newType the newType + * @return the UpdateDialogNodeOptions builder + */ + public Builder newType(String newType) { + this.newType = newType; + return this; + } + + /** + * Set the newEventName. + * + * @param newEventName the newEventName + * @return the UpdateDialogNodeOptions builder + */ + public Builder newEventName(String newEventName) { + this.newEventName = newEventName; + return this; + } + + /** + * Set the newVariable. + * + * @param newVariable the newVariable + * @return the UpdateDialogNodeOptions builder + */ + public Builder newVariable(String newVariable) { + this.newVariable = newVariable; + return this; + } + + /** + * Set the newActions. Existing newActions will be replaced. + * + * @param newActions the newActions + * @return the UpdateDialogNodeOptions builder + */ + public Builder newActions(List newActions) { + this.newActions = newActions; + return this; + } + + /** + * Set the newDigressIn. + * + * @param newDigressIn the newDigressIn + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDigressIn(String newDigressIn) { + this.newDigressIn = newDigressIn; + return this; + } + + /** + * Set the newDigressOut. + * + * @param newDigressOut the newDigressOut + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDigressOut(String newDigressOut) { + this.newDigressOut = newDigressOut; + return this; + } + + /** + * Set the newDigressOutSlots. + * + * @param newDigressOutSlots the newDigressOutSlots + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDigressOutSlots(String newDigressOutSlots) { + this.newDigressOutSlots = newDigressOutSlots; + return this; + } + + /** + * Set the newUserLabel. + * + * @param newUserLabel the newUserLabel + * @return the UpdateDialogNodeOptions builder + */ + public Builder newUserLabel(String newUserLabel) { + this.newUserLabel = newUserLabel; + return this; + } + + /** + * Set the newDisambiguationOptOut. + * + * @param newDisambiguationOptOut the newDisambiguationOptOut + * @return the UpdateDialogNodeOptions builder + */ + public Builder newDisambiguationOptOut(Boolean newDisambiguationOptOut) { + this.newDisambiguationOptOut = newDisambiguationOptOut; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateDialogNodeOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + dialogNode = builder.dialogNode; + newDialogNode = builder.newDialogNode; + newDescription = builder.newDescription; + newConditions = builder.newConditions; + newParent = builder.newParent; + newPreviousSibling = builder.newPreviousSibling; + newOutput = builder.newOutput; + newContext = builder.newContext; + newMetadata = builder.newMetadata; + newNextStep = builder.newNextStep; + newTitle = builder.newTitle; + newType = builder.newType; + newEventName = builder.newEventName; + newVariable = builder.newVariable; + newActions = builder.newActions; + newDigressIn = builder.newDigressIn; + newDigressOut = builder.newDigressOut; + newDigressOutSlots = builder.newDigressOutSlots; + newUserLabel = builder.newUserLabel; + newDisambiguationOptOut = builder.newDisambiguationOptOut; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateDialogNodeOptions 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 newDialogNode. + * + *

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 + */ + public String newDialogNode() { + return newDialogNode; + } + + /** + * Gets the newDescription. + * + *

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

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

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

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

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 + */ + public DialogNodeOutput newOutput() { + return newOutput; + } + + /** + * Gets the newContext. + * + *

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

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

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

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 + */ + public String newTitle() { + return newTitle; + } + + /** + * Gets the newType. + * + *

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

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

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

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

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

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

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

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 + */ + public String newUserLabel() { + return newUserLabel; + } + + /** + * Gets the newDisambiguationOptOut. + * + *

Whether the dialog node should be excluded from disambiguation suggestions. Valid only when + * **type**=`standard` or `frame`. + * + * @return the newDisambiguationOptOut + */ + public Boolean newDisambiguationOptOut() { + return newDisambiguationOptOut; + } + + /** + * 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/UpdateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java new file mode 100644 index 00000000000..5adcc616330 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateEntityOptions.java @@ -0,0 +1,336 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 updateEntity options. */ +public class UpdateEntityOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String newEntity; + protected String newDescription; + protected Map newMetadata; + protected Boolean newFuzzyMatch; + protected List newValues; + protected Boolean append; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String newEntity; + private String newDescription; + private Map newMetadata; + private Boolean newFuzzyMatch; + private List newValues; + 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; + this.newEntity = updateEntityOptions.newEntity; + this.newDescription = updateEntityOptions.newDescription; + this.newMetadata = updateEntityOptions.newMetadata; + this.newFuzzyMatch = updateEntityOptions.newFuzzyMatch; + this.newValues = updateEntityOptions.newValues; + this.append = updateEntityOptions.append; + this.includeAudit = updateEntityOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + */ + public Builder(String workspaceId, String entity) { + this.workspaceId = workspaceId; + this.entity = entity; + } + + /** + * Builds a UpdateEntityOptions. + * + * @return the new UpdateEntityOptions instance + */ + public UpdateEntityOptions build() { + return new UpdateEntityOptions(this); + } + + /** + * Adds a new element to newValues. + * + * @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"); + if (this.newValues == null) { + this.newValues = new ArrayList(); + } + this.newValues.add(value); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateEntityOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the UpdateEntityOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the newEntity. + * + * @param newEntity the newEntity + * @return the UpdateEntityOptions builder + */ + public Builder newEntity(String newEntity) { + this.newEntity = newEntity; + return this; + } + + /** + * Set the newDescription. + * + * @param newDescription the newDescription + * @return the UpdateEntityOptions builder + */ + public Builder newDescription(String newDescription) { + this.newDescription = newDescription; + return this; + } + + /** + * Set the newMetadata. + * + * @param newMetadata the newMetadata + * @return the UpdateEntityOptions builder + */ + public Builder newMetadata(Map newMetadata) { + this.newMetadata = newMetadata; + return this; + } + + /** + * Set the newFuzzyMatch. + * + * @param newFuzzyMatch the newFuzzyMatch + * @return the UpdateEntityOptions builder + */ + public Builder newFuzzyMatch(Boolean newFuzzyMatch) { + this.newFuzzyMatch = newFuzzyMatch; + return this; + } + + /** + * Set the newValues. Existing newValues will be replaced. + * + * @param newValues the newValues + * @return the UpdateEntityOptions builder + */ + public Builder newValues(List newValues) { + this.newValues = newValues; + return this; + } + + /** + * Set the append. + * + * @param append the append + * @return the UpdateEntityOptions builder + */ + public Builder append(Boolean append) { + this.append = append; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateEntityOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + newEntity = builder.newEntity; + newDescription = builder.newDescription; + newMetadata = builder.newMetadata; + newFuzzyMatch = builder.newFuzzyMatch; + newValues = builder.newValues; + append = builder.append; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateEntityOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return 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-`. + * + * @return the newEntity + */ + public String newEntity() { + return newEntity; + } + + /** + * Gets the newDescription. + * + *

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

Any metadata related to the entity. + * + * @return the newMetadata + */ + public Map newMetadata() { + return newMetadata; + } + + /** + * Gets the newFuzzyMatch. + * + *

Whether to use fuzzy matching for the entity. + * + * @return the newFuzzyMatch + */ + public Boolean newFuzzyMatch() { + return newFuzzyMatch; + } + + /** + * Gets the newValues. + * + *

An array of objects describing the entity values. + * + * @return the newValues + */ + public List newValues() { + return 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. + * + *

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; + } + + /** + * 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/UpdateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java new file mode 100644 index 00000000000..8de7bd36e55 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateExampleOptions.java @@ -0,0 +1,252 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 updateExample options. */ +public class UpdateExampleOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String text; + protected String newText; + protected List newMentions; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String intent; + private String text; + private String newText; + 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; + this.text = updateExampleOptions.text; + this.newText = updateExampleOptions.newText; + this.newMentions = updateExampleOptions.newMentions; + this.includeAudit = updateExampleOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + * @param text the text + */ + public Builder(String workspaceId, String intent, String text) { + this.workspaceId = workspaceId; + this.intent = intent; + this.text = text; + } + + /** + * Builds a UpdateExampleOptions. + * + * @return the new UpdateExampleOptions instance + */ + public UpdateExampleOptions build() { + return new UpdateExampleOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.newMentions == null) { + this.newMentions = new ArrayList(); + } + this.newMentions.add(newMentions); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateExampleOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the UpdateExampleOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the UpdateExampleOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the newText. + * + * @param newText the newText + * @return the UpdateExampleOptions builder + */ + public Builder newText(String newText) { + this.newText = newText; + return this; + } + + /** + * Set the newMentions. Existing newMentions will be replaced. + * + * @param newMentions the newMentions + * @return the UpdateExampleOptions builder + */ + public Builder newMentions(List newMentions) { + this.newMentions = newMentions; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateExampleOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + text = builder.text; + newText = builder.newText; + newMentions = builder.newMentions; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateExampleOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the text. + * + *

The text of the user input example. + * + * @return the text + */ + public String text() { + return 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. + * + * @return the newText + */ + public String newText() { + return newText; + } + + /** + * Gets the newMentions. + * + *

An array of contextual entity mentions. + * + * @return the newMentions + */ + public List newMentions() { + return newMentions; + } + + /** + * 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/UpdateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java new file mode 100644 index 00000000000..8a0247e3539 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateIntentOptions.java @@ -0,0 +1,283 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 updateIntent options. */ +public class UpdateIntentOptions extends GenericModel { + + protected String workspaceId; + protected String intent; + protected String newIntent; + protected String newDescription; + protected List newExamples; + protected Boolean append; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String intent; + private String newIntent; + private String newDescription; + private List newExamples; + 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; + this.newIntent = updateIntentOptions.newIntent; + this.newDescription = updateIntentOptions.newDescription; + this.newExamples = updateIntentOptions.newExamples; + this.append = updateIntentOptions.append; + this.includeAudit = updateIntentOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param intent the intent + */ + public Builder(String workspaceId, String intent) { + this.workspaceId = workspaceId; + this.intent = intent; + } + + /** + * Builds a UpdateIntentOptions. + * + * @return the new UpdateIntentOptions instance + */ + public UpdateIntentOptions build() { + return new UpdateIntentOptions(this); + } + + /** + * Adds a new element to newExamples. + * + * @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"); + if (this.newExamples == null) { + this.newExamples = new ArrayList(); + } + this.newExamples.add(example); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateIntentOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the UpdateIntentOptions builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the newIntent. + * + * @param newIntent the newIntent + * @return the UpdateIntentOptions builder + */ + public Builder newIntent(String newIntent) { + this.newIntent = newIntent; + return this; + } + + /** + * Set the newDescription. + * + * @param newDescription the newDescription + * @return the UpdateIntentOptions builder + */ + public Builder newDescription(String newDescription) { + this.newDescription = newDescription; + return this; + } + + /** + * Set the newExamples. Existing newExamples will be replaced. + * + * @param newExamples the newExamples + * @return the UpdateIntentOptions builder + */ + public Builder newExamples(List newExamples) { + this.newExamples = newExamples; + return this; + } + + /** + * Set the append. + * + * @param append the append + * @return the UpdateIntentOptions builder + */ + public Builder append(Boolean append) { + this.append = append; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateIntentOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + intent = builder.intent; + newIntent = builder.newIntent; + newDescription = builder.newDescription; + newExamples = builder.newExamples; + append = builder.append; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateIntentOptions 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 intent. + * + *

The intent name. + * + * @return the intent + */ + public String intent() { + return 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-`. + * + * @return the newIntent + */ + public String newIntent() { + return newIntent; + } + + /** + * Gets the newDescription. + * + *

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

An array of user input examples for the intent. + * + * @return the newExamples + */ + public List newExamples() { + return 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 + * 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. + * + * @return the append + */ + public Boolean append() { + return append; + } + + /** + * 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/UpdateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java new file mode 100644 index 00000000000..7af939d7037 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateSynonymOptions.java @@ -0,0 +1,238 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class UpdateSynonymOptions extends GenericModel { + + protected String workspaceId; + protected String entity; + protected String value; + protected String synonym; + protected String newSynonym; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + private String synonym; + 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; + this.value = updateSynonymOptions.value; + this.synonym = updateSynonymOptions.synonym; + this.newSynonym = updateSynonymOptions.newSynonym; + this.includeAudit = updateSynonymOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + * @param synonym the synonym + */ + public Builder(String workspaceId, String entity, String value, String synonym) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + this.synonym = synonym; + } + + /** + * Builds a UpdateSynonymOptions. + * + * @return the new UpdateSynonymOptions instance + */ + public UpdateSynonymOptions build() { + return new UpdateSynonymOptions(this); + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateSynonymOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the UpdateSynonymOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the UpdateSynonymOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the synonym. + * + * @param synonym the synonym + * @return the UpdateSynonymOptions builder + */ + public Builder synonym(String synonym) { + this.synonym = synonym; + return this; + } + + /** + * Set the newSynonym. + * + * @param newSynonym the newSynonym + * @return the UpdateSynonymOptions builder + */ + public Builder newSynonym(String newSynonym) { + this.newSynonym = newSynonym; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateSynonymOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + synonym = builder.synonym; + newSynonym = builder.newSynonym; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateSynonymOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the synonym. + * + *

The text of the synonym. + * + * @return the synonym + */ + public String synonym() { + return 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. + * + * @return the newSynonym + */ + public String newSynonym() { + return newSynonym; + } + + /** + * 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/UpdateValueOptions.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java new file mode 100644 index 00000000000..40583789789 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateValueOptions.java @@ -0,0 +1,393 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 updateValue options. */ +public class UpdateValueOptions extends GenericModel { + + /** Specifies the type of entity value. */ + public interface NewType { + /** synonyms. */ + String SYNONYMS = "synonyms"; + /** patterns. */ + String PATTERNS = "patterns"; + } + + protected String workspaceId; + protected String entity; + protected String value; + protected String newValue; + protected Map newMetadata; + protected String newType; + protected List newSynonyms; + protected List newPatterns; + protected Boolean append; + protected Boolean includeAudit; + + /** Builder. */ + public static class Builder { + private String workspaceId; + private String entity; + private String value; + private String newValue; + private Map newMetadata; + private String newType; + private List newSynonyms; + private List newPatterns; + 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; + this.value = updateValueOptions.value; + this.newValue = updateValueOptions.newValue; + this.newMetadata = updateValueOptions.newMetadata; + this.newType = updateValueOptions.newType; + this.newSynonyms = updateValueOptions.newSynonyms; + this.newPatterns = updateValueOptions.newPatterns; + this.append = updateValueOptions.append; + this.includeAudit = updateValueOptions.includeAudit; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param workspaceId the workspaceId + * @param entity the entity + * @param value the value + */ + public Builder(String workspaceId, String entity, String value) { + this.workspaceId = workspaceId; + this.entity = entity; + this.value = value; + } + + /** + * Builds a UpdateValueOptions. + * + * @return the new UpdateValueOptions instance + */ + public UpdateValueOptions build() { + return new UpdateValueOptions(this); + } + + /** + * Adds a new element to newSynonyms. + * + * @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"); + if (this.newSynonyms == null) { + this.newSynonyms = new ArrayList(); + } + this.newSynonyms.add(synonym); + return this; + } + + /** + * Adds a new element to newPatterns. + * + * @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"); + if (this.newPatterns == null) { + this.newPatterns = new ArrayList(); + } + this.newPatterns.add(pattern); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateValueOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the entity. + * + * @param entity the entity + * @return the UpdateValueOptions builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the UpdateValueOptions builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the newValue. + * + * @param newValue the newValue + * @return the UpdateValueOptions builder + */ + public Builder newValue(String newValue) { + this.newValue = newValue; + return this; + } + + /** + * Set the newMetadata. + * + * @param newMetadata the newMetadata + * @return the UpdateValueOptions builder + */ + public Builder newMetadata(Map newMetadata) { + this.newMetadata = newMetadata; + return this; + } + + /** + * Set the newType. + * + * @param newType the newType + * @return the UpdateValueOptions builder + */ + public Builder newType(String newType) { + this.newType = newType; + return this; + } + + /** + * Set the newSynonyms. Existing newSynonyms will be replaced. + * + * @param newSynonyms the newSynonyms + * @return the UpdateValueOptions builder + */ + public Builder newSynonyms(List newSynonyms) { + this.newSynonyms = newSynonyms; + return this; + } + + /** + * Set the newPatterns. Existing newPatterns will be replaced. + * + * @param newPatterns the newPatterns + * @return the UpdateValueOptions builder + */ + public Builder newPatterns(List newPatterns) { + this.newPatterns = newPatterns; + return this; + } + + /** + * Set the append. + * + * @param append the append + * @return the UpdateValueOptions builder + */ + public Builder append(Boolean append) { + this.append = append; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateValueOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + 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"); + workspaceId = builder.workspaceId; + entity = builder.entity; + value = builder.value; + newValue = builder.newValue; + newMetadata = builder.newMetadata; + newType = builder.newType; + newSynonyms = builder.newSynonyms; + newPatterns = builder.newPatterns; + append = builder.append; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateValueOptions 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 entity. + * + *

The name of the entity. + * + * @return the entity + */ + public String entity() { + return entity; + } + + /** + * Gets the value. + * + *

The text of the entity value. + * + * @return the value + */ + public String value() { + return 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. + * + * @return the newValue + */ + public String newValue() { + return newValue; + } + + /** + * Gets the newMetadata. + * + *

Any metadata related to the entity value. + * + * @return the newMetadata + */ + public Map newMetadata() { + return newMetadata; + } + + /** + * Gets the newType. + * + *

Specifies the type of entity value. + * + * @return the newType + */ + public String newType() { + return 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. + * + * @return the newSynonyms + */ + public List newSynonyms() { + return 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 + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). + * + * @return the newPatterns + */ + public List newPatterns() { + return 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. + * + *

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; + } + + /** + * 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/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 new file mode 100644 index 00000000000..a1c069de5f1 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/UpdateWorkspaceOptions.java @@ -0,0 +1,523 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 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 Boolean append; + protected Boolean includeAudit; + + /** 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; + 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.append = updateWorkspaceOptions.append; + this.includeAudit = updateWorkspaceOptions.includeAudit; + } + + /** 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 UpdateWorkspaceOptions. + * + * @return the new UpdateWorkspaceOptions instance + */ + public UpdateWorkspaceOptions build() { + return new UpdateWorkspaceOptions(this); + } + + /** + * Adds a new element to dialogNodes. + * + * @param dialogNode 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(); + } + this.dialogNodes.add(dialogNode); + return this; + } + + /** + * Adds a new element to counterexamples. + * + * @param counterexample 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(); + } + this.counterexamples.add(counterexample); + return this; + } + + /** + * Adds a new element to webhooks. + * + * @param webhooks 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(); + } + this.webhooks.add(webhooks); + return this; + } + + /** + * Adds a new element to intents. + * + * @param intent 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(); + } + this.intents.add(intent); + return this; + } + + /** + * Adds a new element to entities. + * + * @param entity 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(); + } + this.entities.add(entity); + return this; + } + + /** + * Set the workspaceId. + * + * @param workspaceId the workspaceId + * @return the UpdateWorkspaceOptions builder + */ + public Builder workspaceId(String workspaceId) { + this.workspaceId = workspaceId; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the UpdateWorkspaceOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the UpdateWorkspaceOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder + */ + public Builder counterexamples(List counterexamples) { + this.counterexamples = counterexamples; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the UpdateWorkspaceOptions builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the learningOptOut. + * + * @param learningOptOut the learningOptOut + * @return the UpdateWorkspaceOptions builder + */ + public Builder learningOptOut(Boolean learningOptOut) { + this.learningOptOut = learningOptOut; + return this; + } + + /** + * Set the systemSettings. + * + * @param systemSettings the systemSettings + * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions 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 UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the append. + * + * @param append the append + * @return the UpdateWorkspaceOptions builder + */ + public Builder append(Boolean append) { + this.append = append; + return this; + } + + /** + * Set the includeAudit. + * + * @param includeAudit the includeAudit + * @return the UpdateWorkspaceOptions builder + */ + public Builder includeAudit(Boolean includeAudit) { + this.includeAudit = includeAudit; + return this; + } + } + + protected UpdateWorkspaceOptions() {} + + protected UpdateWorkspaceOptions(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; + includeAudit = builder.includeAudit; + } + + /** + * New builder. + * + * @return a UpdateWorkspaceOptions 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; + } + + /** + * 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/Value.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java new file mode 100644 index 00000000000..c5385865995 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Value.java @@ -0,0 +1,276 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Value. */ +public class Value extends GenericModel { + + /** Specifies the type of entity value. */ + public interface Type { + /** synonyms. */ + String SYNONYMS = "synonyms"; + /** patterns. */ + String PATTERNS = "patterns"; + } + + protected String value; + protected Map metadata; + protected String type; + protected List synonyms; + protected List patterns; + protected Date created; + protected Date updated; + + /** Builder. */ + public static class Builder { + private String value; + private Map metadata; + private String type; + private List synonyms; + private List patterns; + + /** + * 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param value the value + * @param type the type + */ + public Builder(String value, String type) { + this.value = value; + this.type = type; + } + + /** + * Builds a Value. + * + * @return the new Value instance + */ + public Value build() { + return new Value(this); + } + + /** + * Adds a new element to synonyms. + * + * @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"); + if (this.synonyms == null) { + this.synonyms = new ArrayList(); + } + this.synonyms.add(synonym); + return this; + } + + /** + * Adds a new element to patterns. + * + * @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"); + if (this.patterns == null) { + this.patterns = new ArrayList(); + } + this.patterns.add(pattern); + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the Value builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the Value builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the type. + * + * @param type the type + * @return the Value builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + + /** + * Set the synonyms. Existing synonyms will be replaced. + * + * @param synonyms the synonyms + * @return the Value builder + */ + public Builder synonyms(List synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Set the patterns. Existing patterns will be replaced. + * + * @param patterns the patterns + * @return the Value builder + */ + public Builder patterns(List patterns) { + this.patterns = patterns; + 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"); + value = builder.value; + metadata = builder.metadata; + type = builder.type; + synonyms = builder.synonyms; + patterns = builder.patterns; + } + + /** + * New builder. + * + * @return a Value builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the value + */ + public String value() { + return value; + } + + /** + * Gets the metadata. + * + *

Any metadata related to the entity value. + * + * @return the metadata + */ + public Map metadata() { + return metadata; + } + + /** + * Gets the type. + * + *

Specifies the type of entity value. + * + * @return the type + */ + public String type() { + return 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. + * + * @return the synonyms + */ + public List synonyms() { + return 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 + * [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-create-dictionary-based). + * + * @return the patterns + */ + public List patterns() { + return patterns; + } + + /** + * 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/v1/model/ValueCollection.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java new file mode 100644 index 00000000000..869b0a07027 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/ValueCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** ValueCollection. */ +public class ValueCollection extends GenericModel { + + protected List values; + protected Pagination pagination; + + protected ValueCollection() {} + + /** + * Gets the values. + * + *

An array of entity values. + * + * @return the values + */ + public List getValues() { + return values; + } + + /** + * 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/v1/model/Webhook.java b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java new file mode 100644 index 00000000000..7a9efcf30b5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Webhook.java @@ -0,0 +1,172 @@ +/* + * (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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** + * 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. + */ +public class Webhook extends GenericModel { + + protected String url; + protected String name; + protected List headers; + + /** 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 with required properties. + * + * @param url the url + * @param name the name + */ + public Builder(String url, String name) { + this.url = url; + this.name = name; + } + + /** + * Builds a Webhook. + * + * @return the new Webhook instance + */ + public Webhook build() { + return new Webhook(this); + } + + /** + * Adds a new element to 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"); + if (this.headers == null) { + this.headers = new ArrayList(); + } + this.headers.add(headers); + return this; + } + + /** + * Set the url. + * + * @param url the url + * @return the Webhook builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the name. + * + * @param name the name + * @return the Webhook builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the headers. Existing headers will be replaced. + * + * @param headers the headers + * @return the Webhook builder + */ + public Builder headers(List headers) { + this.headers = headers; + return this; + } + } + + 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"); + url = builder.url; + name = builder.name; + headers = builder.headers; + } + + /** + * New builder. + * + * @return a Webhook builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the url. + * + *

The URL for the external service or application to which you want to send HTTP POST + * requests. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the name. + * + *

The name of the webhook. Currently, `main_webhook` is the only supported value. + * + * @return the name + */ + public String name() { + return name; + } + + /** + * Gets the headers. + * + *

An optional array of HTTP headers to pass with the HTTP request. + * + * @return the headers + */ + public List headers() { + return 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 new file mode 100644 index 00000000000..436bfb87b63 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WebhookHeader.java @@ -0,0 +1,124 @@ +/* + * (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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A key/value pair defining an HTTP header and a value. */ +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 (for example, `Authorization`). + * + * @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/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 new file mode 100644 index 00000000000..4fc9c506a78 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/Workspace.java @@ -0,0 +1,276 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** Workspace. */ +public class Workspace extends GenericModel { + + /** + * 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"; + /** Unavailable. */ + String UNAVAILABLE = "Unavailable"; + } + + 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; + + protected String status; + + @SerializedName("status_errors") + protected List statusErrors; + + protected List webhooks; + protected List intents; + protected List entities; + protected WorkspaceCounts counts; + + protected Workspace() {} + + /** + * Gets the name. + * + *

The name of the workspace. 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 workspace. This string cannot contain carriage return, newline, or + * tab characters. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the language. + * + *

The language of the workspace. + * + * @return the language + */ + 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. + * + * @return the metadata + */ + public Map getMetadata() { + 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 isLearningOptOut() { + return learningOptOut; + } + + /** + * Gets the systemSettings. + * + *

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

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 + */ + public String getStatus() { + return status; + } + + /** + * Gets the statusErrors. + * + *

An array of messages about errors that caused an asynchronous operation to fail. + * + * @return the statusErrors + */ + public List getStatusErrors() { + return statusErrors; + } + + /** + * Gets the webhooks. + * + * @return the webhooks + */ + public List getWebhooks() { + return webhooks; + } + + /** + * Gets the intents. + * + *

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

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

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 counts + */ + 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 new file mode 100644 index 00000000000..6c98c577cc4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceCollection.java @@ -0,0 +1,49 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** 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. + * + * @return the workspaces + */ + public List getWorkspaces() { + return workspaces; + } + + /** + * 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/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 new file mode 100644 index 00000000000..ccab1bbf8f6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettings.java @@ -0,0 +1,389 @@ +/* + * (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.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; + +/** + * Global settings for the workspace. + * + *

This type supports additional properties of type Object. For internal use only. + */ +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; + + @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() {} + + /** + * Builds a WorkspaceSystemSettings. + * + * @return the new WorkspaceSystemSettings instance + */ + public WorkspaceSystemSettings build() { + return new WorkspaceSystemSettings(this); + } + + /** + * Set the tooling. + * + * @param tooling the tooling + * @return the WorkspaceSystemSettings builder + */ + public Builder tooling(WorkspaceSystemSettingsTooling tooling) { + this.tooling = tooling; + return this; + } + + /** + * Set the disambiguation. + * + * @param disambiguation the disambiguation + * @return the WorkspaceSystemSettings builder + */ + public Builder disambiguation(WorkspaceSystemSettingsDisambiguation disambiguation) { + this.disambiguation = disambiguation; + return this; + } + + /** + * Set the humanAgentAssist. + * + * @param humanAgentAssist the humanAgentAssist + * @return the WorkspaceSystemSettings builder + */ + public Builder humanAgentAssist(Map humanAgentAssist) { + this.humanAgentAssist = 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. + * + * @param systemEntities the systemEntities + * @return the WorkspaceSystemSettings builder + */ + public Builder systemEntities(WorkspaceSystemSettingsSystemEntities systemEntities) { + this.systemEntities = systemEntities; + return this; + } + + /** + * Set the offTopic. + * + * @param offTopic the offTopic + * @return the WorkspaceSystemSettings builder + */ + 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); + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettings builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tooling. + * + *

Workspace settings related to the Watson Assistant user interface. + * + * @return the tooling + */ + public WorkspaceSystemSettingsTooling getTooling() { + return this.tooling; + } + + /** + * Sets the tooling. + * + * @param tooling the new tooling + */ + public void setTooling(final WorkspaceSystemSettingsTooling tooling) { + this.tooling = tooling; + } + + /** + * Gets the disambiguation. + * + *

Workspace settings related to the disambiguation feature. + * + * @return the 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. + * + * @return the 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. + * + * @return the 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. + * + * @return the 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 new file mode 100644 index 00000000000..80f3d6c563d --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsDisambiguation.java @@ -0,0 +1,275 @@ +/* + * (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.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Workspace settings related to the disambiguation feature. */ +public class WorkspaceSystemSettingsDisambiguation extends GenericModel { + + /** + * 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. */ + public static class Builder { + private String prompt; + private String noneOfTheAbovePrompt; + private Boolean enabled; + private String sensitivity; + private Boolean randomize; + 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; + this.enabled = workspaceSystemSettingsDisambiguation.enabled; + this.sensitivity = workspaceSystemSettingsDisambiguation.sensitivity; + this.randomize = workspaceSystemSettingsDisambiguation.randomize; + this.maxSuggestions = workspaceSystemSettingsDisambiguation.maxSuggestions; + this.suggestionTextPolicy = workspaceSystemSettingsDisambiguation.suggestionTextPolicy; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a WorkspaceSystemSettingsDisambiguation. + * + * @return the new WorkspaceSystemSettingsDisambiguation instance + */ + public WorkspaceSystemSettingsDisambiguation build() { + return new WorkspaceSystemSettingsDisambiguation(this); + } + + /** + * Set the prompt. + * + * @param prompt the prompt + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder prompt(String prompt) { + this.prompt = prompt; + return this; + } + + /** + * Set the noneOfTheAbovePrompt. + * + * @param noneOfTheAbovePrompt the noneOfTheAbovePrompt + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder noneOfTheAbovePrompt(String noneOfTheAbovePrompt) { + this.noneOfTheAbovePrompt = noneOfTheAbovePrompt; + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the sensitivity. + * + * @param sensitivity the sensitivity + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder sensitivity(String sensitivity) { + this.sensitivity = sensitivity; + return this; + } + + /** + * Set the randomize. + * + * @param randomize the randomize + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder randomize(Boolean randomize) { + this.randomize = randomize; + return this; + } + + /** + * Set the maxSuggestions. + * + * @param maxSuggestions the maxSuggestions + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder maxSuggestions(long maxSuggestions) { + this.maxSuggestions = maxSuggestions; + return this; + } + + /** + * Set the suggestionTextPolicy. + * + * @param suggestionTextPolicy the suggestionTextPolicy + * @return the WorkspaceSystemSettingsDisambiguation builder + */ + public Builder suggestionTextPolicy(String suggestionTextPolicy) { + this.suggestionTextPolicy = suggestionTextPolicy; + return this; + } + } + + protected WorkspaceSystemSettingsDisambiguation() {} + + protected WorkspaceSystemSettingsDisambiguation(Builder builder) { + prompt = builder.prompt; + noneOfTheAbovePrompt = builder.noneOfTheAbovePrompt; + enabled = builder.enabled; + sensitivity = builder.sensitivity; + randomize = builder.randomize; + maxSuggestions = builder.maxSuggestions; + suggestionTextPolicy = builder.suggestionTextPolicy; + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettingsDisambiguation builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the prompt. + * + *

The text of the introductory prompt that accompanies disambiguation options presented to the + * user. + * + * @return the prompt + */ + public String prompt() { + return 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. + * + * @return the noneOfTheAbovePrompt + */ + public String noneOfTheAbovePrompt() { + return noneOfTheAbovePrompt; + } + + /** + * Gets the enabled. + * + *

Whether the disambiguation feature is enabled for the workspace. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the sensitivity. + * + *

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 + */ + public String sensitivity() { + return sensitivity; + } + + /** + * Gets the randomize. + * + *

Whether the order in which disambiguation suggestions are presented should be randomized + * (but still influenced by relative confidence). + * + * @return the randomize + */ + public Boolean randomize() { + return randomize; + } + + /** + * Gets the maxSuggestions. + * + *

The maximum number of disambigation suggestions that can be included in a `suggestion` + * response. + * + * @return the maxSuggestions + */ + public Long maxSuggestions() { + return maxSuggestions; + } + + /** + * Gets the suggestionTextPolicy. + * + *

For internal use only. + * + * @return the suggestionTextPolicy + */ + public String suggestionTextPolicy() { + return 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 new file mode 100644 index 00000000000..f948dc2ecf3 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsOffTopic.java @@ -0,0 +1,85 @@ +/* + * (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.assistant.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Workspace settings related to detection of irrelevant input. */ +public class WorkspaceSystemSettingsOffTopic extends GenericModel { + + protected Boolean enabled; + + /** 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() {} + + /** + * Builds a WorkspaceSystemSettingsOffTopic. + * + * @return the new WorkspaceSystemSettingsOffTopic instance + */ + public WorkspaceSystemSettingsOffTopic build() { + return new WorkspaceSystemSettingsOffTopic(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the WorkspaceSystemSettingsOffTopic builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + } + + protected WorkspaceSystemSettingsOffTopic() {} + + protected WorkspaceSystemSettingsOffTopic(Builder builder) { + enabled = builder.enabled; + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettingsOffTopic builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

Whether enhanced irrelevance detection is enabled for the workspace. + * + * @return the enabled + */ + public Boolean enabled() { + return 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 new file mode 100644 index 00000000000..2cb0a99a5dc --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsSystemEntities.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; + +/** Workspace settings related to the behavior of system entities. */ +public class WorkspaceSystemSettingsSystemEntities extends GenericModel { + + protected Boolean enabled; + + /** 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() {} + + /** + * Builds a WorkspaceSystemSettingsSystemEntities. + * + * @return the new WorkspaceSystemSettingsSystemEntities instance + */ + public WorkspaceSystemSettingsSystemEntities build() { + return new WorkspaceSystemSettingsSystemEntities(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the WorkspaceSystemSettingsSystemEntities builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + } + + protected WorkspaceSystemSettingsSystemEntities() {} + + protected WorkspaceSystemSettingsSystemEntities(Builder builder) { + enabled = builder.enabled; + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettingsSystemEntities builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

Whether the new system entities are enabled for the workspace. + * + * @return the enabled + */ + public Boolean enabled() { + return 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 new file mode 100644 index 00000000000..b4e0484f734 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/model/WorkspaceSystemSettingsTooling.java @@ -0,0 +1,87 @@ +/* + * (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.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. */ +public class WorkspaceSystemSettingsTooling extends GenericModel { + + @SerializedName("store_generic_responses") + protected Boolean storeGenericResponses; + + /** 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() {} + + /** + * Builds a WorkspaceSystemSettingsTooling. + * + * @return the new WorkspaceSystemSettingsTooling instance + */ + public WorkspaceSystemSettingsTooling build() { + return new WorkspaceSystemSettingsTooling(this); + } + + /** + * Set the storeGenericResponses. + * + * @param storeGenericResponses the storeGenericResponses + * @return the WorkspaceSystemSettingsTooling builder + */ + public Builder storeGenericResponses(Boolean storeGenericResponses) { + this.storeGenericResponses = storeGenericResponses; + return this; + } + } + + protected WorkspaceSystemSettingsTooling() {} + + protected WorkspaceSystemSettingsTooling(Builder builder) { + storeGenericResponses = builder.storeGenericResponses; + } + + /** + * New builder. + * + * @return a WorkspaceSystemSettingsTooling builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the storeGenericResponses. + * + *

Whether the dialog JSON editor displays text responses within the `output.generic` object. + * + * @return the storeGenericResponses + */ + public Boolean storeGenericResponses() { + return 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 new file mode 100644 index 00000000000..2c201294c43 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v1/package-info.java @@ -0,0 +1,15 @@ +/* + * (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. + */ + +/** 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 new file mode 100644 index 00000000000..0316d173cb7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/Assistant.java @@ -0,0 +1,1645 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT 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; +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.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.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&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. + * + *

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 { + + /** Default service name used when configuring the `Assistant` client. */ + public static final String DEFAULT_SERVICE_NAME = "assistant"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.assistant.watson.cloud.ibm.com"; + + private String version; + + /** + * Constructs an instance of the `Assistant` client. The default service name is used to configure + * the client instance. + * + * @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 version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + } + + /** + * Constructs an instance of the `Assistant` client. The default service name and specified + * authenticator are used to configure the client instance. + * + * @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 version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `Assistant` client. The specified service name is used to + * configure the client instance. + * + * @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 version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `Assistant` client. The specified service name and authenticator + * are used to configure the client instance. + * + * @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 version, String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + 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).). + * + * @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"); + 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"); + 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)). + * + * @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"); + 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 (stateful). + * + *

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 result of type {@link StatefulMessageResponse} + */ + 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())); + } + if (messageOptions.context() != null) { + 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()); + 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 new file mode 100644 index 00000000000..4b040d9d8ff --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CaptureGroup.java @@ -0,0 +1,139 @@ +/* + * (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; +import java.util.ArrayList; +import java.util.List; + +/** CaptureGroup. */ +public class CaptureGroup extends GenericModel { + + protected String group; + protected List location; + + /** 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 with required properties. + * + * @param group the group + */ + public Builder(String group) { + this.group = group; + } + + /** + * Builds a CaptureGroup. + * + * @return the new CaptureGroup instance + */ + public CaptureGroup build() { + return new CaptureGroup(this); + } + + /** + * Adds a new element to 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"); + if (this.location == null) { + this.location = new ArrayList(); + } + this.location.add(location); + return this; + } + + /** + * Set the group. + * + * @param group the group + * @return the CaptureGroup builder + */ + public Builder group(String group) { + this.group = group; + return this; + } + + /** + * Set the location. Existing location will be replaced. + * + * @param location the location + * @return the CaptureGroup builder + */ + public Builder location(List location) { + this.location = location; + return this; + } + } + + protected CaptureGroup() {} + + protected CaptureGroup(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.group, "group cannot be null"); + group = builder.group; + location = builder.location; + } + + /** + * New builder. + * + * @return a CaptureGroup builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the group. + * + *

A recognized capture group for the entity. + * + * @return the group + */ + public String group() { + return group; + } + + /** + * Gets the location. + * + *

Zero-based character offsets that indicate where the entity value begins and ends in the + * input text. + * + * @return the location + */ + public List location() { + return 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 new file mode 100644 index 00000000000..2cd69d28c8e --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/CreateSessionOptions.java @@ -0,0 +1,157 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class CreateSessionOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected RequestAnalytics analytics; + + /** 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 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 CreateSessionOptions. + * + * @return the new CreateSessionOptions instance + */ + public CreateSessionOptions build() { + return new CreateSessionOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the CreateSessionOptions builder + */ + 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.environmentId, "environmentId cannot be empty"); + assistantId = builder.assistantId; + environmentId = builder.environmentId; + analytics = builder.analytics; + } + + /** + * New builder. + * + * @return a CreateSessionOptions 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 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 new file mode 100644 index 00000000000..e0dac574a86 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DeleteSessionOptions.java @@ -0,0 +1,159 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class DeleteSessionOptions extends GenericModel { + + protected String assistantId; + protected String environmentId; + protected String sessionId; + + /** 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 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 DeleteSessionOptions. + * + * @return the new DeleteSessionOptions instance + */ + public DeleteSessionOptions build() { + return new DeleteSessionOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the DeleteSessionOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = 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. + * + * @param sessionId the sessionId + * @return the DeleteSessionOptions builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + } + + 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.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; + } + + /** + * New builder. + * + * @return a DeleteSessionOptions 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; + } +} 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 new file mode 100644 index 00000000000..b8233f14bc7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogLogMessage.java @@ -0,0 +1,81 @@ +/* + * (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; + +/** Dialog log message details. */ +public class DialogLogMessage extends GenericModel { + + /** The severity of the log message. */ + public interface Level { + /** info. */ + String INFO = "info"; + /** error. */ + String ERROR = "error"; + /** warn. */ + String WARN = "warn"; + } + + protected String level; + protected String message; + protected String code; + protected LogMessageSource source; + + protected DialogLogMessage() {} + + /** + * Gets the level. + * + *

The severity of the log message. + * + * @return the level + */ + public String getLevel() { + return level; + } + + /** + * Gets the 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 new file mode 100644 index 00000000000..2a9ef0237d4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeAction.java @@ -0,0 +1,101 @@ +/* + * (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; +import java.util.Map; + +/** DialogNodeAction. */ +public class DialogNodeAction extends GenericModel { + + /** The type of action to invoke. */ + public interface Type { + /** client. */ + String CLIENT = "client"; + /** server. */ + String SERVER = "server"; + /** web-action. */ + String WEB_ACTION = "web-action"; + /** cloud-function. */ + String CLOUD_FUNCTION = "cloud-function"; + } + + 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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the type. + * + *

The type of action to invoke. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the parameters. + * + *

A map of key/value pairs to be provided to the action. + * + * @return the parameters + */ + public Map getParameters() { + return parameters; + } + + /** + * Gets the resultVariable. + * + *

The location in the dialog context where the result of the action is stored. + * + * @return the resultVariable + */ + public String getResultVariable() { + return resultVariable; + } + + /** + * Gets the credentials. + * + *

The name of the context variable that the client application will use to pass in credentials + * for the action. + * + * @return the credentials + */ + public String getCredentials() { + return 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 new file mode 100644 index 00000000000..812e7fe1451 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElement.java @@ -0,0 +1,48 @@ +/* + * (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; + +/** DialogNodeOutputOptionsElement. */ +public class DialogNodeOutputOptionsElement extends GenericModel { + + protected String label; + protected DialogNodeOutputOptionsElementValue value; + + protected DialogNodeOutputOptionsElement() {} + + /** + * Gets the label. + * + *

The user-facing label for the option. + * + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * Gets the value. + * + *

An object defining the message input to be sent to the assistant if the user selects the + * corresponding option. + * + * @return the value + */ + public DialogNodeOutputOptionsElementValue getValue() { + return 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 new file mode 100644 index 00000000000..46c1e983f75 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogNodeOutputOptionsElementValue.java @@ -0,0 +1,38 @@ +/* + * (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.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. + */ +public class DialogNodeOutputOptionsElementValue extends GenericModel { + + protected MessageInput input; + + protected DialogNodeOutputOptionsElementValue() {} + + /** + * Gets the input. + * + *

An input object that includes the input text. + * + * @return the input + */ + public MessageInput getInput() { + return 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/DialogSuggestion.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java new file mode 100644 index 00000000000..eb1c29b233f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestion.java @@ -0,0 +1,67 @@ +/* + * (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; +import java.util.Map; + +/** 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 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 + */ + public String getLabel() { + return label; + } + + /** + * Gets the value. + * + *

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 + */ + public DialogSuggestionValue getValue() { + return value; + } + + /** + * Gets the output. + * + *

The dialog output that will be returned from the watsonx Assistant service if the user + * selects the corresponding option. + * + * @return the output + */ + public Map getOutput() { + return 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 new file mode 100644 index 00000000000..fb3208180fb --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/DialogSuggestionValue.java @@ -0,0 +1,41 @@ +/* + * (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.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. + * + *

**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. + * + * @return the input + */ + public MessageInput getInput() { + return 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/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 new file mode 100644 index 00000000000..9554af80fae --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContext.java @@ -0,0 +1,140 @@ +/* + * (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; +import java.util.Map; + +/** MessageContext. */ +public class MessageContext extends GenericModel { + + protected MessageContextGlobal global; + protected MessageContextSkills skills; + protected Map integrations; + + /** 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() {} + + /** + * Builds a MessageContext. + * + * @return the new MessageContext instance + */ + public MessageContext build() { + return new MessageContext(this); + } + + /** + * Set the global. + * + * @param global the global + * @return the MessageContext builder + */ + public Builder global(MessageContextGlobal global) { + this.global = global; + return this; + } + + /** + * Set the skills. + * + * @param skills the skills + * @return the MessageContext builder + */ + 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; + } + + /** + * New builder. + * + * @return a MessageContext 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 MessageContextGlobal global() { + return global; + } + + /** + * Gets the skills. + * + *

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 new file mode 100644 index 00000000000..66d65e00a15 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobal.java @@ -0,0 +1,100 @@ +/* + * (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; + +/** Session context data that is shared by all skills used by the assistant. */ +public class MessageContextGlobal extends GenericModel { + + protected MessageContextGlobalSystem system; + + @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() {} + + /** + * Builds a MessageContextGlobal. + * + * @return the new MessageContextGlobal instance + */ + public MessageContextGlobal build() { + return new MessageContextGlobal(this); + } + + /** + * Set the system. + * + * @param system the system + * @return the MessageContextGlobal builder + */ + public Builder system(MessageContextGlobalSystem system) { + this.system = system; + return this; + } + } + + protected MessageContextGlobal() {} + + protected MessageContextGlobal(Builder builder) { + system = builder.system; + } + + /** + * New builder. + * + * @return a MessageContextGlobal 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 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 new file mode 100644 index 00000000000..97b18271d41 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextGlobalSystem.java @@ -0,0 +1,355 @@ +/* + * (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; + +/** 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. + * + *

This property is included only if the new system entities are enabled for the skill. + */ + public interface Locale { + /** en-us. */ + String EN_US = "en-us"; + /** en-ca. */ + String EN_CA = "en-ca"; + /** en-gb. */ + String EN_GB = "en-gb"; + /** ar-ar. */ + String AR_AR = "ar-ar"; + /** cs-cz. */ + String CS_CZ = "cs-cz"; + /** de-de. */ + String DE_DE = "de-de"; + /** es-es. */ + String ES_ES = "es-es"; + /** fr-fr. */ + String FR_FR = "fr-fr"; + /** it-it. */ + String IT_IT = "it-it"; + /** ja-jp. */ + String JA_JP = "ja-jp"; + /** ko-kr. */ + String KO_KR = "ko-kr"; + /** nl-nl. */ + String NL_NL = "nl-nl"; + /** pt-br. */ + String PT_BR = "pt-br"; + /** zh-cn. */ + String ZH_CN = "zh-cn"; + /** zh-tw. */ + String ZH_TW = "zh-tw"; + } + + protected String timezone; + + @SerializedName("user_id") + protected String userId; + + @SerializedName("turn_count") + protected Long turnCount; + + protected String locale; + + @SerializedName("reference_time") + protected String referenceTime; + + @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() {} + + /** + * Builds a MessageContextGlobalSystem. + * + * @return the new MessageContextGlobalSystem instance + */ + public MessageContextGlobalSystem build() { + return new MessageContextGlobalSystem(this); + } + + /** + * Set the timezone. + * + * @param timezone the timezone + * @return the MessageContextGlobalSystem builder + */ + public Builder timezone(String timezone) { + this.timezone = timezone; + return this; + } + + /** + * Set the userId. + * + * @param userId the userId + * @return the MessageContextGlobalSystem builder + */ + public Builder userId(String userId) { + this.userId = userId; + return this; + } + + /** + * Set the turnCount. + * + * @param turnCount the turnCount + * @return the MessageContextGlobalSystem builder + */ + public Builder turnCount(long turnCount) { + this.turnCount = turnCount; + return this; + } + + /** + * Set the locale. + * + * @param locale the locale + * @return the MessageContextGlobalSystem builder + */ + public Builder locale(String locale) { + this.locale = locale; + return this; + } + + /** + * Set the referenceTime. + * + * @param referenceTime the referenceTime + * @return the MessageContextGlobalSystem builder + */ + 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; + } + + /** + * New builder. + * + * @return a MessageContextGlobalSystem builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the timezone. + * + *

The user time zone. The assistant uses the time zone to correctly resolve relative time + * references. + * + * @return the timezone + */ + public String timezone() { + return 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 + * 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 + */ + public String userId() { + return 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). + * + * @return the turnCount + */ + public Long turnCount() { + return 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. + * + *

This property is included only if the new system entities are enabled for the skill. + * + * @return the locale + */ + public String locale() { + return 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. + * + *

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. + * + * @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/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 new file mode 100644 index 00000000000..659eaba8ab7 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageContextSkills.java @@ -0,0 +1,116 @@ +/* + * (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.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 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; + } + + /** + * 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 new file mode 100644 index 00000000000..eb816d5fb97 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInput.java @@ -0,0 +1,349 @@ +/* + * (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; +import java.util.ArrayList; +import java.util.List; + +/** An input object that includes the input text. */ +public class MessageInput 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 MessageInput instance. + * + * @param messageInput the instance to initialize the Builder with + */ + private Builder(MessageInput messageInput) { + this.messageType = messageInput.messageType; + this.text = messageInput.text; + 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() {} + + /** + * Builds a MessageInput. + * + * @return the new MessageInput instance + */ + public MessageInput build() { + return new MessageInput(this); + } + + /** + * Adds a new element to intents. + * + * @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"); + 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 MessageInput 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 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. + * + * @param messageType the messageType + * @return the MessageInput builder + */ + public Builder messageType(String messageType) { + this.messageType = messageType; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the MessageInput 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 MessageInput 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 MessageInput builder + */ + public Builder entities(List entities) { + this.entities = entities; + return this; + } + + /** + * Set the suggestionId. + * + * @param suggestionId the suggestionId + * @return the MessageInput 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 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; + intents = builder.intents; + entities = builder.entities; + suggestionId = builder.suggestionId; + attachments = builder.attachments; + analytics = builder.analytics; + options = builder.options; + } + + /** + * New builder. + * + * @return a MessageInput 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/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 new file mode 100644 index 00000000000..99c897864e4 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageInputOptions.java @@ -0,0 +1,266 @@ +/* + * (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; + +/** Optional properties that control how the assistant responds. */ +public class MessageInputOptions extends GenericModel { + + 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; + + protected Boolean export; + + /** Builder. */ + public static class Builder { + 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.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() {} + + /** + * Builds a MessageInputOptions. + * + * @return the new MessageInputOptions instance + */ + public MessageInputOptions build() { + return new MessageInputOptions(this); + } + + /** + * Set the restart. + * + * @param restart the restart + * @return the MessageInputOptions builder + */ + public Builder restart(Boolean restart) { + this.restart = restart; + return this; + } + + /** + * Set the alternateIntents. + * + * @param alternateIntents the alternateIntents + * @return the MessageInputOptions builder + */ + public Builder alternateIntents(Boolean alternateIntents) { + this.alternateIntents = 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. + * + * @param returnContext the returnContext + * @return the MessageInputOptions builder + */ + 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) { + restart = builder.restart; + alternateIntents = builder.alternateIntents; + asyncCallout = builder.asyncCallout; + spelling = builder.spelling; + debug = builder.debug; + returnContext = builder.returnContext; + export = builder.export; + } + + /** + * New builder. + * + * @return a MessageInputOptions 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. 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 + * 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 new file mode 100644 index 00000000000..c0c11684698 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOptions.java @@ -0,0 +1,250 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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. */ +public class MessageOptions 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 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 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 MessageOptions. + * + * @return the new MessageOptions instance + */ + public MessageOptions build() { + return new MessageOptions(this); + } + + /** + * Set the assistantId. + * + * @param assistantId the assistantId + * @return the MessageOptions builder + */ + public Builder assistantId(String assistantId) { + this.assistantId = 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. + * + * @param sessionId the sessionId + * @return the MessageOptions builder + */ + public Builder sessionId(String sessionId) { + this.sessionId = sessionId; + return this; + } + + /** + * Set the input. + * + * @param input the input + * @return the MessageOptions builder + */ + public Builder input(MessageInput input) { + this.input = input; + return this; + } + + /** + * Set the context. + * + * @param context the context + * @return the MessageOptions builder + */ + 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.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 MessageOptions 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/MessageOutput.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java new file mode 100644 index 00000000000..f59b20b826b --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutput.java @@ -0,0 +1,130 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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 MessageOutput 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 MessageOutput() {} + + /** + * 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/MessageOutputDebug.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java new file mode 100644 index 00000000000..b32857b7da6 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/MessageOutputDebug.java @@ -0,0 +1,110 @@ +/* + * (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; +import java.util.List; + +/** 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. + */ + public interface BranchExitedReason { + /** completed. */ + String COMPLETED = "completed"; + /** fallback. */ + String FALLBACK = "fallback"; + } + + @SerializedName("nodes_visited") + 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 dialog nodes that were + * visited during processing of the input message. + * + * @return the nodesVisited + */ + public List getNodesVisited() { + return nodesVisited; + } + + /** + * Gets the logMessages. + * + *

An array of up to 50 messages logged with the request. + * + * @return the logMessages + */ + public List getLogMessages() { + return logMessages; + } + + /** + * Gets the branchExited. + * + *

Assistant sets this to true when this message response concludes or interrupts a dialog. + * + * @return the branchExited + */ + public Boolean isBranchExited() { + return branchExited; + } + + /** + * 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. + * + * @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/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 new file mode 100644 index 00000000000..cd67fed6fea --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntity.java @@ -0,0 +1,367 @@ +/* + * (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; +import java.util.ArrayList; +import java.util.List; + +/** 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 List groups; + protected RuntimeEntityInterpretation interpretation; + protected List alternatives; + protected RuntimeEntityRole role; + protected String skill; + + /** Builder. */ + public static class Builder { + private String entity; + private List location; + private String value; + private Double confidence; + 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.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 with required properties. + * + * @param entity the entity + * @param value the value + */ + public Builder(String entity, String value) { + this.entity = entity; + this.value = value; + } + + /** + * Builds a RuntimeEntity. + * + * @return the new RuntimeEntity instance + */ + public RuntimeEntity build() { + return new RuntimeEntity(this); + } + + /** + * Adds a new element to 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"); + if (this.location == null) { + this.location = new ArrayList(); + } + this.location.add(location); + return this; + } + + /** + * Adds a new element to 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"); + if (this.groups == null) { + this.groups = new ArrayList(); + } + this.groups.add(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. + * + * @param entity the entity + * @return the RuntimeEntity builder + */ + public Builder entity(String entity) { + this.entity = entity; + return this; + } + + /** + * Set the location. Existing location will be replaced. + * + * @param location the location + * @return the RuntimeEntity builder + */ + public Builder location(List location) { + this.location = location; + return this; + } + + /** + * Set the value. + * + * @param value the value + * @return the RuntimeEntity builder + */ + public Builder value(String value) { + this.value = value; + return this; + } + + /** + * Set the confidence. + * + * @param confidence the confidence + * @return the RuntimeEntity builder + */ + public Builder confidence(Double confidence) { + this.confidence = confidence; + return this; + } + + /** + * Set the groups. Existing groups will be replaced. + * + * @param groups the groups + * @return the RuntimeEntity builder + */ + public Builder groups(List groups) { + this.groups = groups; + return this; + } + + /** + * Set the interpretation. + * + * @param interpretation the interpretation + * @return the RuntimeEntity builder + */ + public Builder interpretation(RuntimeEntityInterpretation interpretation) { + this.interpretation = 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. + * + * @param role the role + * @return the RuntimeEntity builder + */ + 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.value, "value cannot be null"); + entity = builder.entity; + location = builder.location; + value = builder.value; + confidence = builder.confidence; + groups = builder.groups; + interpretation = builder.interpretation; + alternatives = builder.alternatives; + role = builder.role; + skill = builder.skill; + } + + /** + * New builder. + * + * @return a RuntimeEntity builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the entity. + * + *

An entity detected in the input. + * + * @return the entity + */ + public String entity() { + return 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. + * + * @return the location + */ + public List location() { + return location; + } + + /** + * Gets the value. + * + *

The term in the input text that was recognized as an entity value. + * + * @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; + } + + /** + * Gets the groups. + * + *

The recognized capture groups for the entity, as defined by the entity pattern. + * + * @return the groups + */ + public List groups() { + return 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. + * + *

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 + */ + 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 skill. + * + * @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 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 new file mode 100644 index 00000000000..ea779fbe194 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/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.v2.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/v2/model/RuntimeEntityInterpretation.java b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java new file mode 100644 index 00000000000..7b3c2ad64ea --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityInterpretation.java @@ -0,0 +1,837 @@ +/* + * (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; + +/** RuntimeEntityInterpretation. */ +public class RuntimeEntityInterpretation extends GenericModel { + + /** + * The precision or duration of a time range specified by a recognized `@sys-time` or `@sys-date` + * entity. + */ + public interface Granularity { + /** day. */ + String DAY = "day"; + /** fortnight. */ + String FORTNIGHT = "fortnight"; + /** hour. */ + String HOUR = "hour"; + /** instant. */ + String INSTANT = "instant"; + /** minute. */ + String MINUTE = "minute"; + /** month. */ + String MONTH = "month"; + /** quarter. */ + String QUARTER = "quarter"; + /** second. */ + String SECOND = "second"; + /** week. */ + String WEEK = "week"; + /** weekend. */ + String WEEKEND = "weekend"; + /** year. */ + String YEAR = "year"; + } + + @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. */ + public static class Builder { + private String calendarType; + private String datetimeLink; + private String festival; + private String granularity; + private String rangeLink; + private String rangeModifier; + private Double relativeDay; + private Double relativeMonth; + private Double relativeWeek; + private Double relativeWeekend; + private Double relativeYear; + private Double specificDay; + private String specificDayOfWeek; + private Double specificMonth; + private Double specificQuarter; + private Double specificYear; + private Double numericValue; + private String subtype; + private String partOfDay; + private Double relativeHour; + private Double relativeMinute; + private Double relativeSecond; + private Double specificHour; + private Double specificMinute; + 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; + this.festival = runtimeEntityInterpretation.festival; + this.granularity = runtimeEntityInterpretation.granularity; + this.rangeLink = runtimeEntityInterpretation.rangeLink; + this.rangeModifier = runtimeEntityInterpretation.rangeModifier; + this.relativeDay = runtimeEntityInterpretation.relativeDay; + this.relativeMonth = runtimeEntityInterpretation.relativeMonth; + this.relativeWeek = runtimeEntityInterpretation.relativeWeek; + this.relativeWeekend = runtimeEntityInterpretation.relativeWeekend; + this.relativeYear = runtimeEntityInterpretation.relativeYear; + this.specificDay = runtimeEntityInterpretation.specificDay; + this.specificDayOfWeek = runtimeEntityInterpretation.specificDayOfWeek; + this.specificMonth = runtimeEntityInterpretation.specificMonth; + this.specificQuarter = runtimeEntityInterpretation.specificQuarter; + this.specificYear = runtimeEntityInterpretation.specificYear; + this.numericValue = runtimeEntityInterpretation.numericValue; + this.subtype = runtimeEntityInterpretation.subtype; + this.partOfDay = runtimeEntityInterpretation.partOfDay; + this.relativeHour = runtimeEntityInterpretation.relativeHour; + this.relativeMinute = runtimeEntityInterpretation.relativeMinute; + this.relativeSecond = runtimeEntityInterpretation.relativeSecond; + this.specificHour = runtimeEntityInterpretation.specificHour; + this.specificMinute = runtimeEntityInterpretation.specificMinute; + this.specificSecond = runtimeEntityInterpretation.specificSecond; + this.timezone = runtimeEntityInterpretation.timezone; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a RuntimeEntityInterpretation. + * + * @return the new RuntimeEntityInterpretation instance + */ + public RuntimeEntityInterpretation build() { + return new RuntimeEntityInterpretation(this); + } + + /** + * Set the calendarType. + * + * @param calendarType the calendarType + * @return the RuntimeEntityInterpretation builder + */ + public Builder calendarType(String calendarType) { + this.calendarType = calendarType; + return this; + } + + /** + * Set the datetimeLink. + * + * @param datetimeLink the datetimeLink + * @return the RuntimeEntityInterpretation builder + */ + public Builder datetimeLink(String datetimeLink) { + this.datetimeLink = datetimeLink; + return this; + } + + /** + * Set the festival. + * + * @param festival the festival + * @return the RuntimeEntityInterpretation builder + */ + public Builder festival(String festival) { + this.festival = festival; + return this; + } + + /** + * Set the granularity. + * + * @param granularity the granularity + * @return the RuntimeEntityInterpretation builder + */ + public Builder granularity(String granularity) { + this.granularity = granularity; + return this; + } + + /** + * Set the rangeLink. + * + * @param rangeLink the rangeLink + * @return the RuntimeEntityInterpretation builder + */ + public Builder rangeLink(String rangeLink) { + this.rangeLink = rangeLink; + return this; + } + + /** + * Set the rangeModifier. + * + * @param rangeModifier the rangeModifier + * @return the RuntimeEntityInterpretation builder + */ + public Builder rangeModifier(String rangeModifier) { + this.rangeModifier = rangeModifier; + return this; + } + + /** + * Set the relativeDay. + * + * @param relativeDay the relativeDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeDay(Double relativeDay) { + this.relativeDay = relativeDay; + return this; + } + + /** + * Set the relativeMonth. + * + * @param relativeMonth the relativeMonth + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeMonth(Double relativeMonth) { + this.relativeMonth = relativeMonth; + return this; + } + + /** + * Set the relativeWeek. + * + * @param relativeWeek the relativeWeek + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeWeek(Double relativeWeek) { + this.relativeWeek = relativeWeek; + return this; + } + + /** + * Set the relativeWeekend. + * + * @param relativeWeekend the relativeWeekend + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeWeekend(Double relativeWeekend) { + this.relativeWeekend = relativeWeekend; + return this; + } + + /** + * Set the relativeYear. + * + * @param relativeYear the relativeYear + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeYear(Double relativeYear) { + this.relativeYear = relativeYear; + return this; + } + + /** + * Set the specificDay. + * + * @param specificDay the specificDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificDay(Double specificDay) { + this.specificDay = specificDay; + return this; + } + + /** + * Set the specificDayOfWeek. + * + * @param specificDayOfWeek the specificDayOfWeek + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificDayOfWeek(String specificDayOfWeek) { + this.specificDayOfWeek = specificDayOfWeek; + return this; + } + + /** + * Set the specificMonth. + * + * @param specificMonth the specificMonth + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificMonth(Double specificMonth) { + this.specificMonth = specificMonth; + return this; + } + + /** + * Set the specificQuarter. + * + * @param specificQuarter the specificQuarter + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificQuarter(Double specificQuarter) { + this.specificQuarter = specificQuarter; + return this; + } + + /** + * Set the specificYear. + * + * @param specificYear the specificYear + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificYear(Double specificYear) { + this.specificYear = specificYear; + return this; + } + + /** + * Set the numericValue. + * + * @param numericValue the numericValue + * @return the RuntimeEntityInterpretation builder + */ + public Builder numericValue(Double numericValue) { + this.numericValue = numericValue; + return this; + } + + /** + * Set the subtype. + * + * @param subtype the subtype + * @return the RuntimeEntityInterpretation builder + */ + public Builder subtype(String subtype) { + this.subtype = subtype; + return this; + } + + /** + * Set the partOfDay. + * + * @param partOfDay the partOfDay + * @return the RuntimeEntityInterpretation builder + */ + public Builder partOfDay(String partOfDay) { + this.partOfDay = partOfDay; + return this; + } + + /** + * Set the relativeHour. + * + * @param relativeHour the relativeHour + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeHour(Double relativeHour) { + this.relativeHour = relativeHour; + return this; + } + + /** + * Set the relativeMinute. + * + * @param relativeMinute the relativeMinute + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeMinute(Double relativeMinute) { + this.relativeMinute = relativeMinute; + return this; + } + + /** + * Set the relativeSecond. + * + * @param relativeSecond the relativeSecond + * @return the RuntimeEntityInterpretation builder + */ + public Builder relativeSecond(Double relativeSecond) { + this.relativeSecond = relativeSecond; + return this; + } + + /** + * Set the specificHour. + * + * @param specificHour the specificHour + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificHour(Double specificHour) { + this.specificHour = specificHour; + return this; + } + + /** + * Set the specificMinute. + * + * @param specificMinute the specificMinute + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificMinute(Double specificMinute) { + this.specificMinute = specificMinute; + return this; + } + + /** + * Set the specificSecond. + * + * @param specificSecond the specificSecond + * @return the RuntimeEntityInterpretation builder + */ + public Builder specificSecond(Double specificSecond) { + this.specificSecond = specificSecond; + return this; + } + + /** + * Set the timezone. + * + * @param timezone the timezone + * @return the RuntimeEntityInterpretation builder + */ + public Builder timezone(String timezone) { + this.timezone = timezone; + return this; + } + } + + protected RuntimeEntityInterpretation() {} + + protected RuntimeEntityInterpretation(Builder builder) { + calendarType = builder.calendarType; + datetimeLink = builder.datetimeLink; + festival = builder.festival; + granularity = builder.granularity; + rangeLink = builder.rangeLink; + rangeModifier = builder.rangeModifier; + relativeDay = builder.relativeDay; + relativeMonth = builder.relativeMonth; + relativeWeek = builder.relativeWeek; + relativeWeekend = builder.relativeWeekend; + relativeYear = builder.relativeYear; + specificDay = builder.specificDay; + specificDayOfWeek = builder.specificDayOfWeek; + specificMonth = builder.specificMonth; + specificQuarter = builder.specificQuarter; + specificYear = builder.specificYear; + numericValue = builder.numericValue; + subtype = builder.subtype; + partOfDay = builder.partOfDay; + relativeHour = builder.relativeHour; + relativeMinute = builder.relativeMinute; + relativeSecond = builder.relativeSecond; + specificHour = builder.specificHour; + specificMinute = builder.specificMinute; + specificSecond = builder.specificSecond; + timezone = builder.timezone; + } + + /** + * New builder. + * + * @return a RuntimeEntityInterpretation builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the calendarType. + * + *

The calendar used to represent a recognized date (for example, `Gregorian`). + * + * @return the calendarType + */ + public String calendarType() { + return 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). + * + * @return the datetimeLink + */ + public String datetimeLink() { + return 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. + * + * @return the festival + */ + public String festival() { + return festival; + } + + /** + * Gets the granularity. + * + *

The precision or duration of a time range specified by a recognized `@sys-time` or + * `@sys-date` entity. + * + * @return the granularity + */ + public String granularity() { + return 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`). + * + * @return the rangeLink + */ + public String rangeLink() { + return 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`). + * + * @return the rangeModifier + */ + public String rangeModifier() { + return 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`). + * + * @return the relativeDay + */ + public Double relativeDay() { + return 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`). + * + * @return the relativeMonth + */ + public Double relativeMonth() { + return 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). + * + * @return the relativeWeek + */ + public Double relativeWeek() { + return 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`). + * + * @return the relativeWeekend + */ + public Double relativeWeekend() { + return 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`). + * + * @return the relativeYear + */ + public Double relativeYear() { + return 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`.). + * + * @return the specificDay + */ + public Double specificDay() { + return specificDay; + } + + /** + * Gets the specificDayOfWeek. + * + *

A recognized mention of a specific day of the week as a lowercase string (for example, + * `monday`). + * + * @return the specificDayOfWeek + */ + public String specificDayOfWeek() { + return specificDayOfWeek; + } + + /** + * Gets the specificMonth. + * + *

A recognized mention of a specific month, represented numerically (for example, `7` for + * `July`). + * + * @return the specificMonth + */ + public Double specificMonth() { + return specificMonth; + } + + /** + * Gets the specificQuarter. + * + *

A recognized mention of a specific quarter, represented numerically (for example, `3` for + * `the third quarter`). + * + * @return the specificQuarter + */ + public Double specificQuarter() { + return specificQuarter; + } + + /** + * Gets the specificYear. + * + *

A recognized mention of a specific year (for example, `2016`). + * + * @return the specificYear + */ + public Double specificYear() { + return specificYear; + } + + /** + * Gets the numericValue. + * + *

A recognized numeric value, represented as an integer or double. + * + * @return the numericValue + */ + public Double numericValue() { + return numericValue; + } + + /** + * Gets the subtype. + * + *

The type of numeric value recognized in the user input (`integer` or `rational`). + * + * @return the subtype + */ + public String subtype() { + return 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`). + * + * @return the partOfDay + */ + public String partOfDay() { + return 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`). + * + * @return the relativeHour + */ + public Double relativeHour() { + return 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`). + * + * @return the relativeMinute + */ + public Double relativeMinute() { + return 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`). + * + * @return the relativeSecond + */ + public Double relativeSecond() { + return relativeSecond; + } + + /** + * Gets the specificHour. + * + *

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

A recognized specific minute mentioned as part of a time value (for example, `15` for `10:15 + * AM`.). + * + * @return the specificMinute + */ + public Double specificMinute() { + return specificMinute; + } + + /** + * Gets the specificSecond. + * + *

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

A recognized time zone mentioned as part of a time value (for example, `EST`). + * + * @return the timezone + */ + public String timezone() { + return 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 new file mode 100644 index 00000000000..315978c8fd0 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeEntityRole.java @@ -0,0 +1,105 @@ +/* + * (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; + +/** + * 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. */ + public interface Type { + /** date_from. */ + String DATE_FROM = "date_from"; + /** date_to. */ + String DATE_TO = "date_to"; + /** number_from. */ + String NUMBER_FROM = "number_from"; + /** number_to. */ + String NUMBER_TO = "number_to"; + /** time_from. */ + String TIME_FROM = "time_from"; + /** time_to. */ + String TIME_TO = "time_to"; + } + + protected String type; + + /** 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() {} + + /** + * Builds a RuntimeEntityRole. + * + * @return the new RuntimeEntityRole instance + */ + public RuntimeEntityRole build() { + return new RuntimeEntityRole(this); + } + + /** + * Set the type. + * + * @param type the type + * @return the RuntimeEntityRole builder + */ + public Builder type(String type) { + this.type = type; + return this; + } + } + + protected RuntimeEntityRole() {} + + protected RuntimeEntityRole(Builder builder) { + type = builder.type; + } + + /** + * New builder. + * + * @return a RuntimeEntityRole builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the type. + * + *

The relationship of the entity to the range. + * + * @return the type + */ + public String type() { + return 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 new file mode 100644 index 00000000000..70a9bf87a91 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeIntent.java @@ -0,0 +1,151 @@ +/* + * (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; + +/** An intent identified in the user input. */ +public class RuntimeIntent extends GenericModel { + + protected String intent; + protected Double confidence; + protected String skill; + + /** 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 with required properties. + * + * @param intent the intent + */ + public Builder(String intent) { + this.intent = intent; + } + + /** + * Builds a RuntimeIntent. + * + * @return the new RuntimeIntent instance + */ + public RuntimeIntent build() { + return new RuntimeIntent(this); + } + + /** + * Set the intent. + * + * @param intent the intent + * @return the RuntimeIntent builder + */ + public Builder intent(String intent) { + this.intent = intent; + return this; + } + + /** + * Set the confidence. + * + * @param confidence the confidence + * @return the RuntimeIntent builder + */ + 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"); + intent = builder.intent; + confidence = builder.confidence; + skill = builder.skill; + } + + /** + * New builder. + * + * @return a RuntimeIntent builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the intent. + * + *

The name of the recognized intent. + * + * @return the intent + */ + public String intent() { + return intent; + } + + /** + * Gets the confidence. + * + *

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 new file mode 100644 index 00000000000..1bd2e700f48 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/RuntimeResponseGeneric.java @@ -0,0 +1,473 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 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; + +/** + * RuntimeResponseGeneric. + * + *

Classes which extend this class: - + * RuntimeResponseGenericRuntimeResponseTypeConversationalSearch - + * RuntimeResponseGenericRuntimeResponseTypeText - RuntimeResponseGenericRuntimeResponseTypePause - + * RuntimeResponseGenericRuntimeResponseTypeImage - RuntimeResponseGenericRuntimeResponseTypeOption + * - RuntimeResponseGenericRuntimeResponseTypeConnectToAgent - + * RuntimeResponseGenericRuntimeResponseTypeSuggestion - + * RuntimeResponseGenericRuntimeResponseTypeChannelTransfer - + * RuntimeResponseGenericRuntimeResponseTypeSearch - + * RuntimeResponseGenericRuntimeResponseTypeUserDefined - + * RuntimeResponseGenericRuntimeResponseTypeVideo - RuntimeResponseGenericRuntimeResponseTypeAudio - + * RuntimeResponseGenericRuntimeResponseTypeIframe - RuntimeResponseGenericRuntimeResponseTypeDate + */ +public class RuntimeResponseGeneric extends GenericModel { + @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); + } + /** 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; + + @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; + + @SerializedName("primary_results") + protected List primaryResults; + + @SerializedName("additional_results") + protected List additionalResults; + + @SerializedName("user_defined") + protected Map userDefined; + + @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. + * + * @return the responseType + */ + public String responseType() { + return responseType; + } + + /** + * Gets the text. + * + *

The text of the conversational search response. + * + * @return the text + */ + 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. + * + * @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 `https:` URL of the image. + * + * @return the source + */ + public String source() { + return source; + } + + /** + * Gets the title. + * + *

The title 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 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. + * + * @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 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 **title** property of + * the relevant node or the **topic** property of the dialog node response. + * + * @return the topic + */ + public String topic() { + return topic; + } + + /** + * Gets the suggestions. + * + *

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 header. + * + *

The title or introductory text to show before the response. This text is defined in the + * search skill configuration. + * + * @return the header + */ + public String header() { + return header; + } + + /** + * 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 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/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/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 new file mode 100644 index 00000000000..1009c164335 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResult.java @@ -0,0 +1,123 @@ +/* + * (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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + *

This property is included in responses from search skills, which are available only to Plus + * or Enterprise plan users. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the resultMetadata. + * + *

An object containing search result metadata from the Discovery service. + * + * @return the resultMetadata + */ + public SearchResultMetadata getResultMetadata() { + return resultMetadata; + } + + /** + * 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. + * + * @return the body + */ + public String getBody() { + return body; + } + + /** + * 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. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the url. + * + *

The URL of the original data object in its native data source. + * + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * Gets the highlight. + * + *

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 new file mode 100644 index 00000000000..5159b13fb6f --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultHighlight.java @@ -0,0 +1,80 @@ +/* + * (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.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 `<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>() {}); + } + + /** + * Gets the body. + * + *

An array of strings containing segments taken from body text in the search results, with + * query-matching substrings highlighted. + * + * @return the body + */ + public List getBody() { + return this.body; + } + + /** + * Gets the title. + * + *

An array of strings containing segments taken from title text in the search results, with + * query-matching substrings highlighted. + * + * @return the title + */ + public List getTitle() { + return this.title; + } + + /** + * Gets the url. + * + *

An array of strings containing segments taken from URLs in the search results, with + * query-matching substrings highlighted. + * + * @return the url + */ + public List getUrl() { + return this.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 new file mode 100644 index 00000000000..065bc768b96 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SearchResultMetadata.java @@ -0,0 +1,48 @@ +/* + * (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.assistant.v2.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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, as returned by the Discovery service. + * + * @return the confidence + */ + public Double getConfidence() { + return 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; + } +} 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 new file mode 100644 index 00000000000..63817af86f5 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/model/SessionResponse.java @@ -0,0 +1,37 @@ +/* + * (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.assistant.v2.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SessionResponse. */ +public class SessionResponse extends GenericModel { + + @SerializedName("session_id") + protected String sessionId; + + protected SessionResponse() {} + + /** + * Gets the sessionId. + * + *

The session ID. + * + * @return the sessionId + */ + public String getSessionId() { + return 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 new file mode 100644 index 00000000000..9e101146c21 --- /dev/null +++ b/assistant/src/main/java/com/ibm/watson/assistant/v2/package-info.java @@ -0,0 +1,15 @@ +/* + * (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. + */ + +/** watsonx Assistant v2 v2. */ +package com.ibm.watson.assistant.v2; diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/Assistant.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/Assistant.java deleted file mode 100644 index cecaf2c8761..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/Assistant.java +++ /dev/null @@ -1,1513 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CounterexampleCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode; -import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.Entity; -import com.ibm.watson.developer_cloud.assistant.v1.model.EntityCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.EntityExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.Example; -import com.ibm.watson.developer_cloud.assistant.v1.model.ExampleCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Intent; -import com.ibm.watson.developer_cloud.assistant.v1.model.IntentCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.IntentExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListAllLogsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListCounterexamplesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListDialogNodesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListEntitiesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListExamplesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListIntentsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListSynonymsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListValuesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.assistant.v1.model.Synonym; -import com.ibm.watson.developer_cloud.assistant.v1.model.SynonymCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Value; -import com.ibm.watson.developer_cloud.assistant.v1.model.ValueCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.Workspace; -import com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceExport; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The IBM Watson Assistant service combines machine learning, natural language understanding, and integrated dialog - * tools to create conversation flows between your apps and your users. - * - * @version v1 - * @see Assistant - */ -public class Assistant extends WatsonService { - - private static final String SERVICE_NAME = "assistant"; - private static final String URL = "https://gateway.watsonplatform.net/assistant/api"; - - private String versionDate; - - /** - * Instantiates a new `Assistant`. - * - * @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 Assistant(String versionDate) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `Assistant` with username and password. - * - * @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 username the username - * @param password the password - */ - public Assistant(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `Assistant` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public Assistant(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * Get response to user input. - * - * Get a response to a user's input. There is no rate limit for this operation. - * - * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} - */ - public ServiceCall message(MessageOptions messageOptions) { - Validator.notNull(messageOptions, "messageOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "message" }; - String[] pathParameters = { messageOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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", GsonSingleton.getGson().toJsonTree(messageOptions.input())); - } - if (messageOptions.alternateIntents() != null) { - contentJson.addProperty("alternate_intents", messageOptions.alternateIntents()); - } - if (messageOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(messageOptions.context())); - } - if (messageOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(messageOptions.entities())); - } - if (messageOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(messageOptions.intents())); - } - if (messageOptions.output() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(messageOptions.output())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class)); - } - - /** - * Create 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**. - * - * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (createWorkspaceOptions != null) { - final JsonObject contentJson = new JsonObject(); - if (createWorkspaceOptions.name() != null) { - contentJson.addProperty("name", createWorkspaceOptions.name()); - } - if (createWorkspaceOptions.description() != null) { - contentJson.addProperty("description", createWorkspaceOptions.description()); - } - if (createWorkspaceOptions.language() != null) { - contentJson.addProperty("language", createWorkspaceOptions.language()); - } - if (createWorkspaceOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.intents())); - } - if (createWorkspaceOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.entities())); - } - if (createWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.dialogNodes())); - } - if (createWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions - .counterexamples())); - } - if (createWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.metadata())); - } - if (createWorkspaceOptions.learningOptOut() != null) { - contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut()); - } - builder.bodyJson(contentJson); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class)); - } - - /** - * Create 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**. - * - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall createWorkspace() { - return createWorkspace(null); - } - - /** - * Delete workspace. - * - * Delete a workspace from the service instance. This operation is limited to 30 requests per 30 minutes. For more - * information, see **Rate limiting**. - * - * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) { - Validator.notNull(deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { deleteWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link WorkspaceExport} - */ - public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptions) { - Validator.notNull(getWorkspaceOptions, "getWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { getWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getWorkspaceOptions.export() != null) { - builder.query("export", String.valueOf(getWorkspaceOptions.export())); - } - if (getWorkspaceOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceExport.class)); - } - - /** - * List workspaces. - * - * 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 response type of {@link WorkspaceCollection} - */ - public ServiceCall listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listWorkspacesOptions != null) { - 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", listWorkspacesOptions.sort()); - } - if (listWorkspacesOptions.cursor() != null) { - builder.query("cursor", listWorkspacesOptions.cursor()); - } - if (listWorkspacesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceCollection.class)); - } - - /** - * List workspaces. - * - * 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**. - * - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} - */ - public ServiceCall listWorkspaces() { - return listWorkspaces(null); - } - - /** - * Update 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**. - * - * @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) { - Validator.notNull(updateWorkspaceOptions, "updateWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { updateWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (updateWorkspaceOptions.append() != null) { - builder.query("append", String.valueOf(updateWorkspaceOptions.append())); - } - final JsonObject contentJson = new JsonObject(); - if (updateWorkspaceOptions.name() != null) { - contentJson.addProperty("name", updateWorkspaceOptions.name()); - } - if (updateWorkspaceOptions.description() != null) { - contentJson.addProperty("description", updateWorkspaceOptions.description()); - } - if (updateWorkspaceOptions.language() != null) { - contentJson.addProperty("language", updateWorkspaceOptions.language()); - } - if (updateWorkspaceOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.intents())); - } - if (updateWorkspaceOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.entities())); - } - if (updateWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.dialogNodes())); - } - if (updateWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.counterexamples())); - } - if (updateWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.metadata())); - } - if (updateWorkspaceOptions.learningOptOut() != null) { - contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class)); - } - - /** - * Create intent. - * - * Create a new intent. 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} - */ - public ServiceCall createIntent(CreateIntentOptions createIntentOptions) { - Validator.notNull(createIntentOptions, "createIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { createIntentOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("intent", createIntentOptions.intent()); - if (createIntentOptions.description() != null) { - contentJson.addProperty("description", createIntentOptions.description()); - } - if (createIntentOptions.examples() != null) { - contentJson.add("examples", GsonSingleton.getGson().toJsonTree(createIntentOptions.examples())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class)); - } - - /** - * Delete intent. - * - * Delete an intent from a workspace. This operation is limited to 2000 requests per 30 minutes. For more information, - * see **Rate limiting**. - * - * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { - Validator.notNull(deleteIntentOptions, "deleteIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { deleteIntentOptions.workspaceId(), deleteIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getIntentOptions the {@link GetIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentExport} - */ - public ServiceCall getIntent(GetIntentOptions getIntentOptions) { - Validator.notNull(getIntentOptions, "getIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { getIntentOptions.workspaceId(), getIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getIntentOptions.export() != null) { - builder.query("export", String.valueOf(getIntentOptions.export())); - } - if (getIntentOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getIntentOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentExport.class)); - } - - /** - * 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**. - * - * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentCollection} - */ - public ServiceCall listIntents(ListIntentsOptions listIntentsOptions) { - Validator.notNull(listIntentsOptions, "listIntentsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { listIntentsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listIntentsOptions.cursor() != null) { - builder.query("cursor", listIntentsOptions.cursor()); - } - if (listIntentsOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentCollection.class)); - } - - /** - * Update intent. - * - * Update an existing intent with new or modified data. You must provide component objects defining the content of the - * updated intent. 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} - */ - public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) { - Validator.notNull(updateIntentOptions, "updateIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { updateIntentOptions.workspaceId(), updateIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateIntentOptions.newIntent() != null) { - contentJson.addProperty("intent", updateIntentOptions.newIntent()); - } - if (updateIntentOptions.newExamples() != null) { - contentJson.add("examples", GsonSingleton.getGson().toJsonTree(updateIntentOptions.newExamples())); - } - if (updateIntentOptions.newDescription() != null) { - contentJson.addProperty("description", updateIntentOptions.newDescription()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class)); - } - - /** - * Create user input example. - * - * 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**. - * - * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} - */ - public ServiceCall createExample(CreateExampleOptions createExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", createExampleOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * 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**. - * - * @param deleteExampleOptions the {@link DeleteExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getExampleOptions the {@link GetExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} - */ - public ServiceCall getExample(GetExampleOptions getExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getExampleOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getExampleOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * List user input examples. - * - * List the user input examples for an intent. This operation is limited to 2500 requests per 30 minutes. For more - * information, see **Rate limiting**. - * - * @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ExampleCollection} - */ - public ServiceCall listExamples(ListExamplesOptions listExamplesOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listExamplesOptions.cursor() != null) { - builder.query("cursor", listExamplesOptions.cursor()); - } - if (listExamplesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ExampleCollection.class)); - } - - /** - * Update user input example. - * - * Update the text of a user input example. 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} - */ - public ServiceCall updateExample(UpdateExampleOptions updateExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateExampleOptions.newText() != null) { - contentJson.addProperty("text", updateExampleOptions.newText()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * Create counterexample. - * - * 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**. - * - * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) { - Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { createCounterexampleOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", createCounterexampleOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * 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**. - * - * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteCounterexample(DeleteCounterexampleOptions deleteCounterexampleOptions) { - Validator.notNull(deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { deleteCounterexampleOptions.workspaceId(), deleteCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall getCounterexample(GetCounterexampleOptions getCounterexampleOptions) { - Validator.notNull(getCounterexampleOptions, "getCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { getCounterexampleOptions.workspaceId(), getCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getCounterexampleOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getCounterexampleOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * List counterexamples. - * - * 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} - */ - public ServiceCall listCounterexamples( - ListCounterexamplesOptions listCounterexamplesOptions) { - Validator.notNull(listCounterexamplesOptions, "listCounterexamplesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { listCounterexamplesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listCounterexamplesOptions.cursor() != null) { - builder.query("cursor", listCounterexamplesOptions.cursor()); - } - if (listCounterexamplesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CounterexampleCollection.class)); - } - - /** - * Update counterexample. - * - * Update the text of a counterexample. 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**. - * - * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) { - Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateCounterexampleOptions.newText() != null) { - contentJson.addProperty("text", updateCounterexampleOptions.newText()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * Create entity. - * - * Create a new entity. 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} - */ - public ServiceCall createEntity(CreateEntityOptions createEntityOptions) { - Validator.notNull(createEntityOptions, "createEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { createEntityOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("entity", createEntityOptions.entity()); - if (createEntityOptions.description() != null) { - contentJson.addProperty("description", createEntityOptions.description()); - } - if (createEntityOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createEntityOptions.metadata())); - } - if (createEntityOptions.values() != null) { - contentJson.add("values", GsonSingleton.getGson().toJsonTree(createEntityOptions.values())); - } - if (createEntityOptions.fuzzyMatch() != null) { - contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class)); - } - - /** - * Delete entity. - * - * Delete an entity from a workspace. This operation is limited to 1000 requests per 30 minutes. For more information, - * see **Rate limiting**. - * - * @param deleteEntityOptions the {@link DeleteEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { - Validator.notNull(deleteEntityOptions, "deleteEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { deleteEntityOptions.workspaceId(), deleteEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getEntityOptions the {@link GetEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityExport} - */ - public ServiceCall getEntity(GetEntityOptions getEntityOptions) { - Validator.notNull(getEntityOptions, "getEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { getEntityOptions.workspaceId(), getEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getEntityOptions.export() != null) { - builder.query("export", String.valueOf(getEntityOptions.export())); - } - if (getEntityOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getEntityOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(EntityExport.class)); - } - - /** - * 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**. - * - * @param listEntitiesOptions the {@link ListEntitiesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityCollection} - */ - public ServiceCall listEntities(ListEntitiesOptions listEntitiesOptions) { - Validator.notNull(listEntitiesOptions, "listEntitiesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { listEntitiesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listEntitiesOptions.cursor() != null) { - builder.query("cursor", listEntitiesOptions.cursor()); - } - if (listEntitiesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listEntitiesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(EntityCollection.class)); - } - - /** - * Update entity. - * - * Update an existing entity with new or modified data. You must provide component objects defining the content of the - * updated entity. 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} - */ - public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) { - Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { updateEntityOptions.workspaceId(), updateEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateEntityOptions.newFuzzyMatch() != null) { - contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch()); - } - if (updateEntityOptions.newEntity() != null) { - contentJson.addProperty("entity", updateEntityOptions.newEntity()); - } - if (updateEntityOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata())); - } - if (updateEntityOptions.newValues() != null) { - contentJson.add("values", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues())); - } - if (updateEntityOptions.newDescription() != null) { - contentJson.addProperty("description", updateEntityOptions.newDescription()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class)); - } - - /** - * Add entity value. - * - * Create a new value for an entity. This operation is limited to 1000 requests per 30 minutes. For more information, - * see **Rate limiting**. - * - * @param createValueOptions the {@link CreateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} - */ - public ServiceCall createValue(CreateValueOptions createValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("value", createValueOptions.value()); - if (createValueOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createValueOptions.metadata())); - } - if (createValueOptions.synonyms() != null) { - contentJson.add("synonyms", GsonSingleton.getGson().toJsonTree(createValueOptions.synonyms())); - } - if (createValueOptions.patterns() != null) { - contentJson.add("patterns", GsonSingleton.getGson().toJsonTree(createValueOptions.patterns())); - } - if (createValueOptions.valueType() != null) { - contentJson.addProperty("type", createValueOptions.valueType()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Value.class)); - } - - /** - * 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**. - * - * @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getValueOptions the {@link GetValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueExport} - */ - public ServiceCall getValue(GetValueOptions getValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getValueOptions.export() != null) { - builder.query("export", String.valueOf(getValueOptions.export())); - } - if (getValueOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getValueOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ValueExport.class)); - } - - /** - * 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**. - * - * @param listValuesOptions the {@link ListValuesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueCollection} - */ - public ServiceCall listValues(ListValuesOptions listValuesOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listValuesOptions.cursor() != null) { - builder.query("cursor", listValuesOptions.cursor()); - } - if (listValuesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listValuesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ValueCollection.class)); - } - - /** - * 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. This operation is limited to 1000 requests per 30 minutes. For more information, see - * **Rate limiting**. - * - * @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} - */ - public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateValueOptions.newSynonyms() != null) { - contentJson.add("synonyms", GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms())); - } - if (updateValueOptions.valueType() != null) { - contentJson.addProperty("type", updateValueOptions.valueType()); - } - if (updateValueOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata())); - } - if (updateValueOptions.newPatterns() != null) { - contentJson.add("patterns", GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns())); - } - if (updateValueOptions.newValue() != null) { - contentJson.addProperty("value", updateValueOptions.newValue()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Value.class)); - } - - /** - * Add entity value synonym. - * - * Add a new synonym to an entity value. 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} - */ - public ServiceCall createSynonym(CreateSynonymOptions createSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("synonym", createSynonymOptions.synonym()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * 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**. - * - * @param deleteSynonymOptions the {@link DeleteSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} - */ - public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getSynonymOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * 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**. - * - * @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SynonymCollection} - */ - public ServiceCall listSynonyms(ListSynonymsOptions listSynonymsOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listSynonymsOptions.cursor() != null) { - builder.query("cursor", listSynonymsOptions.cursor()); - } - if (listSynonymsOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listSynonymsOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SynonymCollection.class)); - } - - /** - * Update entity value synonym. - * - * Update an existing entity value synonym with new text. 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} - */ - public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateSynonymOptions.newSynonym() != null) { - contentJson.addProperty("synonym", updateSynonymOptions.newSynonym()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * Create dialog node. - * - * Create a new dialog node. This operation is limited to 500 requests per 30 minutes. For more information, see - * **Rate limiting**. - * - * @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall createDialogNode(CreateDialogNodeOptions createDialogNodeOptions) { - Validator.notNull(createDialogNodeOptions, "createDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { createDialogNodeOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("dialog_node", createDialogNodeOptions.dialogNode()); - if (createDialogNodeOptions.description() != null) { - contentJson.addProperty("description", createDialogNodeOptions.description()); - } - if (createDialogNodeOptions.conditions() != null) { - contentJson.addProperty("conditions", createDialogNodeOptions.conditions()); - } - if (createDialogNodeOptions.parent() != null) { - contentJson.addProperty("parent", createDialogNodeOptions.parent()); - } - if (createDialogNodeOptions.previousSibling() != null) { - contentJson.addProperty("previous_sibling", createDialogNodeOptions.previousSibling()); - } - if (createDialogNodeOptions.output() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.output())); - } - if (createDialogNodeOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.context())); - } - if (createDialogNodeOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.metadata())); - } - if (createDialogNodeOptions.nextStep() != null) { - contentJson.add("next_step", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.nextStep())); - } - if (createDialogNodeOptions.actions() != null) { - contentJson.add("actions", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.actions())); - } - if (createDialogNodeOptions.title() != null) { - contentJson.addProperty("title", createDialogNodeOptions.title()); - } - if (createDialogNodeOptions.nodeType() != null) { - contentJson.addProperty("type", createDialogNodeOptions.nodeType()); - } - if (createDialogNodeOptions.eventName() != null) { - contentJson.addProperty("event_name", createDialogNodeOptions.eventName()); - } - if (createDialogNodeOptions.variable() != null) { - contentJson.addProperty("variable", createDialogNodeOptions.variable()); - } - if (createDialogNodeOptions.digressIn() != null) { - contentJson.addProperty("digress_in", createDialogNodeOptions.digressIn()); - } - if (createDialogNodeOptions.digressOut() != null) { - contentJson.addProperty("digress_out", createDialogNodeOptions.digressOut()); - } - if (createDialogNodeOptions.digressOutSlots() != null) { - contentJson.addProperty("digress_out_slots", createDialogNodeOptions.digressOutSlots()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * 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**. - * - * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall getDialogNode(GetDialogNodeOptions getDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getDialogNodeOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getDialogNodeOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * 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**. - * - * @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNodeCollection} - */ - public ServiceCall listDialogNodes(ListDialogNodesOptions listDialogNodesOptions) { - Validator.notNull(listDialogNodesOptions, "listDialogNodesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { listDialogNodesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listDialogNodesOptions.cursor() != null) { - builder.query("cursor", listDialogNodesOptions.cursor()); - } - if (listDialogNodesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listDialogNodesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNodeCollection.class)); - } - - /** - * Update dialog node. - * - * Update an existing dialog node with new or modified data. This operation is limited to 500 requests per 30 minutes. - * For more information, see **Rate limiting**. - * - * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateDialogNodeOptions.nodeType() != null) { - contentJson.addProperty("type", updateDialogNodeOptions.nodeType()); - } - if (updateDialogNodeOptions.newActions() != null) { - contentJson.add("actions", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newActions())); - } - if (updateDialogNodeOptions.newConditions() != null) { - contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions()); - } - if (updateDialogNodeOptions.newContext() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newContext())); - } - if (updateDialogNodeOptions.newPreviousSibling() != null) { - contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling()); - } - if (updateDialogNodeOptions.newVariable() != null) { - contentJson.addProperty("variable", updateDialogNodeOptions.newVariable()); - } - if (updateDialogNodeOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newMetadata())); - } - if (updateDialogNodeOptions.newTitle() != null) { - contentJson.addProperty("title", updateDialogNodeOptions.newTitle()); - } - if (updateDialogNodeOptions.newDescription() != null) { - contentJson.addProperty("description", updateDialogNodeOptions.newDescription()); - } - if (updateDialogNodeOptions.newDigressOut() != null) { - contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut()); - } - if (updateDialogNodeOptions.newEventName() != null) { - contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName()); - } - if (updateDialogNodeOptions.newDigressOutSlots() != null) { - contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots()); - } - if (updateDialogNodeOptions.newNextStep() != null) { - contentJson.add("next_step", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newNextStep())); - } - if (updateDialogNodeOptions.newDigressIn() != null) { - contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn()); - } - if (updateDialogNodeOptions.newOutput() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newOutput())); - } - if (updateDialogNodeOptions.newParent() != null) { - contentJson.addProperty("parent", updateDialogNodeOptions.newParent()); - } - if (updateDialogNodeOptions.newDialogNode() != null) { - contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * List log events in all workspaces. - * - * 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**. - * - * @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} - */ - public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOptions) { - Validator.notNull(listAllLogsOptions, "listAllLogsOptions cannot be null"); - String[] pathSegments = { "v1/logs" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("filter", listAllLogsOptions.filter()); - if (listAllLogsOptions.sort() != null) { - builder.query("sort", listAllLogsOptions.sort()); - } - if (listAllLogsOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit())); - } - if (listAllLogsOptions.cursor() != null) { - builder.query("cursor", listAllLogsOptions.cursor()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class)); - } - - /** - * List log events in a workspace. - * - * List the events from the log of a specific workspace. 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**. - * - * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} - */ - public ServiceCall listLogs(ListLogsOptions listLogsOptions) { - Validator.notNull(listLogsOptions, "listLogsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "logs" }; - String[] pathParameters = { listLogsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (listLogsOptions.sort() != null) { - builder.query("sort", listLogsOptions.sort()); - } - if (listLogsOptions.filter() != null) { - builder.query("filter", listLogsOptions.filter()); - } - if (listLogsOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); - } - if (listLogsOptions.cursor() != null) { - builder.query("cursor", listLogsOptions.cursor()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class)); - } - - /** - * 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://console.bluemix.net/docs/services/conversation/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CaptureGroup.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CaptureGroup.java deleted file mode 100644 index e0bfe1c331a..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CaptureGroup.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CaptureGroup. - */ -public class CaptureGroup extends GenericModel { - - private String group; - private List location; - - /** - * Gets the group. - * - * A recognized capture group for the entity. - * - * @return the group - */ - public String getGroup() { - return group; - } - - /** - * Gets the location. - * - * Zero-based character offsets that indicate where the entity value begins and ends in the input text. - * - * @return the location - */ - public List getLocation() { - return location; - } - - /** - * Sets the group. - * - * @param group the new group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * Sets the location. - * - * @param location the new location - */ - public void setLocation(final List location) { - this.location = location; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Context.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Context.java deleted file mode 100644 index ca3671c2ab5..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Context.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * State information for the conversation. To maintain state, include the context from the previous response. - */ -public class Context extends DynamicModel { - private Type conversationIdType = new TypeToken() { - }.getType(); - private Type systemType = new TypeToken() { - }.getType(); - - /** - * Gets the conversationId. - * - * @return the conversationId - */ - public String getConversationId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("conversation_id"), conversationIdType); - } - - /** - * Gets the system. - * - * @return the system - */ - public SystemResponse getSystem() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("system"), systemType); - } - - /** - * Sets the conversationId. - * - * @param conversationId the new conversationId - */ - public void setConversationId(final String conversationId) { - this.put("conversation_id", conversationId); - } - - /** - * Sets the system. - * - * @param system the new system - */ - public void setSystem(final SystemResponse system) { - this.put("system", system); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Counterexample.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Counterexample.java deleted file mode 100644 index bcb152587d3..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Counterexample.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Counterexample. - */ -public class Counterexample extends GenericModel { - - private String text; - private Date created; - private Date updated; - - /** - * Gets the text. - * - * The text of the counterexample. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the created. - * - * The timestamp for creation of the counterexample. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the counterexample. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CounterexampleCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CounterexampleCollection.java deleted file mode 100644 index fb25506b886..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CounterexampleCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CounterexampleCollection. - */ -public class CounterexampleCollection extends GenericModel { - - private List counterexamples; - private Pagination pagination; - - /** - * Gets the counterexamples. - * - * An array of objects describing the examples marked as irrelevant input. - * - * @return the counterexamples - */ - public List getCounterexamples() { - return counterexamples; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexample.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexample.java deleted file mode 100644 index c550d338b43..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexample.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateCounterexample. - */ -public class CreateCounterexample extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(CreateCounterexample createCounterexample) { - text = createCounterexample.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 CreateCounterexample. - * - * @return the createCounterexample - */ - public CreateCounterexample build() { - return new CreateCounterexample(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateCounterexample builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateCounterexample(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateCounterexample builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 - It - * must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexampleOptions.java deleted file mode 100644 index eb19f38aa38..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateCounterexampleOptions.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createCounterexample options. - */ -public class CreateCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - - private Builder(CreateCounterexampleOptions createCounterexampleOptions) { - workspaceId = createCounterexampleOptions.workspaceId; - text = createCounterexampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a CreateCounterexampleOptions. - * - * @return the createCounterexampleOptions - */ - public CreateCounterexampleOptions build() { - return new CreateCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.text, "text cannot be null"); - workspaceId = builder.workspaceId; - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateCounterexampleOptions 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 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 - It - * must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNode.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNode.java deleted file mode 100644 index a0928b3ed5b..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNode.java +++ /dev/null @@ -1,624 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateDialogNode. - */ -public class CreateDialogNode extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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") - private String dialogNode; - private String description; - private String conditions; - private String parent; - @SerializedName("previous_sibling") - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - @SerializedName("next_step") - private DialogNodeNextStep nextStep; - private List actions; - private String title; - @SerializedName("type") - private String nodeType; - @SerializedName("event_name") - private String eventName; - private String variable; - @SerializedName("digress_in") - private String digressIn; - @SerializedName("digress_out") - private String digressOut; - @SerializedName("digress_out_slots") - private String digressOutSlots; - - /** - * Builder. - */ - public static class Builder { - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - private Builder(CreateDialogNode createDialogNode) { - dialogNode = createDialogNode.dialogNode; - description = createDialogNode.description; - conditions = createDialogNode.conditions; - parent = createDialogNode.parent; - previousSibling = createDialogNode.previousSibling; - output = createDialogNode.output; - context = createDialogNode.context; - metadata = createDialogNode.metadata; - nextStep = createDialogNode.nextStep; - actions = createDialogNode.actions; - title = createDialogNode.title; - nodeType = createDialogNode.nodeType; - eventName = createDialogNode.eventName; - variable = createDialogNode.variable; - digressIn = createDialogNode.digressIn; - digressOut = createDialogNode.digressOut; - digressOutSlots = createDialogNode.digressOutSlots; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param dialogNode the dialogNode - */ - public Builder(String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Builds a CreateDialogNode. - * - * @return the createDialogNode - */ - public CreateDialogNode build() { - return new CreateDialogNode(this); - } - - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the CreateDialogNode builder - */ - public Builder addActions(DialogNodeAction actions) { - 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 CreateDialogNode builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateDialogNode builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conditions. - * - * @param conditions the conditions - * @return the CreateDialogNode builder - */ - public Builder conditions(String conditions) { - this.conditions = conditions; - return this; - } - - /** - * Set the parent. - * - * @param parent the parent - * @return the CreateDialogNode builder - */ - public Builder parent(String parent) { - this.parent = parent; - return this; - } - - /** - * Set the previousSibling. - * - * @param previousSibling the previousSibling - * @return the CreateDialogNode builder - */ - public Builder previousSibling(String previousSibling) { - this.previousSibling = previousSibling; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the CreateDialogNode builder - */ - public Builder output(Map output) { - this.output = output; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the CreateDialogNode builder - */ - public Builder context(Map context) { - this.context = context; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateDialogNode builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the nextStep. - * - * @param nextStep the nextStep - * @return the CreateDialogNode builder - */ - public Builder nextStep(DialogNodeNextStep nextStep) { - this.nextStep = nextStep; - return this; - } - - /** - * Set the actions. - * Existing actions will be replaced. - * - * @param actions the actions - * @return the CreateDialogNode builder - */ - public Builder actions(List actions) { - this.actions = actions; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the CreateDialogNode builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the CreateDialogNode builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the eventName. - * - * @param eventName the eventName - * @return the CreateDialogNode builder - */ - public Builder eventName(String eventName) { - this.eventName = eventName; - return this; - } - - /** - * Set the variable. - * - * @param variable the variable - * @return the CreateDialogNode builder - */ - public Builder variable(String variable) { - this.variable = variable; - return this; - } - - /** - * Set the digressIn. - * - * @param digressIn the digressIn - * @return the CreateDialogNode builder - */ - public Builder digressIn(String digressIn) { - this.digressIn = digressIn; - return this; - } - - /** - * Set the digressOut. - * - * @param digressOut the digressOut - * @return the CreateDialogNode builder - */ - public Builder digressOut(String digressOut) { - this.digressOut = digressOut; - return this; - } - - /** - * Set the digressOutSlots. - * - * @param digressOutSlots the digressOutSlots - * @return the CreateDialogNode builder - */ - public Builder digressOutSlots(String digressOutSlots) { - this.digressOutSlots = digressOutSlots; - return this; - } - } - - private CreateDialogNode(Builder builder) { - Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); - 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; - actions = builder.actions; - title = builder.title; - nodeType = builder.nodeType; - eventName = builder.eventName; - variable = builder.variable; - digressIn = builder.digressIn; - digressOut = builder.digressOut; - digressOutSlots = builder.digressOutSlots; - } - - /** - * New builder. - * - * @return a CreateDialogNode builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - It must be no longer than 1024 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, and it - * must be no longer than 128 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, and it must be no longer than 2048 characters. - * - * @return the conditions - */ - public String conditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. - * - * @return the parent - */ - public String parent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous dialog node. - * - * @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://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the output - */ - public Map output() { - return output; - } - - /** - * Gets the context. - * - * The context for the dialog node. - * - * @return the context - */ - public Map 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 be executed in dialog processing. - * - * @return the nextStep - */ - public DialogNodeNextStep nextStep() { - return nextStep; - } - - /** - * 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 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. - It must be no longer than 64 - * characters. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * 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 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; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNodeOptions.java deleted file mode 100644 index 0049c2b0339..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateDialogNodeOptions.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createDialogNode options. - */ -public class CreateDialogNodeOptions extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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"; - } - - private String workspaceId; - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - private Builder(CreateDialogNodeOptions createDialogNodeOptions) { - workspaceId = createDialogNodeOptions.workspaceId; - dialogNode = createDialogNodeOptions.dialogNode; - description = createDialogNodeOptions.description; - conditions = createDialogNodeOptions.conditions; - parent = createDialogNodeOptions.parent; - previousSibling = createDialogNodeOptions.previousSibling; - output = createDialogNodeOptions.output; - context = createDialogNodeOptions.context; - metadata = createDialogNodeOptions.metadata; - nextStep = createDialogNodeOptions.nextStep; - actions = createDialogNodeOptions.actions; - title = createDialogNodeOptions.title; - nodeType = createDialogNodeOptions.nodeType; - eventName = createDialogNodeOptions.eventName; - variable = createDialogNodeOptions.variable; - digressIn = createDialogNodeOptions.digressIn; - digressOut = createDialogNodeOptions.digressOut; - digressOutSlots = createDialogNodeOptions.digressOutSlots; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a CreateDialogNodeOptions. - * - * @return the createDialogNodeOptions - */ - public CreateDialogNodeOptions build() { - return new CreateDialogNodeOptions(this); - } - - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the CreateDialogNodeOptions builder - */ - public Builder addActions(DialogNodeAction actions) { - Validator.notNull(actions, "actions cannot be null"); - if (this.actions == null) { - this.actions = new ArrayList(); - } - this.actions.add(actions); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the CreateDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateDialogNodeOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conditions. - * - * @param conditions the conditions - * @return the CreateDialogNodeOptions builder - */ - public Builder conditions(String conditions) { - this.conditions = conditions; - return this; - } - - /** - * Set the parent. - * - * @param parent the parent - * @return the CreateDialogNodeOptions builder - */ - public Builder parent(String parent) { - this.parent = parent; - return this; - } - - /** - * Set the previousSibling. - * - * @param previousSibling the previousSibling - * @return the CreateDialogNodeOptions builder - */ - public Builder previousSibling(String previousSibling) { - this.previousSibling = previousSibling; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the CreateDialogNodeOptions builder - */ - public Builder output(Map output) { - this.output = output; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the CreateDialogNodeOptions builder - */ - public Builder context(Map context) { - this.context = context; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateDialogNodeOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the nextStep. - * - * @param nextStep the nextStep - * @return the CreateDialogNodeOptions builder - */ - public Builder nextStep(DialogNodeNextStep nextStep) { - this.nextStep = nextStep; - return this; - } - - /** - * Set the actions. - * Existing actions will be replaced. - * - * @param actions the actions - * @return the CreateDialogNodeOptions builder - */ - public Builder actions(List actions) { - this.actions = actions; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the CreateDialogNodeOptions builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the CreateDialogNodeOptions builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the eventName. - * - * @param eventName the eventName - * @return the CreateDialogNodeOptions builder - */ - public Builder eventName(String eventName) { - this.eventName = eventName; - return this; - } - - /** - * Set the variable. - * - * @param variable the variable - * @return the CreateDialogNodeOptions builder - */ - public Builder variable(String variable) { - this.variable = variable; - return this; - } - - /** - * Set the digressIn. - * - * @param digressIn the digressIn - * @return the CreateDialogNodeOptions builder - */ - public Builder digressIn(String digressIn) { - this.digressIn = digressIn; - return this; - } - - /** - * Set the digressOut. - * - * @param digressOut the digressOut - * @return the CreateDialogNodeOptions builder - */ - public Builder digressOut(String digressOut) { - this.digressOut = digressOut; - return this; - } - - /** - * Set the digressOutSlots. - * - * @param digressOutSlots the digressOutSlots - * @return the CreateDialogNodeOptions builder - */ - public Builder digressOutSlots(String digressOutSlots) { - this.digressOutSlots = digressOutSlots; - return this; - } - } - - private CreateDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); - workspaceId = builder.workspaceId; - 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; - actions = builder.actions; - title = builder.title; - nodeType = builder.nodeType; - eventName = builder.eventName; - variable = builder.variable; - digressIn = builder.digressIn; - digressOut = builder.digressOut; - digressOutSlots = builder.digressOutSlots; - } - - /** - * New builder. - * - * @return a CreateDialogNodeOptions 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. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. - * - It must be no longer than 1024 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, and it - * must be no longer than 128 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, and it must be no longer than 2048 characters. - * - * @return the conditions - */ - public String conditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. - * - * @return the parent - */ - public String parent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous dialog node. - * - * @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://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the output - */ - public Map output() { - return output; - } - - /** - * Gets the context. - * - * The context for the dialog node. - * - * @return the context - */ - public Map 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 be executed in dialog processing. - * - * @return the nextStep - */ - public DialogNodeNextStep nextStep() { - return nextStep; - } - - /** - * 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 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. - * - It must be no longer than 64 characters. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * 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 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; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntity.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntity.java deleted file mode 100644 index 214ae379446..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntity.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateEntity. - */ -public class CreateEntity extends GenericModel { - - private String entity; - private String description; - private Map metadata; - private List values; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - - /** - * Builder. - */ - public static class Builder { - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - private Builder(CreateEntity createEntity) { - entity = createEntity.entity; - description = createEntity.description; - metadata = createEntity.metadata; - values = createEntity.values; - fuzzyMatch = createEntity.fuzzyMatch; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param entity the entity - */ - public Builder(String entity) { - this.entity = entity; - } - - /** - * Builds a CreateEntity. - * - * @return the createEntity - */ - public CreateEntity build() { - return new CreateEntity(this); - } - - /** - * Adds an value to values. - * - * @param value the new value - * @return the CreateEntity builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(value); - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateEntity builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateEntity builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateEntity builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. - * - * @param values the values - * @return the CreateEntity builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the fuzzyMatch. - * - * @param fuzzyMatch the fuzzyMatch - * @return the CreateEntity builder - */ - public Builder fuzzyMatch(Boolean fuzzyMatch) { - this.fuzzyMatch = fuzzyMatch; - return this; - } - } - - private CreateEntity(Builder builder) { - Validator.notNull(builder.entity, "entity cannot be null"); - entity = builder.entity; - description = builder.description; - metadata = builder.metadata; - values = builder.values; - fuzzyMatch = builder.fuzzyMatch; - } - - /** - * New builder. - * - * @return a CreateEntity builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It cannot begin with the reserved prefix `sys-`. - * - It must be no longer than 64 characters. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the description. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the values. - * - * An array of objects describing the entity values. - * - * @return the values - */ - public List values() { - return values; - } - - /** - * Gets the fuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the fuzzyMatch - */ - public Boolean fuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntityOptions.java deleted file mode 100644 index 2347cd453cb..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateEntityOptions.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createEntity options. - */ -public class CreateEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - private Builder(CreateEntityOptions createEntityOptions) { - workspaceId = createEntityOptions.workspaceId; - entity = createEntityOptions.entity; - description = createEntityOptions.description; - metadata = createEntityOptions.metadata; - values = createEntityOptions.values; - fuzzyMatch = createEntityOptions.fuzzyMatch; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a CreateEntityOptions. - * - * @return the createEntityOptions - */ - public CreateEntityOptions build() { - return new CreateEntityOptions(this); - } - - /** - * Adds an value to values. - * - * @param value the new value - * @return the CreateEntityOptions builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(value); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateEntityOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateEntityOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. - * - * @param values the values - * @return the CreateEntityOptions builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the fuzzyMatch. - * - * @param fuzzyMatch the fuzzyMatch - * @return the CreateEntityOptions builder - */ - public Builder fuzzyMatch(Boolean fuzzyMatch) { - this.fuzzyMatch = fuzzyMatch; - return this; - } - } - - private CreateEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.entity, "entity cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - description = builder.description; - metadata = builder.metadata; - values = builder.values; - fuzzyMatch = builder.fuzzyMatch; - } - - /** - * New builder. - * - * @return a CreateEntityOptions 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 entity. - * - * 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-`. - * - It must be no longer than 64 characters. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the description. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the values. - * - * An array of objects describing the entity values. - * - * @return the values - */ - public List values() { - return values; - } - - /** - * Gets the fuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the fuzzyMatch - */ - public Boolean fuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExample.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExample.java deleted file mode 100644 index 4566c653be1..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExample.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateExample. - */ -public class CreateExample extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(CreateExample createExample) { - text = createExample.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 CreateExample. - * - * @return the createExample - */ - public CreateExample build() { - return new CreateExample(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateExample builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateExample(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateExample builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExampleOptions.java deleted file mode 100644 index a8bf2ed62b0..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateExampleOptions.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createExample options. - */ -public class CreateExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - - private Builder(CreateExampleOptions createExampleOptions) { - workspaceId = createExampleOptions.workspaceId; - intent = createExampleOptions.intent; - text = createExampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a CreateExampleOptions. - * - * @return the createExampleOptions - */ - public CreateExampleOptions build() { - return new CreateExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notNull(builder.text, "text cannot be null"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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. - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntent.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntent.java deleted file mode 100644 index 106161e72b2..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntent.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateIntent. - */ -public class CreateIntent extends GenericModel { - - private String intent; - private String description; - private List examples; - - /** - * Builder. - */ - public static class Builder { - private String intent; - private String description; - private List examples; - - private Builder(CreateIntent createIntent) { - intent = createIntent.intent; - description = createIntent.description; - examples = createIntent.examples; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param intent the intent - */ - public Builder(String intent) { - this.intent = intent; - } - - /** - * Builds a CreateIntent. - * - * @return the createIntent - */ - public CreateIntent build() { - return new CreateIntent(this); - } - - /** - * Adds an example to examples. - * - * @param example the new example - * @return the CreateIntent builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.examples == null) { - this.examples = new ArrayList(); - } - this.examples.add(example); - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateIntent builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateIntent builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. - * - * @param examples the examples - * @return the CreateIntent builder - */ - public Builder examples(List examples) { - this.examples = examples; - return this; - } - } - - private CreateIntent(Builder builder) { - Validator.notNull(builder.intent, "intent cannot be null"); - intent = builder.intent; - description = builder.description; - examples = builder.examples; - } - - /** - * New builder. - * - * @return a CreateIntent builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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-`. - * - It must be no longer than 128 characters. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the description. - * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the examples. - * - * An array of user input examples for the intent. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntentOptions.java deleted file mode 100644 index 4c4470f169b..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateIntentOptions.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createIntent options. - */ -public class CreateIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String description; - private List examples; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String description; - private List examples; - - private Builder(CreateIntentOptions createIntentOptions) { - workspaceId = createIntentOptions.workspaceId; - intent = createIntentOptions.intent; - description = createIntentOptions.description; - examples = createIntentOptions.examples; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a CreateIntentOptions. - * - * @return the createIntentOptions - */ - public CreateIntentOptions build() { - return new CreateIntentOptions(this); - } - - /** - * Adds an example to examples. - * - * @param example the new example - * @return the CreateIntentOptions builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.examples == null) { - this.examples = new ArrayList(); - } - this.examples.add(example); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateIntentOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. - * - * @param examples the examples - * @return the CreateIntentOptions builder - */ - public Builder examples(List examples) { - this.examples = examples; - return this; - } - } - - private CreateIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.intent, "intent cannot be null"); - workspaceId = builder.workspaceId; - intent = builder.intent; - description = builder.description; - examples = builder.examples; - } - - /** - * New builder. - * - * @return a CreateIntentOptions 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 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-`. - * - It must be no longer than 128 characters. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the description. - * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the examples. - * - * An array of user input examples for the intent. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateSynonymOptions.java deleted file mode 100644 index d3e1831a5a0..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateSynonymOptions.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createSynonym options. - */ -public class CreateSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - - private Builder(CreateSynonymOptions createSynonymOptions) { - workspaceId = createSynonymOptions.workspaceId; - entity = createSynonymOptions.entity; - value = createSynonymOptions.value; - synonym = createSynonymOptions.synonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a CreateSynonymOptions. - * - * @return the createSynonymOptions - */ - public CreateSynonymOptions build() { - return new CreateSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the CreateSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - } - - private CreateSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notNull(builder.synonym, "synonym cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - } - - /** - * New builder. - * - * @return a CreateSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValue.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValue.java deleted file mode 100644 index 35a0df54335..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValue.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateValue. - */ -public class CreateValue extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String value; - private Map metadata; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Builder. - */ - public static class Builder { - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - private Builder(CreateValue createValue) { - value = createValue.value; - metadata = createValue.metadata; - synonyms = createValue.synonyms; - patterns = createValue.patterns; - valueType = createValue.valueType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param value the value - */ - public Builder(String value) { - this.value = value; - } - - /** - * Builds a CreateValue. - * - * @return the createValue - */ - public CreateValue build() { - return new CreateValue(this); - } - - /** - * Adds an synonym to synonyms. - * - * @param synonym the new synonym - * @return the CreateValue builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.synonyms == null) { - this.synonyms = new ArrayList(); - } - this.synonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to patterns. - * - * @param pattern the new pattern - * @return the CreateValue builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.patterns == null) { - this.patterns = new ArrayList(); - } - this.patterns.add(pattern); - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateValue builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateValue builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the synonyms. - * Existing synonyms will be replaced. - * - * @param synonyms the synonyms - * @return the CreateValue builder - */ - public Builder synonyms(List synonyms) { - this.synonyms = synonyms; - return this; - } - - /** - * Set the patterns. - * Existing patterns will be replaced. - * - * @param patterns the patterns - * @return the CreateValue builder - */ - public Builder patterns(List patterns) { - this.patterns = patterns; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the CreateValue builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - } - - private CreateValue(Builder builder) { - Validator.notNull(builder.value, "value cannot be null"); - value = builder.value; - metadata = builder.metadata; - synonyms = builder.synonyms; - patterns = builder.patterns; - valueType = builder.valueType; - } - - /** - * New builder. - * - * @return a CreateValue builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. You can provide either synonyms or patterns (as indicated by - * **type**), but not both. A synonym must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. - * - It must be no longer than 64 characters. - * - * @return the synonyms - */ - public List synonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the patterns - */ - public List patterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValueOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValueOptions.java deleted file mode 100644 index f1c5779708e..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateValueOptions.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createValue options. - */ -public class CreateValueOptions extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String workspaceId; - private String entity; - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - private Builder(CreateValueOptions createValueOptions) { - workspaceId = createValueOptions.workspaceId; - entity = createValueOptions.entity; - value = createValueOptions.value; - metadata = createValueOptions.metadata; - synonyms = createValueOptions.synonyms; - patterns = createValueOptions.patterns; - valueType = createValueOptions.valueType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a CreateValueOptions. - * - * @return the createValueOptions - */ - public CreateValueOptions build() { - return new CreateValueOptions(this); - } - - /** - * Adds an synonym to synonyms. - * - * @param synonym the new synonym - * @return the CreateValueOptions builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.synonyms == null) { - this.synonyms = new ArrayList(); - } - this.synonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to patterns. - * - * @param pattern the new pattern - * @return the CreateValueOptions builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.patterns == null) { - this.patterns = new ArrayList(); - } - this.patterns.add(pattern); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateValueOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the synonyms. - * Existing synonyms will be replaced. - * - * @param synonyms the synonyms - * @return the CreateValueOptions builder - */ - public Builder synonyms(List synonyms) { - this.synonyms = synonyms; - return this; - } - - /** - * Set the patterns. - * Existing patterns will be replaced. - * - * @param patterns the patterns - * @return the CreateValueOptions builder - */ - public Builder patterns(List patterns) { - this.patterns = patterns; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the CreateValueOptions builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - } - - private CreateValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notNull(builder.value, "value cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - metadata = builder.metadata; - synonyms = builder.synonyms; - patterns = builder.patterns; - valueType = builder.valueType; - } - - /** - * New builder. - * - * @return a CreateValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. You can provide either synonyms or patterns (as indicated by - * **type**), but not both. A synonym must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. - * - It must be no longer than 64 characters. - * - * @return the synonyms - */ - public List synonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the patterns - */ - public List patterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateWorkspaceOptions.java deleted file mode 100644 index f4e67313208..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/CreateWorkspaceOptions.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createWorkspace options. - */ -public class CreateWorkspaceOptions extends GenericModel { - - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - - private Builder(CreateWorkspaceOptions createWorkspaceOptions) { - name = createWorkspaceOptions.name; - description = createWorkspaceOptions.description; - language = createWorkspaceOptions.language; - intents = createWorkspaceOptions.intents; - entities = createWorkspaceOptions.entities; - dialogNodes = createWorkspaceOptions.dialogNodes; - counterexamples = createWorkspaceOptions.counterexamples; - metadata = createWorkspaceOptions.metadata; - learningOptOut = createWorkspaceOptions.learningOptOut; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CreateWorkspaceOptions. - * - * @return the createWorkspaceOptions - */ - public CreateWorkspaceOptions build() { - return new CreateWorkspaceOptions(this); - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the CreateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the CreateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an dialogNode to dialogNodes. - * - * @param dialogNode the new dialogNode - * @return the CreateWorkspaceOptions builder - */ - public Builder addDialogNode(CreateDialogNode dialogNode) { - Validator.notNull(dialogNode, "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); - } - this.dialogNodes.add(dialogNode); - return this; - } - - /** - * Adds an counterexample to counterexamples. - * - * @param counterexample the new counterexample - * @return the CreateWorkspaceOptions builder - */ - public Builder addCounterexample(CreateCounterexample counterexample) { - Validator.notNull(counterexample, "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); - } - this.counterexamples.add(counterexample); - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateWorkspaceOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateWorkspaceOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the CreateWorkspaceOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. - * - * @param dialogNodes the dialogNodes - * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions builder - */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateWorkspaceOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the learningOptOut. - * - * @param learningOptOut the learningOptOut - * @return the CreateWorkspaceOptions builder - */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; - return this; - } - } - - private CreateWorkspaceOptions(Builder builder) { - name = builder.name; - description = builder.description; - language = builder.language; - intents = builder.intents; - entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - metadata = builder.metadata; - learningOptOut = builder.learningOptOut; - } - - /** - * New builder. - * - * @return a CreateWorkspaceOptions 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, and it must be - * no longer than 64 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, and it - * must be no longer than 128 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 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 defining the entities for the workspace. - * - * @return the entities - */ - public List entities() { - return entities; - } - - /** - * Gets the dialogNodes. - * - * An array of objects defining the nodes in the workspace dialog. - * - * @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 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; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteCounterexampleOptions.java deleted file mode 100644 index 2656bdb46e2..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteCounterexampleOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteCounterexample options. - */ -public class DeleteCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - - private Builder(DeleteCounterexampleOptions deleteCounterexampleOptions) { - workspaceId = deleteCounterexampleOptions.workspaceId; - text = deleteCounterexampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a DeleteCounterexampleOptions. - * - * @return the deleteCounterexampleOptions - */ - public DeleteCounterexampleOptions build() { - return new DeleteCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DeleteCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private DeleteCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - } - - /** - * New builder. - * - * @return a DeleteCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteDialogNodeOptions.java deleted file mode 100644 index 6d6d457ef75..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteDialogNodeOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteDialogNode options. - */ -public class DeleteDialogNodeOptions extends GenericModel { - - private String workspaceId; - private String dialogNode; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - - private Builder(DeleteDialogNodeOptions deleteDialogNodeOptions) { - workspaceId = deleteDialogNodeOptions.workspaceId; - dialogNode = deleteDialogNodeOptions.dialogNode; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a DeleteDialogNodeOptions. - * - * @return the deleteDialogNodeOptions - */ - public DeleteDialogNodeOptions build() { - return new DeleteDialogNodeOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the DeleteDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - } - - private DeleteDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - } - - /** - * New builder. - * - * @return a DeleteDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteEntityOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteEntityOptions.java deleted file mode 100644 index 2a5fa0608e1..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteEntityOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteEntity options. - */ -public class DeleteEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - - private Builder(DeleteEntityOptions deleteEntityOptions) { - workspaceId = deleteEntityOptions.workspaceId; - entity = deleteEntityOptions.entity; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a DeleteEntityOptions. - * - * @return the deleteEntityOptions - */ - public DeleteEntityOptions build() { - return new DeleteEntityOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - } - - private DeleteEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - } - - /** - * New builder. - * - * @return a DeleteEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteExampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteExampleOptions.java deleted file mode 100644 index 7497d51d4bb..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteExampleOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteExample options. - */ -public class DeleteExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - - private Builder(DeleteExampleOptions deleteExampleOptions) { - workspaceId = deleteExampleOptions.workspaceId; - intent = deleteExampleOptions.intent; - text = deleteExampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a DeleteExampleOptions. - * - * @return the deleteExampleOptions - */ - public DeleteExampleOptions build() { - return new DeleteExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the DeleteExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DeleteExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private DeleteExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - } - - /** - * New builder. - * - * @return a DeleteExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteIntentOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteIntentOptions.java deleted file mode 100644 index 1493169ef12..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteIntentOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteIntent options. - */ -public class DeleteIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - - private Builder(DeleteIntentOptions deleteIntentOptions) { - workspaceId = deleteIntentOptions.workspaceId; - intent = deleteIntentOptions.intent; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a DeleteIntentOptions. - * - * @return the deleteIntentOptions - */ - public DeleteIntentOptions build() { - return new DeleteIntentOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the DeleteIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - } - - private DeleteIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - } - - /** - * New builder. - * - * @return a DeleteIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteSynonymOptions.java deleted file mode 100644 index f59f719f0b6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteSynonymOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteSynonym options. - */ -public class DeleteSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - - private Builder(DeleteSynonymOptions deleteSynonymOptions) { - workspaceId = deleteSynonymOptions.workspaceId; - entity = deleteSynonymOptions.entity; - value = deleteSynonymOptions.value; - synonym = deleteSynonymOptions.synonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a DeleteSynonymOptions. - * - * @return the deleteSynonymOptions - */ - public DeleteSynonymOptions build() { - return new DeleteSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the DeleteSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the DeleteSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - } - - private DeleteSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - } - - /** - * New builder. - * - * @return a DeleteSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteUserDataOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index 44d5670b461..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/developer_cloud/assistant/v1/model/DeleteValueOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteValueOptions.java deleted file mode 100644 index ee8f479f607..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteValueOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteValue options. - */ -public class DeleteValueOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - - private Builder(DeleteValueOptions deleteValueOptions) { - workspaceId = deleteValueOptions.workspaceId; - entity = deleteValueOptions.entity; - value = deleteValueOptions.value; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a DeleteValueOptions. - * - * @return the deleteValueOptions - */ - public DeleteValueOptions build() { - return new DeleteValueOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the DeleteValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - } - - private DeleteValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - } - - /** - * New builder. - * - * @return a DeleteValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteWorkspaceOptions.java deleted file mode 100644 index 3e562fd8484..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DeleteWorkspaceOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteWorkspace options. - */ -public class DeleteWorkspaceOptions extends GenericModel { - - private String workspaceId; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - - private Builder(DeleteWorkspaceOptions deleteWorkspaceOptions) { - workspaceId = deleteWorkspaceOptions.workspaceId; - } - - /** - * 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 DeleteWorkspaceOptions. - * - * @return the deleteWorkspaceOptions - */ - public DeleteWorkspaceOptions build() { - return new DeleteWorkspaceOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - } - - private DeleteWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - } - - /** - * New builder. - * - * @return a DeleteWorkspaceOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the workspaceId. - * - * Unique identifier of the workspace. - * - * @return the workspaceId - */ - public String workspaceId() { - return workspaceId; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNode.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNode.java deleted file mode 100644 index 4927373a8cf..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNode.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNode. - */ -public class DialogNode extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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") - private String dialogNodeId; - private String description; - private String conditions; - private String parent; - @SerializedName("previous_sibling") - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - @SerializedName("next_step") - private DialogNodeNextStep nextStep; - private Date created; - private Date updated; - private List actions; - private String title; - @SerializedName("type") - private String nodeType; - @SerializedName("event_name") - private String eventName; - private String variable; - @SerializedName("digress_in") - private String digressIn; - @SerializedName("digress_out") - private String digressOut; - @SerializedName("digress_out_slots") - private String digressOutSlots; - - /** - * Gets the dialogNodeId. - * - * The dialog node ID. - * - * @return the dialogNodeId - */ - public String getDialogNodeId() { - return dialogNodeId; - } - - /** - * Gets the description. - * - * The description of the dialog node. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the conditions. - * - * The condition that triggers the dialog node. - * - * @return the conditions - */ - public String getConditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. This property is not returned if the dialog node has no parent. - * - * @return the parent - */ - public String getParent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous sibling dialog node. This property is not returned if the dialog node has no previous - * sibling. - * - * @return the previousSibling - */ - public String getPreviousSibling() { - return previousSibling; - } - - /** - * Gets the output. - * - * The output of the dialog node. - * - * @return the output - */ - public Map getOutput() { - return output; - } - - /** - * Gets the context. - * - * The context (if defined) for the dialog node. - * - * @return the context - */ - public Map getContext() { - return context; - } - - /** - * Gets the metadata. - * - * Any metadata for the dialog node. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the nextStep. - * - * The next step to execute following this dialog node. - * - * @return the nextStep - */ - public DialogNodeNextStep getNextStep() { - return nextStep; - } - - /** - * Gets the created. - * - * The timestamp for creation of the dialog node. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the most recent update to the dialog node. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the actions. - * - * The actions for the dialog node. - * - * @return the actions - */ - public List getActions() { - return actions; - } - - /** - * Gets the title. - * - * The alias used to identify the dialog node. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String getNodeType() { - return nodeType; - } - - /** - * Gets the eventName. - * - * How an `event_handler` node is processed. - * - * @return the eventName - */ - public String getEventName() { - return eventName; - } - - /** - * Gets the variable. - * - * The location in the dialog context where output is stored. - * - * @return the variable - */ - public String getVariable() { - return variable; - } - - /** - * Gets the digressIn. - * - * Whether this top-level dialog node can be digressed into. - * - * @return the digressIn - */ - public String getDigressIn() { - return digressIn; - } - - /** - * Gets the digressOut. - * - * Whether this dialog node can be returned to after a digression. - * - * @return the digressOut - */ - public String getDigressOut() { - return digressOut; - } - - /** - * Gets the digressOutSlots. - * - * Whether the user can digress to top-level nodes while filling out slots. - * - * @return the digressOutSlots - */ - public String getDigressOutSlots() { - return digressOutSlots; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeAction.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeAction.java deleted file mode 100644 index bfa47c94e99..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeAction.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNodeAction. - */ -public class DialogNodeAction extends GenericModel { - - /** - * The type of action to invoke. - */ - public interface ActionType { - /** client. */ - String CLIENT = "client"; - /** server. */ - String SERVER = "server"; - } - - private String name; - @SerializedName("type") - private String actionType; - private Map parameters; - @SerializedName("result_variable") - private String resultVariable; - private String credentials; - - /** - * Gets the name. - * - * The name of the action. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the actionType. - * - * The type of action to invoke. - * - * @return the actionType - */ - public String getActionType() { - return actionType; - } - - /** - * Gets the parameters. - * - * A map of key/value pairs to be provided to the action. - * - * @return the parameters - */ - public Map getParameters() { - return parameters; - } - - /** - * Gets the resultVariable. - * - * The location in the dialog context where the result of the action is stored. - * - * @return the resultVariable - */ - public String getResultVariable() { - return resultVariable; - } - - /** - * Gets the credentials. - * - * The name of the context variable that the client application will use to pass in credentials for the action. - * - * @return the credentials - */ - public String getCredentials() { - return credentials; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Sets the actionType. - * - * @param actionType the new actionType - */ - public void setActionType(final String actionType) { - this.actionType = actionType; - } - - /** - * Sets the parameters. - * - * @param parameters the new parameters - */ - public void setParameters(final Map parameters) { - this.parameters = parameters; - } - - /** - * Sets the resultVariable. - * - * @param resultVariable the new resultVariable - */ - public void setResultVariable(final String resultVariable) { - this.resultVariable = resultVariable; - } - - /** - * Sets the credentials. - * - * @param credentials the new credentials - */ - public void setCredentials(final String credentials) { - this.credentials = credentials; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeCollection.java deleted file mode 100644 index 9c662cf2fed..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeCollection.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An array of dialog nodes. - */ -public class DialogNodeCollection extends GenericModel { - - @SerializedName("dialog_nodes") - private List dialogNodes; - private Pagination pagination; - - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes defined for the workspace. - * - * @return the dialogNodes - */ - public List getDialogNodes() { - return dialogNodes; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeNextStep.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeNextStep.java deleted file mode 100644 index 32e4887470c..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeNextStep.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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. - */ - public interface Behavior { - /** get_user_input. */ - String GET_USER_INPUT = "get_user_input"; - /** skip_user_input. */ - String SKIP_USER_INPUT = "skip_user_input"; - /** jump_to. */ - String JUMP_TO = "jump_to"; - /** reprompt. */ - String REPROMPT = "reprompt"; - /** skip_slot. */ - String SKIP_SLOT = "skip_slot"; - /** skip_all_slots. */ - String SKIP_ALL_SLOTS = "skip_all_slots"; - } - - /** - * Which part of the dialog node to process next. - */ - public interface Selector { - /** condition. */ - String CONDITION = "condition"; - /** client. */ - String CLIENT = "client"; - /** user_input. */ - String USER_INPUT = "user_input"; - /** body. */ - String BODY = "body"; - } - - private String behavior; - @SerializedName("dialog_node") - private String dialogNode; - private String selector; - - /** - * 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. - * - * @return the behavior - */ - public String getBehavior() { - return behavior; - } - - /** - * Gets the dialogNode. - * - * The ID of the dialog node to process next. This parameter is required if **behavior**=`jump_to`. - * - * @return the dialogNode - */ - public String getDialogNode() { - return dialogNode; - } - - /** - * Gets the selector. - * - * Which part of the dialog node to process next. - * - * @return the selector - */ - public String getSelector() { - return selector; - } - - /** - * Sets the behavior. - * - * @param behavior the new behavior - */ - public void setBehavior(final String behavior) { - this.behavior = behavior; - } - - /** - * Sets the dialogNode. - * - * @param dialogNode the new dialogNode - */ - public void setDialogNode(final String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Sets the selector. - * - * @param selector the new selector - */ - public void setSelector(final String selector) { - this.selector = selector; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeVisitedDetails.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeVisitedDetails.java deleted file mode 100644 index d8e4fdd1edc..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/DialogNodeVisitedDetails.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNodeVisitedDetails. - */ -public class DialogNodeVisitedDetails extends GenericModel { - - @SerializedName("dialog_node") - private String dialogNode; - private String title; - private 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; - } - - /** - * Sets the dialogNode. - * - * @param dialogNode the new dialogNode - */ - public void setDialogNode(final String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Sets the title. - * - * @param title the new title - */ - public void setTitle(final String title) { - this.title = title; - } - - /** - * Sets the conditions. - * - * @param conditions the new conditions - */ - public void setConditions(final String conditions) { - this.conditions = conditions; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Entity.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Entity.java deleted file mode 100644 index 2317890ad25..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Entity.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Entity. - */ -public class Entity extends GenericModel { - - @SerializedName("entity") - private String entityName; - private Date created; - private Date updated; - private String description; - private Map metadata; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - - /** - * Gets the entityName. - * - * The name of the entity. - * - * @return the entityName - */ - public String getEntityName() { - return entityName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the entity. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the fuzzyMatch. - * - * Whether fuzzy matching is used for the entity. - * - * @return the fuzzyMatch - */ - public Boolean isFuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityCollection.java deleted file mode 100644 index a11af934d42..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An array of entities. - */ -public class EntityCollection extends GenericModel { - - private List entities; - private Pagination pagination; - - /** - * Gets the entities. - * - * An array of objects describing the entities defined for the workspace. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityExport.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityExport.java deleted file mode 100644 index 0074702bd99..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/EntityExport.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * EntityExport. - */ -public class EntityExport extends GenericModel { - - @SerializedName("entity") - private String entityName; - private Date created; - private Date updated; - private String description; - private Map metadata; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - private List values; - - /** - * Gets the entityName. - * - * The name of the entity. - * - * @return the entityName - */ - public String getEntityName() { - return entityName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the entity. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the fuzzyMatch. - * - * Whether fuzzy matching is used for the entity. - * - * @return the fuzzyMatch - */ - public Boolean isFuzzyMatch() { - return fuzzyMatch; - } - - /** - * Gets the values. - * - * An array objects describing the entity values. - * - * @return the values - */ - public List getValues() { - return values; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Example.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Example.java deleted file mode 100644 index 483c40bb048..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Example.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Example. - */ -public class Example extends GenericModel { - - @SerializedName("text") - private String exampleText; - private Date created; - private Date updated; - - /** - * Gets the exampleText. - * - * The text of the user input example. - * - * @return the exampleText - */ - public String getExampleText() { - return exampleText; - } - - /** - * Gets the created. - * - * The timestamp for creation of the example. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the example. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ExampleCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ExampleCollection.java deleted file mode 100644 index 6a7a0332dc6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ExampleCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ExampleCollection. - */ -public class ExampleCollection extends GenericModel { - - private List examples; - private Pagination pagination; - - /** - * Gets the examples. - * - * An array of objects describing the examples defined for the intent. - * - * @return the examples - */ - public List getExamples() { - return examples; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetCounterexampleOptions.java deleted file mode 100644 index 3d1a1c33863..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetCounterexampleOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getCounterexample options. - */ -public class GetCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - private Boolean includeAudit; - - private Builder(GetCounterexampleOptions getCounterexampleOptions) { - workspaceId = getCounterexampleOptions.workspaceId; - text = getCounterexampleOptions.text; - includeAudit = getCounterexampleOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a GetCounterexampleOptions. - * - * @return the getCounterexampleOptions - */ - public GetCounterexampleOptions build() { - return new GetCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the GetCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetCounterexampleOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetDialogNodeOptions.java deleted file mode 100644 index a424dd90e00..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetDialogNodeOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getDialogNode options. - */ -public class GetDialogNodeOptions extends GenericModel { - - private String workspaceId; - private String dialogNode; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private Boolean includeAudit; - - private Builder(GetDialogNodeOptions getDialogNodeOptions) { - workspaceId = getDialogNodeOptions.workspaceId; - dialogNode = getDialogNodeOptions.dialogNode; - includeAudit = getDialogNodeOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a GetDialogNodeOptions. - * - * @return the getDialogNodeOptions - */ - public GetDialogNodeOptions build() { - return new GetDialogNodeOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the GetDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetDialogNodeOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetEntityOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetEntityOptions.java deleted file mode 100644 index 691d4676ee8..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetEntityOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getEntity options. - */ -public class GetEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetEntityOptions getEntityOptions) { - workspaceId = getEntityOptions.workspaceId; - entity = getEntityOptions.entity; - export = getEntityOptions.export; - includeAudit = getEntityOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a GetEntityOptions. - * - * @return the getEntityOptions - */ - public GetEntityOptions build() { - return new GetEntityOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetEntityOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetEntityOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetExampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetExampleOptions.java deleted file mode 100644 index b98e8b97cb2..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetExampleOptions.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getExample options. - */ -public class GetExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - private Boolean includeAudit; - - private Builder(GetExampleOptions getExampleOptions) { - workspaceId = getExampleOptions.workspaceId; - intent = getExampleOptions.intent; - text = getExampleOptions.text; - includeAudit = getExampleOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a GetExampleOptions. - * - * @return the getExampleOptions - */ - public GetExampleOptions build() { - return new GetExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the GetExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the GetExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetExampleOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetIntentOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetIntentOptions.java deleted file mode 100644 index 2126ba8a1e7..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetIntentOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getIntent options. - */ -public class GetIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetIntentOptions getIntentOptions) { - workspaceId = getIntentOptions.workspaceId; - intent = getIntentOptions.intent; - export = getIntentOptions.export; - includeAudit = getIntentOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a GetIntentOptions. - * - * @return the getIntentOptions - */ - public GetIntentOptions build() { - return new GetIntentOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the GetIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetIntentOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetIntentOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetSynonymOptions.java deleted file mode 100644 index 253f8a57cd1..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetSynonymOptions.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getSynonym options. - */ -public class GetSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - private Boolean includeAudit; - - private Builder(GetSynonymOptions getSynonymOptions) { - workspaceId = getSynonymOptions.workspaceId; - entity = getSynonymOptions.entity; - value = getSynonymOptions.value; - synonym = getSynonymOptions.synonym; - includeAudit = getSynonymOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a GetSynonymOptions. - * - * @return the getSynonymOptions - */ - public GetSynonymOptions build() { - return new GetSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the GetSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the GetSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetSynonymOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetValueOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetValueOptions.java deleted file mode 100644 index d71078c18ba..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetValueOptions.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getValue options. - */ -public class GetValueOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetValueOptions getValueOptions) { - workspaceId = getValueOptions.workspaceId; - entity = getValueOptions.entity; - value = getValueOptions.value; - export = getValueOptions.export; - includeAudit = getValueOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a GetValueOptions. - * - * @return the getValueOptions - */ - public GetValueOptions build() { - return new GetValueOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the GetValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetValueOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetValueOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/developer_cloud/assistant/v1/model/GetWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetWorkspaceOptions.java deleted file mode 100644 index 276472b1d74..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/GetWorkspaceOptions.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getWorkspace options. - */ -public class GetWorkspaceOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetWorkspaceOptions getWorkspaceOptions) { - workspaceId = getWorkspaceOptions.workspaceId; - export = getWorkspaceOptions.export; - includeAudit = getWorkspaceOptions.includeAudit; - } - - /** - * 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 GetWorkspaceOptions. - * - * @return the getWorkspaceOptions - */ - public GetWorkspaceOptions build() { - return new GetWorkspaceOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetWorkspaceOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetWorkspaceOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetWorkspaceOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/developer_cloud/assistant/v1/model/InputData.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/InputData.java deleted file mode 100644 index 636ee1f5f7d..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/InputData.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The user input. - */ -public class InputData extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(InputData inputData) { - text = inputData.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 InputData. - * - * @return the inputData - */ - public InputData build() { - return new InputData(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the InputData builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private InputData(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a InputData 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, and it must be - * no longer than 2048 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Intent.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Intent.java deleted file mode 100644 index 2bdd49222f6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Intent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Intent. - */ -public class Intent extends GenericModel { - - @SerializedName("intent") - private String intentName; - private Date created; - private Date updated; - private String description; - - /** - * Gets the intentName. - * - * The name of the intent. - * - * @return the intentName - */ - public String getIntentName() { - return intentName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the intent. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the intent. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the intent. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentCollection.java deleted file mode 100644 index b105655d785..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IntentCollection. - */ -public class IntentCollection extends GenericModel { - - private List intents; - private Pagination pagination; - - /** - * Gets the intents. - * - * An array of objects describing the intents defined for the workspace. - * - * @return the intents - */ - public List getIntents() { - return intents; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentExport.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentExport.java deleted file mode 100644 index 918b9ddccab..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/IntentExport.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IntentExport. - */ -public class IntentExport extends GenericModel { - - @SerializedName("intent") - private String intentName; - private Date created; - private Date updated; - private String description; - private List examples; - - /** - * Gets the intentName. - * - * The name of the intent. - * - * @return the intentName - */ - public String getIntentName() { - return intentName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the intent. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the intent. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the intent. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the examples. - * - * An array of objects describing the user input examples for the intent. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListAllLogsOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListAllLogsOptions.java deleted file mode 100644 index 7e67bde960a..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListAllLogsOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listAllLogs options. - */ -public class ListAllLogsOptions extends GenericModel { - - private String filter; - private String sort; - private Long pageLimit; - private String cursor; - - /** - * Builder. - */ - public static class Builder { - private String filter; - private String sort; - private Long pageLimit; - private String cursor; - - private Builder(ListAllLogsOptions listAllLogsOptions) { - filter = listAllLogsOptions.filter; - sort = listAllLogsOptions.sort; - pageLimit = listAllLogsOptions.pageLimit; - cursor = listAllLogsOptions.cursor; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param filter the filter - */ - public Builder(String filter) { - this.filter = filter; - } - - /** - * Builds a ListAllLogsOptions. - * - * @return the listAllLogsOptions - */ - public ListAllLogsOptions build() { - return new ListAllLogsOptions(this); - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the ListAllLogsOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the ListAllLogsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListAllLogsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = pageLimit; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListAllLogsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - } - - private ListAllLogsOptions(Builder builder) { - Validator.notNull(builder.filter, "filter cannot be null"); - filter = builder.filter; - sort = builder.sort; - pageLimit = builder.pageLimit; - cursor = builder.cursor; - } - - /** - * New builder. - * - * @return a ListAllLogsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 `workspace_id` or - * `request.context.metadata.deployment`. For more information, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax). - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the pageLimit. - * - * The number of records to return in each page of results. - * - * @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/developer_cloud/assistant/v1/model/ListCounterexamplesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListCounterexamplesOptions.java deleted file mode 100644 index ce8a6ea7d43..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListCounterexamplesOptions.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listCounterexamples options. - */ -public class ListCounterexamplesOptions extends GenericModel { - - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListCounterexamplesOptions listCounterexamplesOptions) { - workspaceId = listCounterexamplesOptions.workspaceId; - pageLimit = listCounterexamplesOptions.pageLimit; - includeCount = listCounterexamplesOptions.includeCount; - sort = listCounterexamplesOptions.sort; - cursor = listCounterexamplesOptions.cursor; - includeAudit = listCounterexamplesOptions.includeAudit; - } - - /** - * 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 ListCounterexamplesOptions. - * - * @return the listCounterexamplesOptions - */ - public ListCounterexamplesOptions build() { - return new ListCounterexamplesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListCounterexamplesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListCounterexamplesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListCounterexamplesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListCounterexamplesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListCounterexamplesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListCounterexamplesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListCounterexamplesOptions 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 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListDialogNodesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListDialogNodesOptions.java deleted file mode 100644 index 8902276ae28..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListDialogNodesOptions.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listDialogNodes options. - */ -public class ListDialogNodesOptions extends GenericModel { - - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListDialogNodesOptions listDialogNodesOptions) { - workspaceId = listDialogNodesOptions.workspaceId; - pageLimit = listDialogNodesOptions.pageLimit; - includeCount = listDialogNodesOptions.includeCount; - sort = listDialogNodesOptions.sort; - cursor = listDialogNodesOptions.cursor; - includeAudit = listDialogNodesOptions.includeAudit; - } - - /** - * 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 ListDialogNodesOptions. - * - * @return the listDialogNodesOptions - */ - public ListDialogNodesOptions build() { - return new ListDialogNodesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListDialogNodesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListDialogNodesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListDialogNodesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListDialogNodesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListDialogNodesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListDialogNodesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListDialogNodesOptions 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 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListEntitiesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListEntitiesOptions.java deleted file mode 100644 index 881da8659b6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListEntitiesOptions.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listEntities options. - */ -public class ListEntitiesOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListEntitiesOptions listEntitiesOptions) { - workspaceId = listEntitiesOptions.workspaceId; - export = listEntitiesOptions.export; - pageLimit = listEntitiesOptions.pageLimit; - includeCount = listEntitiesOptions.includeCount; - sort = listEntitiesOptions.sort; - cursor = listEntitiesOptions.cursor; - includeAudit = listEntitiesOptions.includeAudit; - } - - /** - * 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 ListEntitiesOptions. - * - * @return the listEntitiesOptions - */ - public ListEntitiesOptions build() { - return new ListEntitiesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListEntitiesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListEntitiesOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListEntitiesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListEntitiesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListEntitiesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListEntitiesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListEntitiesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListEntitiesOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListExamplesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListExamplesOptions.java deleted file mode 100644 index ae40f1593f6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListExamplesOptions.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listExamples options. - */ -public class ListExamplesOptions extends GenericModel { - - private String workspaceId; - private String intent; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListExamplesOptions listExamplesOptions) { - workspaceId = listExamplesOptions.workspaceId; - intent = listExamplesOptions.intent; - pageLimit = listExamplesOptions.pageLimit; - includeCount = listExamplesOptions.includeCount; - sort = listExamplesOptions.sort; - cursor = listExamplesOptions.cursor; - includeAudit = listExamplesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a ListExamplesOptions. - * - * @return the listExamplesOptions - */ - public ListExamplesOptions build() { - return new ListExamplesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListExamplesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the ListExamplesOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListExamplesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListExamplesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListExamplesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListExamplesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListExamplesOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListExamplesOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListIntentsOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListIntentsOptions.java deleted file mode 100644 index a35fb0eec42..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListIntentsOptions.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listIntents options. - */ -public class ListIntentsOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListIntentsOptions listIntentsOptions) { - workspaceId = listIntentsOptions.workspaceId; - export = listIntentsOptions.export; - pageLimit = listIntentsOptions.pageLimit; - includeCount = listIntentsOptions.includeCount; - sort = listIntentsOptions.sort; - cursor = listIntentsOptions.cursor; - includeAudit = listIntentsOptions.includeAudit; - } - - /** - * 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 ListIntentsOptions. - * - * @return the listIntentsOptions - */ - public ListIntentsOptions build() { - return new ListIntentsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListIntentsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListIntentsOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListIntentsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListIntentsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListIntentsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListIntentsOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListIntentsOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListIntentsOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListLogsOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListLogsOptions.java deleted file mode 100644 index 7a7e1ff7438..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListLogsOptions.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listLogs options. - */ -public class ListLogsOptions extends GenericModel { - - private String workspaceId; - private String sort; - private String filter; - private Long pageLimit; - private String cursor; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String sort; - private String filter; - private Long pageLimit; - private String cursor; - - private Builder(ListLogsOptions listLogsOptions) { - workspaceId = listLogsOptions.workspaceId; - sort = listLogsOptions.sort; - filter = listLogsOptions.filter; - pageLimit = listLogsOptions.pageLimit; - cursor = listLogsOptions.cursor; - } - - /** - * 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 ListLogsOptions. - * - * @return the listLogsOptions - */ - public ListLogsOptions build() { - return new ListLogsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListLogsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - 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; - } - } - - private ListLogsOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - 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 workspaceId. - * - * Unique identifier of the workspace. - * - * @return the workspaceId - */ - public String workspaceId() { - return workspaceId; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax). - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the pageLimit. - * - * The number of records to return in each page of results. - * - * @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/developer_cloud/assistant/v1/model/ListSynonymsOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListSynonymsOptions.java deleted file mode 100644 index 2a4e410d2b6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListSynonymsOptions.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listSynonyms options. - */ -public class ListSynonymsOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListSynonymsOptions listSynonymsOptions) { - workspaceId = listSynonymsOptions.workspaceId; - entity = listSynonymsOptions.entity; - value = listSynonymsOptions.value; - pageLimit = listSynonymsOptions.pageLimit; - includeCount = listSynonymsOptions.includeCount; - sort = listSynonymsOptions.sort; - cursor = listSynonymsOptions.cursor; - includeAudit = listSynonymsOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a ListSynonymsOptions. - * - * @return the listSynonymsOptions - */ - public ListSynonymsOptions build() { - return new ListSynonymsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListSynonymsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the ListSynonymsOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the ListSynonymsOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListSynonymsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListSynonymsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListSynonymsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListSynonymsOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListSynonymsOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListSynonymsOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListValuesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListValuesOptions.java deleted file mode 100644 index 17d875cefe5..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListValuesOptions.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listValues options. - */ -public class ListValuesOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListValuesOptions listValuesOptions) { - workspaceId = listValuesOptions.workspaceId; - entity = listValuesOptions.entity; - export = listValuesOptions.export; - pageLimit = listValuesOptions.pageLimit; - includeCount = listValuesOptions.includeCount; - sort = listValuesOptions.sort; - cursor = listValuesOptions.cursor; - includeAudit = listValuesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a ListValuesOptions. - * - * @return the listValuesOptions - */ - public ListValuesOptions build() { - return new ListValuesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListValuesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the ListValuesOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListValuesOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListValuesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListValuesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListValuesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListValuesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListValuesOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListValuesOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/ListWorkspacesOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListWorkspacesOptions.java deleted file mode 100644 index 8278958d36e..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ListWorkspacesOptions.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listWorkspaces options. - */ -public class ListWorkspacesOptions extends GenericModel { - - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListWorkspacesOptions listWorkspacesOptions) { - pageLimit = listWorkspacesOptions.pageLimit; - includeCount = listWorkspacesOptions.includeCount; - sort = listWorkspacesOptions.sort; - cursor = listWorkspacesOptions.cursor; - includeAudit = listWorkspacesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListWorkspacesOptions. - * - * @return the listWorkspacesOptions - */ - public ListWorkspacesOptions build() { - return new ListWorkspacesOptions(this); - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListWorkspacesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListWorkspacesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListWorkspacesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListWorkspacesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListWorkspacesOptions(Builder builder) { - pageLimit = builder.pageLimit; - includeCount = builder.includeCount; - sort = builder.sort; - cursor = builder.cursor; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a ListWorkspacesOptions 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/developer_cloud/assistant/v1/model/LogCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogCollection.java deleted file mode 100644 index 8b38ccece03..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LogCollection. - */ -public class LogCollection extends GenericModel { - - private List logs; - private LogPagination pagination; - - /** - * 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. - * - * @return the pagination - */ - public LogPagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogExport.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogExport.java deleted file mode 100644 index 246d5eb9592..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogExport.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LogExport. - */ -public class LogExport extends GenericModel { - - private MessageRequest request; - private MessageResponse response; - @SerializedName("log_id") - private String logId; - @SerializedName("request_timestamp") - private String requestTimestamp; - @SerializedName("response_timestamp") - private String responseTimestamp; - @SerializedName("workspace_id") - private String workspaceId; - private String language; - - /** - * Gets the request. - * - * A request received by the workspace, including the user input and context. - * - * @return the request - */ - public MessageRequest getRequest() { - return request; - } - - /** - * Gets the response. - * - * The response sent by the workspace, including the output text, detected intents and entities, and context. - * - * @return the response - */ - public MessageResponse getResponse() { - return response; - } - - /** - * Gets the logId. - * - * A unique identifier for the logged event. - * - * @return the logId - */ - public String getLogId() { - return logId; - } - - /** - * 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 workspaceId. - * - * The unique identifier of the workspace where the request was made. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the language. - * - * The language of the workspace where the message request was made. - * - * @return the language - */ - public String getLanguage() { - return language; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogMessage.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogMessage.java deleted file mode 100644 index 8f503818c4b..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * Log message details. - */ -public class LogMessage extends DynamicModel { - /** - * The severity of the log message. - */ - public interface Level { - /** info. */ - String INFO = "info"; - /** error. */ - String ERROR = "error"; - /** warn. */ - String WARN = "warn"; - } - - private Type levelType = new TypeToken() { - }.getType(); - private Type msgType = new TypeToken() { - }.getType(); - - /** - * Gets the level. - * - * @return the level - */ - public String getLevel() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("level"), levelType); - } - - /** - * Gets the msg. - * - * @return the msg - */ - public String getMsg() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("msg"), msgType); - } - - /** - * Sets the level. - * - * @param level the new level - */ - public void setLevel(final String level) { - this.put("level", level); - } - - /** - * Sets the msg. - * - * @param msg the new msg - */ - public void setMsg(final String msg) { - this.put("msg", msg); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogPagination.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogPagination.java deleted file mode 100644 index e1b1e96e43e..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/LogPagination.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The pagination data for the returned objects. - */ -public class LogPagination extends GenericModel { - - @SerializedName("next_url") - private String nextUrl; - private Long matched; - @SerializedName("next_cursor") - private String nextCursor; - - /** - * 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/developer_cloud/assistant/v1/model/MessageInput.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageInput.java deleted file mode 100644 index bbdcaa4e2eb..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageInput.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The text of the user input. - */ -public class MessageInput extends GenericModel { - - private String text; - - /** - * Gets the text. - * - * The user's input. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageOptions.java deleted file mode 100644 index 6c303a63315..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageOptions.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The message options. - */ -public class MessageOptions extends GenericModel { - - private String workspaceId; - private InputData input; - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - private Boolean nodesVisitedDetails; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private InputData input; - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - private Boolean nodesVisitedDetails; - - private Builder(MessageOptions messageOptions) { - workspaceId = messageOptions.workspaceId; - input = messageOptions.input; - alternateIntents = messageOptions.alternateIntents; - context = messageOptions.context; - entities = messageOptions.entities; - intents = messageOptions.intents; - output = messageOptions.output; - nodesVisitedDetails = messageOptions.nodesVisitedDetails; - } - - /** - * 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 MessageOptions. - * - * @return the messageOptions - */ - public MessageOptions build() { - return new MessageOptions(this); - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the MessageOptions builder - */ - public Builder addEntity(RuntimeEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the MessageOptions builder - */ - public Builder addIntent(RuntimeIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the MessageOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the input. - * - * @param input the input - * @return the MessageOptions builder - */ - public Builder input(InputData input) { - this.input = input; - return this; - } - - /** - * Set the alternateIntents. - * - * @param alternateIntents the alternateIntents - * @return the MessageOptions builder - */ - public Builder alternateIntents(Boolean alternateIntents) { - this.alternateIntents = alternateIntents; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the MessageOptions builder - */ - public Builder context(Context context) { - this.context = context; - return this; - } - - /** - * Set the entities. - * Existing entities will be replaced. - * - * @param entities the entities - * @return the MessageOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the MessageOptions builder - */ - public Builder intents(List intents) { - this.intents = intents; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the MessageOptions builder - */ - public Builder output(OutputData output) { - this.output = output; - return this; - } - - /** - * Set the nodesVisitedDetails. - * - * @param nodesVisitedDetails the nodesVisitedDetails - * @return the MessageOptions builder - */ - public Builder nodesVisitedDetails(Boolean nodesVisitedDetails) { - this.nodesVisitedDetails = nodesVisitedDetails; - return this; - } - - /** - * Set the messageRequest. - * - * @param messageRequest the messageRequest - * @return the MessageOptions builder - */ - public Builder messageRequest(MessageRequest messageRequest) { - this.input = messageRequest.getInput(); - this.alternateIntents = messageRequest.isAlternateIntents(); - this.context = messageRequest.getContext(); - this.entities = messageRequest.getEntities(); - this.intents = messageRequest.getIntents(); - this.output = messageRequest.getOutput(); - return this; - } - } - - private MessageOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - input = builder.input; - alternateIntents = builder.alternateIntents; - context = builder.context; - entities = builder.entities; - intents = builder.intents; - output = builder.output; - nodesVisitedDetails = builder.nodesVisitedDetails; - } - - /** - * New builder. - * - * @return a MessageOptions 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 input object that includes the input text. - * - * @return the input - */ - public InputData input() { - return input; - } - - /** - * 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 context. - * - * State information for the conversation. Continue a conversation by including the context object from the previous - * response. - * - * @return the context - */ - public Context context() { - return context; - } - - /** - * 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 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 output. - * - * System output. Include the output from the previous response to maintain intermediate information over multiple - * requests. - * - * @return the output - */ - public OutputData output() { - return output; - } - - /** - * Gets the nodesVisitedDetails. - * - * Whether to include additional diagnostic information about the dialog nodes that were visited during processing of - * the message. - * - * @return the nodesVisitedDetails - */ - public Boolean nodesVisitedDetails() { - return nodesVisitedDetails; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageRequest.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageRequest.java deleted file mode 100644 index 04dbcfe8de1..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageRequest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A request formatted for the Watson Assistant service. - */ -public class MessageRequest extends GenericModel { - - private InputData input; - @SerializedName("alternate_intents") - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - - /** - * Gets the input. - * - * An input object that includes the input text. - * - * @return the input - */ - public InputData getInput() { - return input; - } - - /** - * Gets the alternateIntents. - * - * Whether to return more than one intent. Set to `true` to return all matching intents. - * - * @return the alternateIntents - */ - public Boolean isAlternateIntents() { - return alternateIntents; - } - - /** - * Gets the context. - * - * State information for the conversation. Continue a conversation by including the context object from the previous - * response. - * - * @return the context - */ - public Context getContext() { - return context; - } - - /** - * 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 getEntities() { - return entities; - } - - /** - * 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 getIntents() { - return intents; - } - - /** - * Gets the output. - * - * System output. Include the output from the previous response to maintain intermediate information over multiple - * requests. - * - * @return the output - */ - public OutputData getOutput() { - return output; - } - - /** - * Sets the input. - * - * @param input the new input - */ - public void setInput(final InputData input) { - this.input = input; - } - - /** - * Sets the alternateIntents. - * - * @param alternateIntents the new alternateIntents - */ - public void setAlternateIntents(final Boolean alternateIntents) { - this.alternateIntents = alternateIntents; - } - - /** - * Sets the context. - * - * @param context the new context - */ - public void setContext(final Context context) { - this.context = context; - } - - /** - * Sets the entities. - * - * @param entities the new entities - */ - public void setEntities(final List entities) { - this.entities = entities; - } - - /** - * Sets the intents. - * - * @param intents the new intents - */ - public void setIntents(final List intents) { - this.intents = intents; - } - - /** - * Sets the output. - * - * @param output the new output - */ - public void setOutput(final OutputData output) { - this.output = output; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageResponse.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageResponse.java deleted file mode 100644 index 8c54d129b74..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/MessageResponse.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; -import java.util.List; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * A response from the Watson Assistant service. - */ -public class MessageResponse extends DynamicModel { - private Type inputType = new TypeToken() { - }.getType(); - private Type intentsType = new TypeToken>() { - }.getType(); - private Type entitiesType = new TypeToken>() { - }.getType(); - private Type alternateIntentsType = new TypeToken() { - }.getType(); - private Type contextType = new TypeToken() { - }.getType(); - private Type outputType = new TypeToken() { - }.getType(); - - /** - * Gets the input. - * - * @return the input - */ - public MessageInput getInput() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("input"), inputType); - } - - /** - * Gets the intents. - * - * @return the intents - */ - public List getIntents() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("intents"), intentsType); - } - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("entities"), entitiesType); - } - - /** - * Gets the alternateIntents. - * - * @return the alternateIntents - */ - public Boolean isAlternateIntents() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("alternate_intents"), alternateIntentsType); - } - - /** - * Gets the context. - * - * @return the context - */ - public Context getContext() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("context"), contextType); - } - - /** - * Gets the output. - * - * @return the output - */ - public OutputData getOutput() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("output"), outputType); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/OutputData.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/OutputData.java deleted file mode 100644 index dc27b3c4930..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/OutputData.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; -import java.util.List; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * An output object that includes the response to the user, the nodes that were hit, and messages from the log. - */ -public class OutputData extends DynamicModel { - private Type logMessagesType = new TypeToken>() { - }.getType(); - private Type textType = new TypeToken>() { - }.getType(); - private Type nodesVisitedType = new TypeToken>() { - }.getType(); - private Type nodesVisitedDetailsType = new TypeToken>() { - }.getType(); - - /** - * Gets the logMessages. - * - * @return the logMessages - */ - public List getLogMessages() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("log_messages"), logMessagesType); - } - - /** - * Gets the text. - * - * @return the text - */ - public List getText() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("text"), textType); - } - - /** - * Gets the nodesVisited. - * - * @return the nodesVisited - */ - public List getNodesVisited() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("nodes_visited"), nodesVisitedType); - } - - /** - * Gets the nodesVisitedDetails. - * - * @return the nodesVisitedDetails - */ - public List getNodesVisitedDetails() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("nodes_visited_details"), - nodesVisitedDetailsType); - } - - /** - * Sets the logMessages. - * - * @param logMessages the new logMessages - */ - public void setLogMessages(final List logMessages) { - this.put("log_messages", logMessages); - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final List text) { - this.put("text", text); - } - - /** - * Sets the nodesVisited. - * - * @param nodesVisited the new nodesVisited - */ - public void setNodesVisited(final List nodesVisited) { - this.put("nodes_visited", nodesVisited); - } - - /** - * Sets the nodesVisitedDetails. - * - * @param nodesVisitedDetails the new nodesVisitedDetails - */ - public void setNodesVisitedDetails(final List nodesVisitedDetails) { - this.put("nodes_visited_details", nodesVisitedDetails); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Pagination.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Pagination.java deleted file mode 100644 index 27f7141ee21..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Pagination.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The pagination data for the returned objects. - */ -public class Pagination extends GenericModel { - - @SerializedName("refresh_url") - private String refreshUrl; - @SerializedName("next_url") - private String nextUrl; - private Long total; - private Long matched; - @SerializedName("refresh_cursor") - private String refreshCursor; - @SerializedName("next_cursor") - private String nextCursor; - - /** - * 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. - * - * Reserved for future use. - * - * @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/developer_cloud/assistant/v1/model/RuntimeEntity.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/RuntimeEntity.java deleted file mode 100644 index c7decaeffd6..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/RuntimeEntity.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * A term from the request that was identified as an entity. - */ -public class RuntimeEntity extends DynamicModel { - private Type entityType = new TypeToken() { - }.getType(); - private Type locationType = new TypeToken>() { - }.getType(); - private Type valueType = new TypeToken() { - }.getType(); - private Type confidenceType = new TypeToken() { - }.getType(); - private Type metadataType = new TypeToken() { - }.getType(); - private Type groupsType = new TypeToken>() { - }.getType(); - - /** - * Gets the entity. - * - * @return the entity - */ - public String getEntity() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("entity"), entityType); - } - - /** - * Gets the location. - * - * @return the location - */ - public List getLocation() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("location"), locationType); - } - - /** - * Gets the value. - * - * @return the value - */ - public String getValue() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("value"), valueType); - } - - /** - * Gets the confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("confidence"), confidenceType); - } - - /** - * Gets the metadata. - * - * @return the metadata - */ - public Map getMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("metadata"), metadataType); - } - - /** - * Gets the groups. - * - * @return the groups - */ - public List getGroups() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("groups"), groupsType); - } - - /** - * Sets the entity. - * - * @param entity the new entity - */ - public void setEntity(final String entity) { - this.put("entity", entity); - } - - /** - * Sets the location. - * - * @param location the new location - */ - public void setLocation(final List location) { - this.put("location", location); - } - - /** - * Sets the value. - * - * @param value the new value - */ - public void setValue(final String value) { - this.put("value", value); - } - - /** - * Sets the confidence. - * - * @param confidence the new confidence - */ - public void setConfidence(final Double confidence) { - this.put("confidence", confidence); - } - - /** - * Sets the metadata. - * - * @param metadata the new metadata - */ - public void setMetadata(final Map metadata) { - this.put("metadata", metadata); - } - - /** - * Sets the groups. - * - * @param groups the new groups - */ - public void setGroups(final List groups) { - this.put("groups", groups); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/RuntimeIntent.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/RuntimeIntent.java deleted file mode 100644 index 8075834cf33..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/RuntimeIntent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * An intent identified in the user input. - */ -public class RuntimeIntent extends DynamicModel { - private Type intentType = new TypeToken() { - }.getType(); - private Type confidenceType = new TypeToken() { - }.getType(); - - /** - * Gets the intent. - * - * @return the intent - */ - public String getIntent() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("intent"), intentType); - } - - /** - * Gets the confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("confidence"), confidenceType); - } - - /** - * Sets the intent. - * - * @param intent the new intent - */ - public void setIntent(final String intent) { - this.put("intent", intent); - } - - /** - * Sets the confidence. - * - * @param confidence the new confidence - */ - public void setConfidence(final Double confidence) { - this.put("confidence", confidence); - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Synonym.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Synonym.java deleted file mode 100644 index ad7030e0d73..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Synonym.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Synonym. - */ -public class Synonym extends GenericModel { - - @SerializedName("synonym") - private String synonymText; - private Date created; - private Date updated; - - /** - * Gets the synonymText. - * - * The text of the synonym. - * - * @return the synonymText - */ - public String getSynonymText() { - return synonymText; - } - - /** - * Gets the created. - * - * The timestamp for creation of the synonym. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the most recent update to the synonym. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SynonymCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SynonymCollection.java deleted file mode 100644 index cf50b220ea2..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SynonymCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SynonymCollection. - */ -public class SynonymCollection extends GenericModel { - - private List synonyms; - private Pagination pagination; - - /** - * Gets the synonyms. - * - * An array of synonyms. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SystemResponse.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SystemResponse.java deleted file mode 100644 index 1544c48ddc7..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/SystemResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.DynamicModel; - -/** - * For internal use only. - */ -public class SystemResponse extends DynamicModel { - -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateCounterexampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateCounterexampleOptions.java deleted file mode 100644 index 437ebbfee09..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateCounterexampleOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateCounterexample options. - */ -public class UpdateCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - private String newText; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - private String newText; - - private Builder(UpdateCounterexampleOptions updateCounterexampleOptions) { - workspaceId = updateCounterexampleOptions.workspaceId; - text = updateCounterexampleOptions.text; - newText = updateCounterexampleOptions.newText; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a UpdateCounterexampleOptions. - * - * @return the updateCounterexampleOptions - */ - public UpdateCounterexampleOptions build() { - return new UpdateCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the UpdateCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the newText. - * - * @param newText the newText - * @return the UpdateCounterexampleOptions builder - */ - public Builder newText(String newText) { - this.newText = newText; - return this; - } - } - - private UpdateCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - newText = builder.newText; - } - - /** - * New builder. - * - * @return a UpdateCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the newText. - * - * The text of a user input counterexample. - * - * @return the newText - */ - public String newText() { - return newText; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateDialogNodeOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateDialogNodeOptions.java deleted file mode 100644 index 46895c13cd9..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateDialogNodeOptions.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The UpdateDialogNode options. - */ -public class UpdateDialogNodeOptions extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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"; - } - - /** - * Whether this dialog node can be returned to after a digression. - */ - public interface NewDigressOut { - /** 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"; - } - - /** - * How an `event_handler` node is processed. - */ - public interface NewEventName { - /** 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 the user can digress to top-level nodes while filling out slots. - */ - public interface NewDigressOutSlots { - /** not_allowed. */ - String NOT_ALLOWED = "not_allowed"; - /** allow_returning. */ - String ALLOW_RETURNING = "allow_returning"; - /** allow_all. */ - String ALLOW_ALL = "allow_all"; - } - - /** - * Whether this top-level dialog node can be digressed into. - */ - public interface NewDigressIn { - /** not_available. */ - String NOT_AVAILABLE = "not_available"; - /** returns. */ - String RETURNS = "returns"; - /** does_not_return. */ - String DOES_NOT_RETURN = "does_not_return"; - } - - private String workspaceId; - private String dialogNode; - private String nodeType; - private List newActions; - private String newConditions; - private Map newContext; - private String newPreviousSibling; - private String newVariable; - private Map newMetadata; - private String newTitle; - private String newDescription; - private String newDigressOut; - private String newEventName; - private String newDigressOutSlots; - private DialogNodeNextStep newNextStep; - private String newDigressIn; - private Map newOutput; - private String newParent; - private String newDialogNode; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private String nodeType; - private List newActions; - private String newConditions; - private Map newContext; - private String newPreviousSibling; - private String newVariable; - private Map newMetadata; - private String newTitle; - private String newDescription; - private String newDigressOut; - private String newEventName; - private String newDigressOutSlots; - private DialogNodeNextStep newNextStep; - private String newDigressIn; - private Map newOutput; - private String newParent; - private String newDialogNode; - - private Builder(UpdateDialogNodeOptions updateDialogNodeOptions) { - workspaceId = updateDialogNodeOptions.workspaceId; - dialogNode = updateDialogNodeOptions.dialogNode; - nodeType = updateDialogNodeOptions.nodeType; - newActions = updateDialogNodeOptions.newActions; - newConditions = updateDialogNodeOptions.newConditions; - newContext = updateDialogNodeOptions.newContext; - newPreviousSibling = updateDialogNodeOptions.newPreviousSibling; - newVariable = updateDialogNodeOptions.newVariable; - newMetadata = updateDialogNodeOptions.newMetadata; - newTitle = updateDialogNodeOptions.newTitle; - newDescription = updateDialogNodeOptions.newDescription; - newDigressOut = updateDialogNodeOptions.newDigressOut; - newEventName = updateDialogNodeOptions.newEventName; - newDigressOutSlots = updateDialogNodeOptions.newDigressOutSlots; - newNextStep = updateDialogNodeOptions.newNextStep; - newDigressIn = updateDialogNodeOptions.newDigressIn; - newOutput = updateDialogNodeOptions.newOutput; - newParent = updateDialogNodeOptions.newParent; - newDialogNode = updateDialogNodeOptions.newDialogNode; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a UpdateDialogNodeOptions. - * - * @return the updateDialogNodeOptions - */ - public UpdateDialogNodeOptions build() { - return new UpdateDialogNodeOptions(this); - } - - /** - * Adds an newActions to newActions. - * - * @param newActions the new newActions - * @return the UpdateDialogNodeOptions builder - */ - public Builder addNewActions(DialogNodeAction newActions) { - Validator.notNull(newActions, "newActions cannot be null"); - if (this.newActions == null) { - this.newActions = new ArrayList(); - } - this.newActions.add(newActions); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the UpdateDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the UpdateDialogNodeOptions builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the newActions. - * Existing newActions will be replaced. - * - * @param newActions the newActions - * @return the UpdateDialogNodeOptions builder - */ - public Builder newActions(List newActions) { - this.newActions = newActions; - return this; - } - - /** - * Set the newConditions. - * - * @param newConditions the newConditions - * @return the UpdateDialogNodeOptions builder - */ - public Builder newConditions(String newConditions) { - this.newConditions = newConditions; - return this; - } - - /** - * Set the newContext. - * - * @param newContext the newContext - * @return the UpdateDialogNodeOptions builder - */ - public Builder newContext(Map newContext) { - this.newContext = newContext; - return this; - } - - /** - * Set the newPreviousSibling. - * - * @param newPreviousSibling the newPreviousSibling - * @return the UpdateDialogNodeOptions builder - */ - public Builder newPreviousSibling(String newPreviousSibling) { - this.newPreviousSibling = newPreviousSibling; - return this; - } - - /** - * Set the newVariable. - * - * @param newVariable the newVariable - * @return the UpdateDialogNodeOptions builder - */ - public Builder newVariable(String newVariable) { - this.newVariable = newVariable; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateDialogNodeOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newTitle. - * - * @param newTitle the newTitle - * @return the UpdateDialogNodeOptions builder - */ - public Builder newTitle(String newTitle) { - this.newTitle = newTitle; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - - /** - * Set the newDigressOut. - * - * @param newDigressOut the newDigressOut - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressOut(String newDigressOut) { - this.newDigressOut = newDigressOut; - return this; - } - - /** - * Set the newEventName. - * - * @param newEventName the newEventName - * @return the UpdateDialogNodeOptions builder - */ - public Builder newEventName(String newEventName) { - this.newEventName = newEventName; - return this; - } - - /** - * Set the newDigressOutSlots. - * - * @param newDigressOutSlots the newDigressOutSlots - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressOutSlots(String newDigressOutSlots) { - this.newDigressOutSlots = newDigressOutSlots; - return this; - } - - /** - * Set the newNextStep. - * - * @param newNextStep the newNextStep - * @return the UpdateDialogNodeOptions builder - */ - public Builder newNextStep(DialogNodeNextStep newNextStep) { - this.newNextStep = newNextStep; - return this; - } - - /** - * Set the newDigressIn. - * - * @param newDigressIn the newDigressIn - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressIn(String newDigressIn) { - this.newDigressIn = newDigressIn; - return this; - } - - /** - * Set the newOutput. - * - * @param newOutput the newOutput - * @return the UpdateDialogNodeOptions builder - */ - public Builder newOutput(Map newOutput) { - this.newOutput = newOutput; - return this; - } - - /** - * Set the newParent. - * - * @param newParent the newParent - * @return the UpdateDialogNodeOptions builder - */ - public Builder newParent(String newParent) { - this.newParent = newParent; - return this; - } - - /** - * Set the newDialogNode. - * - * @param newDialogNode the newDialogNode - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDialogNode(String newDialogNode) { - this.newDialogNode = newDialogNode; - return this; - } - } - - private UpdateDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - nodeType = builder.nodeType; - newActions = builder.newActions; - newConditions = builder.newConditions; - newContext = builder.newContext; - newPreviousSibling = builder.newPreviousSibling; - newVariable = builder.newVariable; - newMetadata = builder.newMetadata; - newTitle = builder.newTitle; - newDescription = builder.newDescription; - newDigressOut = builder.newDigressOut; - newEventName = builder.newEventName; - newDigressOutSlots = builder.newDigressOutSlots; - newNextStep = builder.newNextStep; - newDigressIn = builder.newDigressIn; - newOutput = builder.newOutput; - newParent = builder.newParent; - newDialogNode = builder.newDialogNode; - } - - /** - * New builder. - * - * @return a UpdateDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * Gets the newActions. - * - * An array of objects describing any actions to be invoked by the dialog node. - * - * @return the newActions - */ - public List newActions() { - return newActions; - } - - /** - * Gets the newConditions. - * - * The condition that will trigger the dialog node. This string cannot contain carriage return, newline, or tab - * characters, and it must be no longer than 2048 characters. - * - * @return the newConditions - */ - public String newConditions() { - return newConditions; - } - - /** - * Gets the newContext. - * - * The context for the dialog node. - * - * @return the newContext - */ - public Map newContext() { - return newContext; - } - - /** - * Gets the newPreviousSibling. - * - * The ID of the previous sibling dialog node. - * - * @return the newPreviousSibling - */ - public String newPreviousSibling() { - return newPreviousSibling; - } - - /** - * Gets the newVariable. - * - * The location in the dialog context where output is stored. - * - * @return the newVariable - */ - public String newVariable() { - return newVariable; - } - - /** - * Gets the newMetadata. - * - * The metadata for the dialog node. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the newTitle - */ - public String newTitle() { - return newTitle; - } - - /** - * Gets the newDescription. - * - * The description of the dialog node. This string cannot contain carriage return, newline, or tab characters, and it - * must be no longer than 128 characters. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } - - /** - * Gets the newDigressOut. - * - * Whether this dialog node can be returned to after a digression. - * - * @return the newDigressOut - */ - public String newDigressOut() { - return newDigressOut; - } - - /** - * Gets the newEventName. - * - * How an `event_handler` node is processed. - * - * @return the newEventName - */ - public String newEventName() { - return newEventName; - } - - /** - * Gets the newDigressOutSlots. - * - * Whether the user can digress to top-level nodes while filling out slots. - * - * @return the newDigressOutSlots - */ - public String newDigressOutSlots() { - return newDigressOutSlots; - } - - /** - * Gets the newNextStep. - * - * The next step to be executed in dialog processing. - * - * @return the newNextStep - */ - public DialogNodeNextStep newNextStep() { - return newNextStep; - } - - /** - * Gets the newDigressIn. - * - * Whether this top-level dialog node can be digressed into. - * - * @return the newDigressIn - */ - public String newDigressIn() { - return newDigressIn; - } - - /** - * Gets the newOutput. - * - * The output of the dialog node. For more information about how to specify dialog node output, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the newOutput - */ - public Map newOutput() { - return newOutput; - } - - /** - * Gets the newParent. - * - * The ID of the parent dialog node. - * - * @return the newParent - */ - public String newParent() { - return newParent; - } - - /** - * 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. - * - It must be no longer than 1024 characters. - * - * @return the newDialogNode - */ - public String newDialogNode() { - return newDialogNode; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateEntityOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateEntityOptions.java deleted file mode 100644 index 494efa00bf2..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateEntityOptions.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateEntity options. - */ -public class UpdateEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean newFuzzyMatch; - private String newEntity; - private Map newMetadata; - private List newValues; - private String newDescription; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private Boolean newFuzzyMatch; - private String newEntity; - private Map newMetadata; - private List newValues; - private String newDescription; - - private Builder(UpdateEntityOptions updateEntityOptions) { - workspaceId = updateEntityOptions.workspaceId; - entity = updateEntityOptions.entity; - newFuzzyMatch = updateEntityOptions.newFuzzyMatch; - newEntity = updateEntityOptions.newEntity; - newMetadata = updateEntityOptions.newMetadata; - newValues = updateEntityOptions.newValues; - newDescription = updateEntityOptions.newDescription; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a UpdateEntityOptions. - * - * @return the updateEntityOptions - */ - public UpdateEntityOptions build() { - return new UpdateEntityOptions(this); - } - - /** - * Adds an value to newValues. - * - * @param value the new value - * @return the UpdateEntityOptions builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.newValues == null) { - this.newValues = new ArrayList(); - } - this.newValues.add(value); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the newFuzzyMatch. - * - * @param newFuzzyMatch the newFuzzyMatch - * @return the UpdateEntityOptions builder - */ - public Builder newFuzzyMatch(Boolean newFuzzyMatch) { - this.newFuzzyMatch = newFuzzyMatch; - return this; - } - - /** - * Set the newEntity. - * - * @param newEntity the newEntity - * @return the UpdateEntityOptions builder - */ - public Builder newEntity(String newEntity) { - this.newEntity = newEntity; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateEntityOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newValues. - * Existing newValues will be replaced. - * - * @param newValues the newValues - * @return the UpdateEntityOptions builder - */ - public Builder newValues(List newValues) { - this.newValues = newValues; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateEntityOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - } - - private UpdateEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - newFuzzyMatch = builder.newFuzzyMatch; - newEntity = builder.newEntity; - newMetadata = builder.newMetadata; - newValues = builder.newValues; - newDescription = builder.newDescription; - } - - /** - * New builder. - * - * @return a UpdateEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the newFuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the newFuzzyMatch - */ - public Boolean newFuzzyMatch() { - return newFuzzyMatch; - } - - /** - * 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-`. - * - It must be no longer than 64 characters. - * - * @return the newEntity - */ - public String newEntity() { - return newEntity; - } - - /** - * Gets the newMetadata. - * - * Any metadata related to the entity. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * Gets the newValues. - * - * An array of entity values. - * - * @return the newValues - */ - public List newValues() { - return newValues; - } - - /** - * Gets the newDescription. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateExampleOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateExampleOptions.java deleted file mode 100644 index 20d9905c11f..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateExampleOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateExample options. - */ -public class UpdateExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - private String newText; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - private String newText; - - private Builder(UpdateExampleOptions updateExampleOptions) { - workspaceId = updateExampleOptions.workspaceId; - intent = updateExampleOptions.intent; - text = updateExampleOptions.text; - newText = updateExampleOptions.newText; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a UpdateExampleOptions. - * - * @return the updateExampleOptions - */ - public UpdateExampleOptions build() { - return new UpdateExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the UpdateExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the UpdateExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the newText. - * - * @param newText the newText - * @return the UpdateExampleOptions builder - */ - public Builder newText(String newText) { - this.newText = newText; - return this; - } - } - - private UpdateExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - newText = builder.newText; - } - - /** - * New builder. - * - * @return a UpdateExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return 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. - * - It must be no longer than 1024 characters. - * - * @return the newText - */ - public String newText() { - return newText; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateIntentOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateIntentOptions.java deleted file mode 100644 index 006f3ec3a52..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateIntentOptions.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateIntent options. - */ -public class UpdateIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String newIntent; - private List newExamples; - private String newDescription; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String newIntent; - private List newExamples; - private String newDescription; - - private Builder(UpdateIntentOptions updateIntentOptions) { - workspaceId = updateIntentOptions.workspaceId; - intent = updateIntentOptions.intent; - newIntent = updateIntentOptions.newIntent; - newExamples = updateIntentOptions.newExamples; - newDescription = updateIntentOptions.newDescription; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a UpdateIntentOptions. - * - * @return the updateIntentOptions - */ - public UpdateIntentOptions build() { - return new UpdateIntentOptions(this); - } - - /** - * Adds an example to newExamples. - * - * @param example the new example - * @return the UpdateIntentOptions builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.newExamples == null) { - this.newExamples = new ArrayList(); - } - this.newExamples.add(example); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the UpdateIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the newIntent. - * - * @param newIntent the newIntent - * @return the UpdateIntentOptions builder - */ - public Builder newIntent(String newIntent) { - this.newIntent = newIntent; - return this; - } - - /** - * Set the newExamples. - * Existing newExamples will be replaced. - * - * @param newExamples the newExamples - * @return the UpdateIntentOptions builder - */ - public Builder newExamples(List newExamples) { - this.newExamples = newExamples; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateIntentOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - } - - private UpdateIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - newIntent = builder.newIntent; - newExamples = builder.newExamples; - newDescription = builder.newDescription; - } - - /** - * New builder. - * - * @return a UpdateIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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-`. - * - It must be no longer than 128 characters. - * - * @return the newIntent - */ - public String newIntent() { - return newIntent; - } - - /** - * Gets the newExamples. - * - * An array of user input examples for the intent. - * - * @return the newExamples - */ - public List newExamples() { - return newExamples; - } - - /** - * Gets the newDescription. - * - * The description of the intent. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateSynonymOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateSynonymOptions.java deleted file mode 100644 index 7138d30daa0..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateSynonymOptions.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateSynonym options. - */ -public class UpdateSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - private String newSynonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - private String newSynonym; - - private Builder(UpdateSynonymOptions updateSynonymOptions) { - workspaceId = updateSynonymOptions.workspaceId; - entity = updateSynonymOptions.entity; - value = updateSynonymOptions.value; - synonym = updateSynonymOptions.synonym; - newSynonym = updateSynonymOptions.newSynonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a UpdateSynonymOptions. - * - * @return the updateSynonymOptions - */ - public UpdateSynonymOptions build() { - return new UpdateSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the UpdateSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the UpdateSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - - /** - * Set the newSynonym. - * - * @param newSynonym the newSynonym - * @return the UpdateSynonymOptions builder - */ - public Builder newSynonym(String newSynonym) { - this.newSynonym = newSynonym; - return this; - } - } - - private UpdateSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - newSynonym = builder.newSynonym; - } - - /** - * New builder. - * - * @return a UpdateSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the newSynonym - */ - public String newSynonym() { - return newSynonym; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateValueOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateValueOptions.java deleted file mode 100644 index 83f6f11b408..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateValueOptions.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateValue options. - */ -public class UpdateValueOptions extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String workspaceId; - private String entity; - private String value; - private List newSynonyms; - private String valueType; - private Map newMetadata; - private List newPatterns; - private String newValue; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private List newSynonyms; - private String valueType; - private Map newMetadata; - private List newPatterns; - private String newValue; - - private Builder(UpdateValueOptions updateValueOptions) { - workspaceId = updateValueOptions.workspaceId; - entity = updateValueOptions.entity; - value = updateValueOptions.value; - newSynonyms = updateValueOptions.newSynonyms; - valueType = updateValueOptions.valueType; - newMetadata = updateValueOptions.newMetadata; - newPatterns = updateValueOptions.newPatterns; - newValue = updateValueOptions.newValue; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a UpdateValueOptions. - * - * @return the updateValueOptions - */ - public UpdateValueOptions build() { - return new UpdateValueOptions(this); - } - - /** - * Adds an synonym to newSynonyms. - * - * @param synonym the new synonym - * @return the UpdateValueOptions builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.newSynonyms == null) { - this.newSynonyms = new ArrayList(); - } - this.newSynonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to newPatterns. - * - * @param pattern the new pattern - * @return the UpdateValueOptions builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.newPatterns == null) { - this.newPatterns = new ArrayList(); - } - this.newPatterns.add(pattern); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the UpdateValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the newSynonyms. - * Existing newSynonyms will be replaced. - * - * @param newSynonyms the newSynonyms - * @return the UpdateValueOptions builder - */ - public Builder newSynonyms(List newSynonyms) { - this.newSynonyms = newSynonyms; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the UpdateValueOptions builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateValueOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newPatterns. - * Existing newPatterns will be replaced. - * - * @param newPatterns the newPatterns - * @return the UpdateValueOptions builder - */ - public Builder newPatterns(List newPatterns) { - this.newPatterns = newPatterns; - return this; - } - - /** - * Set the newValue. - * - * @param newValue the newValue - * @return the UpdateValueOptions builder - */ - public Builder newValue(String newValue) { - this.newValue = newValue; - return this; - } - } - - private UpdateValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - newSynonyms = builder.newSynonyms; - valueType = builder.valueType; - newMetadata = builder.newMetadata; - newPatterns = builder.newPatterns; - newValue = builder.newValue; - } - - /** - * New builder. - * - * @return a UpdateValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the newSynonyms. - * - * An array of synonyms for the entity value. You can provide either synonyms or patterns (as indicated by **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. - * - It must be no longer than 64 characters. - * - * @return the newSynonyms - */ - public List newSynonyms() { - return newSynonyms; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } - - /** - * Gets the newMetadata. - * - * Any metadata related to the entity value. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * Gets the newPatterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the newPatterns - */ - public List newPatterns() { - return newPatterns; - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the newValue - */ - public String newValue() { - return newValue; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateWorkspaceOptions.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateWorkspaceOptions.java deleted file mode 100644 index 83c17c339ef..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/UpdateWorkspaceOptions.java +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateWorkspace options. - */ -public class UpdateWorkspaceOptions extends GenericModel { - - private String workspaceId; - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - private Boolean append; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - private Boolean append; - - private Builder(UpdateWorkspaceOptions updateWorkspaceOptions) { - workspaceId = updateWorkspaceOptions.workspaceId; - name = updateWorkspaceOptions.name; - description = updateWorkspaceOptions.description; - language = updateWorkspaceOptions.language; - intents = updateWorkspaceOptions.intents; - entities = updateWorkspaceOptions.entities; - dialogNodes = updateWorkspaceOptions.dialogNodes; - counterexamples = updateWorkspaceOptions.counterexamples; - metadata = updateWorkspaceOptions.metadata; - learningOptOut = updateWorkspaceOptions.learningOptOut; - append = updateWorkspaceOptions.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 UpdateWorkspaceOptions. - * - * @return the updateWorkspaceOptions - */ - public UpdateWorkspaceOptions build() { - return new UpdateWorkspaceOptions(this); - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the UpdateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the UpdateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an dialogNode to dialogNodes. - * - * @param dialogNode the new dialogNode - * @return the UpdateWorkspaceOptions builder - */ - public Builder addDialogNode(CreateDialogNode dialogNode) { - Validator.notNull(dialogNode, "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); - } - this.dialogNodes.add(dialogNode); - return this; - } - - /** - * Adds an counterexample to counterexamples. - * - * @param counterexample the new counterexample - * @return the UpdateWorkspaceOptions builder - */ - public Builder addCounterexample(CreateCounterexample counterexample) { - Validator.notNull(counterexample, "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); - } - this.counterexamples.add(counterexample); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateWorkspaceOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateWorkspaceOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the UpdateWorkspaceOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. - * - * @param dialogNodes the dialogNodes - * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder - */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the UpdateWorkspaceOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the learningOptOut. - * - * @param learningOptOut the learningOptOut - * @return the UpdateWorkspaceOptions builder - */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; - return this; - } - - /** - * Set the append. - * - * @param append the append - * @return the UpdateWorkspaceOptions builder - */ - public Builder append(Boolean append) { - this.append = append; - return this; - } - } - - private UpdateWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - name = builder.name; - description = builder.description; - language = builder.language; - intents = builder.intents; - entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - metadata = builder.metadata; - learningOptOut = builder.learningOptOut; - append = builder.append; - } - - /** - * New builder. - * - * @return a UpdateWorkspaceOptions 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, and it must be - * no longer than 64 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, and it - * must be no longer than 128 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 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 defining the entities for the workspace. - * - * @return the entities - */ - public List entities() { - return entities; - } - - /** - * Gets the dialogNodes. - * - * An array of objects defining the nodes in the workspace dialog. - * - * @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 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 append. - * - * Whether the new data is to be appended to the existing data in the workspace. If **append**=`false`, elements - * included in the new data completely replace the corresponding existing elements, including all subelements. For - * example, if the new data 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/developer_cloud/assistant/v1/model/Value.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Value.java deleted file mode 100644 index 846e3916404..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Value.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Value. - */ -public class Value extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - @SerializedName("value") - private String valueText; - private Map metadata; - private Date created; - private Date updated; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Gets the valueText. - * - * The text of the entity value. - * - * @return the valueText - */ - public String getValueText() { - return valueText; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity value. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity value. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array containing any patterns for the entity value. - * - * @return the patterns - */ - public List getPatterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String getValueType() { - return valueType; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueCollection.java deleted file mode 100644 index 0a047f38e93..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ValueCollection. - */ -public class ValueCollection extends GenericModel { - - private List values; - private Pagination pagination; - - /** - * Gets the values. - * - * An array of entity values. - * - * @return the values - */ - public List getValues() { - return values; - } - - /** - * Gets the pagination. - * - * An object defining the pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueExport.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueExport.java deleted file mode 100644 index 4834c2f58d7..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/ValueExport.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ValueExport. - */ -public class ValueExport extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - @SerializedName("value") - private String valueText; - private Map metadata; - private Date created; - private Date updated; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Gets the valueText. - * - * The text of the entity value. - * - * @return the valueText - */ - public String getValueText() { - return valueText; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity value. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity value. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array containing any patterns for the entity value. - * - * @return the patterns - */ - public List getPatterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String getValueType() { - return valueType; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Workspace.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Workspace.java deleted file mode 100644 index e717adeee79..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/Workspace.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Workspace. - */ -public class Workspace extends GenericModel { - - private String name; - private String language; - private Date created; - private Date updated; - @SerializedName("workspace_id") - private String workspaceId; - private String description; - private Map metadata; - @SerializedName("learning_opt_out") - private Boolean learningOptOut; - - /** - * Gets the name. - * - * The name of the workspace. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the language. - * - * The language of the workspace. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the created. - * - * The timestamp for creation of the workspace. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the workspace. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the workspaceId. - * - * The workspace ID. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the description. - * - * The description of the workspace. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the workspace. - * - * @return the metadata - */ - public Map getMetadata() { - 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 isLearningOptOut() { - return learningOptOut; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceCollection.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceCollection.java deleted file mode 100644 index 8ff83e75d2e..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WorkspaceCollection. - */ -public class WorkspaceCollection extends GenericModel { - - private List workspaces; - private Pagination pagination; - - /** - * Gets the workspaces. - * - * An array of objects describing the workspaces associated with the service instance. - * - * @return the workspaces - */ - public List getWorkspaces() { - return workspaces; - } - - /** - * Gets the pagination. - * - * An object defining the pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceExport.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceExport.java deleted file mode 100644 index 939446e119a..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/model/WorkspaceExport.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WorkspaceExport. - */ -public class WorkspaceExport extends GenericModel { - - /** - * The current status of the workspace. - */ - 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"; - } - - private String name; - private String description; - private String language; - private Map metadata; - private Date created; - private Date updated; - @SerializedName("workspace_id") - private String workspaceId; - private String status; - @SerializedName("learning_opt_out") - private Boolean learningOptOut; - private List intents; - private List entities; - private List counterexamples; - @SerializedName("dialog_nodes") - private List dialogNodes; - - /** - * Gets the name. - * - * The name of the workspace. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the description. - * - * The description of the workspace. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the language. - * - * The language of the workspace. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the metadata. - * - * Any metadata that is required by the workspace. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the workspace. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the workspace. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the workspaceId. - * - * The workspace ID. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the status. - * - * The current status of the workspace. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the learningOptOut. - * - * Whether training data from the workspace 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 isLearningOptOut() { - return learningOptOut; - } - - /** - * Gets the intents. - * - * An array of intents. - * - * @return the intents - */ - public List getIntents() { - return intents; - } - - /** - * Gets the entities. - * - * An array of entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the counterexamples. - * - * An array of counterexamples. - * - * @return the counterexamples - */ - public List getCounterexamples() { - return counterexamples; - } - - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List getDialogNodes() { - return dialogNodes; - } -} diff --git a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/package-info.java b/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/package-info.java deleted file mode 100644 index 9c29917c7a7..00000000000 --- a/assistant/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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. - */ -package com.ibm.watson.developer_cloud.assistant.v1; 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 new file mode 100644 index 00000000000..ff6026d6bcf --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceIT.java @@ -0,0 +1,2130 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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.*; +import com.ibm.watson.common.RetryRunner; +import io.reactivex.Single; +import io.reactivex.functions.Consumer; +import io.reactivex.schedulers.Schedulers; +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; + +/** Integration test for the {@link Assistant}. */ +@RunWith(RetryRunner.class) +public class AssistantServiceIT extends AssistantServiceTest { + + private String exampleIntent; + private Assistant service; + 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 { + super.setUp(); + this.service = getService(); + this.workspaceId = getWorkspaceId(); + } + + /** 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(); + + 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 { + MessageInput input = new MessageInput(); + input.setText("Hi"); + MessageOptions options = new MessageOptions.Builder(workspaceId).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()); */ + } + + @Override + public void onFailure(Exception e) {} + }); + + // reactive + 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()); + } + }); + + 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")); + MessageOptions options = new MessageOptions.Builder(workspaceId).build(); + badService.message(options).execute().getResult(); + } + + /** Test start a conversation without message. */ + @Test() + public void testStartAConversationWithoutMessage() { + MessageOptions options = new MessageOptions.Builder(workspaceId).build(); + service.message(options).execute().getResult(); + } + + /** + * Test send messages. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testSendMessages() throws InterruptedException { + 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(); + + if (message.equals("yes")) { + 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(); + + assertMessageFromService(response); + assertNotNull(response.getOutput().getNodesVisitedDetails()); + context = new Context(); + for (String propName : response.getContext().getPropertyNames()) { + context.put(propName, response.getContext().get(propName)); + } + Thread.sleep(500); + } + } + + /** + * Assert {@link MessageResponse} from service. + * + * @param message the message from the {@link Assistant} + */ + private void assertMessageFromService(MessageResponse message) { + assertNotNull(message); + assertNotNull(message.getEntities()); + assertNotNull(message.getIntents()); + } + + /** Test message with null. */ + @Test(expected = IllegalArgumentException.class) + public void testMessageWithNull() { + service.message(null).execute().getResult(); + } + + /** Test to string. */ + @Test + public void testToString() { + assertNotNull(service.toString()); + } + + /** 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(); + Counterexample response = service.createCounterexample(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), counterExampleText); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); + service.deleteCounterexample(deleteOptions).execute(); + } + } + + /** 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(); + service.createCounterexample(createOptions).execute().getResult(); + + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); + service.deleteCounterexample(deleteOptions).execute(); + + try { + GetCounterexampleOptions getOptions = + new GetCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); + service.getCounterexample(getOptions).execute(); + fail("deleteCounterexample failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** 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(); + service.createCounterexample(createOptions).execute().getResult(); + + try { + GetCounterexampleOptions getOptions = + new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) + .includeAudit(true) + .build(); + Counterexample response = service.getCounterexample(getOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), counterExampleText); + assertNotNull(response.created()); + assertNotNull(response.updated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.created(), now)); + assertTrue(fuzzyAfter(response.created(), start)); + assertTrue(fuzzyBefore(response.updated(), now)); + assertTrue(fuzzyAfter(response.updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); + service.deleteCounterexample(deleteOptions).execute(); + } + } + + /** Test listCounterexamples. */ + @Test + public void testListCounterexamples() { + + 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(); + assertNotNull(ccResponse); + assertNotNull(ccResponse.getCounterexamples()); + assertNotNull(ccResponse.getPagination()); + assertNotNull(ccResponse.getPagination().getRefreshUrl()); + // nextUrl may be null + + Date start = new Date(); + + // Now add a counterexample and make sure we get it back + 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(); + assertNotNull(ccResponse2); + assertNotNull(ccResponse2.getCounterexamples()); + + List counterexamples = ccResponse2.getCounterexamples(); + assertTrue(counterexamples.size() > count); + + Counterexample exResponse = null; + for (Counterexample resp : counterexamples) { + if (resp.text().equals(counterExampleText)) { + exResponse = resp; + break; + } + } + + assertNotNull(exResponse); + Date now = new Date(); + assertTrue(fuzzyBefore(exResponse.created(), now)); + assertTrue(fuzzyAfter(exResponse.created(), start)); + assertTrue(fuzzyBefore(exResponse.updated(), now)); + assertTrue(fuzzyAfter(exResponse.updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + try { + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText).build(); + service.deleteCounterexample(deleteOptions).execute(); + } catch (NotFoundException ex) { + // Okay + } + } + } + + /** Test listCounterexamples with paging. */ + @Test + public void testListCounterexamplesWithPaging() { + + String counterExampleText1 = "alpha" + UUID.randomUUID().toString(); // gotta be unique + String counterExampleText2 = "zeta" + UUID.randomUUID().toString(); // gotta be unique + + // Add two counterexamples + CreateCounterexampleOptions createOptions = + new CreateCounterexampleOptions.Builder(workspaceId, counterExampleText1).build(); + service.createCounterexample(createOptions).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(); + assertNotNull(response); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + boolean found1 = false; + boolean found2 = false; + while (true) { + assertNotNull(response.getCounterexamples()); + assertTrue(response.getCounterexamples().size() == 1); + found1 |= response.getCounterexamples().get(0).text().equals(counterExampleText1); + found2 |= response.getCounterexamples().get(0).text().equals(counterExampleText2); + assertTrue(found1 || !found2); // verify sort + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service + .listCounterexamples(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); + } + + assertTrue(found1 && found2); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteCounterexampleOptions deleteOptions = + new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText1).build(); + service.deleteCounterexample(deleteOptions).execute(); + service + .deleteCounterexample(deleteOptions.newBuilder().text(counterExampleText2).build()) + .execute(); + } + } + + /** 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(); + service.createCounterexample(createOptions).execute().getResult(); + + try { + UpdateCounterexampleOptions updateOptions = + new UpdateCounterexampleOptions.Builder(workspaceId, counterExampleText) + .newText(counterExampleText2) + .build(); + Counterexample response = service.updateCounterexample(updateOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), counterExampleText2); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + 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(); + service.createIntent(createOptions).execute().getResult(); + } catch (Exception ex) { + // Exception is okay if is for Unique Violation + assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); + } + } + + /** 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(); + Example response = service.createExample(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), exampleText); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + service.deleteExample(deleteOptions).execute(); + } + } + + /** 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(); + service.createExample(createOptions).execute().getResult(); + + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + service.deleteExample(deleteOptions).execute(); + + try { + GetExampleOptions getOptions = + new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + service.getExample(getOptions).execute().getResult(); + fail("deleteCounterexample failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getExample. */ + @Test + public void testGetExample() { + + createExampleIntent(); + + Date start = new Date(); + + String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique + 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(); + Example response = service.getExample(getOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), exampleText); + assertNotNull(response.created()); + assertNotNull(response.updated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.created(), now)); + assertTrue(fuzzyAfter(response.created(), start)); + assertTrue(fuzzyBefore(response.updated(), now)); + assertTrue(fuzzyAfter(response.updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + service.deleteExample(deleteOptions).execute(); + } + } + + /** Test listExamples. */ + @Test + public void testListExamples() { + + createExampleIntent(); + + String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique + + try { + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, exampleIntent).includeAudit(true).build(); + ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); + assertNotNull(ecResponse); + assertNotNull(ecResponse.getExamples()); + assertNotNull(ecResponse.getPagination()); + assertNotNull(ecResponse.getPagination().getRefreshUrl()); + // nextUrl may be null + + Date start = new Date(); + + // Now add an example and make sure we get it back + 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(); + assertNotNull(ecResponse2); + assertNotNull(ecResponse2.getExamples()); + + List examples = ecResponse2.getExamples(); + assertTrue(examples.size() > count); + + Example exResponse = null; + for (Example resp : examples) { + if (resp.text().equals(exampleText)) { + exResponse = resp; + break; + } + } + + assertNotNull(exResponse); + Date now = new Date(); + assertTrue(fuzzyBefore(exResponse.created(), now)); + assertTrue(fuzzyAfter(exResponse.created(), start)); + assertTrue(fuzzyBefore(exResponse.updated(), now)); + assertTrue(fuzzyAfter(exResponse.updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); + service.deleteExample(deleteOptions).execute(); + } + } + + /** Test listExamples with paging. */ + @Test + public void testListExamplesWithPaging() { + + createExampleIntent(); + + 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(); + service.createExample(createOptions).execute().getResult(); + service + .createExample(createOptions.newBuilder().text(exampleText2).build()) + .execute() + .getResult(); + + try { + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, exampleIntent) + .pageLimit(1L) + .sort("-text") + .build(); + ExampleCollection response = service.listExamples(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getExamples()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + boolean found1 = false; + boolean found2 = false; + while (true) { + assertNotNull(response.getExamples()); + assertTrue(response.getExamples().size() == 1); + found1 |= response.getExamples().get(0).text().equals(exampleText1); + found2 |= response.getExamples().get(0).text().equals(exampleText2); + assertTrue(found2 || !found1); // verify sort + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service + .listExamples(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); + } + assertTrue(found1 && found2); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText1).build(); + service.deleteExample(deleteOptions).execute(); + service.deleteExample(deleteOptions.newBuilder().text(exampleText2).build()).execute(); + } + } + + /** Test updateExample. */ + @Test + public void testUpdateExample() { + + createExampleIntent(); + + 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(); + service.createExample(createOptions).execute().getResult(); + + try { + UpdateExampleOptions updateOptions = + new UpdateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) + .newText(exampleText2) + .build(); + Example response = service.updateExample(updateOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.text()); + assertEquals(response.text(), exampleText2); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteExampleOptions deleteOptions = + new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText2).build(); + service.deleteExample(deleteOptions).execute(); + } + } + + /** Test createIntent. */ + @Test + public void testCreateIntent() { + + 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()); + + Date start = new Date(); + + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); + Intent response = service.createIntent(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.getIntent()); + assertEquals(response.getIntent(), intentName); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), intentDescription); + + Date now = new Date(); + + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, intentName).includeAudit(true).build(); + ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); + assertNotNull(ecResponse); + assertNotNull(ecResponse.getExamples()); + + List examples = ecResponse.getExamples(); + assertTrue(examples.size() == 1); + assertEquals(examples.get(0).text(), intentExample); + assertTrue(fuzzyBefore(examples.get(0).created(), now)); + assertTrue(fuzzyAfter(examples.get(0).created(), start)); + assertTrue(fuzzyBefore(examples.get(0).updated(), now)); + assertTrue(fuzzyAfter(examples.get(0).updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + service.deleteIntent(deleteOptions).execute(); + } + } + + /** Test deleteIntent. */ + @Test + public void testDeleteIntent() { + + String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique + + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName).build(); + service.createIntent(createOptions).execute().getResult(); + + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + service.deleteIntent(deleteOptions).execute(); + + try { + GetIntentOptions getOptions = new GetIntentOptions.Builder(workspaceId, intentName).build(); + service.getIntent(getOptions).execute(); + fail("deleteIntent failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getIntent. */ + @Test + public void testGetIntent() { + + 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()); + + Date start = new Date(); + + 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(); + Intent response = service.getIntent(getOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getIntent()); + assertEquals(response.getIntent(), intentName); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), intentDescription); + assertNotNull(response.getExamples()); + assertNotNull(response.getCreated()); + assertNotNull(response.getUpdated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.getCreated(), now)); + assertTrue(fuzzyAfter(response.getCreated(), start)); + assertTrue(fuzzyBefore(response.getUpdated(), now)); + assertTrue(fuzzyAfter(response.getUpdated(), start)); + + List examples = response.getExamples(); + assertTrue(examples.size() == 1); + assertEquals(examples.get(0).text(), intentExample); + assertTrue(fuzzyBefore(examples.get(0).created(), now)); + assertTrue(fuzzyAfter(examples.get(0).created(), start)); + assertTrue(fuzzyBefore(examples.get(0).updated(), now)); + assertTrue(fuzzyAfter(examples.get(0).updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + service.deleteIntent(deleteOptions).execute(); + } + } + + /** 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(); + IntentCollection response = service.listIntents(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getIntents()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + + // Now add an intent and make sure we get it back + String intentDescription = "Description of " + intentName; + String intentExample = "Example of " + intentName; + List intentExamples = new ArrayList<>(); + intentExamples.add(new Example.Builder().text(intentExample).build()); + + Date start = new Date(); + + 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(); + IntentCollection response2 = service.listIntents(listOptions2).execute().getResult(); + assertNotNull(response2); + assertNotNull(response2.getIntents()); + + List intents = response2.getIntents(); + assertTrue(intents.size() > count); + + Intent ieResponse = null; + for (Intent resp : intents) { + if (resp.getIntent().equals(intentName)) { + ieResponse = resp; + break; + } + } + + assertNotNull(ieResponse); + assertNotNull(ieResponse.getDescription()); + assertEquals(ieResponse.getDescription(), intentDescription); + assertNotNull(ieResponse.getExamples()); + assertTrue(ieResponse.getExamples().size() == 1); + assertEquals(ieResponse.getExamples().get(0).text(), intentExample); + + Date now = new Date(); + assertTrue(fuzzyBefore(ieResponse.getCreated(), now)); + assertTrue(fuzzyAfter(ieResponse.getCreated(), start)); + assertTrue(fuzzyBefore(ieResponse.getUpdated(), now)); + assertTrue(fuzzyAfter(ieResponse.getUpdated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + service.deleteIntent(deleteOptions).execute(); + } + } + + /** 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(); + service.createIntent(createOptions).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(); + IntentCollection response = service.listIntents(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getIntents()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + boolean found1 = false; + boolean found2 = false; + while (true) { + assertNotNull(response.getIntents()); + assertTrue(response.getIntents().size() == 1); + found1 |= response.getIntents().get(0).getIntent().equals(intentName1); + found2 |= response.getIntents().get(0).getIntent().equals(intentName2); + assertTrue(found1 || !found2); // verify sort + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service + .listIntents(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); + } + assertTrue(found1 && found2); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName1).build(); + service.deleteIntent(deleteOptions).execute(); + service.deleteIntent(deleteOptions.newBuilder().intent(intentName2).build()).execute(); + } + } + + /** Test updateIntent. */ + @Test + public void testUpdateIntent() { + + 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()); + + CreateIntentOptions createOptions = + new CreateIntentOptions.Builder(workspaceId, intentName) + .description(intentDescription) + .examples(intentExamples) + .build(); + service.createIntent(createOptions).execute().getResult(); + + try { + String intentDescription2 = "Updated description of " + intentName; + String intentExample2 = "Updated Example of " + intentName; + 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(); + Intent response = service.updateIntent(updateOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getIntent()); + assertEquals(response.getIntent(), intentName); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), intentDescription2); + + Date now = new Date(); + + ListExamplesOptions listOptions = + new ListExamplesOptions.Builder(workspaceId, intentName).includeAudit(true).build(); + ExampleCollection ecResponse = service.listExamples(listOptions).execute().getResult(); + assertNotNull(ecResponse); + assertNotNull(ecResponse.getExamples()); + + List examples = ecResponse.getExamples(); + assertTrue(examples.size() == 1); + assertEquals(examples.get(0).text(), intentExample2); + assertTrue(fuzzyBefore(examples.get(0).created(), now)); + assertTrue(fuzzyAfter(examples.get(0).created(), start)); + assertTrue(fuzzyBefore(examples.get(0).updated(), now)); + assertTrue(fuzzyAfter(examples.get(0).updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteIntentOptions deleteOptions = + new DeleteIntentOptions.Builder(workspaceId, intentName).build(); + service.deleteIntent(deleteOptions).execute(); + } + } + + /** Test createWorkspace. */ + @Test + public void testCreateWorkspace() { + + 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(); + + 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 { + Workspace response = service.createWorkspace(createOptions).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.getWorkspaceId()); + workspaceId = response.getWorkspaceId(); + assertNotNull(response.getName()); + assertEquals(response.getName(), workspaceName); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), workspaceDescription); + assertNotNull(response.getLanguage()); + assertEquals(response.getLanguage(), workspaceLanguage); + + // metadata + assertNotNull(response.getMetadata()); + assertNotNull(response.getMetadata().get("key")); + assertEquals(response.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()); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + if (workspaceId != null) { + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); + service.deleteWorkspace(deleteOptions).execute(); + } + } + } + + /** Test deleteWorkspace. */ + @Test + public void testDeleteWorkspace() { + + CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().build(); + + String workspaceId = null; + try { + Workspace response = service.createWorkspace(createOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getWorkspaceId()); + workspaceId = response.getWorkspaceId(); + + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); + service.deleteWorkspace(deleteOptions).execute(); + + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); + service.getWorkspace(getOptions).execute().getResult(); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + workspaceId = null; + } finally { + // Clean up + if (workspaceId != null) { + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); + service.deleteWorkspace(deleteOptions).execute(); + } + } + } + + /** Test getWorkspace. */ + @Test + public void testGetWorkspace() { + + GetWorkspaceOptions getOptions = + new GetWorkspaceOptions.Builder(workspaceId).export(false).includeAudit(true).build(); + Workspace response = service.getWorkspace(getOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.getWorkspaceId()); + assertEquals(response.getWorkspaceId(), workspaceId); + assertNotNull(response.getName()); + assertNotNull(response.getLanguage()); + + Date now = new Date(); + + assertNotNull(response.getCreated()); + assertNotNull(response.getUpdated()); + assertTrue(fuzzyBefore(response.getCreated(), now)); + assertTrue(fuzzyBefore(response.getUpdated(), now)); + + // metadata, intents, entities, dialogNodes, and counterexamples could be null + + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + /** 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); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + + Workspace wResponse = null; + for (Workspace resp : response.getWorkspaces()) { + if (resp.getWorkspaceId().equals(workspaceId)) { + wResponse = resp; + break; + } + } + + assertNotNull(wResponse); + assertNotNull(wResponse.getName()); + } + + /** Test listWorkspaces with paging. */ + @Test + public void testListWorkspacesWithPaging() { + + ListWorkspacesOptions listOptions = + new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build(); + WorkspaceCollection response = service.listWorkspaces(listOptions).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + + boolean found = false; + while (true) { + assertNotNull(response.getWorkspaces()); + assertTrue(response.getWorkspaces().size() == 1); + found |= response.getWorkspaces().get(0).getWorkspaceId().equals(workspaceId); + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service + .listWorkspaces(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); + } + + assertTrue(found); + } + + /** Test updateWorkspace. */ + @Test + public void testUpdateWorkspace() { + + String workspaceName = "testUpdateWorkspace"; + String workspaceDescription = "Description for testUpdateWorkspace"; + + // intents + CreateIntent intent0 = new CreateIntent.Builder("Hello").build(); + CreateIntent intent1 = new CreateIntent.Builder("Goodbye").build(); + + // entities + CreateEntity entity0 = new CreateEntity.Builder("animal").build(); + CreateEntity entity1 = new CreateEntity.Builder("beverage").build(); + + // counterexamples + 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(); + + String workspaceId = null; + try { + Workspace createResponse = service.createWorkspace(createOptions).execute().getResult(); + + assertNotNull(createResponse); + assertNotNull(createResponse.getWorkspaceId()); + workspaceId = createResponse.getWorkspaceId(); + + String counterExampleText = "What are you drinking"; + Counterexample counterexample2 = new Counterexample.Builder(counterExampleText).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(); + + 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(); + Counterexample eResponse = service.getCounterexample(getOptions).execute().getResult(); + assertNotNull(eResponse); + assertNotNull(eResponse.text()); + assertEquals(eResponse.text(), counterExampleText); + + // webhooks + assertNotNull(updateResponse.getWebhooks()); + 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()); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + if (workspaceId != null) { + DeleteWorkspaceOptions deleteOptions = + new DeleteWorkspaceOptions.Builder(workspaceId).build(); + service.deleteWorkspace(deleteOptions).execute(); + } + } + } + + /** 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 { + ListLogsOptions listOptions = new ListLogsOptions.Builder().workspaceId(workspaceId).build(); + LogCollection response = service.listLogs(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getLogs()); + assertNotNull(response.getPagination()); + // Empirically -- no refresh_url in pagination of listLogs + // assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + if (response.getPagination().getNextUrl() == null) { + assertNull(response.getPagination().getNextCursor()); + } else { + assertNotNull(response.getPagination().getNextCursor()); + } + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + /** Test listLogs with pagination. */ + @Test + @Ignore("To be run locally until we fix the Rate limitation issue") + public void testListLogsWithPaging() { + + try { + ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId); + listOptionsBuilder.sort("-request_timestamp"); + listOptionsBuilder.filter("request.intents:intent:off_topic"); + listOptionsBuilder.pageLimit(1L); + + LogCollection response = service.listLogs(listOptionsBuilder.build()).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getLogs()); + assertNotNull(response.getPagination()); + // Empirically -- no refresh_url in pagination of listLogs + // assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + assertTrue(response.getLogs().size() == 1); + Log logEntry1 = response.getLogs().get(0); + + String cursor = response.getPagination().getNextCursor(); + response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); + + assertNotNull(response.getLogs()); + assertTrue(response.getLogs().size() == 1); + + Log logEntry2 = response.getLogs().get(0); + + Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp()); + Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp()); + + assertTrue(requestDate2.before(requestDate1)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + /** 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(); + DialogNode response = service.createDialogNode(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.dialogNode()); + assertEquals(response.dialogNode(), dialogNodeName); + assertNotNull(response.description()); + assertEquals(response.description(), dialogNodeDescription); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + + /** Test deleteDialogNode. */ + @Test + public void testDeleteDialogNode() { + String dialogNodeName = "Test" + UUID.randomUUID().toString(); // gotta be unique + + CreateDialogNodeOptions createOptions = + new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.createDialogNode(createOptions).execute().getResult(); + + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.deleteDialogNode(deleteOptions).execute(); + + try { + GetDialogNodeOptions getOptions = + new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.getDialogNode(getOptions).execute(); + fail("deleteDialogNode failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getDialogNode. */ + @Test + public void testGetDialogNode() { + String dialogNodeName = "Test" + UUID.randomUUID().toString(); + String dialogNodeDescription = "Description of " + dialogNodeName; + + Date start = new Date(); + + 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(); + DialogNode response = service.getDialogNode(getOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.dialogNode()); + assertEquals(response.dialogNode(), dialogNodeName); + assertNotNull(response.description()); + assertEquals(response.description(), dialogNodeDescription); + assertNotNull(response.created()); + assertNotNull(response.updated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.created(), now)); + assertTrue(fuzzyAfter(response.created(), start)); + assertTrue(fuzzyBefore(response.updated(), now)); + assertTrue(fuzzyAfter(response.updated(), start)); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + + /** Test listDialogNodes. */ + @Test + public void testListDialogNodes() { + String dialogNodeName = "Test" + UUID.randomUUID().toString(); + + try { + ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder(workspaceId).build(); + DialogNodeCollection response = service.listDialogNodes(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getDialogNodes()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + + // Now add a dialog node and make sure we get it back + String dialogNodeDescription = "Description of " + dialogNodeName; + + Date start = new Date(); + + 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(); + DialogNodeCollection response2 = service.listDialogNodes(listOptions2).execute().getResult(); + assertNotNull(response2); + assertNotNull(response2.getDialogNodes()); + + List dialogNodes = response2.getDialogNodes(); + assertTrue(dialogNodes.size() > count); + + DialogNode dialogResponse = null; + for (DialogNode node : dialogNodes) { + if (node.dialogNode().equals(dialogNodeName)) { + dialogResponse = node; + break; + } + } + + assertNotNull(dialogResponse); + assertNotNull(dialogResponse.description()); + assertEquals(dialogResponse.description(), dialogNodeDescription); + + Date now = new Date(); + assertTrue(fuzzyBefore(dialogResponse.created(), now)); + assertTrue(fuzzyAfter(dialogResponse.created(), start)); + assertTrue(fuzzyBefore(dialogResponse.updated(), now)); + assertTrue(fuzzyAfter(dialogResponse.updated(), start)); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + + /** 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(); + service.createDialogNode(createOptions).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(); + DialogNodeCollection response = service.listDialogNodes(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getDialogNodes()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + boolean found1 = false, found2 = false; + while (true) { + assertNotNull(response.getDialogNodes()); + assertTrue(response.getDialogNodes().size() == 1); + found1 |= response.getDialogNodes().get(0).dialogNode().equals(dialogNodeName1); + found2 |= response.getDialogNodes().get(0).dialogNode().equals(dialogNodeName2); + assertTrue(found1 || !found2); // verify sort + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + 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(); + service.deleteDialogNode(deleteOptions).execute(); + service + .deleteDialogNode(deleteOptions.newBuilder().dialogNode(dialogNodeName2).build()) + .execute(); + } + } + + /** 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(); + 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(); + DialogNode response = service.updateDialogNode(updateOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.dialogNode()); + assertEquals(response.dialogNode(), dialogNodeName2); + assertNotNull(response.description()); + assertEquals(response.description(), dialogNodeDescription2); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteDialogNodeOptions deleteOptions = + new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName2).build(); + service.deleteDialogNode(deleteOptions).execute(); + } + } + + /** 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(); + service.deleteUserData(deleteOptions).execute(); + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + /** Test list mentions. */ + @Test + public void testListMentions() { + String entity = "beverage"; + + 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 new file mode 100644 index 00000000000..f9b281f612a --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantServiceTest.java @@ -0,0 +1,102 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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; + +/** 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.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + String apiKey = System.getenv("ASSISTANT_APIKEY"); + workspaceId = System.getenv("ASSISTANT_WORKSPACE_ID"); + String serviceUrl = System.getenv("ASSISTANT_URL"); + + 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(serviceUrl); + service.setDefaultHeaders(getDefaultHeaders()); + } + + private long tolerance = 2000; // 2 secs in ms + + /** + * 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. + * + * @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 new file mode 100644 index 00000000000..19dc8438dc4 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/AssistantTest.java @@ -0,0 +1,4311 @@ +/* + * (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.assistant.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.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.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); + } + + // Test the updateDialogNodeNullable operation with null options model parameter + @Test(expectedExceptions = IllegalArgumentException.class) + public void testUpdateDialogNodeNullableNoOptions() throws Throwable { + // construct the service + constructClientService(); + + 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(); + } + + // 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"); + // 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(); + + 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 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(); + } + + // 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"); + // 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 new file mode 100644 index 00000000000..1bd5b5a0463 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/EntitiesIT.java @@ -0,0 +1,361 @@ +/* + * (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; + +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; +import com.ibm.watson.assistant.v1.model.DeleteEntityOptions; +import com.ibm.watson.assistant.v1.model.Entity; +import com.ibm.watson.assistant.v1.model.EntityCollection; +import com.ibm.watson.assistant.v1.model.GetEntityOptions; +import com.ibm.watson.assistant.v1.model.ListEntitiesOptions; +import com.ibm.watson.assistant.v1.model.UpdateEntityOptions; +import com.ibm.watson.assistant.v1.model.Value; +import com.ibm.watson.common.RetryRunner; +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; + +/** 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 { + super.setUp(); + this.service = getService(); + this.workspaceId = getWorkspaceId(); + } + + /** Test createEntity. */ + @Test + public void testCreateEntity() { + + String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique + String entityDescription = "Description of " + entity; + Map entityMetadata = new HashMap(); + String metadataValue = "value for " + entity; + entityMetadata.put("key", metadataValue); + + CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); + optionsBuilder.workspaceId(workspaceId); + optionsBuilder.entity(entity); + optionsBuilder.description(entityDescription); + optionsBuilder.metadata(entityMetadata); + optionsBuilder.fuzzyMatch(true); // default is false + Entity response = service.createEntity(optionsBuilder.build()).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.getEntity()); + assertEquals(response.getEntity(), entity); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), entityDescription); + + assertNotNull(response.getMetadata()); + assertNotNull(response.getMetadata().get("key")); + assertEquals(response.getMetadata().get("key"), metadataValue); + + assertNotNull(response.isFuzzyMatch()); + assertTrue(response.isFuzzyMatch()); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + } + } + + /** Test deleteEntity. */ + @Test + public void testDeleteEntity() { + + String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique + + CreateEntityOptions options = new CreateEntityOptions.Builder(workspaceId, entity).build(); + Entity response = service.createEntity(options).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.getEntity()); + assertEquals(response.getEntity(), entity); + assertNull(response.getDescription()); + assertNull(response.getMetadata()); + assertTrue(response.isFuzzyMatch() == null || response.isFuzzyMatch().equals(Boolean.FALSE)); + } catch (Exception ex) { + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + fail(ex.getMessage()); + } + + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + + try { + GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity).build(); + service.getEntity(getOptions).execute().getResult(); + fail("deleteEntity failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getEntity. */ + @Test + public void testGetEntity() { + + String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique + String entityDescription = "Description of " + entity; + String entityValue = "Value of " + entity; + List entityValues = new ArrayList(); + entityValues.add(new CreateValue.Builder().value(entityValue).build()); + + CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); + optionsBuilder.workspaceId(workspaceId); + optionsBuilder.entity(entity); + optionsBuilder.description(entityDescription); + optionsBuilder.values(entityValues); + service.createEntity(optionsBuilder.build()).execute().getResult(); + + Date start = new Date(); + + try { + GetEntityOptions getOptions = + new GetEntityOptions.Builder(workspaceId, entity).export(true).includeAudit(true).build(); + Entity response = service.getEntity(getOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getEntity()); + assertEquals(response.getEntity(), entity); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), entityDescription); + assertNotNull(response.getValues()); + assertNotNull(response.getCreated()); + assertNotNull(response.getUpdated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.getCreated(), now)); + assertTrue(fuzzyAfter(response.getCreated(), start)); + assertTrue(fuzzyBefore(response.getUpdated(), now)); + assertTrue(fuzzyAfter(response.getUpdated(), start)); + + List values = response.getValues(); + assertTrue(values.size() == 1); + assertEquals(values.get(0).value(), entityValue); + assertTrue(fuzzyBefore(values.get(0).created(), now)); + assertTrue(fuzzyAfter(values.get(0).created(), start)); + assertTrue(fuzzyBefore(values.get(0).updated(), now)); + assertTrue(fuzzyAfter(values.get(0).updated(), start)); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + } + } + + /** Test listEntities. */ + @Test + @Ignore("To be run locally until we fix the Rate limitation issue") + public void testListEntities() { + + String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique + + try { + ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId).build(); + EntityCollection response = service.listEntities(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getEntities()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + + // 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(); + service.createEntity(options).execute().getResult(); + + ListEntitiesOptions listOptions2 = + listOptions.newBuilder().sort("-updated").pageLimit(5L).export(true).build(); + EntityCollection response2 = service.listEntities(listOptions2).execute().getResult(); + assertNotNull(response2); + assertNotNull(response2.getEntities()); + + List entities = response2.getEntities(); + Entity ieResponse = null; + for (Entity resp : entities) { + if (resp.getEntity().equals(entity)) { + ieResponse = resp; + break; + } + } + + assertNotNull(ieResponse); + assertNotNull(ieResponse.getDescription()); + assertEquals(ieResponse.getDescription(), entityDescription); + assertNotNull(ieResponse.getValues()); + assertTrue(ieResponse.getValues().size() == 1); + assertTrue(ieResponse.getValues().get(0).value().equals(entityValue)); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + } + } + + /** Test listEntities with pagination. */ + @Test + @Ignore("To be run locally until we fix the Rate limitation issue") + 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(); + 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(); + EntityCollection response = service.listEntities(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getEntities()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + assertTrue(!response.getEntities().get(0).getEntity().equals(entity1)); + + Entity ieResponse = null; + while (response.getPagination().getNextCursor() != null) { + assertNotNull(response.getEntities()); + assertTrue(response.getEntities().size() == 1); + if (response.getEntities().get(0).getEntity().equals(entity1)) { + ieResponse = response.getEntities().get(0); + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service + .listEntities(listOptions.newBuilder().cursor(cursor).build()) + .execute() + .getResult(); + } + + assertNotNull(ieResponse); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteEntityOptions deleteOptions = + new DeleteEntityOptions.Builder(workspaceId, entity1).build(); + service.deleteEntity(deleteOptions).execute().getResult(); + service + .deleteEntity(deleteOptions.newBuilder().entity(entity2).build()) + .execute() + .getResult(); + } + } + + /** Test updateEntity. */ + @Test + public void testUpdateEntity() { + + String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique + String entity2 = "Goodbye" + UUID.randomUUID().toString(); // gotta be unique + String entityDescription = "Description of " + entity; + + CreateEntityOptions.Builder createOptionsBuilder = new CreateEntityOptions.Builder(); + createOptionsBuilder.workspaceId(workspaceId); + createOptionsBuilder.entity(entity); + createOptionsBuilder.description(entityDescription); + service.createEntity(createOptionsBuilder.build()).execute().getResult(); + + try { + String entityDescription2 = "Description of " + entity2; + String entityValue2 = "Value of " + entity2; + Map entityMetadata2 = new HashMap(); + String metadataValue2 = "value for " + entity2; + entityMetadata2.put("key", metadataValue2); + + UpdateEntityOptions.Builder updateOptionsBuilder = + new UpdateEntityOptions.Builder(workspaceId, entity); + updateOptionsBuilder.newEntity(entity2); + updateOptionsBuilder.newDescription(entityDescription2); + updateOptionsBuilder.addValue(new CreateValue.Builder().value(entityValue2).build()); + updateOptionsBuilder.newMetadata(entityMetadata2); + updateOptionsBuilder.newFuzzyMatch(true); + + Entity response = service.updateEntity(updateOptionsBuilder.build()).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getEntity()); + assertEquals(response.getEntity(), entity2); + assertNotNull(response.getDescription()); + assertEquals(response.getDescription(), entityDescription2); + + assertNotNull(response.getMetadata()); + assertNotNull(response.getMetadata().get("key")); + assertEquals(response.getMetadata().get("key"), metadataValue2); + + assertNotNull(response.isFuzzyMatch()); + assertTrue(response.isFuzzyMatch()); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + 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 new file mode 100644 index 00000000000..5de2b4487dc --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/SynonymsIT.java @@ -0,0 +1,462 @@ +/* + * (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; + +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; +import com.ibm.watson.assistant.v1.model.CreateValueOptions; +import com.ibm.watson.assistant.v1.model.DeleteSynonymOptions; +import com.ibm.watson.assistant.v1.model.GetSynonymOptions; +import com.ibm.watson.assistant.v1.model.ListSynonymsOptions; +import com.ibm.watson.assistant.v1.model.Synonym; +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; + +/** 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 { + super.setUp(); + this.service = getService(); + this.workspaceId = getWorkspaceId(); + } + + /** Test createSynonym. */ + @Test + public void testCreateSynonym() { + + String entity = "beverage"; + String entityValue = "orange juice"; + String synonym = "OJ"; + + try { + 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")); + } + + try { + 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(); + Synonym response = service.createSynonym(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.synonym()); + assertEquals(response.synonym(), synonym); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); + service.deleteSynonym(deleteOptions).execute().getResult(); + } + } + + /** Test deleteSynonym. */ + @Test + public void testDeleteSynonym() { + + String entity = "beverage"; + String entityValue = "orange juice"; + String synonym = "OJ"; + + try { + 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")); + } + + try { + 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(); + Synonym response = service.createSynonym(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.synonym()); + assertEquals(response.synonym(), synonym); + } catch (Exception ex) { + 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(); + service.deleteSynonym(deleteOptions).execute().getResult(); + + try { + GetSynonymOptions getOptions = + new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); + service.getSynonym(getOptions).execute().getResult(); + fail("deleteSynonym failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getSynonym. */ + @Test + public void testGetSynonym() { + + String entity = "beverage"; + String entityValue = "orange juice"; + String synonym = "OJ"; + + try { + 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")); + } + + try { + 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")); + } + + Date start = new Date(); + + 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(); + Synonym response = service.getSynonym(getOptions).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.synonym()); + assertEquals(response.synonym(), synonym); + assertNotNull(response.created()); + assertNotNull(response.updated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.created(), now)); + assertTrue(fuzzyAfter(response.created(), start)); + assertTrue(fuzzyBefore(response.updated(), now)); + assertTrue(fuzzyAfter(response.updated(), start)); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); + service.deleteSynonym(deleteOptions).execute().getResult(); + } + } + + /** Test listSynonyms. */ + @Test + public void testListSynonyms() { + + String entity = "beverage"; + String entityValue = "coffee"; + String synonym1 = "java"; + String synonym2 = "joe"; + + try { + 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")); + } + + try { + 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")); + } + + try { + CreateSynonymOptions createOptions = + new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); + service.createSynonym(createOptions).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(); + final SynonymCollection response = service.listSynonyms(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getSynonyms()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + if (response.getPagination().getNextUrl() == null) { + assertNull(response.getPagination().getNextCursor()); + } else { + assertNotNull(response.getPagination().getNextCursor()); + } + + assertTrue(response.getSynonyms().size() >= 2); + + // 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); + boolean found1 = false; + boolean found2 = false; + for (Synonym synonymResponse : response.getSynonyms()) { + found1 |= synonymResponse.synonym().equals(synonym1); + found2 |= synonymResponse.synonym().equals(synonym2); + } + assertTrue(found1 && found2); + } + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); + service.deleteSynonym(deleteOptions).execute().getResult(); + service + .deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); + } + } + + /** Test listSynonyms with pagination. */ + @Test + public void testListSynonymsWithPaging() { + + String entity = "beverage"; + String entityValue = "coffee"; + String synonym1 = "java"; + String synonym2 = "joe"; + + try { + 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")); + } + + try { + 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(); + try { + service.createSynonym(createOptions).execute().getResult(); + } catch (Exception ex) { + // Exception is okay if is for Unique Violation + assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); + } + try { + 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); + listOptionsBuilder.sort("modified"); + listOptionsBuilder.pageLimit(1L); + + 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; + boolean found2 = false; + + while (true) { + assertNotNull(response.getSynonyms()); + assertTrue(response.getSynonyms().size() == 1); + found1 |= response.getSynonyms().get(0).synonym().equals(synonym1); + found2 |= response.getSynonyms().get(0).synonym().equals(synonym2); + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service.listSynonyms(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); + } + + assertTrue(found1 && found2); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteSynonymOptions deleteOptions = + new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1).build(); + service.deleteSynonym(deleteOptions).execute().getResult(); + service + .deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()) + .execute() + .getResult(); + } + } + + /** Test updateSynonym. */ + @Test + public void testUpdateSynonym() { + + String entity = "beverage"; + String entityValue = "coffee"; + String synonym1 = "joe"; + String synonym2 = "mud"; + + try { + 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")); + } + + try { + 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")); + } + + try { + 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(); + Synonym response = service.updateSynonym(updateOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.synonym()); + assertEquals(response.synonym(), synonym2); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + 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 new file mode 100644 index 00000000000..32b5bbb1145 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v1/ValuesIT.java @@ -0,0 +1,463 @@ +/* + * (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; + +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; +import com.ibm.watson.assistant.v1.model.DeleteValueOptions; +import com.ibm.watson.assistant.v1.model.GetValueOptions; +import com.ibm.watson.assistant.v1.model.ListValuesOptions; +import com.ibm.watson.assistant.v1.model.UpdateValueOptions; +import com.ibm.watson.assistant.v1.model.Value; +import com.ibm.watson.assistant.v1.model.ValueCollection; +import com.ibm.watson.common.RetryRunner; +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; + +/** 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 { + super.setUp(); + this.service = getService(); + this.workspaceId = getWorkspaceId(); + } + + /** Test createValue. */ + @Test + public void testCreateValue() { + + String entity = "beverage"; + String entityValue = "coffee" + UUID.randomUUID().toString(); + + // metadata + Map valueMetadata = new HashMap(); + String metadataValue = "value for " + entityValue; + valueMetadata.put("key", metadataValue); + + try { + 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(); + Value response = service.createValue(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.value()); + assertEquals(response.value(), entityValue); + assertNotNull(response.metadata()); + + // metadata + assertNotNull(response.metadata()); + assertNotNull(response.metadata().get("key")); + assertEquals(response.metadata().get("key"), metadataValue); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); + service.deleteValue(deleteOptions).execute().getResult(); + } + } + + /** Test deleteValue. */ + @Test + public void testDeleteValue() { + + String entity = "beverage"; + String entityValue = "coffee" + UUID.randomUUID().toString(); + + try { + 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(); + Value response = service.createValue(createOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.value()); + assertEquals(response.value(), entityValue); + assertNull(response.metadata()); + } catch (Exception ex) { + // Clean up + 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(); + service.deleteValue(deleteOptions).execute().getResult(); + + try { + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue).build(); + service.getValue(getOptions).execute().getResult(); + fail("deleteValue failed"); + } catch (Exception ex) { + // Expected result + assertTrue(ex instanceof NotFoundException); + } + } + + /** Test getValue. */ + @Test + public void testGetValue() { + + String entity = "beverage"; + String entityValue = "coffee" + UUID.randomUUID().toString(); + String synonym1 = "java"; + String synonym2 = "joe"; + + try { + 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(); + service.createValue(createOptions).execute().getResult(); + + Date start = new Date(); + + try { + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue) + .export(true) + .includeAudit(true) + .build(); + Value response = service.getValue(getOptions).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.value()); + assertEquals(response.value(), entityValue); + assertNotNull(response.created()); + assertNotNull(response.updated()); + + Date now = new Date(); + assertTrue(fuzzyBefore(response.created(), now)); + assertTrue(fuzzyAfter(response.created(), start)); + assertTrue(fuzzyBefore(response.updated(), now)); + assertTrue(fuzzyAfter(response.updated(), start)); + + assertNotNull(response.synonyms()); + assertTrue(response.synonyms().size() == 2); + assertTrue(response.synonyms().contains(synonym1)); + assertTrue(response.synonyms().contains(synonym2)); + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); + service.deleteValue(deleteOptions).execute().getResult(); + } + } + + /** Test listValues. */ + @Test + public void testListValues() { + + String entity = "beverage"; + String entityValue1 = "coffee"; + String entityValue2 = "orange juice"; + + try { + 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(); + try { + service.createValue(createOptions).execute().getResult(); + } catch (Exception ex) { + // Exception is okay if is for Unique Violation + assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); + } + + try { + 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(); + final ValueCollection response = service.listValues(listOptions).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getValues()); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + // nextUrl may be null + if (response.getPagination().getNextUrl() == null) { + assertNull(response.getPagination().getNextCursor()); + } else { + assertNotNull(response.getPagination().getNextCursor()); + } + + assertTrue(response.getValues().size() >= 2); + + // 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); + boolean found1 = false; + boolean found2 = false; + for (Value valueResponse : response.getValues()) { + found1 |= valueResponse.value().equals(entityValue1); + found2 |= valueResponse.value().equals(entityValue2); + } + assertTrue(found1 && found2); + } + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); + service.deleteValue(deleteOptions).execute().getResult(); + service + .deleteValue(deleteOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); + } + } + + /** Test listValues with pagination. */ + @Test + public void testListValuesWithPaging() { + + String entity = "beverage"; + String entityValue1 = "coffee"; + String entityValue2 = "orange juice"; + + try { + 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(); + try { + service.createValue(createOptions).execute().getResult(); + } catch (Exception ex) { + // Exception is okay if is for Unique Violation + assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); + } + + try { + 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); + listOptionsBuilder.sort("updated"); + listOptionsBuilder.pageLimit(1L); + listOptionsBuilder.export(true); + + ValueCollection response = + service.listValues(listOptionsBuilder.build()).execute().getResult(); + assertNotNull(response); + assertNotNull(response.getPagination()); + assertNotNull(response.getPagination().getRefreshUrl()); + assertNotNull(response.getPagination().getNextUrl()); + assertNotNull(response.getPagination().getNextCursor()); + + boolean found1 = false; + boolean found2 = false; + while (true) { + assertNotNull(response.getValues()); + assertTrue(response.getValues().size() == 1); + found1 |= response.getValues().get(0).value().equals(entityValue1); + found2 |= response.getValues().get(0).value().equals(entityValue2); + if (response.getPagination().getNextCursor() == null) { + break; + } + String cursor = response.getPagination().getNextCursor(); + response = + service.listValues(listOptionsBuilder.cursor(cursor).build()).execute().getResult(); + } + + assertTrue(found1 && found2); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + DeleteValueOptions deleteOptions = + new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); + service.deleteValue(deleteOptions).execute().getResult(); + service + .deleteValue(deleteOptions.newBuilder().value(entityValue2).build()) + .execute() + .getResult(); + } + } + + /** Test updateValue. */ + @Test + public void testUpdateValue() { + + String entity = "beverage"; + String entityValue1 = "coffee" + UUID.randomUUID().toString(); + String entityValue2 = "coffee" + UUID.randomUUID().toString(); + String synonym1 = "java"; + String synonym2 = "joe"; + + // metadata + Map valueMetadata = new HashMap<>(); + String metadataValue = "value for " + entityValue2; + valueMetadata.put("key", metadataValue); + + try { + 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")); + } + + try { + 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(); + Value response = service.updateValue(updateOptions).execute().getResult(); + + try { + assertNotNull(response); + assertNotNull(response.value()); + assertEquals(response.value(), entityValue2); + + GetValueOptions getOptions = + new GetValueOptions.Builder(workspaceId, entity, entityValue2) + .export(true) + .includeAudit(true) + .build(); + Value vResponse = service.getValue(getOptions).execute().getResult(); + + assertNotNull(vResponse); + assertNotNull(vResponse.value()); + assertEquals(vResponse.value(), entityValue2); + assertNotNull(vResponse.created()); + assertNotNull(vResponse.updated()); + + assertNotNull(vResponse.synonyms()); + assertTrue(vResponse.synonyms().size() == 2); + assertTrue(vResponse.synonyms().contains(synonym1)); + assertTrue(vResponse.synonyms().contains(synonym2)); + + // metadata + assertNotNull(response.metadata()); + assertNotNull(response.metadata().get("key")); + assertEquals(response.metadata().get("key"), metadataValue); + + } catch (Exception ex) { + fail(ex.getMessage()); + } finally { + // Clean up + 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 new file mode 100644 index 00000000000..7bdebf092ed --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceIT.java @@ -0,0 +1,580 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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; + +/** 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 { + super.setUp(); + this.service = getService(); + this.assistantId = getAssistantId(); + } + + /** 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(); + String sessionId = sessionResponse.getSessionId(); + + 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(); + 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("text")) { + foundTextResponse = true; + break; + } + } + assertTrue(foundTextResponse); + 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(); + 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 new file mode 100644 index 00000000000..1bbc38e47d2 --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantServiceTest.java @@ -0,0 +1,102 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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 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; + +/** 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.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + String apiKey = System.getenv("ASSISTANT_APIKEY"); + assistantId = System.getenv("ASSISTANT_ASSISTANT_ID"); + String serviceUrl = System.getenv("ASSISTANT_URL"); + + 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(serviceUrl); + service.setDefaultHeaders(getDefaultHeaders()); + } + + private long tolerance = 2000; // 2 secs in ms + + /** + * 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. + * + * @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 new file mode 100644 index 00000000000..4e25f0d8d3d --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/AssistantTest.java @@ -0,0 +1,3178 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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.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.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.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; + +/** 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 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(); + + 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); + + // 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 testDeleteSessionWRetries() throws Throwable { + assistantService.enableRetries(4, 30); + testDeleteSessionWOptions(); + + assistantService.disableRetries(); + testDeleteSessionWOptions(); + } + + // 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 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"); + } + + // 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 messageStateless operation with a valid options model parameter + @Test + 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(); + + // 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); + 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, 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 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)); + + // 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"; + + 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..8e240b641af --- /dev/null +++ b/assistant/src/test/java/com/ibm/watson/assistant/v2/model/CompleteItemTest.java @@ -0,0 +1,65 @@ +/* + * (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 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.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/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/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/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceIT.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceIT.java deleted file mode 100644 index 1f172c78748..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceIT.java +++ /dev/null @@ -1,1682 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.assistant.v1.model.Context; -import com.ibm.watson.developer_cloud.assistant.v1.model.Counterexample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CounterexampleCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateExample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNode; -import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.Example; -import com.ibm.watson.developer_cloud.assistant.v1.model.ExampleCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.InputData; -import com.ibm.watson.developer_cloud.assistant.v1.model.Intent; -import com.ibm.watson.developer_cloud.assistant.v1.model.IntentCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.IntentExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListCounterexamplesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListDialogNodesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListExamplesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListIntentsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListLogsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListWorkspacesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.LogCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.LogExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.assistant.v1.model.OutputData; -import com.ibm.watson.developer_cloud.assistant.v1.model.RuntimeIntent; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateCounterexampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateExampleOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Workspace; -import com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.WorkspaceExport; -import com.ibm.watson.developer_cloud.http.ServiceCallback; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import jersey.repackaged.jsr166e.CompletableFuture; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -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 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}. - */ -@RunWith(RetryRunner.class) -public class AssistantServiceIT extends AssistantServiceTest { - - private String exampleIntent; - - DateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); - - /** - * Test README. - */ - @Test - public void testReadme() { - InputData input = new InputData.Builder("Hi").build(); - MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); - MessageResponse response = service.message(options).execute(); - System.out.println(response); - } - - /** - * Test Example. - */ - @Test - public void testExample() { - InputData input = new InputData.Builder("Hi").build(); - MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); - - // sync - MessageResponse response = service.message(options).execute(); - System.out.println(response); - - // async - service.message(options).enqueue(new ServiceCallback() { - @Override - public void onResponse(MessageResponse response) { - System.out.println(response); - } - - @Override - public void onFailure(Exception e) { - } - }); - - // rx callback - service.message(options).rx().thenApply(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx async callback - service.message(options).rx().thenApplyAsync(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx sync - try { - MessageResponse rxMessageResponse = service.message(options).rx().get(); - System.out.println(rxMessageResponse); - } catch (Exception ex) { - // Handle exception - } - } - - @Test(expected = UnauthorizedException.class) - public void pingBadCredentialsThrowsException() { - Assistant badService = new Assistant("2018-02-16", "foo", "bar"); - MessageOptions options = new MessageOptions.Builder(workspaceId).build(); - badService.message(options).execute(); - } - - /** - * Test start a conversation without message. - */ - @Test() - public void testStartAConversationWithoutMessage() { - MessageOptions options = new MessageOptions.Builder(workspaceId).build(); - service.message(options).execute(); - } - - /** - * Test send messages. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessages() throws InterruptedException { - final String[] messages = new String[] { "turn ac on", "turn right", "no", "yes" }; - Context context = null; - for (final String message : messages) { - MessageOptions request = new MessageOptions.Builder(workspaceId) - .input(new InputData.Builder(message).build()) - .alternateIntents(true) - .context(context) - .nodesVisitedDetails(true) - .build(); - - if (message.equals("yes")) { - RuntimeIntent offTopic = new RuntimeIntent(); - offTopic.setIntent("off_topic"); - offTopic.setConfidence(1.0); - request = request.newBuilder().addIntent(offTopic).build(); - } - MessageResponse response = service.message(request).execute(); - - assertMessageFromService(response); - assertNotNull(response.getOutput().getNodesVisitedDetails()); - context = new Context(); - context.putAll(response.getContext()); - Thread.sleep(500); - } - } - - /** - * Assert {@link MessageResponse} from service. - * - * @param message the message from the {@link Assistant} - */ - private void assertMessageFromService(MessageResponse message) { - assertNotNull(message); - assertNotNull(message.getEntities()); - assertNotNull(message.getIntents()); - } - - /** - * Test message with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testMessageWithNull() { - service.message(null).execute(); - } - - /** - * Test to string. - */ - @Test - public void testToString() { - assertNotNull(service.toString()); - } - - /** - * 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(); - Counterexample response = service.createCounterexample(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - service.deleteCounterexample(deleteOptions).execute(); - - try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - service.getCounterexample(getOptions).execute(); - fail("deleteCounterexample failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .includeAudit(true) - .build(); - Counterexample response = service.getCounterexample(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - /** - * Test listCounterexamples. - */ - @Test - public void testListCounterexamples() { - - 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(); - assertNotNull(ccResponse); - assertNotNull(ccResponse.getCounterexamples()); - assertNotNull(ccResponse.getPagination()); - assertNotNull(ccResponse.getPagination().getRefreshUrl()); - // nextUrl may be null - - Date start = new Date(); - - // Now add a counterexample and make sure we get it back - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.createCounterexample(createOptions).execute(); - - long count = ccResponse.getCounterexamples().size(); - CounterexampleCollection ccResponse2 = service.listCounterexamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()).execute(); - assertNotNull(ccResponse2); - assertNotNull(ccResponse2.getCounterexamples()); - - List counterexamples = ccResponse2.getCounterexamples(); - assertTrue(counterexamples.size() > count); - - Counterexample exResponse = null; - for (Counterexample resp : counterexamples) { - if (resp.getText().equals(counterExampleText)) { - exResponse = resp; - break; - } - } - - assertNotNull(exResponse); - Date now = new Date(); - assertTrue(fuzzyBefore(exResponse.getCreated(), now)); - assertTrue(fuzzyAfter(exResponse.getCreated(), start)); - assertTrue(fuzzyBefore(exResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(exResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - try { - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } catch (NotFoundException ex) { - // Okay - } - } - } - - /** - * Test listCounterexamples with paging. - */ - @Test - public void testListCounterexamplesWithPaging() { - - String counterExampleText1 = "alpha" + UUID.randomUUID().toString(); // gotta be unique - String counterExampleText2 = "zeta" + UUID.randomUUID().toString(); // gotta be unique - - // Add two counterexamples - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); - service.createCounterexample(createOptions).execute(); - service.createCounterexample(createOptions.newBuilder().text(counterExampleText2).build()).execute(); - - try { - ListCounterexamplesOptions listOptions = new ListCounterexamplesOptions.Builder(workspaceId).pageLimit(1L).sort( - "text").build(); - CounterexampleCollection response = service.listCounterexamples(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getCounterexamples()); - assertTrue(response.getCounterexamples().size() == 1); - found1 |= response.getCounterexamples().get(0).getText().equals(counterExampleText1); - found2 |= response.getCounterexamples().get(0).getText().equals(counterExampleText2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listCounterexamples(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); - service.deleteCounterexample(deleteOptions).execute(); - service.deleteCounterexample(deleteOptions.newBuilder().text(counterExampleText2).build()).execute(); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - try { - UpdateCounterexampleOptions updateOptions = new UpdateCounterexampleOptions.Builder(workspaceId, - counterExampleText).newText(counterExampleText2) - .build(); - Counterexample response = service.updateCounterexample(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText2).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - public void createExampleIntent() { - exampleIntent = "Hello"; - try { - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, exampleIntent).description( - "Example Intent").build(); - service.createIntent(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - } - - /** - * 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(); - Example response = service.createExample(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createExample(createOptions).execute(); - - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - - try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); - service.getExample(getOptions).execute(); - fail("deleteCounterexample failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getExample. - */ - @Test - public void testGetExample() { - - createExampleIntent(); - - Date start = new Date(); - - String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.createExample(createOptions).execute(); - - try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .includeAudit(true) - .build(); - Example response = service.getExample(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * Test listExamples. - */ - @Test - public void testListExamples() { - - createExampleIntent(); - - String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - - try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - assertNotNull(ecResponse.getPagination()); - assertNotNull(ecResponse.getPagination().getRefreshUrl()); - // nextUrl may be null - - Date start = new Date(); - - // Now add an example and make sure we get it back - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.createExample(createOptions).execute(); - - long count = ecResponse.getExamples().size(); - ExampleCollection ecResponse2 = service.listExamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()) - .execute(); - assertNotNull(ecResponse2); - assertNotNull(ecResponse2.getExamples()); - - List examples = ecResponse2.getExamples(); - assertTrue(examples.size() > count); - - Example exResponse = null; - for (Example resp : examples) { - if (resp.getExampleText().equals(exampleText)) { - exResponse = resp; - break; - } - } - - assertNotNull(exResponse); - Date now = new Date(); - assertTrue(fuzzyBefore(exResponse.getCreated(), now)); - assertTrue(fuzzyAfter(exResponse.getCreated(), start)); - assertTrue(fuzzyBefore(exResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(exResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - - } - - /** - * Test listExamples with paging. - */ - @Test - public void testListExamplesWithPaging() { - - createExampleIntent(); - - 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(); - service.createExample(createOptions).execute(); - service.createExample(createOptions.newBuilder().text(exampleText2).build()).execute(); - - try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent).pageLimit(1L).sort( - "-text").build(); - ExampleCollection response = service.listExamples(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExamples()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getExamples()); - assertTrue(response.getExamples().size() == 1); - found1 |= response.getExamples().get(0).getExampleText().equals(exampleText1); - found2 |= response.getExamples().get(0).getExampleText().equals(exampleText2); - assertTrue(found2 || !found1); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listExamples(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText1) - .build(); - service.deleteExample(deleteOptions).execute(); - service.deleteExample(deleteOptions.newBuilder().text(exampleText2).build()).execute(); - } - - } - - /** - * Test updateExample. - */ - @Test - public void testUpdateExample() { - - createExampleIntent(); - - 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(); - service.createExample(createOptions).execute(); - - try { - UpdateExampleOptions updateOptions = new UpdateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .newText(exampleText2).build(); - Example response = service.updateExample(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText2) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * Test createIntent. - */ - @Test - public void testCreateIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - Intent response = service.createIntent(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription); - - Date now = new Date(); - - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - - List examples = ecResponse.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * Test deleteIntent. - */ - @Test - public void testDeleteIntent() { - - String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName).build(); - service.createIntent(createOptions).execute(); - - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - - try { - GetIntentOptions getOptions = new GetIntentOptions.Builder(workspaceId, intentName).build(); - service.getIntent(getOptions).execute(); - fail("deleteIntent failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getIntent. - */ - @Test - public void testGetIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder().workspaceId(workspaceId).intent(intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - try { - GetIntentOptions getOptions = new GetIntentOptions.Builder() - .workspaceId(workspaceId) - .intent(intentName) - .export(true) - .includeAudit(true) - .build(); - IntentExport response = service.getIntent(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription); - assertNotNull(response.getExamples()); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - List examples = response.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * 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(); - IntentCollection response = service.listIntents(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntents()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // Now add an intent and make sure we get it back - String intentDescription = "Description of " + intentName; - String intentExample = "Example of " + intentName; - List intentExamples = new ArrayList(); - intentExamples.add(new CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - long count = response.getIntents().size(); - ListIntentsOptions listOptions2 = new ListIntentsOptions.Builder(workspaceId) - .export(true) - .pageLimit(count + 1) - .includeAudit(true) - .build(); - IntentCollection response2 = service.listIntents(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getIntents()); - - List intents = response2.getIntents(); - assertTrue(intents.size() > count); - - IntentExport ieResponse = null; - for (IntentExport resp : intents) { - if (resp.getIntentName().equals(intentName)) { - ieResponse = resp; - break; - } - } - - assertNotNull(ieResponse); - assertNotNull(ieResponse.getDescription()); - assertEquals(ieResponse.getDescription(), intentDescription); - assertNotNull(ieResponse.getExamples()); - assertTrue(ieResponse.getExamples().size() == 1); - assertEquals(ieResponse.getExamples().get(0).getExampleText(), intentExample); - - Date now = new Date(); - assertTrue(fuzzyBefore(ieResponse.getCreated(), now)); - assertTrue(fuzzyAfter(ieResponse.getCreated(), start)); - assertTrue(fuzzyBefore(ieResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(ieResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createIntent(createOptions).execute(); - service.createIntent(createOptions.newBuilder().intent(intentName2).build()).execute(); - - try { - ListIntentsOptions listOptions = new ListIntentsOptions.Builder() - .workspaceId(workspaceId) - .export(true) - .pageLimit(1L) - .sort("modified") - .includeAudit(true) - .build(); - IntentCollection response = service.listIntents(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntents()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getIntents()); - assertTrue(response.getIntents().size() == 1); - found1 |= response.getIntents().get(0).getIntentName().equals(intentName1); - found2 |= response.getIntents().get(0).getIntentName().equals(intentName2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listIntents(listOptions.newBuilder().cursor(cursor).build()).execute(); - - } - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName1).build(); - service.deleteIntent(deleteOptions).execute(); - service.deleteIntent(deleteOptions.newBuilder().intent(intentName2).build()).execute(); - } - } - - /** - * Test updateIntent. - */ - @Test - public void testUpdateIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - try { - String intentDescription2 = "Updated description of " + intentName; - String intentExample2 = "Updated Example of " + intentName; - List intentExamples2 = new ArrayList(); - intentExamples2.add(new CreateExample.Builder().text(intentExample2).build()); - Date start = new Date(); - UpdateIntentOptions updateOptions = new UpdateIntentOptions.Builder(workspaceId, intentName) - .newDescription(intentDescription2).newExamples(intentExamples2).build(); - Intent response = service.updateIntent(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription2); - - Date now = new Date(); - - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - - List examples = ecResponse.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample2); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * Test createWorkspace. - */ - @Test - public void testCreateWorkspace() { - - 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 CreateExample.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 entitySource = "Source for " + 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 CreateCounterexample.Builder().text(counterExampleText).build()); - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().name(workspaceName) - .description(workspaceDescription).language(workspaceLanguage).metadata(workspaceMetadata) - .intents(workspaceIntents).entities(workspaceEntities).counterexamples(workspaceCounterExamples).build(); - - String workspaceId = null; - try { - Workspace response = service.createWorkspace(createOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - workspaceId = response.getWorkspaceId(); - assertNotNull(response.getName()); - assertEquals(response.getName(), workspaceName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), workspaceDescription); - assertNotNull(response.getLanguage()); - assertEquals(response.getLanguage(), workspaceLanguage); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); - WorkspaceExport exResponse = service.getWorkspace(getOptions).execute(); - assertNotNull(exResponse); - - // intents - assertNotNull(exResponse.getIntents()); - assertTrue(exResponse.getIntents().size() == 1); - assertNotNull(exResponse.getIntents().get(0).getIntentName()); - assertEquals(exResponse.getIntents().get(0).getIntentName(), 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).getExampleText()); - assertEquals(exResponse.getIntents().get(0).getExamples().get(0).getExampleText(), intentExample); - - // entities - assertNotNull(exResponse.getEntities()); - assertTrue(exResponse.getEntities().size() == 1); - assertNotNull(exResponse.getEntities().get(0).getEntityName()); - assertEquals(exResponse.getEntities().get(0).getEntityName(), 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).getValueText()); - assertEquals(exResponse.getEntities().get(0).getValues().get(0).getValueText(), entityValue); - assertNotNull(exResponse.getEntities().get(0).getValues().get(0).getSynonyms()); - assertTrue(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().size() == 1); - assertEquals(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().get(0), entityValueSynonym); - - // counterexamples - assertNotNull(exResponse.getCounterexamples()); - assertTrue(exResponse.getCounterexamples().size() == 1); - assertNotNull(exResponse.getCounterexamples().get(0).getText()); - assertEquals(exResponse.getCounterexamples().get(0).getText(), counterExampleText); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - } - } - } - - /** - * Test deleteWorkspace. - */ - @Test - public void testDeleteWorkspace() { - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().build(); - - String workspaceId = null; - try { - Workspace response = service.createWorkspace(createOptions).execute(); - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - workspaceId = response.getWorkspaceId(); - - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); - service.getWorkspace(getOptions).execute(); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - workspaceId = null; - } finally { - // Clean up - if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - } - } - } - - /** - * Test getWorkspace. - */ - @Test - public void testGetWorkspace() { - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId) - .export(false) - .includeAudit(true) - .build(); - WorkspaceExport response = service.getWorkspace(getOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - assertEquals(response.getWorkspaceId(), workspaceId); - assertNotNull(response.getName()); - assertNotNull(response.getLanguage()); - - Date now = new Date(); - - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - - // metadata, intents, entities, dialogNodes, and counterexamples could be null - - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * Test listWorkspaces. - */ - @Test - public void testListWorkspaces() { - - ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().build(); - WorkspaceCollection response = service.listWorkspaces(listOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getWorkspaces()); - assertTrue(response.getWorkspaces().size() > 0); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - - Workspace wResponse = null; - for (Workspace resp : response.getWorkspaces()) { - if (resp.getWorkspaceId().equals(workspaceId)) { - wResponse = resp; - break; - } - } - - assertNotNull(wResponse); - assertNotNull(wResponse.getName()); - } - - /** - * Test listWorkspaces with paging. - */ - @Test - public void testListWorkspacesWithPaging() { - - ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build(); - WorkspaceCollection response = service.listWorkspaces(listOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - - boolean found = false; - while (true) { - assertNotNull(response.getWorkspaces()); - assertTrue(response.getWorkspaces().size() == 1); - found |= response.getWorkspaces().get(0).getWorkspaceId().equals(workspaceId); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listWorkspaces(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertTrue(found); - } - - /** - * Test updateWorkspace. - */ - @Test - public void testUpdateWorkspace() { - - String workspaceName = "testUpdateWorkspace"; - String workspaceDescription = "Description for testUpdateWorkspace"; - - // intents - CreateIntent intent0 = new CreateIntent.Builder("Hello").build(); - CreateIntent intent1 = new CreateIntent.Builder("Goodbye").build(); - - // entities - CreateEntity entity0 = new CreateEntity.Builder("animal").build(); - CreateEntity entity1 = new CreateEntity.Builder("beverage").build(); - - // counterexamples - CreateCounterexample counterexample0 = new CreateCounterexample.Builder("What are you wearing?").build(); - CreateCounterexample counterexample1 = new CreateCounterexample.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(); - - String workspaceId = null; - try { - Workspace createResponse = service.createWorkspace(createOptions).execute(); - - assertNotNull(createResponse); - assertNotNull(createResponse.getWorkspaceId()); - workspaceId = createResponse.getWorkspaceId(); - - String counterExampleText = "What are you drinking"; - CreateCounterexample counterexample2 = new CreateCounterexample.Builder(counterExampleText).build(); - UpdateWorkspaceOptions updateOptions = new UpdateWorkspaceOptions.Builder(workspaceId) - .addCounterexample(counterexample2) - .append(false) - .build(); - Workspace updateResponse = service.updateWorkspace(updateOptions).execute(); - - assertNotNull(updateResponse); - - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - Counterexample eResponse = service.getCounterexample(getOptions).execute(); - assertNotNull(eResponse); - assertNotNull(eResponse.getText()); - assertEquals(eResponse.getText(), counterExampleText); - - } 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 - public void testListLogs() { - - try { - ListLogsOptions listOptions = new ListLogsOptions.Builder().workspaceId(workspaceId).build(); - LogCollection response = service.listLogs(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getLogs()); - assertNotNull(response.getPagination()); - // Empirically -- no refresh_url in pagination of listLogs - // assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * Test listLogs with pagination. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - public void testListLogsWithPaging() { - - try { - ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId); - listOptionsBuilder.sort("-request_timestamp"); - listOptionsBuilder.filter("request.intents:intent:off_topic"); - listOptionsBuilder.pageLimit(1L); - - LogCollection response = service.listLogs(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getLogs()); - assertNotNull(response.getPagination()); - // Empirically -- no refresh_url in pagination of listLogs - // assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - assertTrue(response.getLogs().size() == 1); - LogExport logEntry1 = response.getLogs().get(0); - - String cursor = response.getPagination().getNextCursor(); - response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute(); - - assertNotNull(response.getLogs()); - assertTrue(response.getLogs().size() == 1); - - LogExport logEntry2 = response.getLogs().get(0); - - Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp()); - Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp()); - - assertTrue(requestDate2.before(requestDate1)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * 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(); - DialogNode response = service.createDialogNode(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * Test deleteDialogNode. - */ - @Test - public void testDeleteDialogNode() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); // gotta be unique - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.createDialogNode(createOptions).execute(); - - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - - try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.getDialogNode(getOptions).execute(); - fail("deleteDialogNode failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getDialogNode. - */ - @Test - public void testGetDialogNode() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); - String dialogNodeDescription = "Description of " + dialogNodeName; - - Date start = new Date(); - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription).build(); - service.createDialogNode(createOptions).execute(); - - try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder() - .workspaceId(workspaceId) - .dialogNode(dialogNodeName) - .includeAudit(true) - .build(); - DialogNode response = service.getDialogNode(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * Test listDialogNodes. - */ - @Test - public void testListDialogNodes() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); - - try { - ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder(workspaceId).build(); - DialogNodeCollection response = service.listDialogNodes(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodes()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // Now add a dialog node and make sure we get it back - String dialogNodeDescription = "Description of " + dialogNodeName; - - Date start = new Date(); - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription) - .build(); - service.createDialogNode(createOptions).execute(); - - long count = response.getDialogNodes().size(); - ListDialogNodesOptions listOptions2 = new ListDialogNodesOptions.Builder(workspaceId) - .pageLimit(count + 1) - .includeAudit(true) - .build(); - DialogNodeCollection response2 = service.listDialogNodes(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getDialogNodes()); - - List dialogNodes = response2.getDialogNodes(); - assertTrue(dialogNodes.size() > count); - - DialogNode dialogResponse = null; - for (DialogNode node : dialogNodes) { - if (node.getDialogNodeId().equals(dialogNodeName)) { - dialogResponse = node; - break; - } - } - - assertNotNull(dialogResponse); - assertNotNull(dialogResponse.getDescription()); - assertEquals(dialogResponse.getDescription(), dialogNodeDescription); - - Date now = new Date(); - assertTrue(fuzzyBefore(dialogResponse.getCreated(), now)); - assertTrue(fuzzyAfter(dialogResponse.getCreated(), start)); - assertTrue(fuzzyBefore(dialogResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(dialogResponse.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createDialogNode(createOptions).execute(); - service.createDialogNode(createOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute(); - - try { - ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder().workspaceId(workspaceId).pageLimit(1L) - .sort("dialog_node").build(); - DialogNodeCollection response = service.listDialogNodes(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodes()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getDialogNodes()); - assertTrue(response.getDialogNodes().size() == 1); - found1 |= response.getDialogNodes().get(0).getDialogNodeId().equals(dialogNodeName1); - found2 |= response.getDialogNodes().get(0).getDialogNodeId().equals(dialogNodeName2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listDialogNodes(listOptions.newBuilder().cursor(cursor).build()).execute(); - - } - assertTrue(found1 && found2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); - service.deleteDialogNode(deleteOptions).execute(); - service.deleteDialogNode(deleteOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute(); - } - } - - /** - * 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(); - service.createDialogNode(createOptions).execute(); - - 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(); - DialogNode response = service.updateDialogNode(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName2); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription2); - } 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(); - service.deleteUserData(deleteOptions).execute(); - } catch (Exception ex) { - fail(ex.getMessage()); - } - } -} diff --git a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceTest.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceTest.java deleted file mode 100644 index 31aec04ae96..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantServiceTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import org.junit.Assume; -import org.junit.Before; - -import java.util.Date; - -public class AssistantServiceTest extends WatsonServiceTest { - - Assistant service; - String workspaceId; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("conversation.v1.username"); - String password = getProperty("conversation.v1.password"); - workspaceId = getProperty("conversation.v1.workspace_id"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new Assistant("2018-02-16"); - service.setEndPoint(getProperty("conversation.v1.url")); - service.setUsernameAndPassword(username, password); - service.setDefaultHeaders(getDefaultHeaders()); - } - - long tolerance = 2000; // 2 secs in ms - - /** - * return `true` if ldate before rdate within tolerance. - */ - public boolean fuzzyBefore(Date ldate, Date rdate) { - return (ldate.getTime() - rdate.getTime()) < tolerance; - } - - /** - * return `true` if ldate after rdate within tolerance. - */ - public boolean fuzzyAfter(Date ldate, Date rdate) { - return (rdate.getTime() - ldate.getTime()) < tolerance; - } - -} diff --git a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantTest.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantTest.java deleted file mode 100644 index 7ee4cd59108..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantTest.java +++ /dev/null @@ -1,742 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.assistant.v1.model.Context; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateCounterexample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNode; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntity; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateExample; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntent; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DialogNodeAction; -import com.ibm.watson.developer_cloud.assistant.v1.model.InputData; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListAllLogsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.assistant.v1.model.RuntimeEntity; -import com.ibm.watson.developer_cloud.assistant.v1.model.RuntimeIntent; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -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.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Unit tests for the {@link Assistant}. - */ -public class AssistantTest extends WatsonServiceUnitTest { - 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("2018-02-16"); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Assistant(null); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Assistant(""); - } - - /** - * Negative - Test assistant with null options. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullOptions() { - service.message(null).execute(); - } - - /** - * Negative - Test assistant with null workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithNullWorkspaceId() { - MessageOptions options = new MessageOptions.Builder().build(); - service.message(options).execute(); - } - - /** - * Negative - Test assistant with empty workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testAssistantWithEmptyWorkspaceId() { - MessageOptions options = new MessageOptions.Builder("").build(); - service.message(options).execute(); - } - - /** - * 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)); - - InputData input = new InputData.Builder(text).build(); - RuntimeIntent intent = new RuntimeIntent(); - intent.setIntent("turn_on"); - intent.setConfidence(0.0); - RuntimeEntity entity = new RuntimeEntity(); - entity.setEntity("genre"); - entity.setValue("jazz"); - 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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=2018-02-16"); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getDialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getTitle()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getConditions()); - assertEquals(serviceResponse, mockResponse); - } - - /** - * 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)); - - Context contextTemp = new Context(); - contextTemp.put("name", "Myname"); - InputData inputTemp = new InputData.Builder("My text").build(); - - 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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=2018-02-16"); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - assertEquals(serviceResponse, mockResponse); - } - - /** - * 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"; - - InputData input = new InputData.Builder(text).build(); - MessageOptions options = new MessageOptions.Builder().input(input).alternateIntents(true).build(); - - service.message(options).execute(); - } - - /** - * Test CreateWorkspace builder. - */ - @Test - public void testCreateWorkspaceBuilder() { - - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; - - // 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 - CreateCounterexample testCounterexample0 = new CreateCounterexample.Builder("testCounterexample0").build(); - CreateCounterexample testCounterexample1 = new CreateCounterexample.Builder("testCounterexample1").build(); - - // dialognodes - CreateDialogNode testDialogNode0 = new CreateDialogNode.Builder("dialogNode0").build(); - CreateDialogNode testDialogNode1 = new CreateDialogNode.Builder("dialogNode1").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - 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) - .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(1), testDialogNode1); - - CreateWorkspaceOptions.Builder builder = createOptions.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build(); - CreateDialogNode testDialogNode2 = new CreateDialogNode.Builder("dialogNode2").build(); - - builder.intents(Arrays.asList(testIntent2)); - builder.entities(Arrays.asList(testEntity2)); - builder.counterexamples(Arrays.asList(testCounterexample2)); - builder.dialogNodes(Arrays.asList(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 - CreateCounterexample testCounterexample = new CreateCounterexample.Builder("testCounterexample").build(); - - // dialognodes - CreateDialogNode testDialogNode = new CreateDialogNode.Builder("dialogNode").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - 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); - - 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); - - UpdateWorkspaceOptions.Builder builder2 = options.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build(); - CreateDialogNode testDialogNode2 = new CreateDialogNode.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 CreateIntentOptions builder. - */ - @Test - public void testCreateIntentOptionsBuilder() { - String intent = "anIntent"; - CreateExample intentExample0 = new CreateExample.Builder().text("intentExample0").build(); - CreateExample intentExample1 = new CreateExample.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(); - - CreateExample intentExample2 = new CreateExample.Builder().text("intentExample2").build(); - builder.examples(Arrays.asList(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"; - CreateExample intentExample0 = new CreateExample.Builder().text("intentExample0").build(); - CreateExample intentExample1 = new CreateExample.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(); - - CreateExample intentExample2 = new CreateExample.Builder().text("intentExample2").build(); - builder.newExamples(Arrays.asList(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) - .addValue(entityValue0).addValue(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(Arrays.asList(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(Arrays.asList(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) - .valueType(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.valueType(), valueType); - - CreateValueOptions.Builder builder = createOptions.newBuilder(); - - String valueSynonym2 = "valueSynonym2"; - String valuePattern2 = "valuePattern2"; - builder.synonyms(Arrays.asList(valueSynonym2)); - builder.patterns(Arrays.asList(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(Arrays.asList(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(); - action0.setName("action0"); - action0.setCredentials("credential0"); - DialogNodeAction action1 = new DialogNodeAction(); - action1.setName("action1"); - action1.setCredentials("credential1"); - - 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) - .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).getCredentials(), "credential0"); - assertEquals(createOptions.actions().get(1), action1); - assertEquals(createOptions.actions().get(1).getCredentials(), "credential1"); - assertEquals(createOptions.digressIn(), CreateDialogNodeOptions.DigressIn.RETURNS); - assertEquals(createOptions.digressOut(), CreateDialogNodeOptions.DigressOut.ALLOW_ALL); - assertEquals(createOptions.digressOutSlots(), CreateDialogNodeOptions.DigressOutSlots.ALLOW_ALL); - } - - /** - * Test UpdateDialogNodeOptions builder. - */ - @Test - public void testUpdateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - String newDialogNodeName = "renamedDialogNode"; - DialogNodeAction action0 = new DialogNodeAction(); - action0.setName("action0"); - action0.setCredentials("credential0"); - DialogNodeAction action1 = new DialogNodeAction(); - action1.setName("action1"); - action1.setCredentials("credential1"); - - 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) - .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).getCredentials(), "credential0"); - assertEquals(updateOptions.newActions().get(1), action1); - assertEquals(updateOptions.newActions().get(1).getCredentials(), "credential1"); - assertEquals(updateOptions.newDigressIn(), UpdateDialogNodeOptions.NewDigressIn.RETURNS); - assertEquals(updateOptions.newDigressOut(), UpdateDialogNodeOptions.NewDigressOut.ALLOW_ALL); - assertEquals(updateOptions.newDigressOutSlots(), UpdateDialogNodeOptions.NewDigressOutSlots.ALLOW_ALL); - } - - /** - * 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); - } -} diff --git a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/EntitiesIT.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/EntitiesIT.java deleted file mode 100644 index 47182d39a59..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/EntitiesIT.java +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Entity; -import com.ibm.watson.developer_cloud.assistant.v1.model.EntityCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.EntityExport; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListEntitiesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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 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; - -@RunWith(RetryRunner.class) -public class EntitiesIT extends AssistantServiceTest { - - /** - * Test createEntity. - */ - @Test - public void testCreateEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - Map entityMetadata = new HashMap(); - String metadataValue = "value for " + entity; - entityMetadata.put("key", metadataValue); - - CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); - optionsBuilder.workspaceId(workspaceId); - optionsBuilder.entity(entity); - optionsBuilder.description(entityDescription); - optionsBuilder.metadata(entityMetadata); - optionsBuilder.fuzzyMatch(true); // default is false - Entity response = service.createEntity(optionsBuilder.build()).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription); - - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - assertNotNull(response.isFuzzyMatch()); - assertTrue(response.isFuzzyMatch()); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test deleteEntity. - */ - @Test - public void testDeleteEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - CreateEntityOptions options = new CreateEntityOptions.Builder(workspaceId, entity).build(); - Entity response = service.createEntity(options).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNull(response.getDescription()); - assertNull(response.getMetadata()); - assertTrue(response.isFuzzyMatch() == null || response.isFuzzyMatch().equals(Boolean.FALSE)); - } catch (Exception ex) { - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - - try { - GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity).build(); - service.getEntity(getOptions).execute(); - fail("deleteEntity failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getEntity. - */ - @Test - public void testGetEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - String entityValue = "Value of " + entity; - List entityValues = new ArrayList(); - entityValues.add(new CreateValue.Builder().value(entityValue).build()); - - CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); - optionsBuilder.workspaceId(workspaceId); - optionsBuilder.entity(entity); - optionsBuilder.description(entityDescription); - optionsBuilder.values(entityValues); - service.createEntity(optionsBuilder.build()).execute(); - - Date start = new Date(); - - try { - GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity) - .export(true) - .includeAudit(true) - .build(); - EntityExport response = service.getEntity(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription); - assertNotNull(response.getValues()); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - List values = response.getValues(); - assertTrue(values.size() == 1); - assertEquals(values.get(0).getValueText(), entityValue); - assertTrue(fuzzyBefore(values.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(values.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(values.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(values.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test listEntities. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - public void testListEntities() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - try { - ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId).build(); - EntityCollection response = service.listEntities(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntities()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // 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) - .addValue(new CreateValue.Builder(entityValue).build()) - .build(); - service.createEntity(options).execute(); - - ListEntitiesOptions listOptions2 = listOptions.newBuilder() - .sort("-updated").pageLimit(5L).export(true).build(); - EntityCollection response2 = service.listEntities(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getEntities()); - - List entities = response2.getEntities(); - EntityExport ieResponse = null; - for (EntityExport resp : entities) { - if (resp.getEntityName().equals(entity)) { - ieResponse = resp; - break; - } - } - - assertNotNull(ieResponse); - assertNotNull(ieResponse.getDescription()); - assertEquals(ieResponse.getDescription(), entityDescription); - assertNotNull(ieResponse.getValues()); - assertTrue(ieResponse.getValues().size() == 1); - assertTrue(ieResponse.getValues().get(0).getValueText().equals(entityValue)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test listEntities with pagination. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - 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(); - service.createEntity(createOptions).execute(); - service.createEntity(createOptions.newBuilder().entity(entity2).build()).execute(); - - try { - ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId) - .sort("entity") - .pageLimit(1L) - .build(); - EntityCollection response = service.listEntities(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntities()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - assertTrue(!response.getEntities().get(0).getEntityName().equals(entity1)); - - EntityExport ieResponse = null; - while (response.getPagination().getNextCursor() != null) { - assertNotNull(response.getEntities()); - assertTrue(response.getEntities().size() == 1); - if (response.getEntities().get(0).getEntityName().equals(entity1)) { - ieResponse = response.getEntities().get(0); - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listEntities(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertNotNull(ieResponse); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity1).build(); - service.deleteEntity(deleteOptions).execute(); - service.deleteEntity(deleteOptions.newBuilder().entity(entity2).build()).execute(); - } - } - - /** - * Test updateEntity. - */ - @Test - public void testUpdateEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entity2 = "Goodbye" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - - CreateEntityOptions.Builder createOptionsBuilder = new CreateEntityOptions.Builder(); - createOptionsBuilder.workspaceId(workspaceId); - createOptionsBuilder.entity(entity); - createOptionsBuilder.description(entityDescription); - service.createEntity(createOptionsBuilder.build()).execute(); - - try { - String entityDescription2 = "Description of " + entity2; - String entityValue2 = "Value of " + entity2; - Map entityMetadata2 = new HashMap(); - String metadataValue2 = "value for " + entity2; - entityMetadata2.put("key", metadataValue2); - - UpdateEntityOptions.Builder updateOptionsBuilder = new UpdateEntityOptions.Builder(workspaceId, entity); - updateOptionsBuilder.newEntity(entity2); - updateOptionsBuilder.newDescription(entityDescription2); - updateOptionsBuilder.addValue(new CreateValue.Builder().value(entityValue2).build()); - updateOptionsBuilder.newMetadata(entityMetadata2); - updateOptionsBuilder.newFuzzyMatch(true); - - Entity response = service.updateEntity(updateOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity2); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription2); - - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue2); - - assertNotNull(response.isFuzzyMatch()); - assertTrue(response.isFuzzyMatch()); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity2).build(); - service.deleteEntity(deleteOptions).execute(); - } - } -} diff --git a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/SynonymsIT.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/SynonymsIT.java deleted file mode 100644 index 2d452615790..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/SynonymsIT.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetSynonymOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListSynonymsOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Synonym; -import com.ibm.watson.developer_cloud.assistant.v1.model.SynonymCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateSynonymOptions; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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; - -@RunWith(RetryRunner.class) -public class SynonymsIT extends AssistantServiceTest { - - /** - * Test createSynonym. - */ - @Test - public void testCreateSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - Synonym response = service.createSynonym(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } - - /** - * Test deleteSynonym. - */ - @Test - public void testDeleteSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - Synonym response = service.createSynonym(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - } catch (Exception ex) { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .synonym(synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - - try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); - service.getSynonym(getOptions).execute(); - fail("deleteSynonym failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getSynonym. - */ - @Test - public void testGetSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - Date start = new Date(); - - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.createSynonym(createOptions).execute(); - - try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .includeAudit(true) - .build(); - Synonym response = service.getSynonym(getOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } - - /** - * Test listSynonyms. - */ - @Test - public void testListSynonyms() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.createSynonym(createOptions).execute(); - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute(); - } 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(); - final SynonymCollection response = service.listSynonyms(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getSynonyms()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - - assertTrue(response.getSynonyms().size() >= 2); - - // 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); - boolean found1 = false, found2 = false; - for (Synonym synonymResponse : response.getSynonyms()) { - found1 |= synonymResponse.getSynonymText().equals(synonym1); - found2 |= synonymResponse.getSynonymText().equals(synonym2); - } - assertTrue(found1 && found2); - } - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.deleteSynonym(deleteOptions).execute(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute(); - } - } - - /** - * Test listSynonyms with pagination. - */ - @Test - public void testListSynonymsWithPaging() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - try { - service.createSynonym(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - try { - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute(); - } 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); - listOptionsBuilder.sort("modified"); - listOptionsBuilder.pageLimit(1L); - - SynonymCollection response = service.listSynonyms(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getSynonyms()); - assertTrue(response.getSynonyms().size() == 1); - found1 |= response.getSynonyms().get(0).getSynonymText().equals(synonym1); - found2 |= response.getSynonyms().get(0).getSynonymText().equals(synonym2); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listSynonyms(listOptionsBuilder.cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.deleteSynonym(deleteOptions).execute(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute(); - } - } - - /** - * Test updateSynonym. - */ - @Test - public void testUpdateSynonym() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "joe"; - String synonym2 = "mud"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.createSynonym(createOptions).execute(); - } 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(); - Synonym response = service.updateSynonym(updateOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym2) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } -} diff --git a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/ValuesIT.java b/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/ValuesIT.java deleted file mode 100644 index 2c7cd1ec480..00000000000 --- a/assistant/src/test/java/com/ibm/watson/developer_cloud/assistant/v1/ValuesIT.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.DeleteValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.GetValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.ListValuesOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.Value; -import com.ibm.watson.developer_cloud.assistant.v1.model.ValueCollection; -import com.ibm.watson.developer_cloud.assistant.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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 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; - -@RunWith(RetryRunner.class) -public class ValuesIT extends AssistantServiceTest { - - /** - * Test createValue. - */ - @Test - public void testCreateValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - - // metadata - Map valueMetadata = new HashMap(); - String metadataValue = "value for " + entityValue; - valueMetadata.put("key", metadataValue); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - Value response = service.createValue(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNotNull(response.getMetadata()); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - } - } - - /** - * Test deleteValue. - */ - @Test - public void testDeleteValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - Value response = service.createValue(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNull(response.getMetadata()); - } catch (Exception ex) { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .build(); - service.deleteValue(deleteOptions).execute(); - - try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.getValue(getOptions).execute(); - fail("deleteValue failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getValue. - */ - @Test - public void testGetValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - service.createValue(createOptions).execute(); - - Date start = new Date(); - - try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue) - .export(true) - .includeAudit(true) - .build(); - ValueExport response = service.getValue(getOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - assertNotNull(response.getSynonyms()); - assertTrue(response.getSynonyms().size() == 2); - assertTrue(response.getSynonyms().contains(synonym1)); - assertTrue(response.getSynonyms().contains(synonym2)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - } - } - - /** - * Test listValues. - */ - @Test - public void testListValues() { - - String entity = "beverage"; - String entityValue1 = "coffee"; - String entityValue2 = "orange juice"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - try { - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute(); - } 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(); - final ValueCollection response = service.listValues(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getValues()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - - assertTrue(response.getValues().size() >= 2); - - // 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); - boolean found1 = false, found2 = false; - for (ValueExport valueResponse : response.getValues()) { - found1 |= valueResponse.getValueText().equals(entityValue1); - found2 |= valueResponse.getValueText().equals(entityValue2); - } - assertTrue(found1 && found2); - } - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.deleteValue(deleteOptions).execute(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute(); - } - } - - /** - * Test listValues with pagination. - */ - @Test - public void testListValuesWithPaging() { - - String entity = "beverage"; - String entityValue1 = "coffee"; - String entityValue2 = "orange juice"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - try { - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute(); - } 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); - listOptionsBuilder.sort("updated"); - listOptionsBuilder.pageLimit(1L); - listOptionsBuilder.export(true); - - ValueCollection response = service.listValues(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getValues()); - assertTrue(response.getValues().size() == 1); - found1 |= response.getValues().get(0).getValueText().equals(entityValue1); - found2 |= response.getValues().get(0).getValueText().equals(entityValue2); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listValues(listOptionsBuilder.cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.deleteValue(deleteOptions).execute(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute(); - } - } - - /** - * Test updateValue. - */ - @Test - public void testUpdateValue() { - - String entity = "beverage"; - String entityValue1 = "coffee" + UUID.randomUUID().toString(); - String entityValue2 = "coffee" + UUID.randomUUID().toString(); - String synonym1 = "java"; - String synonym2 = "joe"; - - // metadata - Map valueMetadata = new HashMap(); - String metadataValue = "value for " + entityValue2; - valueMetadata.put("key", metadataValue); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.createValue(createOptions).execute(); - } 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(); - Value response = service.updateValue(updateOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue2); - - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue2) - .export(true) - .includeAudit(true) - .build(); - ValueExport vResponse = service.getValue(getOptions).execute(); - - assertNotNull(vResponse); - assertNotNull(vResponse.getValueText()); - assertEquals(vResponse.getValueText(), entityValue2); - assertNotNull(vResponse.getCreated()); - assertNotNull(vResponse.getUpdated()); - - assertNotNull(vResponse.getSynonyms()); - assertTrue(vResponse.getSynonyms().size() == 2); - assertTrue(vResponse.getSynonyms().contains(synonym1)); - assertTrue(vResponse.getSynonyms().contains(synonym2)); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue2).build(); - service.deleteValue(deleteOptions).execute(); - } - } -} diff --git a/assistant/src/test/resources/assistant/assistant.json b/assistant/src/test/resources/assistant/assistant.json index 4ece4091566..5cbf5f13537 100644 --- a/assistant/src/test/resources/assistant/assistant.json +++ b/assistant/src/test/resources/assistant/assistant.json @@ -47,9 +47,6 @@ "Genre On Off Check", "node_3_1484628332751" ], - "action": { - "music_on": "jazz" - }, "nodes_visited_details": [ { "dialog_node": "Entry Point For On Off Commands", @@ -108,5 +105,16 @@ "previous_cuisine": "", "previous_restaurant_date": "", "previous_restaurant_time": "" - } + }, + "actions": [ + { + "name": "test_action", + "type": "client", + "parameters": { + "param_1": "val_1" + }, + "result_variable": "var", + "credentials": "creds" + } + ] } diff --git a/assistant/src/test/resources/assistant/message_response.json b/assistant/src/test/resources/assistant/message_response.json new file mode 100644 index 00000000000..dc629057df5 --- /dev/null +++ b/assistant/src/test/resources/assistant/message_response.json @@ -0,0 +1,186 @@ +{ + "context": { + "global": { + "system": { + "timezone": "timezone", + "user_id": "user_id", + "turn_count": "10" + } + }, + "skills": { + "main skill": { + "skill_key": "skill_var" + } + } + }, + "output": { + "generic": [ + { + "response_type": "text", + "text": "text", + "time": 1234, + "typing": true, + "source": "source", + "title": "title", + "description": "description", + "preference": "button", + "options": [ + { + "label": "label", + "value": { + "input": { + "message_type": "text", + "text": "text", + "options": { + "debug": true, + "restart": true, + "alternate_intents": true, + "return_context": true + }, + "intents": [ + { + "intent": "intent", + "confidence": 0.0 + } + ], + "entities": [ + { + "entity": "entity", + "location": [ + 1, + 2 + ], + "value": "value", + "confidence": 0.0, + "metadata": { + "key": "value" + }, + "groups": [ + { + "group": "group", + "location": [ + 1, + 2 + ] + } + ] + } + ], + "suggestion_id": "suggestion_id" + } + } + } + ], + "message_to_human_agent": "message", + "topic": "topic", + "suggestions": [ + { + "label": "label", + "value": { + "input": { + "message_type": "text", + "text": "text", + "options": { + "debug": true, + "restart": true, + "alternate_intents": true, + "return_context": true + }, + "intents": [ + { + "intent": "intent", + "confidence": 0.0 + } + ], + "entities": [ + { + "entity": "entity", + "location": [ + 1, + 2 + ], + "value": "value", + "confidence": 0.0, + "metadata": { + "key": "value" + }, + "groups": [ + { + "group": "group", + "location": [ + 1, + 2 + ] + } + ] + } + ], + "suggestion_id": "suggestion_id" + } + }, + "output": { + "key": "value" + } + } + ] + } + ], + "intents": [ + { + "intent": "intent", + "confidence": 0.0 + } + ], + "entities": [ + { + "entity": "entity", + "location": [ + 1, + 2 + ], + "value": "value", + "confidence": 0.0, + "metadata": { + "key": "value" + }, + "groups": [ + { + "group": "group", + "location": [ + 1, + 2 + ] + } + ] + } + ], + "actions": [ + { + "name": "name", + "type": "client", + "parameters": { + "key": "value" + }, + "result_variable": "result_variable", + "credentials": "credentials" + } + ], + "debug": { + "nodes_visited": [ + { + "dialog_node": "dialog_node", + "title": "title", + "conditions": "conditions" + } + ], + "log_messages": [ + { + "level": "info", + "message": "message" + } + ], + "branch_exited": true, + "branch_exited_reason": "completed" + } + } +} diff --git a/assistant/src/test/resources/assistant/session_response.json b/assistant/src/test/resources/assistant/session_response.json new file mode 100644 index 00000000000..af8c87828c8 --- /dev/null +++ b/assistant/src/test/resources/assistant/session_response.json @@ -0,0 +1,3 @@ +{ + "session_id": "session_id" +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index d7b881ab20c..00000000000 --- a/build.gradle +++ /dev/null @@ -1,158 +0,0 @@ -plugins { - id 'net.researchgate.release' version '2.4.0' - id 'me.champeau.gradle.japicmp' version '0.2.6' -} - -apply from: 'utils.gradle' -apply plugin: 'java' -apply plugin: 'checkstyle' -apply plugin: 'eclipse' -apply plugin: 'idea' - -import org.apache.tools.ant.filters.* - -archivesBaseName = 'parent' - -description = 'Client library to use the IBM Watson and Alchemy Services' - -javadoc { - source = 'src/main/java' -} - -checkstyle { - ignoreFailures = false -} - -checkstyleMain { - ignoreFailures = false -} - -checkstyleTest { - ignoreFailures = false -} - -task docs(type: Javadoc) { - destinationDir = file("$buildDir/docs/all") -} - -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' - - sourceCompatibility = JavaVersion.VERSION_1_7 - targetCompatibility = JavaVersion.VERSION_1_7 - - repositories { - mavenCentral() - } -} - -subprojects { - - dependencies { - testCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '3.8.0' - testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - testCompile group: 'com.google.guava', name: 'guava', version: '20.0' - 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 -} - -release { - tagTemplate = 'java-sdk-$version' -} - -task startmessage { - doLast { - println 'starting build' - } -} - -task printversion { - doLast { - println project.version - } -} - -task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask) { - ext.oldJarVersion = project.hasProperty('oldJarVersion') ? project.getProperty('oldJarVersion') : "pass-in-older-jar-version" - ext.newJarVersion = project.hasProperty('newJarVersion') ? project.getProperty('newJarVersion') : "pass-in-newer-jar-version" - ext.oldJarPath = project.hasProperty('oldJarPath') ? project.getProperty('oldJarPath') : "pass/in/path/to/older/version.jar" - ext.newJarPath = project.hasProperty('newJarPath') ? project.getProperty('newJarPath') : "pass/in/path/to/newer/version.jar" - - oldClasspath = files(oldJarPath) - newClasspath = files(newJarPath) - - onlyModified = true - failOnModification = true - - htmlOutputFile = file("$buildDir/reports/java-sdk-api-diff-" + oldJarVersion + "-to-" + newJarVersion + ".html") -} - -beforeReleaseBuild.dependsOn startmessage -afterReleaseBuild.dependsOn printversion 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 35af59655d6..f33535703fe 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -1,18 +1,21 @@ + "-//Puppy Crawl//DTD Check Configuration 1.3//EN" + "http://www.puppycrawl.com/dtds/configuration_1_3.dtd"> - + - - - +--> + + + + + + @@ -30,9 +33,6 @@ - - - @@ -43,11 +43,13 @@ - - - + + + + @@ -62,9 +64,6 @@ - - - @@ -73,23 +72,10 @@ - - - - - - - @@ -101,42 +87,32 @@ - - - - - - - - - - - - - - - - + + + + + + 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 new file mode 100644 index 00000000000..fe7aa1337e3 --- /dev/null +++ b/common/src/main/java/com/ibm/watson/common/SdkCommon.java @@ -0,0 +1,73 @@ +/* + * (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; +import java.util.Properties; +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 static String loadSdkVersion() { + ClassLoader classLoader = SdkCommon.class.getClassLoader(); + InputStream inputStream = classLoader.getResourceAsStream("java-sdk-version.properties"); + Properties properties = new Properties(); + + try { + properties.load(inputStream); + } catch (Exception e) { + LOG.log(Level.WARNING, "Could not load java-sdk-version.properties", e); + } + + return properties.getProperty("version", "unknown-version"); + } + + private static String getUserAgent() { + if (userAgent == null) { + userAgent = "watson-apis-java-sdk/" + loadSdkVersion() + "; " + RequestUtils.getUserAgent(); + } + return userAgent; + } + + /** + * 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); + + headers.put(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS, sdkAnalyticsHeaderValue); + headers.put(HttpHeaders.USER_AGENT, getUserAgent()); + return headers; + } +} diff --git a/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java b/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java new file mode 100644 index 00000000000..352561f306e --- /dev/null +++ b/common/src/main/java/com/ibm/watson/common/WatsonHttpHeaders.java @@ -0,0 +1,25 @@ +/* + * (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"; + + /** Header containing analytics info. */ + String X_IBMCLOUD_SDK_ANALYTICS = "X-IBMCloud-SDK-Analytics"; + + /** Mark API calls as tests. */ + String X_WATSON_TEST = "X-Watson-Test"; +} diff --git a/common/src/main/resources/java-sdk-version.properties b/common/src/main/resources/java-sdk-version.properties new file mode 100644 index 00000000000..fd927a882ea --- /dev/null +++ b/common/src/main/resources/java-sdk-version.properties @@ -0,0 +1 @@ +version=@pom.version@ diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/RetryRunner.java b/common/src/test/java/com/ibm/watson/common/RetryRunner.java similarity index 88% rename from core/src/test/java/com/ibm/watson/developer_cloud/util/RetryRunner.java rename to common/src/test/java/com/ibm/watson/common/RetryRunner.java index 0dc776e8e52..bb6e734a080 100644 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/RetryRunner.java +++ b/common/src/test/java/com/ibm/watson/common/RetryRunner.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,11 +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.developer_cloud.util; +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; @@ -26,20 +27,13 @@ import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; -import com.ibm.watson.developer_cloud.service.exception.TooManyRequestsException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; - -/** - * 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; /** @@ -54,7 +48,6 @@ public RetryRunner(Class clazz) throws InitializationError { /* * (non-Javadoc) - * * @see org.junit.runners.ParentRunner#run(org.junit.runner.notification.RunNotifier) */ @Override @@ -75,7 +68,6 @@ public void run(final RunNotifier notifier) { /* * (non-Javadoc) - * * @see org.junit.runners.BlockJUnit4ClassRunner#runChild(org.junit.runners.model.FrameworkMethod, * org.junit.runner.notification.RunNotifier) */ @@ -104,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 new file mode 100644 index 00000000000..e328ebf9758 --- /dev/null +++ b/common/src/test/java/com/ibm/watson/common/SdkCommonTest.java @@ -0,0 +1,41 @@ +/* + * (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 static org.junit.Assert.assertTrue; + +import com.ibm.cloud.sdk.core.http.HttpHeaders; +import java.util.Map; +import org.junit.Test; + +/** 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); + + assertTrue(defaultHeaders.containsKey(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS)); + String analyticsHeaderValue = defaultHeaders.get(WatsonHttpHeaders.X_IBMCLOUD_SDK_ANALYTICS); + assertTrue(analyticsHeaderValue.contains(serviceName)); + assertTrue(analyticsHeaderValue.contains(serviceVersion)); + assertTrue(analyticsHeaderValue.contains(operationId)); + assertTrue(defaultHeaders.containsKey(HttpHeaders.USER_AGENT)); + assertTrue(defaultHeaders.get(HttpHeaders.USER_AGENT).startsWith("watson-apis-java-sdk/")); + } +} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/TestUtils.java b/common/src/test/java/com/ibm/watson/common/TestUtils.java similarity index 90% rename from core/src/test/java/com/ibm/watson/developer_cloud/util/TestUtils.java rename to common/src/test/java/com/ibm/watson/common/TestUtils.java index cae8b2b7848..493b0b014da 100644 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/TestUtils.java +++ b/common/src/test/java/com/ibm/watson/common/TestUtils.java @@ -1,5 +1,5 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. +/* + * (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,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.developer_cloud.util; +package com.ibm.watson.common; import java.beans.BeanInfo; import java.beans.Introspector; @@ -20,16 +20,14 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; - -import org.junit.Ignore; - import junit.framework.AssertionFailedError; +import org.junit.Ignore; -/** - * The Class TestUtils. - */ +/** The Class TestUtils. */ @Ignore public final class TestUtils { + /** Private constructor. */ + private TestUtils() {} /** * Test that a collection is not null or empty. @@ -51,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); } @@ -74,7 +73,7 @@ public static void assertNoExceptionsOnGetters(final Object obj) throws Exceptio if (readMethod != null) { try { - readMethod.invoke(obj, new Object[] { }); + readMethod.invoke(obj, new Object[] {}); } catch (final InvocationTargetException e) { final StringBuffer msg = new StringBuffer(); msg.append("Failure: " + propertyDescriptor.getName()); @@ -84,7 +83,6 @@ public static void assertNoExceptionsOnGetters(final Object obj) throws Exceptio } } } - } /** @@ -93,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"); @@ -104,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 @@ -113,7 +112,8 @@ public static void assertNotEmpty(final Collection objs) throws Exception { */ public static boolean streamContentEquals(InputStream s1, InputStream s2) throws IOException { try { - int b1, b2; + int b1; + int b2; do { // read while both stream contents are equal and s1 still has more bytes b1 = s1.read(); @@ -131,12 +131,4 @@ public static boolean streamContentEquals(InputStream s1, InputStream s2) throws } } } - - /** - * Private constructor. - */ - private TestUtils() { - - } - } diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/WaitFor.java b/common/src/test/java/com/ibm/watson/common/WaitFor.java similarity index 86% rename from core/src/test/java/com/ibm/watson/developer_cloud/util/WaitFor.java rename to common/src/test/java/com/ibm/watson/common/WaitFor.java index 4120bc59502..c2b3db5eab5 100644 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/WaitFor.java +++ b/common/src/test/java/com/ibm/watson/common/WaitFor.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,20 +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.developer_cloud.util; +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. @@ -32,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) { @@ -51,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/core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java b/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java old mode 100755 new mode 100644 similarity index 82% rename from core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java rename to common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java index 76a41c92c76..dede080d3f5 --- a/core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java +++ b/common/src/test/java/com/ibm/watson/common/WatsonServiceTest.java @@ -1,5 +1,5 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. +/* + * (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,10 +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. */ -package com.ibm.watson.developer_cloud; +package com.ibm.watson.common; 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; @@ -30,31 +31,20 @@ import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.Logger; - import org.slf4j.LoggerFactory; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -/** - * 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"; private static final String LOCAL_PROPERTIES = ".config.properties"; - /** The Constant PLACEHOLDER. */ - protected static final String PLACEHOLDER = "SERVICE_USERNAME"; - private static final Logger LOG = Logger.getLogger(WatsonServiceTest.class.getName()); /** 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(); @@ -68,9 +58,9 @@ public WatsonServiceTest() { * @return the default headers */ protected Map getDefaultHeaders() { - Map headers = new HashMap(); - headers.put(HttpHeaders.X_WATSON_LEARNING_OPT_OUT, String.valueOf(true)); - headers.put(HttpHeaders.X_WATSON_TEST, String.valueOf(true)); + Map headers = new HashMap<>(); + headers.put(WatsonHttpHeaders.X_WATSON_LEARNING_OPT_OUT, "1"); + headers.put(WatsonHttpHeaders.X_WATSON_TEST, "1"); return headers; } @@ -105,7 +95,6 @@ public static String getStringFromInputStream(InputStream is) { } return sb.toString(); - } /** The prop. */ @@ -124,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); } @@ -140,12 +131,9 @@ 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); @@ -197,32 +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 { } + public void setUp() throws Exception {} + + /** Fuzzy date checking. */ + private long tolerance = 5000; // 5 secs in ms /** - * Fuzzy date checking. + * return `true` if ldate before rdate within tolerance. + * + * @param ldate the ldate + * @param rdate the rdate + * @return true, if successful */ - - long tolerance = 5000; // 5 secs in ms - - /** return `true` if ldate before rdate within tolerance. */ 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 new file mode 100644 index 00000000000..74514906a26 --- /dev/null +++ b/common/src/test/java/com/ibm/watson/common/WatsonServiceUnitTest.java @@ -0,0 +1,101 @@ +/* + * (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; + +/** The Class WatsonServiceUnitTest. */ +public class WatsonServiceUnitTest extends WatsonServiceTest { + /** The Constant DELETE. */ + protected static final String DELETE = "DELETE"; + + /** The Constant GET. */ + protected static final String GET = "GET"; + + /** The Constant POST. */ + protected static final String POST = "POST"; + + /** The Constant PUT. */ + protected static final String PUT = "PUT"; + + private static final Gson GSON = GsonSingleton.getGson(); + + /** The server. */ + protected MockWebServer server; + + /** + * Setups and starts the mock server. + * + * @throws Exception the exception + */ + @Override + public void setUp() throws Exception { + server = new MockWebServer(); + server.start(); + } + + /** + * Tear down. + * + * @throws IOException Signals that an I/O exception has occurred. + */ + @After + public void tearDown() throws IOException { + server.shutdown(); + } + + /** + * Gets the mock web server url. + * + * @return the server url + */ + protected String getMockWebServerUrl() { + return StringUtils.chop(server.url("/").toString()); + } + + /** + * Create a MockResponse with JSON content type and the object serialized to JSON as body. + * + * @param body the body + * @return the mock response + */ + protected static MockResponse jsonResponse(Object 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/core/src/test/resources/logging.properties b/common/src/test/resources/logging.properties similarity index 83% rename from core/src/test/resources/logging.properties rename to common/src/test/resources/logging.properties index 9f2588b4385..602e1a4e93d 100644 --- a/core/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 +com.ibm.watson.common.util.level=WARNING \ No newline at end of file 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 index fa2aaa868de..e1b43a48eaa 100644 Binary files a/config.properties.enc and b/config.properties.enc differ diff --git a/conversation/README.md b/conversation/README.md deleted file mode 100644 index bf0fd9dfbd5..00000000000 --- a/conversation/README.md +++ /dev/null @@ -1,61 +0,0 @@ -# Conversation - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - conversation - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:conversation:6.1.0' -``` - -## Usage - -Use the [Conversation][conversation] service to identify intents, entities, and conduct conversations. - -```java -Conversation service = new Conversation("2018-02-16"); -service.setUsernameAndPassword("", ""); - -InputData input = new InputData.Builder("Hi").build(); -MessageOptions options = new MessageOptions.Builder(workspaceId) - .input(input) - .build(); -MessageResponse response = service.message(options).execute(); -System.out.println(response); -``` - -Moving from Node 1 to Node 2. - -```java -Context context = null; - -// first message -MessageOptions newMessageOptions = new MessageOptions.Builder() - .workspaceId("") - .input(new InputData.Builder("First message").build()) - .context(context) - .build(); - -MessageResponse response = service.message(newMessageOptions).execute(); - -// second message -newMessageOptions = new MessageOptions.Builder() - .workspaceId("") - .input(new InputData.Builder("Second message").build()) - .context(response.getContext()) // output context from the first message - .build(); - -response = service.message(newMessageOptions).execute(); - -System.out.println(response); -``` - -[conversation]: https://console.bluemix.net/docs/services/conversation/index.html diff --git a/conversation/build.gradle b/conversation/build.gradle deleted file mode 100644 index b0524486884..00000000000 --- a/conversation/build.gradle +++ /dev/null @@ -1,112 +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' - -task javadocJar(type: Jar) { - classifier = 'javadoc' - from javadoc -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'conversation' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Conversation Service' - url 'https://console.bluemix.net/docs/services/conversation/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/Conversation.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/Conversation.java deleted file mode 100644 index 4e4ed5b5208..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/Conversation.java +++ /dev/null @@ -1,1561 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CounterexampleCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode; -import com.ibm.watson.developer_cloud.conversation.v1.model.DialogNodeCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.Entity; -import com.ibm.watson.developer_cloud.conversation.v1.model.EntityCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.EntityExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.Example; -import com.ibm.watson.developer_cloud.conversation.v1.model.ExampleCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.Intent; -import com.ibm.watson.developer_cloud.conversation.v1.model.IntentCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.IntentExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListAllLogsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListCounterexamplesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListDialogNodesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListEntitiesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListExamplesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListIntentsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListLogsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListSynonymsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListValuesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.conversation.v1.model.Synonym; -import com.ibm.watson.developer_cloud.conversation.v1.model.SynonymCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.Value; -import com.ibm.watson.developer_cloud.conversation.v1.model.ValueCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.Workspace; -import com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceExport; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The IBM Watson™ Conversation service combines machine learning, natural language understanding, and integrated - * dialog tools to create conversation flows between your apps and your users. - * - * @version v1 - * @see Conversation - */ -public class Conversation extends WatsonService { - - private static final String SERVICE_NAME = "conversation"; - private static final String URL = "https://gateway.watsonplatform.net/conversation/api"; - - private String versionDate; - - /** - * Instantiates a new `Conversation`. - * - * @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 Conversation(String versionDate) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `Conversation` with username and password. - * - * @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 username the username - * @param password the password - */ - public Conversation(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `Conversation` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public Conversation(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * Get response to user input. - * - * Get a response to a user's input. - * - * There is no rate limit for this operation. - * - * @param messageOptions the {@link MessageOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link MessageResponse} - */ - public ServiceCall message(MessageOptions messageOptions) { - Validator.notNull(messageOptions, "messageOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "message" }; - String[] pathParameters = { messageOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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", GsonSingleton.getGson().toJsonTree(messageOptions.input())); - } - if (messageOptions.alternateIntents() != null) { - contentJson.addProperty("alternate_intents", messageOptions.alternateIntents()); - } - if (messageOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(messageOptions.context())); - } - if (messageOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(messageOptions.entities())); - } - if (messageOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(messageOptions.intents())); - } - if (messageOptions.output() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(messageOptions.output())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(MessageResponse.class)); - } - - /** - * Create 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**. - * - * @param createWorkspaceOptions the {@link CreateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall createWorkspace(CreateWorkspaceOptions createWorkspaceOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (createWorkspaceOptions != null) { - final JsonObject contentJson = new JsonObject(); - if (createWorkspaceOptions.name() != null) { - contentJson.addProperty("name", createWorkspaceOptions.name()); - } - if (createWorkspaceOptions.description() != null) { - contentJson.addProperty("description", createWorkspaceOptions.description()); - } - if (createWorkspaceOptions.language() != null) { - contentJson.addProperty("language", createWorkspaceOptions.language()); - } - if (createWorkspaceOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.intents())); - } - if (createWorkspaceOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.entities())); - } - if (createWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.dialogNodes())); - } - if (createWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions - .counterexamples())); - } - if (createWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createWorkspaceOptions.metadata())); - } - if (createWorkspaceOptions.learningOptOut() != null) { - contentJson.addProperty("learning_opt_out", createWorkspaceOptions.learningOptOut()); - } - builder.bodyJson(contentJson); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class)); - } - - /** - * Create 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**. - * - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall createWorkspace() { - return createWorkspace(null); - } - - /** - * Delete workspace. - * - * Delete a workspace from the service instance. - * - * This operation is limited to 30 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param deleteWorkspaceOptions the {@link DeleteWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteWorkspace(DeleteWorkspaceOptions deleteWorkspaceOptions) { - Validator.notNull(deleteWorkspaceOptions, "deleteWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { deleteWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getWorkspaceOptions the {@link GetWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link WorkspaceExport} - */ - public ServiceCall getWorkspace(GetWorkspaceOptions getWorkspaceOptions) { - Validator.notNull(getWorkspaceOptions, "getWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { getWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getWorkspaceOptions.export() != null) { - builder.query("export", String.valueOf(getWorkspaceOptions.export())); - } - if (getWorkspaceOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getWorkspaceOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceExport.class)); - } - - /** - * List workspaces. - * - * List the workspaces associated with a Conversation 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 response type of {@link WorkspaceCollection} - */ - public ServiceCall listWorkspaces(ListWorkspacesOptions listWorkspacesOptions) { - String[] pathSegments = { "v1/workspaces" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listWorkspacesOptions != null) { - 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", listWorkspacesOptions.sort()); - } - if (listWorkspacesOptions.cursor() != null) { - builder.query("cursor", listWorkspacesOptions.cursor()); - } - if (listWorkspacesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listWorkspacesOptions.includeAudit())); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(WorkspaceCollection.class)); - } - - /** - * List workspaces. - * - * List the workspaces associated with a Conversation service instance. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @return a {@link ServiceCall} with a response type of {@link WorkspaceCollection} - */ - public ServiceCall listWorkspaces() { - return listWorkspaces(null); - } - - /** - * Update 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**. - * - * @param updateWorkspaceOptions the {@link UpdateWorkspaceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Workspace} - */ - public ServiceCall updateWorkspace(UpdateWorkspaceOptions updateWorkspaceOptions) { - Validator.notNull(updateWorkspaceOptions, "updateWorkspaceOptions cannot be null"); - String[] pathSegments = { "v1/workspaces" }; - String[] pathParameters = { updateWorkspaceOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (updateWorkspaceOptions.append() != null) { - builder.query("append", String.valueOf(updateWorkspaceOptions.append())); - } - final JsonObject contentJson = new JsonObject(); - if (updateWorkspaceOptions.name() != null) { - contentJson.addProperty("name", updateWorkspaceOptions.name()); - } - if (updateWorkspaceOptions.description() != null) { - contentJson.addProperty("description", updateWorkspaceOptions.description()); - } - if (updateWorkspaceOptions.language() != null) { - contentJson.addProperty("language", updateWorkspaceOptions.language()); - } - if (updateWorkspaceOptions.intents() != null) { - contentJson.add("intents", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.intents())); - } - if (updateWorkspaceOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.entities())); - } - if (updateWorkspaceOptions.dialogNodes() != null) { - contentJson.add("dialog_nodes", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.dialogNodes())); - } - if (updateWorkspaceOptions.counterexamples() != null) { - contentJson.add("counterexamples", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.counterexamples())); - } - if (updateWorkspaceOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateWorkspaceOptions.metadata())); - } - if (updateWorkspaceOptions.learningOptOut() != null) { - contentJson.addProperty("learning_opt_out", updateWorkspaceOptions.learningOptOut()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Workspace.class)); - } - - /** - * Create intent. - * - * Create a new intent. - * - * 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} - */ - public ServiceCall createIntent(CreateIntentOptions createIntentOptions) { - Validator.notNull(createIntentOptions, "createIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { createIntentOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("intent", createIntentOptions.intent()); - if (createIntentOptions.description() != null) { - contentJson.addProperty("description", createIntentOptions.description()); - } - if (createIntentOptions.examples() != null) { - contentJson.add("examples", GsonSingleton.getGson().toJsonTree(createIntentOptions.examples())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class)); - } - - /** - * Delete intent. - * - * Delete an intent from a workspace. - * - * This operation is limited to 2000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param deleteIntentOptions the {@link DeleteIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteIntent(DeleteIntentOptions deleteIntentOptions) { - Validator.notNull(deleteIntentOptions, "deleteIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { deleteIntentOptions.workspaceId(), deleteIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getIntentOptions the {@link GetIntentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentExport} - */ - public ServiceCall getIntent(GetIntentOptions getIntentOptions) { - Validator.notNull(getIntentOptions, "getIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { getIntentOptions.workspaceId(), getIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getIntentOptions.export() != null) { - builder.query("export", String.valueOf(getIntentOptions.export())); - } - if (getIntentOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getIntentOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentExport.class)); - } - - /** - * 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**. - * - * @param listIntentsOptions the {@link ListIntentsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link IntentCollection} - */ - public ServiceCall listIntents(ListIntentsOptions listIntentsOptions) { - Validator.notNull(listIntentsOptions, "listIntentsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { listIntentsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listIntentsOptions.cursor() != null) { - builder.query("cursor", listIntentsOptions.cursor()); - } - if (listIntentsOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listIntentsOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IntentCollection.class)); - } - - /** - * Update intent. - * - * Update an existing intent with new or modified data. You must provide component objects defining the content of the - * updated intent. - * - * 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} - */ - public ServiceCall updateIntent(UpdateIntentOptions updateIntentOptions) { - Validator.notNull(updateIntentOptions, "updateIntentOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "intents" }; - String[] pathParameters = { updateIntentOptions.workspaceId(), updateIntentOptions.intent() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateIntentOptions.newIntent() != null) { - contentJson.addProperty("intent", updateIntentOptions.newIntent()); - } - if (updateIntentOptions.newExamples() != null) { - contentJson.add("examples", GsonSingleton.getGson().toJsonTree(updateIntentOptions.newExamples())); - } - if (updateIntentOptions.newDescription() != null) { - contentJson.addProperty("description", updateIntentOptions.newDescription()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Intent.class)); - } - - /** - * Create user input example. - * - * 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**. - * - * @param createExampleOptions the {@link CreateExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} - */ - public ServiceCall createExample(CreateExampleOptions createExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", createExampleOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * 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**. - * - * @param deleteExampleOptions the {@link DeleteExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteExample(DeleteExampleOptions deleteExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getExampleOptions the {@link GetExampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Example} - */ - public ServiceCall getExample(GetExampleOptions getExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getExampleOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getExampleOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * List user input examples. - * - * List the user input examples for an intent. - * - * This operation is limited to 2500 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param listExamplesOptions the {@link ListExamplesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ExampleCollection} - */ - public ServiceCall listExamples(ListExamplesOptions listExamplesOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listExamplesOptions.cursor() != null) { - builder.query("cursor", listExamplesOptions.cursor()); - } - if (listExamplesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listExamplesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ExampleCollection.class)); - } - - /** - * Update user input example. - * - * Update the text of a user input example. - * - * 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} - */ - public ServiceCall updateExample(UpdateExampleOptions updateExampleOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateExampleOptions.newText() != null) { - contentJson.addProperty("text", updateExampleOptions.newText()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Example.class)); - } - - /** - * Create counterexample. - * - * 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**. - * - * @param createCounterexampleOptions the {@link CreateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall createCounterexample(CreateCounterexampleOptions createCounterexampleOptions) { - Validator.notNull(createCounterexampleOptions, "createCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { createCounterexampleOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", createCounterexampleOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * 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**. - * - * @param deleteCounterexampleOptions the {@link DeleteCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteCounterexample(DeleteCounterexampleOptions deleteCounterexampleOptions) { - Validator.notNull(deleteCounterexampleOptions, "deleteCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { deleteCounterexampleOptions.workspaceId(), deleteCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getCounterexampleOptions the {@link GetCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall getCounterexample(GetCounterexampleOptions getCounterexampleOptions) { - Validator.notNull(getCounterexampleOptions, "getCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { getCounterexampleOptions.workspaceId(), getCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getCounterexampleOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getCounterexampleOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * List counterexamples. - * - * 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} - */ - public ServiceCall listCounterexamples( - ListCounterexamplesOptions listCounterexamplesOptions) { - Validator.notNull(listCounterexamplesOptions, "listCounterexamplesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { listCounterexamplesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listCounterexamplesOptions.cursor() != null) { - builder.query("cursor", listCounterexamplesOptions.cursor()); - } - if (listCounterexamplesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listCounterexamplesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(CounterexampleCollection.class)); - } - - /** - * Update counterexample. - * - * Update the text of a counterexample. 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**. - * - * @param updateCounterexampleOptions the {@link UpdateCounterexampleOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Counterexample} - */ - public ServiceCall updateCounterexample(UpdateCounterexampleOptions updateCounterexampleOptions) { - Validator.notNull(updateCounterexampleOptions, "updateCounterexampleOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "counterexamples" }; - String[] pathParameters = { updateCounterexampleOptions.workspaceId(), updateCounterexampleOptions.text() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateCounterexampleOptions.newText() != null) { - contentJson.addProperty("text", updateCounterexampleOptions.newText()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Counterexample.class)); - } - - /** - * Create entity. - * - * Create a new entity. - * - * 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} - */ - public ServiceCall createEntity(CreateEntityOptions createEntityOptions) { - Validator.notNull(createEntityOptions, "createEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { createEntityOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("entity", createEntityOptions.entity()); - if (createEntityOptions.description() != null) { - contentJson.addProperty("description", createEntityOptions.description()); - } - if (createEntityOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createEntityOptions.metadata())); - } - if (createEntityOptions.values() != null) { - contentJson.add("values", GsonSingleton.getGson().toJsonTree(createEntityOptions.values())); - } - if (createEntityOptions.fuzzyMatch() != null) { - contentJson.addProperty("fuzzy_match", createEntityOptions.fuzzyMatch()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class)); - } - - /** - * Delete entity. - * - * Delete an entity from a workspace. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param deleteEntityOptions the {@link DeleteEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteEntity(DeleteEntityOptions deleteEntityOptions) { - Validator.notNull(deleteEntityOptions, "deleteEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { deleteEntityOptions.workspaceId(), deleteEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getEntityOptions the {@link GetEntityOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityExport} - */ - public ServiceCall getEntity(GetEntityOptions getEntityOptions) { - Validator.notNull(getEntityOptions, "getEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { getEntityOptions.workspaceId(), getEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getEntityOptions.export() != null) { - builder.query("export", String.valueOf(getEntityOptions.export())); - } - if (getEntityOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getEntityOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(EntityExport.class)); - } - - /** - * 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**. - * - * @param listEntitiesOptions the {@link ListEntitiesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link EntityCollection} - */ - public ServiceCall listEntities(ListEntitiesOptions listEntitiesOptions) { - Validator.notNull(listEntitiesOptions, "listEntitiesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { listEntitiesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listEntitiesOptions.cursor() != null) { - builder.query("cursor", listEntitiesOptions.cursor()); - } - if (listEntitiesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listEntitiesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(EntityCollection.class)); - } - - /** - * Update entity. - * - * Update an existing entity with new or modified data. You must provide component objects defining the content of the - * updated entity. - * - * 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} - */ - public ServiceCall updateEntity(UpdateEntityOptions updateEntityOptions) { - Validator.notNull(updateEntityOptions, "updateEntityOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "entities" }; - String[] pathParameters = { updateEntityOptions.workspaceId(), updateEntityOptions.entity() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateEntityOptions.newFuzzyMatch() != null) { - contentJson.addProperty("fuzzy_match", updateEntityOptions.newFuzzyMatch()); - } - if (updateEntityOptions.newEntity() != null) { - contentJson.addProperty("entity", updateEntityOptions.newEntity()); - } - if (updateEntityOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newMetadata())); - } - if (updateEntityOptions.newValues() != null) { - contentJson.add("values", GsonSingleton.getGson().toJsonTree(updateEntityOptions.newValues())); - } - if (updateEntityOptions.newDescription() != null) { - contentJson.addProperty("description", updateEntityOptions.newDescription()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Entity.class)); - } - - /** - * Add entity value. - * - * Create a new value for an entity. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param createValueOptions the {@link CreateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} - */ - public ServiceCall createValue(CreateValueOptions createValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("value", createValueOptions.value()); - if (createValueOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createValueOptions.metadata())); - } - if (createValueOptions.synonyms() != null) { - contentJson.add("synonyms", GsonSingleton.getGson().toJsonTree(createValueOptions.synonyms())); - } - if (createValueOptions.patterns() != null) { - contentJson.add("patterns", GsonSingleton.getGson().toJsonTree(createValueOptions.patterns())); - } - if (createValueOptions.valueType() != null) { - contentJson.addProperty("type", createValueOptions.valueType()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Value.class)); - } - - /** - * 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**. - * - * @param deleteValueOptions the {@link DeleteValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteValue(DeleteValueOptions deleteValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getValueOptions the {@link GetValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueExport} - */ - public ServiceCall getValue(GetValueOptions getValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getValueOptions.export() != null) { - builder.query("export", String.valueOf(getValueOptions.export())); - } - if (getValueOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getValueOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ValueExport.class)); - } - - /** - * 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**. - * - * @param listValuesOptions the {@link ListValuesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link ValueCollection} - */ - public ServiceCall listValues(ListValuesOptions listValuesOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listValuesOptions.cursor() != null) { - builder.query("cursor", listValuesOptions.cursor()); - } - if (listValuesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listValuesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ValueCollection.class)); - } - - /** - * 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. - * - * This operation is limited to 1000 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param updateValueOptions the {@link UpdateValueOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Value} - */ - public ServiceCall updateValue(UpdateValueOptions updateValueOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateValueOptions.newSynonyms() != null) { - contentJson.add("synonyms", GsonSingleton.getGson().toJsonTree(updateValueOptions.newSynonyms())); - } - if (updateValueOptions.valueType() != null) { - contentJson.addProperty("type", updateValueOptions.valueType()); - } - if (updateValueOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateValueOptions.newMetadata())); - } - if (updateValueOptions.newPatterns() != null) { - contentJson.add("patterns", GsonSingleton.getGson().toJsonTree(updateValueOptions.newPatterns())); - } - if (updateValueOptions.newValue() != null) { - contentJson.addProperty("value", updateValueOptions.newValue()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Value.class)); - } - - /** - * Add entity value synonym. - * - * Add a new synonym to an entity value. - * - * 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} - */ - public ServiceCall createSynonym(CreateSynonymOptions createSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("synonym", createSynonymOptions.synonym()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * 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**. - * - * @param deleteSynonymOptions the {@link DeleteSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteSynonym(DeleteSynonymOptions deleteSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getSynonymOptions the {@link GetSynonymOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Synonym} - */ - public ServiceCall getSynonym(GetSynonymOptions getSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getSynonymOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getSynonymOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * 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**. - * - * @param listSynonymsOptions the {@link ListSynonymsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SynonymCollection} - */ - public ServiceCall listSynonyms(ListSynonymsOptions listSynonymsOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listSynonymsOptions.cursor() != null) { - builder.query("cursor", listSynonymsOptions.cursor()); - } - if (listSynonymsOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listSynonymsOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SynonymCollection.class)); - } - - /** - * Update entity value synonym. - * - * Update an existing entity value synonym with new text. - * - * 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} - */ - public ServiceCall updateSynonym(UpdateSynonymOptions updateSynonymOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateSynonymOptions.newSynonym() != null) { - contentJson.addProperty("synonym", updateSynonymOptions.newSynonym()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Synonym.class)); - } - - /** - * Create dialog node. - * - * Create a new dialog node. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param createDialogNodeOptions the {@link CreateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall createDialogNode(CreateDialogNodeOptions createDialogNodeOptions) { - Validator.notNull(createDialogNodeOptions, "createDialogNodeOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { createDialogNodeOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("dialog_node", createDialogNodeOptions.dialogNode()); - if (createDialogNodeOptions.description() != null) { - contentJson.addProperty("description", createDialogNodeOptions.description()); - } - if (createDialogNodeOptions.conditions() != null) { - contentJson.addProperty("conditions", createDialogNodeOptions.conditions()); - } - if (createDialogNodeOptions.parent() != null) { - contentJson.addProperty("parent", createDialogNodeOptions.parent()); - } - if (createDialogNodeOptions.previousSibling() != null) { - contentJson.addProperty("previous_sibling", createDialogNodeOptions.previousSibling()); - } - if (createDialogNodeOptions.output() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.output())); - } - if (createDialogNodeOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.context())); - } - if (createDialogNodeOptions.metadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.metadata())); - } - if (createDialogNodeOptions.nextStep() != null) { - contentJson.add("next_step", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.nextStep())); - } - if (createDialogNodeOptions.actions() != null) { - contentJson.add("actions", GsonSingleton.getGson().toJsonTree(createDialogNodeOptions.actions())); - } - if (createDialogNodeOptions.title() != null) { - contentJson.addProperty("title", createDialogNodeOptions.title()); - } - if (createDialogNodeOptions.nodeType() != null) { - contentJson.addProperty("type", createDialogNodeOptions.nodeType()); - } - if (createDialogNodeOptions.eventName() != null) { - contentJson.addProperty("event_name", createDialogNodeOptions.eventName()); - } - if (createDialogNodeOptions.variable() != null) { - contentJson.addProperty("variable", createDialogNodeOptions.variable()); - } - if (createDialogNodeOptions.digressIn() != null) { - contentJson.addProperty("digress_in", createDialogNodeOptions.digressIn()); - } - if (createDialogNodeOptions.digressOut() != null) { - contentJson.addProperty("digress_out", createDialogNodeOptions.digressOut()); - } - if (createDialogNodeOptions.digressOutSlots() != null) { - contentJson.addProperty("digress_out_slots", createDialogNodeOptions.digressOutSlots()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * 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**. - * - * @param deleteDialogNodeOptions the {@link DeleteDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteDialogNode(DeleteDialogNodeOptions deleteDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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**. - * - * @param getDialogNodeOptions the {@link GetDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall getDialogNode(GetDialogNodeOptions getDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (getDialogNodeOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(getDialogNodeOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * 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**. - * - * @param listDialogNodesOptions the {@link ListDialogNodesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNodeCollection} - */ - public ServiceCall listDialogNodes(ListDialogNodesOptions listDialogNodesOptions) { - Validator.notNull(listDialogNodesOptions, "listDialogNodesOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "dialog_nodes" }; - String[] pathParameters = { listDialogNodesOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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()); - } - if (listDialogNodesOptions.cursor() != null) { - builder.query("cursor", listDialogNodesOptions.cursor()); - } - if (listDialogNodesOptions.includeAudit() != null) { - builder.query("include_audit", String.valueOf(listDialogNodesOptions.includeAudit())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNodeCollection.class)); - } - - /** - * Update dialog node. - * - * Update an existing dialog node with new or modified data. - * - * This operation is limited to 500 requests per 30 minutes. For more information, see **Rate limiting**. - * - * @param updateDialogNodeOptions the {@link UpdateDialogNodeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DialogNode} - */ - public ServiceCall updateDialogNode(UpdateDialogNodeOptions updateDialogNodeOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateDialogNodeOptions.nodeType() != null) { - contentJson.addProperty("type", updateDialogNodeOptions.nodeType()); - } - if (updateDialogNodeOptions.newActions() != null) { - contentJson.add("actions", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newActions())); - } - if (updateDialogNodeOptions.newConditions() != null) { - contentJson.addProperty("conditions", updateDialogNodeOptions.newConditions()); - } - if (updateDialogNodeOptions.newContext() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newContext())); - } - if (updateDialogNodeOptions.newPreviousSibling() != null) { - contentJson.addProperty("previous_sibling", updateDialogNodeOptions.newPreviousSibling()); - } - if (updateDialogNodeOptions.newVariable() != null) { - contentJson.addProperty("variable", updateDialogNodeOptions.newVariable()); - } - if (updateDialogNodeOptions.newMetadata() != null) { - contentJson.add("metadata", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newMetadata())); - } - if (updateDialogNodeOptions.newTitle() != null) { - contentJson.addProperty("title", updateDialogNodeOptions.newTitle()); - } - if (updateDialogNodeOptions.newDescription() != null) { - contentJson.addProperty("description", updateDialogNodeOptions.newDescription()); - } - if (updateDialogNodeOptions.newDigressOut() != null) { - contentJson.addProperty("digress_out", updateDialogNodeOptions.newDigressOut()); - } - if (updateDialogNodeOptions.newEventName() != null) { - contentJson.addProperty("event_name", updateDialogNodeOptions.newEventName()); - } - if (updateDialogNodeOptions.newDigressOutSlots() != null) { - contentJson.addProperty("digress_out_slots", updateDialogNodeOptions.newDigressOutSlots()); - } - if (updateDialogNodeOptions.newNextStep() != null) { - contentJson.add("next_step", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newNextStep())); - } - if (updateDialogNodeOptions.newDigressIn() != null) { - contentJson.addProperty("digress_in", updateDialogNodeOptions.newDigressIn()); - } - if (updateDialogNodeOptions.newOutput() != null) { - contentJson.add("output", GsonSingleton.getGson().toJsonTree(updateDialogNodeOptions.newOutput())); - } - if (updateDialogNodeOptions.newParent() != null) { - contentJson.addProperty("parent", updateDialogNodeOptions.newParent()); - } - if (updateDialogNodeOptions.newDialogNode() != null) { - contentJson.addProperty("dialog_node", updateDialogNodeOptions.newDialogNode()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DialogNode.class)); - } - - /** - * List log events in all workspaces. - * - * 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**. - * - * @param listAllLogsOptions the {@link ListAllLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} - */ - public ServiceCall listAllLogs(ListAllLogsOptions listAllLogsOptions) { - Validator.notNull(listAllLogsOptions, "listAllLogsOptions cannot be null"); - String[] pathSegments = { "v1/logs" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("filter", listAllLogsOptions.filter()); - if (listAllLogsOptions.sort() != null) { - builder.query("sort", listAllLogsOptions.sort()); - } - if (listAllLogsOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listAllLogsOptions.pageLimit())); - } - if (listAllLogsOptions.cursor() != null) { - builder.query("cursor", listAllLogsOptions.cursor()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class)); - } - - /** - * List log events in a workspace. - * - * List the events from the log of a specific workspace. - * - * 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**. - * - * @param listLogsOptions the {@link ListLogsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LogCollection} - */ - public ServiceCall listLogs(ListLogsOptions listLogsOptions) { - Validator.notNull(listLogsOptions, "listLogsOptions cannot be null"); - String[] pathSegments = { "v1/workspaces", "logs" }; - String[] pathParameters = { listLogsOptions.workspaceId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (listLogsOptions.sort() != null) { - builder.query("sort", listLogsOptions.sort()); - } - if (listLogsOptions.filter() != null) { - builder.query("filter", listLogsOptions.filter()); - } - if (listLogsOptions.pageLimit() != null) { - builder.query("page_limit", String.valueOf(listLogsOptions.pageLimit())); - } - if (listLogsOptions.cursor() != null) { - builder.query("cursor", listLogsOptions.cursor()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LogCollection.class)); - } - - /** - * 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://console.bluemix.net/docs/services/conversation/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CaptureGroup.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CaptureGroup.java deleted file mode 100644 index 0caf64746fa..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CaptureGroup.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CaptureGroup. - */ -public class CaptureGroup extends GenericModel { - - private String group; - private List location; - - /** - * Gets the group. - * - * A recognized capture group for the entity. - * - * @return the group - */ - public String getGroup() { - return group; - } - - /** - * Gets the location. - * - * Zero-based character offsets that indicate where the entity value begins and ends in the input text. - * - * @return the location - */ - public List getLocation() { - return location; - } - - /** - * Sets the group. - * - * @param group the new group - */ - public void setGroup(final String group) { - this.group = group; - } - - /** - * Sets the location. - * - * @param location the new location - */ - public void setLocation(final List location) { - this.location = location; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Context.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Context.java deleted file mode 100644 index d65245af84a..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Context.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * State information for the conversation. To maintain state, include the context from the previous response. - */ -public class Context extends DynamicModel { - private Type conversationIdType = new TypeToken() { - }.getType(); - private Type systemType = new TypeToken() { - }.getType(); - - /** - * Gets the conversationId. - * - * @return the conversationId - */ - public String getConversationId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("conversation_id"), conversationIdType); - } - - /** - * Gets the system. - * - * @return the system - */ - public SystemResponse getSystem() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("system"), systemType); - } - - /** - * Sets the conversationId. - * - * @param conversationId the new conversationId - */ - public void setConversationId(final String conversationId) { - this.put("conversation_id", conversationId); - } - - /** - * Sets the system. - * - * @param system the new system - */ - public void setSystem(final SystemResponse system) { - this.put("system", system); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Counterexample.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Counterexample.java deleted file mode 100644 index db3a8c88719..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Counterexample.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Counterexample. - */ -public class Counterexample extends GenericModel { - - private String text; - private Date created; - private Date updated; - - /** - * Gets the text. - * - * The text of the counterexample. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the created. - * - * The timestamp for creation of the counterexample. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the counterexample. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CounterexampleCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CounterexampleCollection.java deleted file mode 100644 index b60fe853420..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CounterexampleCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CounterexampleCollection. - */ -public class CounterexampleCollection extends GenericModel { - - private List counterexamples; - private Pagination pagination; - - /** - * Gets the counterexamples. - * - * An array of objects describing the examples marked as irrelevant input. - * - * @return the counterexamples - */ - public List getCounterexamples() { - return counterexamples; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexample.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexample.java deleted file mode 100644 index 776b20aaef1..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexample.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateCounterexample. - */ -public class CreateCounterexample extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(CreateCounterexample createCounterexample) { - text = createCounterexample.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 CreateCounterexample. - * - * @return the createCounterexample - */ - public CreateCounterexample build() { - return new CreateCounterexample(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateCounterexample builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateCounterexample(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateCounterexample builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexampleOptions.java deleted file mode 100644 index 1300b6f4885..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateCounterexampleOptions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createCounterexample options. - */ -public class CreateCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - - private Builder(CreateCounterexampleOptions createCounterexampleOptions) { - workspaceId = createCounterexampleOptions.workspaceId; - text = createCounterexampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a CreateCounterexampleOptions. - * - * @return the createCounterexampleOptions - */ - public CreateCounterexampleOptions build() { - return new CreateCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.text, "text cannot be null"); - workspaceId = builder.workspaceId; - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateCounterexampleOptions 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 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 - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNode.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNode.java deleted file mode 100644 index 7512dfbdd09..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNode.java +++ /dev/null @@ -1,625 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateDialogNode. - */ -public class CreateDialogNode extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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") - private String dialogNode; - private String description; - private String conditions; - private String parent; - @SerializedName("previous_sibling") - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - @SerializedName("next_step") - private DialogNodeNextStep nextStep; - private List actions; - private String title; - @SerializedName("type") - private String nodeType; - @SerializedName("event_name") - private String eventName; - private String variable; - @SerializedName("digress_in") - private String digressIn; - @SerializedName("digress_out") - private String digressOut; - @SerializedName("digress_out_slots") - private String digressOutSlots; - - /** - * Builder. - */ - public static class Builder { - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - private Builder(CreateDialogNode createDialogNode) { - dialogNode = createDialogNode.dialogNode; - description = createDialogNode.description; - conditions = createDialogNode.conditions; - parent = createDialogNode.parent; - previousSibling = createDialogNode.previousSibling; - output = createDialogNode.output; - context = createDialogNode.context; - metadata = createDialogNode.metadata; - nextStep = createDialogNode.nextStep; - actions = createDialogNode.actions; - title = createDialogNode.title; - nodeType = createDialogNode.nodeType; - eventName = createDialogNode.eventName; - variable = createDialogNode.variable; - digressIn = createDialogNode.digressIn; - digressOut = createDialogNode.digressOut; - digressOutSlots = createDialogNode.digressOutSlots; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param dialogNode the dialogNode - */ - public Builder(String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Builds a CreateDialogNode. - * - * @return the createDialogNode - */ - public CreateDialogNode build() { - return new CreateDialogNode(this); - } - - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the CreateDialogNode builder - */ - public Builder addActions(DialogNodeAction actions) { - 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 CreateDialogNode builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateDialogNode builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conditions. - * - * @param conditions the conditions - * @return the CreateDialogNode builder - */ - public Builder conditions(String conditions) { - this.conditions = conditions; - return this; - } - - /** - * Set the parent. - * - * @param parent the parent - * @return the CreateDialogNode builder - */ - public Builder parent(String parent) { - this.parent = parent; - return this; - } - - /** - * Set the previousSibling. - * - * @param previousSibling the previousSibling - * @return the CreateDialogNode builder - */ - public Builder previousSibling(String previousSibling) { - this.previousSibling = previousSibling; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the CreateDialogNode builder - */ - public Builder output(Map output) { - this.output = output; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the CreateDialogNode builder - */ - public Builder context(Map context) { - this.context = context; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateDialogNode builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the nextStep. - * - * @param nextStep the nextStep - * @return the CreateDialogNode builder - */ - public Builder nextStep(DialogNodeNextStep nextStep) { - this.nextStep = nextStep; - return this; - } - - /** - * Set the actions. - * Existing actions will be replaced. - * - * @param actions the actions - * @return the CreateDialogNode builder - */ - public Builder actions(List actions) { - this.actions = actions; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the CreateDialogNode builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the CreateDialogNode builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the eventName. - * - * @param eventName the eventName - * @return the CreateDialogNode builder - */ - public Builder eventName(String eventName) { - this.eventName = eventName; - return this; - } - - /** - * Set the variable. - * - * @param variable the variable - * @return the CreateDialogNode builder - */ - public Builder variable(String variable) { - this.variable = variable; - return this; - } - - /** - * Set the digressIn. - * - * @param digressIn the digressIn - * @return the CreateDialogNode builder - */ - public Builder digressIn(String digressIn) { - this.digressIn = digressIn; - return this; - } - - /** - * Set the digressOut. - * - * @param digressOut the digressOut - * @return the CreateDialogNode builder - */ - public Builder digressOut(String digressOut) { - this.digressOut = digressOut; - return this; - } - - /** - * Set the digressOutSlots. - * - * @param digressOutSlots the digressOutSlots - * @return the CreateDialogNode builder - */ - public Builder digressOutSlots(String digressOutSlots) { - this.digressOutSlots = digressOutSlots; - return this; - } - } - - private CreateDialogNode(Builder builder) { - Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); - 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; - actions = builder.actions; - title = builder.title; - nodeType = builder.nodeType; - eventName = builder.eventName; - variable = builder.variable; - digressIn = builder.digressIn; - digressOut = builder.digressOut; - digressOutSlots = builder.digressOutSlots; - } - - /** - * New builder. - * - * @return a CreateDialogNode builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It must be no longer than 1024 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, and it - * must be no longer than 128 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, and it must be no longer than 2048 characters. - * - * @return the conditions - */ - public String conditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. - * - * @return the parent - */ - public String parent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous dialog node. - * - * @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://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the output - */ - public Map output() { - return output; - } - - /** - * Gets the context. - * - * The context for the dialog node. - * - * @return the context - */ - public Map 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 be executed in dialog processing. - * - * @return the nextStep - */ - public DialogNodeNextStep nextStep() { - return nextStep; - } - - /** - * 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 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. - * - It must be no longer than 64 characters. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * 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 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; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNodeOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNodeOptions.java deleted file mode 100644 index 1a75bee47de..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateDialogNodeOptions.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createDialogNode options. - */ -public class CreateDialogNodeOptions extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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"; - } - - private String workspaceId; - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private String description; - private String conditions; - private String parent; - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - private DialogNodeNextStep nextStep; - private List actions; - private String title; - private String nodeType; - private String eventName; - private String variable; - private String digressIn; - private String digressOut; - private String digressOutSlots; - - private Builder(CreateDialogNodeOptions createDialogNodeOptions) { - workspaceId = createDialogNodeOptions.workspaceId; - dialogNode = createDialogNodeOptions.dialogNode; - description = createDialogNodeOptions.description; - conditions = createDialogNodeOptions.conditions; - parent = createDialogNodeOptions.parent; - previousSibling = createDialogNodeOptions.previousSibling; - output = createDialogNodeOptions.output; - context = createDialogNodeOptions.context; - metadata = createDialogNodeOptions.metadata; - nextStep = createDialogNodeOptions.nextStep; - actions = createDialogNodeOptions.actions; - title = createDialogNodeOptions.title; - nodeType = createDialogNodeOptions.nodeType; - eventName = createDialogNodeOptions.eventName; - variable = createDialogNodeOptions.variable; - digressIn = createDialogNodeOptions.digressIn; - digressOut = createDialogNodeOptions.digressOut; - digressOutSlots = createDialogNodeOptions.digressOutSlots; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a CreateDialogNodeOptions. - * - * @return the createDialogNodeOptions - */ - public CreateDialogNodeOptions build() { - return new CreateDialogNodeOptions(this); - } - - /** - * Adds an actions to actions. - * - * @param actions the new actions - * @return the CreateDialogNodeOptions builder - */ - public Builder addActions(DialogNodeAction actions) { - Validator.notNull(actions, "actions cannot be null"); - if (this.actions == null) { - this.actions = new ArrayList(); - } - this.actions.add(actions); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the CreateDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateDialogNodeOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the conditions. - * - * @param conditions the conditions - * @return the CreateDialogNodeOptions builder - */ - public Builder conditions(String conditions) { - this.conditions = conditions; - return this; - } - - /** - * Set the parent. - * - * @param parent the parent - * @return the CreateDialogNodeOptions builder - */ - public Builder parent(String parent) { - this.parent = parent; - return this; - } - - /** - * Set the previousSibling. - * - * @param previousSibling the previousSibling - * @return the CreateDialogNodeOptions builder - */ - public Builder previousSibling(String previousSibling) { - this.previousSibling = previousSibling; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the CreateDialogNodeOptions builder - */ - public Builder output(Map output) { - this.output = output; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the CreateDialogNodeOptions builder - */ - public Builder context(Map context) { - this.context = context; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateDialogNodeOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the nextStep. - * - * @param nextStep the nextStep - * @return the CreateDialogNodeOptions builder - */ - public Builder nextStep(DialogNodeNextStep nextStep) { - this.nextStep = nextStep; - return this; - } - - /** - * Set the actions. - * Existing actions will be replaced. - * - * @param actions the actions - * @return the CreateDialogNodeOptions builder - */ - public Builder actions(List actions) { - this.actions = actions; - return this; - } - - /** - * Set the title. - * - * @param title the title - * @return the CreateDialogNodeOptions builder - */ - public Builder title(String title) { - this.title = title; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the CreateDialogNodeOptions builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the eventName. - * - * @param eventName the eventName - * @return the CreateDialogNodeOptions builder - */ - public Builder eventName(String eventName) { - this.eventName = eventName; - return this; - } - - /** - * Set the variable. - * - * @param variable the variable - * @return the CreateDialogNodeOptions builder - */ - public Builder variable(String variable) { - this.variable = variable; - return this; - } - - /** - * Set the digressIn. - * - * @param digressIn the digressIn - * @return the CreateDialogNodeOptions builder - */ - public Builder digressIn(String digressIn) { - this.digressIn = digressIn; - return this; - } - - /** - * Set the digressOut. - * - * @param digressOut the digressOut - * @return the CreateDialogNodeOptions builder - */ - public Builder digressOut(String digressOut) { - this.digressOut = digressOut; - return this; - } - - /** - * Set the digressOutSlots. - * - * @param digressOutSlots the digressOutSlots - * @return the CreateDialogNodeOptions builder - */ - public Builder digressOutSlots(String digressOutSlots) { - this.digressOutSlots = digressOutSlots; - return this; - } - } - - private CreateDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.dialogNode, "dialogNode cannot be null"); - workspaceId = builder.workspaceId; - 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; - actions = builder.actions; - title = builder.title; - nodeType = builder.nodeType; - eventName = builder.eventName; - variable = builder.variable; - digressIn = builder.digressIn; - digressOut = builder.digressOut; - digressOutSlots = builder.digressOutSlots; - } - - /** - * New builder. - * - * @return a CreateDialogNodeOptions 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. This string must conform to the following restrictions: - * - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot characters. - * - It must be no longer than 1024 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, and it - * must be no longer than 128 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, and it must be no longer than 2048 characters. - * - * @return the conditions - */ - public String conditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. - * - * @return the parent - */ - public String parent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous dialog node. - * - * @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://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the output - */ - public Map output() { - return output; - } - - /** - * Gets the context. - * - * The context for the dialog node. - * - * @return the context - */ - public Map 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 be executed in dialog processing. - * - * @return the nextStep - */ - public DialogNodeNextStep nextStep() { - return nextStep; - } - - /** - * 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 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. - * - It must be no longer than 64 characters. - * - * @return the title - */ - public String title() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * 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 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; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntity.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntity.java deleted file mode 100644 index 0abc537e0a6..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntity.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateEntity. - */ -public class CreateEntity extends GenericModel { - - private String entity; - private String description; - private Map metadata; - private List values; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - - /** - * Builder. - */ - public static class Builder { - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - private Builder(CreateEntity createEntity) { - entity = createEntity.entity; - description = createEntity.description; - metadata = createEntity.metadata; - values = createEntity.values; - fuzzyMatch = createEntity.fuzzyMatch; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param entity the entity - */ - public Builder(String entity) { - this.entity = entity; - } - - /** - * Builds a CreateEntity. - * - * @return the createEntity - */ - public CreateEntity build() { - return new CreateEntity(this); - } - - /** - * Adds an value to values. - * - * @param value the new value - * @return the CreateEntity builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(value); - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateEntity builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateEntity builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateEntity builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. - * - * @param values the values - * @return the CreateEntity builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the fuzzyMatch. - * - * @param fuzzyMatch the fuzzyMatch - * @return the CreateEntity builder - */ - public Builder fuzzyMatch(Boolean fuzzyMatch) { - this.fuzzyMatch = fuzzyMatch; - return this; - } - } - - private CreateEntity(Builder builder) { - Validator.notNull(builder.entity, "entity cannot be null"); - entity = builder.entity; - description = builder.description; - metadata = builder.metadata; - values = builder.values; - fuzzyMatch = builder.fuzzyMatch; - } - - /** - * New builder. - * - * @return a CreateEntity builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It cannot begin with the reserved prefix `sys-`. - * - It must be no longer than 64 characters. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the description. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the values. - * - * An array of objects describing the entity values. - * - * @return the values - */ - public List values() { - return values; - } - - /** - * Gets the fuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the fuzzyMatch - */ - public Boolean fuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntityOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntityOptions.java deleted file mode 100644 index 6ee5002e28b..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateEntityOptions.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createEntity options. - */ -public class CreateEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String description; - private Map metadata; - private List values; - private Boolean fuzzyMatch; - - private Builder(CreateEntityOptions createEntityOptions) { - workspaceId = createEntityOptions.workspaceId; - entity = createEntityOptions.entity; - description = createEntityOptions.description; - metadata = createEntityOptions.metadata; - values = createEntityOptions.values; - fuzzyMatch = createEntityOptions.fuzzyMatch; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a CreateEntityOptions. - * - * @return the createEntityOptions - */ - public CreateEntityOptions build() { - return new CreateEntityOptions(this); - } - - /** - * Adds an value to values. - * - * @param value the new value - * @return the CreateEntityOptions builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.values == null) { - this.values = new ArrayList(); - } - this.values.add(value); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateEntityOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateEntityOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the values. - * Existing values will be replaced. - * - * @param values the values - * @return the CreateEntityOptions builder - */ - public Builder values(List values) { - this.values = values; - return this; - } - - /** - * Set the fuzzyMatch. - * - * @param fuzzyMatch the fuzzyMatch - * @return the CreateEntityOptions builder - */ - public Builder fuzzyMatch(Boolean fuzzyMatch) { - this.fuzzyMatch = fuzzyMatch; - return this; - } - } - - private CreateEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.entity, "entity cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - description = builder.description; - metadata = builder.metadata; - values = builder.values; - fuzzyMatch = builder.fuzzyMatch; - } - - /** - * New builder. - * - * @return a CreateEntityOptions 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 entity. - * - * 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-`. - * - It must be no longer than 64 characters. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the description. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the values. - * - * An array of objects describing the entity values. - * - * @return the values - */ - public List values() { - return values; - } - - /** - * Gets the fuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the fuzzyMatch - */ - public Boolean fuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExample.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExample.java deleted file mode 100644 index 27ab693d2fe..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExample.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateExample. - */ -public class CreateExample extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(CreateExample createExample) { - text = createExample.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 CreateExample. - * - * @return the createExample - */ - public CreateExample build() { - return new CreateExample(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateExample builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateExample(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateExample builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExampleOptions.java deleted file mode 100644 index 8a5f62a562c..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateExampleOptions.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createExample options. - */ -public class CreateExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - - private Builder(CreateExampleOptions createExampleOptions) { - workspaceId = createExampleOptions.workspaceId; - intent = createExampleOptions.intent; - text = createExampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a CreateExampleOptions. - * - * @return the createExampleOptions - */ - public CreateExampleOptions build() { - return new CreateExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the CreateExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private CreateExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notNull(builder.text, "text cannot be null"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - } - - /** - * New builder. - * - * @return a CreateExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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. - * - It must be no longer than 1024 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntent.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntent.java deleted file mode 100644 index 58a5b603314..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntent.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateIntent. - */ -public class CreateIntent extends GenericModel { - - private String intent; - private String description; - private List examples; - - /** - * Builder. - */ - public static class Builder { - private String intent; - private String description; - private List examples; - - private Builder(CreateIntent createIntent) { - intent = createIntent.intent; - description = createIntent.description; - examples = createIntent.examples; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param intent the intent - */ - public Builder(String intent) { - this.intent = intent; - } - - /** - * Builds a CreateIntent. - * - * @return the createIntent - */ - public CreateIntent build() { - return new CreateIntent(this); - } - - /** - * Adds an example to examples. - * - * @param example the new example - * @return the CreateIntent builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.examples == null) { - this.examples = new ArrayList(); - } - this.examples.add(example); - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateIntent builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateIntent builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. - * - * @param examples the examples - * @return the CreateIntent builder - */ - public Builder examples(List examples) { - this.examples = examples; - return this; - } - } - - private CreateIntent(Builder builder) { - Validator.notNull(builder.intent, "intent cannot be null"); - intent = builder.intent; - description = builder.description; - examples = builder.examples; - } - - /** - * New builder. - * - * @return a CreateIntent builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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-`. - * - It must be no longer than 128 characters. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the description. - * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the examples. - * - * An array of user input examples for the intent. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntentOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntentOptions.java deleted file mode 100644 index 05cac595f67..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateIntentOptions.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createIntent options. - */ -public class CreateIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String description; - private List examples; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String description; - private List examples; - - private Builder(CreateIntentOptions createIntentOptions) { - workspaceId = createIntentOptions.workspaceId; - intent = createIntentOptions.intent; - description = createIntentOptions.description; - examples = createIntentOptions.examples; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a CreateIntentOptions. - * - * @return the createIntentOptions - */ - public CreateIntentOptions build() { - return new CreateIntentOptions(this); - } - - /** - * Adds an example to examples. - * - * @param example the new example - * @return the CreateIntentOptions builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.examples == null) { - this.examples = new ArrayList(); - } - this.examples.add(example); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the CreateIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateIntentOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the examples. - * Existing examples will be replaced. - * - * @param examples the examples - * @return the CreateIntentOptions builder - */ - public Builder examples(List examples) { - this.examples = examples; - return this; - } - } - - private CreateIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notNull(builder.intent, "intent cannot be null"); - workspaceId = builder.workspaceId; - intent = builder.intent; - description = builder.description; - examples = builder.examples; - } - - /** - * New builder. - * - * @return a CreateIntentOptions 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 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-`. - * - It must be no longer than 128 characters. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the description. - * - * The description of the intent. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the description - */ - public String description() { - return description; - } - - /** - * Gets the examples. - * - * An array of user input examples for the intent. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateSynonymOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateSynonymOptions.java deleted file mode 100644 index 046199d347d..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateSynonymOptions.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createSynonym options. - */ -public class CreateSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - - private Builder(CreateSynonymOptions createSynonymOptions) { - workspaceId = createSynonymOptions.workspaceId; - entity = createSynonymOptions.entity; - value = createSynonymOptions.value; - synonym = createSynonymOptions.synonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a CreateSynonymOptions. - * - * @return the createSynonymOptions - */ - public CreateSynonymOptions build() { - return new CreateSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the CreateSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - } - - private CreateSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notNull(builder.synonym, "synonym cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - } - - /** - * New builder. - * - * @return a CreateSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValue.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValue.java deleted file mode 100644 index 5fbe65a4108..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValue.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * CreateValue. - */ -public class CreateValue extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String value; - private Map metadata; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Builder. - */ - public static class Builder { - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - private Builder(CreateValue createValue) { - value = createValue.value; - metadata = createValue.metadata; - synonyms = createValue.synonyms; - patterns = createValue.patterns; - valueType = createValue.valueType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param value the value - */ - public Builder(String value) { - this.value = value; - } - - /** - * Builds a CreateValue. - * - * @return the createValue - */ - public CreateValue build() { - return new CreateValue(this); - } - - /** - * Adds an synonym to synonyms. - * - * @param synonym the new synonym - * @return the CreateValue builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.synonyms == null) { - this.synonyms = new ArrayList(); - } - this.synonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to patterns. - * - * @param pattern the new pattern - * @return the CreateValue builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.patterns == null) { - this.patterns = new ArrayList(); - } - this.patterns.add(pattern); - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateValue builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateValue builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the synonyms. - * Existing synonyms will be replaced. - * - * @param synonyms the synonyms - * @return the CreateValue builder - */ - public Builder synonyms(List synonyms) { - this.synonyms = synonyms; - return this; - } - - /** - * Set the patterns. - * Existing patterns will be replaced. - * - * @param patterns the patterns - * @return the CreateValue builder - */ - public Builder patterns(List patterns) { - this.patterns = patterns; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the CreateValue builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - } - - private CreateValue(Builder builder) { - Validator.notNull(builder.value, "value cannot be null"); - value = builder.value; - metadata = builder.metadata; - synonyms = builder.synonyms; - patterns = builder.patterns; - valueType = builder.valueType; - } - - /** - * New builder. - * - * @return a CreateValue builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. You can provide either synonyms or patterns (as indicated by - * **type**), but not both. A synonym must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. - * - It must be no longer than 64 characters. - * - * @return the synonyms - */ - public List synonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the patterns - */ - public List patterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValueOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValueOptions.java deleted file mode 100644 index 90541dd6254..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateValueOptions.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createValue options. - */ -public class CreateValueOptions extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String workspaceId; - private String entity; - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private Map metadata; - private List synonyms; - private List patterns; - private String valueType; - - private Builder(CreateValueOptions createValueOptions) { - workspaceId = createValueOptions.workspaceId; - entity = createValueOptions.entity; - value = createValueOptions.value; - metadata = createValueOptions.metadata; - synonyms = createValueOptions.synonyms; - patterns = createValueOptions.patterns; - valueType = createValueOptions.valueType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a CreateValueOptions. - * - * @return the createValueOptions - */ - public CreateValueOptions build() { - return new CreateValueOptions(this); - } - - /** - * Adds an synonym to synonyms. - * - * @param synonym the new synonym - * @return the CreateValueOptions builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.synonyms == null) { - this.synonyms = new ArrayList(); - } - this.synonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to patterns. - * - * @param pattern the new pattern - * @return the CreateValueOptions builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.patterns == null) { - this.patterns = new ArrayList(); - } - this.patterns.add(pattern); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the CreateValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the CreateValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the CreateValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateValueOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the synonyms. - * Existing synonyms will be replaced. - * - * @param synonyms the synonyms - * @return the CreateValueOptions builder - */ - public Builder synonyms(List synonyms) { - this.synonyms = synonyms; - return this; - } - - /** - * Set the patterns. - * Existing patterns will be replaced. - * - * @param patterns the patterns - * @return the CreateValueOptions builder - */ - public Builder patterns(List patterns) { - this.patterns = patterns; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the CreateValueOptions builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - } - - private CreateValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notNull(builder.value, "value cannot be null"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - metadata = builder.metadata; - synonyms = builder.synonyms; - patterns = builder.patterns; - valueType = builder.valueType; - } - - /** - * New builder. - * - * @return a CreateValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map metadata() { - return metadata; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. You can provide either synonyms or patterns (as indicated by - * **type**), but not both. A synonym must conform to the following restrictions: - * - It cannot contain carriage return, newline, or tab characters. - * - It cannot consist of only whitespace characters. - * - It must be no longer than 64 characters. - * - * @return the synonyms - */ - public List synonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the patterns - */ - public List patterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateWorkspaceOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateWorkspaceOptions.java deleted file mode 100644 index 379d4537026..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/CreateWorkspaceOptions.java +++ /dev/null @@ -1,364 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createWorkspace options. - */ -public class CreateWorkspaceOptions extends GenericModel { - - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - - private Builder(CreateWorkspaceOptions createWorkspaceOptions) { - name = createWorkspaceOptions.name; - description = createWorkspaceOptions.description; - language = createWorkspaceOptions.language; - intents = createWorkspaceOptions.intents; - entities = createWorkspaceOptions.entities; - dialogNodes = createWorkspaceOptions.dialogNodes; - counterexamples = createWorkspaceOptions.counterexamples; - metadata = createWorkspaceOptions.metadata; - learningOptOut = createWorkspaceOptions.learningOptOut; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CreateWorkspaceOptions. - * - * @return the createWorkspaceOptions - */ - public CreateWorkspaceOptions build() { - return new CreateWorkspaceOptions(this); - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the CreateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the CreateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an dialogNode to dialogNodes. - * - * @param dialogNode the new dialogNode - * @return the CreateWorkspaceOptions builder - */ - public Builder addDialogNode(CreateDialogNode dialogNode) { - Validator.notNull(dialogNode, "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); - } - this.dialogNodes.add(dialogNode); - return this; - } - - /** - * Adds an counterexample to counterexamples. - * - * @param counterexample the new counterexample - * @return the CreateWorkspaceOptions builder - */ - public Builder addCounterexample(CreateCounterexample counterexample) { - Validator.notNull(counterexample, "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); - } - this.counterexamples.add(counterexample); - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateWorkspaceOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateWorkspaceOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the CreateWorkspaceOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. - * - * @param dialogNodes the dialogNodes - * @return the CreateWorkspaceOptions 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 CreateWorkspaceOptions builder - */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateWorkspaceOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the learningOptOut. - * - * @param learningOptOut the learningOptOut - * @return the CreateWorkspaceOptions builder - */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; - return this; - } - } - - private CreateWorkspaceOptions(Builder builder) { - name = builder.name; - description = builder.description; - language = builder.language; - intents = builder.intents; - entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - metadata = builder.metadata; - learningOptOut = builder.learningOptOut; - } - - /** - * New builder. - * - * @return a CreateWorkspaceOptions 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, and it must be - * no longer than 64 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, and it - * must be no longer than 128 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 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 defining the entities for the workspace. - * - * @return the entities - */ - public List entities() { - return entities; - } - - /** - * Gets the dialogNodes. - * - * An array of objects defining the nodes in the workspace dialog. - * - * @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 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; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteCounterexampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteCounterexampleOptions.java deleted file mode 100644 index 0a30cc935e4..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteCounterexampleOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteCounterexample options. - */ -public class DeleteCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - - private Builder(DeleteCounterexampleOptions deleteCounterexampleOptions) { - workspaceId = deleteCounterexampleOptions.workspaceId; - text = deleteCounterexampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a DeleteCounterexampleOptions. - * - * @return the deleteCounterexampleOptions - */ - public DeleteCounterexampleOptions build() { - return new DeleteCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DeleteCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private DeleteCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - } - - /** - * New builder. - * - * @return a DeleteCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteDialogNodeOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteDialogNodeOptions.java deleted file mode 100644 index e7c4e0977a7..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteDialogNodeOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteDialogNode options. - */ -public class DeleteDialogNodeOptions extends GenericModel { - - private String workspaceId; - private String dialogNode; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - - private Builder(DeleteDialogNodeOptions deleteDialogNodeOptions) { - workspaceId = deleteDialogNodeOptions.workspaceId; - dialogNode = deleteDialogNodeOptions.dialogNode; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a DeleteDialogNodeOptions. - * - * @return the deleteDialogNodeOptions - */ - public DeleteDialogNodeOptions build() { - return new DeleteDialogNodeOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the DeleteDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - } - - private DeleteDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - } - - /** - * New builder. - * - * @return a DeleteDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteEntityOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteEntityOptions.java deleted file mode 100644 index 12d91e30812..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteEntityOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteEntity options. - */ -public class DeleteEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - - private Builder(DeleteEntityOptions deleteEntityOptions) { - workspaceId = deleteEntityOptions.workspaceId; - entity = deleteEntityOptions.entity; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a DeleteEntityOptions. - * - * @return the deleteEntityOptions - */ - public DeleteEntityOptions build() { - return new DeleteEntityOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - } - - private DeleteEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - } - - /** - * New builder. - * - * @return a DeleteEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteExampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteExampleOptions.java deleted file mode 100644 index 8f92171e8de..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteExampleOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteExample options. - */ -public class DeleteExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - - private Builder(DeleteExampleOptions deleteExampleOptions) { - workspaceId = deleteExampleOptions.workspaceId; - intent = deleteExampleOptions.intent; - text = deleteExampleOptions.text; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a DeleteExampleOptions. - * - * @return the deleteExampleOptions - */ - public DeleteExampleOptions build() { - return new DeleteExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the DeleteExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the DeleteExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private DeleteExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - } - - /** - * New builder. - * - * @return a DeleteExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteIntentOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteIntentOptions.java deleted file mode 100644 index 037f09e76a7..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteIntentOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteIntent options. - */ -public class DeleteIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - - private Builder(DeleteIntentOptions deleteIntentOptions) { - workspaceId = deleteIntentOptions.workspaceId; - intent = deleteIntentOptions.intent; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a DeleteIntentOptions. - * - * @return the deleteIntentOptions - */ - public DeleteIntentOptions build() { - return new DeleteIntentOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the DeleteIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - } - - private DeleteIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - } - - /** - * New builder. - * - * @return a DeleteIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteSynonymOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteSynonymOptions.java deleted file mode 100644 index afdcedcba82..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteSynonymOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteSynonym options. - */ -public class DeleteSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - - private Builder(DeleteSynonymOptions deleteSynonymOptions) { - workspaceId = deleteSynonymOptions.workspaceId; - entity = deleteSynonymOptions.entity; - value = deleteSynonymOptions.value; - synonym = deleteSynonymOptions.synonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a DeleteSynonymOptions. - * - * @return the deleteSynonymOptions - */ - public DeleteSynonymOptions build() { - return new DeleteSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the DeleteSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the DeleteSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - } - - private DeleteSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - } - - /** - * New builder. - * - * @return a DeleteSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteUserDataOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index efabdc5ba85..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteValueOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteValueOptions.java deleted file mode 100644 index 6d4d658625f..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteValueOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteValue options. - */ -public class DeleteValueOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - - private Builder(DeleteValueOptions deleteValueOptions) { - workspaceId = deleteValueOptions.workspaceId; - entity = deleteValueOptions.entity; - value = deleteValueOptions.value; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a DeleteValueOptions. - * - * @return the deleteValueOptions - */ - public DeleteValueOptions build() { - return new DeleteValueOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the DeleteValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the DeleteValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - } - - private DeleteValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - } - - /** - * New builder. - * - * @return a DeleteValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteWorkspaceOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteWorkspaceOptions.java deleted file mode 100644 index 724e732037c..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DeleteWorkspaceOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteWorkspace options. - */ -public class DeleteWorkspaceOptions extends GenericModel { - - private String workspaceId; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - - private Builder(DeleteWorkspaceOptions deleteWorkspaceOptions) { - workspaceId = deleteWorkspaceOptions.workspaceId; - } - - /** - * 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 DeleteWorkspaceOptions. - * - * @return the deleteWorkspaceOptions - */ - public DeleteWorkspaceOptions build() { - return new DeleteWorkspaceOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the DeleteWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - } - - private DeleteWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - } - - /** - * New builder. - * - * @return a DeleteWorkspaceOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the workspaceId. - * - * Unique identifier of the workspace. - * - * @return the workspaceId - */ - public String workspaceId() { - return workspaceId; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNode.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNode.java deleted file mode 100644 index 91d96e4f805..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNode.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNode. - */ -public class DialogNode extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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") - private String dialogNodeId; - private String description; - private String conditions; - private String parent; - @SerializedName("previous_sibling") - private String previousSibling; - private Map output; - private Map context; - private Map metadata; - @SerializedName("next_step") - private DialogNodeNextStep nextStep; - private Date created; - private Date updated; - private List actions; - private String title; - @SerializedName("type") - private String nodeType; - @SerializedName("event_name") - private String eventName; - private String variable; - @SerializedName("digress_in") - private String digressIn; - @SerializedName("digress_out") - private String digressOut; - @SerializedName("digress_out_slots") - private String digressOutSlots; - - /** - * Gets the dialogNodeId. - * - * The dialog node ID. - * - * @return the dialogNodeId - */ - public String getDialogNodeId() { - return dialogNodeId; - } - - /** - * Gets the description. - * - * The description of the dialog node. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the conditions. - * - * The condition that triggers the dialog node. - * - * @return the conditions - */ - public String getConditions() { - return conditions; - } - - /** - * Gets the parent. - * - * The ID of the parent dialog node. This property is not returned if the dialog node has no parent. - * - * @return the parent - */ - public String getParent() { - return parent; - } - - /** - * Gets the previousSibling. - * - * The ID of the previous sibling dialog node. This property is not returned if the dialog node has no previous - * sibling. - * - * @return the previousSibling - */ - public String getPreviousSibling() { - return previousSibling; - } - - /** - * Gets the output. - * - * The output of the dialog node. - * - * @return the output - */ - public Map getOutput() { - return output; - } - - /** - * Gets the context. - * - * The context (if defined) for the dialog node. - * - * @return the context - */ - public Map getContext() { - return context; - } - - /** - * Gets the metadata. - * - * Any metadata for the dialog node. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the nextStep. - * - * The next step to execute following this dialog node. - * - * @return the nextStep - */ - public DialogNodeNextStep getNextStep() { - return nextStep; - } - - /** - * Gets the created. - * - * The timestamp for creation of the dialog node. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the most recent update to the dialog node. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the actions. - * - * The actions for the dialog node. - * - * @return the actions - */ - public List getActions() { - return actions; - } - - /** - * Gets the title. - * - * The alias used to identify the dialog node. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String getNodeType() { - return nodeType; - } - - /** - * Gets the eventName. - * - * How an `event_handler` node is processed. - * - * @return the eventName - */ - public String getEventName() { - return eventName; - } - - /** - * Gets the variable. - * - * The location in the dialog context where output is stored. - * - * @return the variable - */ - public String getVariable() { - return variable; - } - - /** - * Gets the digressIn. - * - * Whether this top-level dialog node can be digressed into. - * - * @return the digressIn - */ - public String getDigressIn() { - return digressIn; - } - - /** - * Gets the digressOut. - * - * Whether this dialog node can be returned to after a digression. - * - * @return the digressOut - */ - public String getDigressOut() { - return digressOut; - } - - /** - * Gets the digressOutSlots. - * - * Whether the user can digress to top-level nodes while filling out slots. - * - * @return the digressOutSlots - */ - public String getDigressOutSlots() { - return digressOutSlots; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeAction.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeAction.java deleted file mode 100644 index e7c9577e7e6..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeAction.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNodeAction. - */ -public class DialogNodeAction extends GenericModel { - - /** - * The type of action to invoke. - */ - public interface ActionType { - /** client. */ - String CLIENT = "client"; - /** server. */ - String SERVER = "server"; - } - - private String name; - @SerializedName("type") - private String actionType; - private Map parameters; - @SerializedName("result_variable") - private String resultVariable; - private String credentials; - - /** - * Gets the name. - * - * The name of the action. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the actionType. - * - * The type of action to invoke. - * - * @return the actionType - */ - public String getActionType() { - return actionType; - } - - /** - * Gets the parameters. - * - * A map of key/value pairs to be provided to the action. - * - * @return the parameters - */ - public Map getParameters() { - return parameters; - } - - /** - * Gets the resultVariable. - * - * The location in the dialog context where the result of the action is stored. - * - * @return the resultVariable - */ - public String getResultVariable() { - return resultVariable; - } - - /** - * Gets the credentials. - * - * The name of the context variable that the client application will use to pass in credentials for the action. - * - * @return the credentials - */ - public String getCredentials() { - return credentials; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Sets the actionType. - * - * @param actionType the new actionType - */ - public void setActionType(final String actionType) { - this.actionType = actionType; - } - - /** - * Sets the parameters. - * - * @param parameters the new parameters - */ - public void setParameters(final Map parameters) { - this.parameters = parameters; - } - - /** - * Sets the resultVariable. - * - * @param resultVariable the new resultVariable - */ - public void setResultVariable(final String resultVariable) { - this.resultVariable = resultVariable; - } - - /** - * Sets the credentials. - * - * @param credentials the new credentials - */ - public void setCredentials(final String credentials) { - this.credentials = credentials; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeCollection.java deleted file mode 100644 index 7d15ee473f2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeCollection.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An array of dialog nodes. - */ -public class DialogNodeCollection extends GenericModel { - - @SerializedName("dialog_nodes") - private List dialogNodes; - private Pagination pagination; - - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes defined for the workspace. - * - * @return the dialogNodes - */ - public List getDialogNodes() { - return dialogNodes; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeNextStep.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeNextStep.java deleted file mode 100644 index 8c68c57ccc3..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeNextStep.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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. - */ - public interface Behavior { - /** get_user_input. */ - String GET_USER_INPUT = "get_user_input"; - /** skip_user_input. */ - String SKIP_USER_INPUT = "skip_user_input"; - /** jump_to. */ - String JUMP_TO = "jump_to"; - /** reprompt. */ - String REPROMPT = "reprompt"; - /** skip_slot. */ - String SKIP_SLOT = "skip_slot"; - /** skip_all_slots. */ - String SKIP_ALL_SLOTS = "skip_all_slots"; - } - - /** - * Which part of the dialog node to process next. - */ - public interface Selector { - /** condition. */ - String CONDITION = "condition"; - /** client. */ - String CLIENT = "client"; - /** user_input. */ - String USER_INPUT = "user_input"; - /** body. */ - String BODY = "body"; - } - - private String behavior; - @SerializedName("dialog_node") - private String dialogNode; - private String selector; - - /** - * 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. - * - * @return the behavior - */ - public String getBehavior() { - return behavior; - } - - /** - * Gets the dialogNode. - * - * The ID of the dialog node to process next. This parameter is required if **behavior**=`jump_to`. - * - * @return the dialogNode - */ - public String getDialogNode() { - return dialogNode; - } - - /** - * Gets the selector. - * - * Which part of the dialog node to process next. - * - * @return the selector - */ - public String getSelector() { - return selector; - } - - /** - * Sets the behavior. - * - * @param behavior the new behavior - */ - public void setBehavior(final String behavior) { - this.behavior = behavior; - } - - /** - * Sets the dialogNode. - * - * @param dialogNode the new dialogNode - */ - public void setDialogNode(final String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Sets the selector. - * - * @param selector the new selector - */ - public void setSelector(final String selector) { - this.selector = selector; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeVisitedDetails.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeVisitedDetails.java deleted file mode 100644 index 775f9762d36..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/DialogNodeVisitedDetails.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DialogNodeVisitedDetails. - */ -public class DialogNodeVisitedDetails extends GenericModel { - - @SerializedName("dialog_node") - private String dialogNode; - private String title; - private 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; - } - - /** - * Sets the dialogNode. - * - * @param dialogNode the new dialogNode - */ - public void setDialogNode(final String dialogNode) { - this.dialogNode = dialogNode; - } - - /** - * Sets the title. - * - * @param title the new title - */ - public void setTitle(final String title) { - this.title = title; - } - - /** - * Sets the conditions. - * - * @param conditions the new conditions - */ - public void setConditions(final String conditions) { - this.conditions = conditions; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Entity.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Entity.java deleted file mode 100644 index 55d5d6e9bd5..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Entity.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Entity. - */ -public class Entity extends GenericModel { - - @SerializedName("entity") - private String entityName; - private Date created; - private Date updated; - private String description; - private Map metadata; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - - /** - * Gets the entityName. - * - * The name of the entity. - * - * @return the entityName - */ - public String getEntityName() { - return entityName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the entity. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the fuzzyMatch. - * - * Whether fuzzy matching is used for the entity. - * - * @return the fuzzyMatch - */ - public Boolean isFuzzyMatch() { - return fuzzyMatch; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityCollection.java deleted file mode 100644 index c403fdc9f5c..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An array of entities. - */ -public class EntityCollection extends GenericModel { - - private List entities; - private Pagination pagination; - - /** - * Gets the entities. - * - * An array of objects describing the entities defined for the workspace. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityExport.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityExport.java deleted file mode 100644 index 6dfa1f31e33..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/EntityExport.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * EntityExport. - */ -public class EntityExport extends GenericModel { - - @SerializedName("entity") - private String entityName; - private Date created; - private Date updated; - private String description; - private Map metadata; - @SerializedName("fuzzy_match") - private Boolean fuzzyMatch; - private List values; - - /** - * Gets the entityName. - * - * The name of the entity. - * - * @return the entityName - */ - public String getEntityName() { - return entityName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the entity. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the fuzzyMatch. - * - * Whether fuzzy matching is used for the entity. - * - * @return the fuzzyMatch - */ - public Boolean isFuzzyMatch() { - return fuzzyMatch; - } - - /** - * Gets the values. - * - * An array objects describing the entity values. - * - * @return the values - */ - public List getValues() { - return values; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Example.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Example.java deleted file mode 100644 index 267d6169712..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Example.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Example. - */ -public class Example extends GenericModel { - - @SerializedName("text") - private String exampleText; - private Date created; - private Date updated; - - /** - * Gets the exampleText. - * - * The text of the user input example. - * - * @return the exampleText - */ - public String getExampleText() { - return exampleText; - } - - /** - * Gets the created. - * - * The timestamp for creation of the example. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the example. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ExampleCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ExampleCollection.java deleted file mode 100644 index 555fb829510..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ExampleCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ExampleCollection. - */ -public class ExampleCollection extends GenericModel { - - private List examples; - private Pagination pagination; - - /** - * Gets the examples. - * - * An array of objects describing the examples defined for the intent. - * - * @return the examples - */ - public List getExamples() { - return examples; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetCounterexampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetCounterexampleOptions.java deleted file mode 100644 index c7d91d989d5..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetCounterexampleOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getCounterexample options. - */ -public class GetCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - private Boolean includeAudit; - - private Builder(GetCounterexampleOptions getCounterexampleOptions) { - workspaceId = getCounterexampleOptions.workspaceId; - text = getCounterexampleOptions.text; - includeAudit = getCounterexampleOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a GetCounterexampleOptions. - * - * @return the getCounterexampleOptions - */ - public GetCounterexampleOptions build() { - return new GetCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the GetCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetCounterexampleOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetDialogNodeOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetDialogNodeOptions.java deleted file mode 100644 index 28d3a413578..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetDialogNodeOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getDialogNode options. - */ -public class GetDialogNodeOptions extends GenericModel { - - private String workspaceId; - private String dialogNode; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private Boolean includeAudit; - - private Builder(GetDialogNodeOptions getDialogNodeOptions) { - workspaceId = getDialogNodeOptions.workspaceId; - dialogNode = getDialogNodeOptions.dialogNode; - includeAudit = getDialogNodeOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a GetDialogNodeOptions. - * - * @return the getDialogNodeOptions - */ - public GetDialogNodeOptions build() { - return new GetDialogNodeOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the GetDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetDialogNodeOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetEntityOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetEntityOptions.java deleted file mode 100644 index 6e969346224..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetEntityOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getEntity options. - */ -public class GetEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetEntityOptions getEntityOptions) { - workspaceId = getEntityOptions.workspaceId; - entity = getEntityOptions.entity; - export = getEntityOptions.export; - includeAudit = getEntityOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a GetEntityOptions. - * - * @return the getEntityOptions - */ - public GetEntityOptions build() { - return new GetEntityOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetEntityOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetEntityOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetExampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetExampleOptions.java deleted file mode 100644 index 49fb2a0d0ca..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetExampleOptions.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getExample options. - */ -public class GetExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - private Boolean includeAudit; - - private Builder(GetExampleOptions getExampleOptions) { - workspaceId = getExampleOptions.workspaceId; - intent = getExampleOptions.intent; - text = getExampleOptions.text; - includeAudit = getExampleOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a GetExampleOptions. - * - * @return the getExampleOptions - */ - public GetExampleOptions build() { - return new GetExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the GetExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the GetExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetExampleOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetIntentOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetIntentOptions.java deleted file mode 100644 index 1c8ae57d4b6..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetIntentOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getIntent options. - */ -public class GetIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetIntentOptions getIntentOptions) { - workspaceId = getIntentOptions.workspaceId; - intent = getIntentOptions.intent; - export = getIntentOptions.export; - includeAudit = getIntentOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a GetIntentOptions. - * - * @return the getIntentOptions - */ - public GetIntentOptions build() { - return new GetIntentOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the GetIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetIntentOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetIntentOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetSynonymOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetSynonymOptions.java deleted file mode 100644 index 26102a58597..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetSynonymOptions.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getSynonym options. - */ -public class GetSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - private Boolean includeAudit; - - private Builder(GetSynonymOptions getSynonymOptions) { - workspaceId = getSynonymOptions.workspaceId; - entity = getSynonymOptions.entity; - value = getSynonymOptions.value; - synonym = getSynonymOptions.synonym; - includeAudit = getSynonymOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a GetSynonymOptions. - * - * @return the getSynonymOptions - */ - public GetSynonymOptions build() { - return new GetSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the GetSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the GetSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetSynonymOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return synonym; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetValueOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetValueOptions.java deleted file mode 100644 index 6f329d291af..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetValueOptions.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getValue options. - */ -public class GetValueOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetValueOptions getValueOptions) { - workspaceId = getValueOptions.workspaceId; - entity = getValueOptions.entity; - value = getValueOptions.value; - export = getValueOptions.export; - includeAudit = getValueOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a GetValueOptions. - * - * @return the getValueOptions - */ - public GetValueOptions build() { - return new GetValueOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the GetValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the GetValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetValueOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetValueOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetWorkspaceOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetWorkspaceOptions.java deleted file mode 100644 index 2b24816186d..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/GetWorkspaceOptions.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getWorkspace options. - */ -public class GetWorkspaceOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Boolean export; - private Boolean includeAudit; - - private Builder(GetWorkspaceOptions getWorkspaceOptions) { - workspaceId = getWorkspaceOptions.workspaceId; - export = getWorkspaceOptions.export; - includeAudit = getWorkspaceOptions.includeAudit; - } - - /** - * 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 GetWorkspaceOptions. - * - * @return the getWorkspaceOptions - */ - public GetWorkspaceOptions build() { - return new GetWorkspaceOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the GetWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the GetWorkspaceOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the GetWorkspaceOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private GetWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - export = builder.export; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a GetWorkspaceOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/InputData.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/InputData.java deleted file mode 100644 index 7a2afbc8235..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/InputData.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The user input. - */ -public class InputData extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(InputData inputData) { - text = inputData.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 InputData. - * - * @return the inputData - */ - public InputData build() { - return new InputData(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the InputData builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - } - - private InputData(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - } - - /** - * New builder. - * - * @return a InputData 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, and it must be - * no longer than 2048 characters. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Intent.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Intent.java deleted file mode 100644 index e087199ee23..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Intent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Intent. - */ -public class Intent extends GenericModel { - - @SerializedName("intent") - private String intentName; - private Date created; - private Date updated; - private String description; - - /** - * Gets the intentName. - * - * The name of the intent. - * - * @return the intentName - */ - public String getIntentName() { - return intentName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the intent. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the intent. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the intent. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentCollection.java deleted file mode 100644 index d1c4cb8f90d..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IntentCollection. - */ -public class IntentCollection extends GenericModel { - - private List intents; - private Pagination pagination; - - /** - * Gets the intents. - * - * An array of objects describing the intents defined for the workspace. - * - * @return the intents - */ - public List getIntents() { - return intents; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentExport.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentExport.java deleted file mode 100644 index 0724ff2cba6..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/IntentExport.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IntentExport. - */ -public class IntentExport extends GenericModel { - - @SerializedName("intent") - private String intentName; - private Date created; - private Date updated; - private String description; - private List examples; - - /** - * Gets the intentName. - * - * The name of the intent. - * - * @return the intentName - */ - public String getIntentName() { - return intentName; - } - - /** - * Gets the created. - * - * The timestamp for creation of the intent. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the intent. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the intent. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the examples. - * - * An array of objects describing the user input examples for the intent. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListAllLogsOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListAllLogsOptions.java deleted file mode 100644 index 2b0bf2cf362..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListAllLogsOptions.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listAllLogs options. - */ -public class ListAllLogsOptions extends GenericModel { - - private String filter; - private String sort; - private Long pageLimit; - private String cursor; - - /** - * Builder. - */ - public static class Builder { - private String filter; - private String sort; - private Long pageLimit; - private String cursor; - - private Builder(ListAllLogsOptions listAllLogsOptions) { - filter = listAllLogsOptions.filter; - sort = listAllLogsOptions.sort; - pageLimit = listAllLogsOptions.pageLimit; - cursor = listAllLogsOptions.cursor; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param filter the filter - */ - public Builder(String filter) { - this.filter = filter; - } - - /** - * Builds a ListAllLogsOptions. - * - * @return the listAllLogsOptions - */ - public ListAllLogsOptions build() { - return new ListAllLogsOptions(this); - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the ListAllLogsOptions builder - */ - public Builder filter(String filter) { - this.filter = filter; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the ListAllLogsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListAllLogsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = pageLimit; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListAllLogsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - } - - private ListAllLogsOptions(Builder builder) { - Validator.notNull(builder.filter, "filter cannot be null"); - filter = builder.filter; - sort = builder.sort; - pageLimit = builder.pageLimit; - cursor = builder.cursor; - } - - /** - * New builder. - * - * @return a ListAllLogsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 `workspace_id` or - * `request.context.metadata.deployment`. For more information, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax). - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the pageLimit. - * - * The number of records to return in each page of results. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListCounterexamplesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListCounterexamplesOptions.java deleted file mode 100644 index 7088c4fd20d..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListCounterexamplesOptions.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listCounterexamples options. - */ -public class ListCounterexamplesOptions extends GenericModel { - - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListCounterexamplesOptions listCounterexamplesOptions) { - workspaceId = listCounterexamplesOptions.workspaceId; - pageLimit = listCounterexamplesOptions.pageLimit; - includeCount = listCounterexamplesOptions.includeCount; - sort = listCounterexamplesOptions.sort; - cursor = listCounterexamplesOptions.cursor; - includeAudit = listCounterexamplesOptions.includeAudit; - } - - /** - * 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 ListCounterexamplesOptions. - * - * @return the listCounterexamplesOptions - */ - public ListCounterexamplesOptions build() { - return new ListCounterexamplesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListCounterexamplesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListCounterexamplesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListCounterexamplesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListCounterexamplesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListCounterexamplesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListCounterexamplesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListCounterexamplesOptions 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 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListDialogNodesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListDialogNodesOptions.java deleted file mode 100644 index bd11278beff..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListDialogNodesOptions.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listDialogNodes options. - */ -public class ListDialogNodesOptions extends GenericModel { - - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListDialogNodesOptions listDialogNodesOptions) { - workspaceId = listDialogNodesOptions.workspaceId; - pageLimit = listDialogNodesOptions.pageLimit; - includeCount = listDialogNodesOptions.includeCount; - sort = listDialogNodesOptions.sort; - cursor = listDialogNodesOptions.cursor; - includeAudit = listDialogNodesOptions.includeAudit; - } - - /** - * 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 ListDialogNodesOptions. - * - * @return the listDialogNodesOptions - */ - public ListDialogNodesOptions build() { - return new ListDialogNodesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListDialogNodesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListDialogNodesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListDialogNodesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListDialogNodesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListDialogNodesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListDialogNodesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListDialogNodesOptions 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 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListEntitiesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListEntitiesOptions.java deleted file mode 100644 index 0d6caf5ef29..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListEntitiesOptions.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listEntities options. - */ -public class ListEntitiesOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListEntitiesOptions listEntitiesOptions) { - workspaceId = listEntitiesOptions.workspaceId; - export = listEntitiesOptions.export; - pageLimit = listEntitiesOptions.pageLimit; - includeCount = listEntitiesOptions.includeCount; - sort = listEntitiesOptions.sort; - cursor = listEntitiesOptions.cursor; - includeAudit = listEntitiesOptions.includeAudit; - } - - /** - * 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 ListEntitiesOptions. - * - * @return the listEntitiesOptions - */ - public ListEntitiesOptions build() { - return new ListEntitiesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListEntitiesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListEntitiesOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListEntitiesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListEntitiesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListEntitiesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListEntitiesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListEntitiesOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListEntitiesOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListExamplesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListExamplesOptions.java deleted file mode 100644 index e42fd77f546..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListExamplesOptions.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listExamples options. - */ -public class ListExamplesOptions extends GenericModel { - - private String workspaceId; - private String intent; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListExamplesOptions listExamplesOptions) { - workspaceId = listExamplesOptions.workspaceId; - intent = listExamplesOptions.intent; - pageLimit = listExamplesOptions.pageLimit; - includeCount = listExamplesOptions.includeCount; - sort = listExamplesOptions.sort; - cursor = listExamplesOptions.cursor; - includeAudit = listExamplesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a ListExamplesOptions. - * - * @return the listExamplesOptions - */ - public ListExamplesOptions build() { - return new ListExamplesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListExamplesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the ListExamplesOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListExamplesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListExamplesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListExamplesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListExamplesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListExamplesOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListExamplesOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListIntentsOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListIntentsOptions.java deleted file mode 100644 index bddb1daa822..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListIntentsOptions.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listIntents options. - */ -public class ListIntentsOptions extends GenericModel { - - private String workspaceId; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListIntentsOptions listIntentsOptions) { - workspaceId = listIntentsOptions.workspaceId; - export = listIntentsOptions.export; - pageLimit = listIntentsOptions.pageLimit; - includeCount = listIntentsOptions.includeCount; - sort = listIntentsOptions.sort; - cursor = listIntentsOptions.cursor; - includeAudit = listIntentsOptions.includeAudit; - } - - /** - * 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 ListIntentsOptions. - * - * @return the listIntentsOptions - */ - public ListIntentsOptions build() { - return new ListIntentsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListIntentsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListIntentsOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListIntentsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListIntentsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListIntentsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListIntentsOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListIntentsOptions(Builder builder) { - 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; - } - - /** - * New builder. - * - * @return a ListIntentsOptions 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 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListLogsOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListLogsOptions.java deleted file mode 100644 index 88329bd9ae2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListLogsOptions.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listLogs options. - */ -public class ListLogsOptions extends GenericModel { - - private String workspaceId; - private String sort; - private String filter; - private Long pageLimit; - private String cursor; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String sort; - private String filter; - private Long pageLimit; - private String cursor; - - private Builder(ListLogsOptions listLogsOptions) { - workspaceId = listLogsOptions.workspaceId; - sort = listLogsOptions.sort; - filter = listLogsOptions.filter; - pageLimit = listLogsOptions.pageLimit; - cursor = listLogsOptions.cursor; - } - - /** - * 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 ListLogsOptions. - * - * @return the listLogsOptions - */ - public ListLogsOptions build() { - return new ListLogsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListLogsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - 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; - } - } - - private ListLogsOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - 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 workspaceId. - * - * Unique identifier of the workspace. - * - * @return the workspaceId - */ - public String workspaceId() { - return workspaceId; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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://console.bluemix.net/docs/services/conversation/filter-reference.html#filter-query-syntax). - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the pageLimit. - * - * The number of records to return in each page of results. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListSynonymsOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListSynonymsOptions.java deleted file mode 100644 index 7ced8a573d3..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListSynonymsOptions.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listSynonyms options. - */ -public class ListSynonymsOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListSynonymsOptions listSynonymsOptions) { - workspaceId = listSynonymsOptions.workspaceId; - entity = listSynonymsOptions.entity; - value = listSynonymsOptions.value; - pageLimit = listSynonymsOptions.pageLimit; - includeCount = listSynonymsOptions.includeCount; - sort = listSynonymsOptions.sort; - cursor = listSynonymsOptions.cursor; - includeAudit = listSynonymsOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a ListSynonymsOptions. - * - * @return the listSynonymsOptions - */ - public ListSynonymsOptions build() { - return new ListSynonymsOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListSynonymsOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the ListSynonymsOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the ListSynonymsOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListSynonymsOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListSynonymsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListSynonymsOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListSynonymsOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListSynonymsOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListSynonymsOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListValuesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListValuesOptions.java deleted file mode 100644 index 85377d6f616..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListValuesOptions.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listValues options. - */ -public class ListValuesOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean export; - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * 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; - - private Builder(ListValuesOptions listValuesOptions) { - workspaceId = listValuesOptions.workspaceId; - entity = listValuesOptions.entity; - export = listValuesOptions.export; - pageLimit = listValuesOptions.pageLimit; - includeCount = listValuesOptions.includeCount; - sort = listValuesOptions.sort; - cursor = listValuesOptions.cursor; - includeAudit = listValuesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a ListValuesOptions. - * - * @return the listValuesOptions - */ - public ListValuesOptions build() { - return new ListValuesOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the ListValuesOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the ListValuesOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the export. - * - * @param export the export - * @return the ListValuesOptions builder - */ - public Builder export(Boolean export) { - this.export = export; - return this; - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListValuesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListValuesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListValuesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListValuesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListValuesOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - 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; - } - - /** - * New builder. - * - * @return a ListValuesOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return 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. - * - * @return the export - */ - public Boolean export() { - return export; - } - - /** - * 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListWorkspacesOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListWorkspacesOptions.java deleted file mode 100644 index 2ec5e4fc5c2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ListWorkspacesOptions.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listWorkspaces options. - */ -public class ListWorkspacesOptions extends GenericModel { - - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - /** - * Builder. - */ - public static class Builder { - private Long pageLimit; - private Boolean includeCount; - private String sort; - private String cursor; - private Boolean includeAudit; - - private Builder(ListWorkspacesOptions listWorkspacesOptions) { - pageLimit = listWorkspacesOptions.pageLimit; - includeCount = listWorkspacesOptions.includeCount; - sort = listWorkspacesOptions.sort; - cursor = listWorkspacesOptions.cursor; - includeAudit = listWorkspacesOptions.includeAudit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListWorkspacesOptions. - * - * @return the listWorkspacesOptions - */ - public ListWorkspacesOptions build() { - return new ListWorkspacesOptions(this); - } - - /** - * Set the pageLimit. - * - * @param pageLimit the pageLimit - * @return the ListWorkspacesOptions builder - */ - public Builder pageLimit(long pageLimit) { - this.pageLimit = 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. - * - * @param sort the sort - * @return the ListWorkspacesOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the cursor. - * - * @param cursor the cursor - * @return the ListWorkspacesOptions builder - */ - public Builder cursor(String cursor) { - this.cursor = cursor; - return this; - } - - /** - * Set the includeAudit. - * - * @param includeAudit the includeAudit - * @return the ListWorkspacesOptions builder - */ - public Builder includeAudit(Boolean includeAudit) { - this.includeAudit = includeAudit; - return this; - } - } - - private ListWorkspacesOptions(Builder builder) { - pageLimit = builder.pageLimit; - includeCount = builder.includeCount; - sort = builder.sort; - cursor = builder.cursor; - includeAudit = builder.includeAudit; - } - - /** - * New builder. - * - * @return a ListWorkspacesOptions 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 returned. - * - * @return the includeCount - */ - public Boolean includeCount() { - return includeCount; - } - - /** - * Gets the sort. - * - * The attribute by which returned results will be sorted. To reverse the sort order, prefix the value with a minus - * sign (`-`). Supported values are `name`, `updated`, and `workspace_id`. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogCollection.java deleted file mode 100644 index 766736c06b4..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LogCollection. - */ -public class LogCollection extends GenericModel { - - private List logs; - private LogPagination pagination; - - /** - * 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. - * - * @return the pagination - */ - public LogPagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogExport.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogExport.java deleted file mode 100644 index 4466ccd2964..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogExport.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LogExport. - */ -public class LogExport extends GenericModel { - - private MessageRequest request; - private MessageResponse response; - @SerializedName("log_id") - private String logId; - @SerializedName("request_timestamp") - private String requestTimestamp; - @SerializedName("response_timestamp") - private String responseTimestamp; - @SerializedName("workspace_id") - private String workspaceId; - private String language; - - /** - * Gets the request. - * - * A request received by the workspace, including the user input and context. - * - * @return the request - */ - public MessageRequest getRequest() { - return request; - } - - /** - * Gets the response. - * - * The response sent by the workspace, including the output text, detected intents and entities, and context. - * - * @return the response - */ - public MessageResponse getResponse() { - return response; - } - - /** - * Gets the logId. - * - * A unique identifier for the logged event. - * - * @return the logId - */ - public String getLogId() { - return logId; - } - - /** - * 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 workspaceId. - * - * The unique identifier of the workspace where the request was made. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the language. - * - * The language of the workspace where the message request was made. - * - * @return the language - */ - public String getLanguage() { - return language; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogMessage.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogMessage.java deleted file mode 100644 index 2814e440e9a..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogMessage.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * Log message details. - */ -public class LogMessage extends DynamicModel { - /** - * The severity of the log message. - */ - public interface Level { - /** info. */ - String INFO = "info"; - /** error. */ - String ERROR = "error"; - /** warn. */ - String WARN = "warn"; - } - - private Type levelType = new TypeToken() { - }.getType(); - private Type msgType = new TypeToken() { - }.getType(); - - /** - * Gets the level. - * - * @return the level - */ - public String getLevel() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("level"), levelType); - } - - /** - * Gets the msg. - * - * @return the msg - */ - public String getMsg() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("msg"), msgType); - } - - /** - * Sets the level. - * - * @param level the new level - */ - public void setLevel(final String level) { - this.put("level", level); - } - - /** - * Sets the msg. - * - * @param msg the new msg - */ - public void setMsg(final String msg) { - this.put("msg", msg); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogPagination.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogPagination.java deleted file mode 100644 index 41b2e9f402a..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/LogPagination.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The pagination data for the returned objects. - */ -public class LogPagination extends GenericModel { - - @SerializedName("next_url") - private String nextUrl; - private Long matched; - @SerializedName("next_cursor") - private String nextCursor; - - /** - * 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageInput.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageInput.java deleted file mode 100644 index a312d11460a..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageInput.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The text of the user input. - */ -public class MessageInput extends GenericModel { - - private String text; - - /** - * Gets the text. - * - * The user's input. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageOptions.java deleted file mode 100644 index 572ea612430..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageOptions.java +++ /dev/null @@ -1,333 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The message options. - */ -public class MessageOptions extends GenericModel { - - private String workspaceId; - private InputData input; - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - private Boolean nodesVisitedDetails; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private InputData input; - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - private Boolean nodesVisitedDetails; - - private Builder(MessageOptions messageOptions) { - workspaceId = messageOptions.workspaceId; - input = messageOptions.input; - alternateIntents = messageOptions.alternateIntents; - context = messageOptions.context; - entities = messageOptions.entities; - intents = messageOptions.intents; - output = messageOptions.output; - nodesVisitedDetails = messageOptions.nodesVisitedDetails; - } - - /** - * 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 MessageOptions. - * - * @return the messageOptions - */ - public MessageOptions build() { - return new MessageOptions(this); - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the MessageOptions builder - */ - public Builder addEntity(RuntimeEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the MessageOptions builder - */ - public Builder addIntent(RuntimeIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the MessageOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the input. - * - * @param input the input - * @return the MessageOptions builder - */ - public Builder input(InputData input) { - this.input = input; - return this; - } - - /** - * Set the alternateIntents. - * - * @param alternateIntents the alternateIntents - * @return the MessageOptions builder - */ - public Builder alternateIntents(Boolean alternateIntents) { - this.alternateIntents = alternateIntents; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the MessageOptions builder - */ - public Builder context(Context context) { - this.context = context; - return this; - } - - /** - * Set the entities. - * Existing entities will be replaced. - * - * @param entities the entities - * @return the MessageOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the MessageOptions builder - */ - public Builder intents(List intents) { - this.intents = intents; - return this; - } - - /** - * Set the output. - * - * @param output the output - * @return the MessageOptions builder - */ - public Builder output(OutputData output) { - this.output = output; - return this; - } - - /** - * Set the nodesVisitedDetails. - * - * @param nodesVisitedDetails the nodesVisitedDetails - * @return the MessageOptions builder - */ - public Builder nodesVisitedDetails(Boolean nodesVisitedDetails) { - this.nodesVisitedDetails = nodesVisitedDetails; - return this; - } - - /** - * Set the messageRequest. - * - * @param messageRequest the messageRequest - * @return the MessageOptions builder - */ - public Builder messageRequest(MessageRequest messageRequest) { - this.input = messageRequest.getInput(); - this.alternateIntents = messageRequest.isAlternateIntents(); - this.context = messageRequest.getContext(); - this.entities = messageRequest.getEntities(); - this.intents = messageRequest.getIntents(); - this.output = messageRequest.getOutput(); - return this; - } - } - - private MessageOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - input = builder.input; - alternateIntents = builder.alternateIntents; - context = builder.context; - entities = builder.entities; - intents = builder.intents; - output = builder.output; - nodesVisitedDetails = builder.nodesVisitedDetails; - } - - /** - * New builder. - * - * @return a MessageOptions 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 input object that includes the input text. - * - * @return the input - */ - public InputData input() { - return input; - } - - /** - * 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 context. - * - * State information for the conversation. Continue a conversation by including the context object from the previous - * response. - * - * @return the context - */ - public Context context() { - return context; - } - - /** - * 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 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 output. - * - * System output. Include the output from the previous response to maintain intermediate information over multiple - * requests. - * - * @return the output - */ - public OutputData output() { - return output; - } - - /** - * Gets the nodesVisitedDetails. - * - * Whether to include additional diagnostic information about the dialog nodes that were visited during processing of - * the message. - * - * @return the nodesVisitedDetails - */ - public Boolean nodesVisitedDetails() { - return nodesVisitedDetails; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageRequest.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageRequest.java deleted file mode 100644 index acf9d8937f2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageRequest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A request formatted for the Conversation service. - */ -public class MessageRequest extends GenericModel { - - private InputData input; - @SerializedName("alternate_intents") - private Boolean alternateIntents; - private Context context; - private List entities; - private List intents; - private OutputData output; - - /** - * Gets the input. - * - * An input object that includes the input text. - * - * @return the input - */ - public InputData getInput() { - return input; - } - - /** - * Gets the alternateIntents. - * - * Whether to return more than one intent. Set to `true` to return all matching intents. - * - * @return the alternateIntents - */ - public Boolean isAlternateIntents() { - return alternateIntents; - } - - /** - * Gets the context. - * - * State information for the conversation. Continue a conversation by including the context object from the previous - * response. - * - * @return the context - */ - public Context getContext() { - return context; - } - - /** - * 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 getEntities() { - return entities; - } - - /** - * 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 getIntents() { - return intents; - } - - /** - * Gets the output. - * - * System output. Include the output from the previous response to maintain intermediate information over multiple - * requests. - * - * @return the output - */ - public OutputData getOutput() { - return output; - } - - /** - * Sets the input. - * - * @param input the new input - */ - public void setInput(final InputData input) { - this.input = input; - } - - /** - * Sets the alternateIntents. - * - * @param alternateIntents the new alternateIntents - */ - public void setAlternateIntents(final Boolean alternateIntents) { - this.alternateIntents = alternateIntents; - } - - /** - * Sets the context. - * - * @param context the new context - */ - public void setContext(final Context context) { - this.context = context; - } - - /** - * Sets the entities. - * - * @param entities the new entities - */ - public void setEntities(final List entities) { - this.entities = entities; - } - - /** - * Sets the intents. - * - * @param intents the new intents - */ - public void setIntents(final List intents) { - this.intents = intents; - } - - /** - * Sets the output. - * - * @param output the new output - */ - public void setOutput(final OutputData output) { - this.output = output; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageResponse.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageResponse.java deleted file mode 100644 index 75d36483f11..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/MessageResponse.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; -import java.util.List; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * A response from the Conversation service. - */ -public class MessageResponse extends DynamicModel { - private Type inputType = new TypeToken() { - }.getType(); - private Type intentsType = new TypeToken>() { - }.getType(); - private Type entitiesType = new TypeToken>() { - }.getType(); - private Type alternateIntentsType = new TypeToken() { - }.getType(); - private Type contextType = new TypeToken() { - }.getType(); - private Type outputType = new TypeToken() { - }.getType(); - - /** - * Gets the input. - * - * @return the input - */ - public MessageInput getInput() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("input"), inputType); - } - - /** - * Gets the intents. - * - * @return the intents - */ - public List getIntents() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("intents"), intentsType); - } - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("entities"), entitiesType); - } - - /** - * Gets the alternateIntents. - * - * @return the alternateIntents - */ - public Boolean isAlternateIntents() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("alternate_intents"), alternateIntentsType); - } - - /** - * Gets the context. - * - * @return the context - */ - public Context getContext() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("context"), contextType); - } - - /** - * Gets the output. - * - * @return the output - */ - public OutputData getOutput() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("output"), outputType); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/OutputData.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/OutputData.java deleted file mode 100644 index 69479b6b2b2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/OutputData.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; -import java.util.List; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * An output object that includes the response to the user, the nodes that were hit, and messages from the log. - */ -public class OutputData extends DynamicModel { - private Type logMessagesType = new TypeToken>() { - }.getType(); - private Type textType = new TypeToken>() { - }.getType(); - private Type nodesVisitedType = new TypeToken>() { - }.getType(); - private Type nodesVisitedDetailsType = new TypeToken>() { - }.getType(); - - /** - * Gets the logMessages. - * - * @return the logMessages - */ - public List getLogMessages() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("log_messages"), logMessagesType); - } - - /** - * Gets the text. - * - * @return the text - */ - public List getText() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("text"), textType); - } - - /** - * Gets the nodesVisited. - * - * @return the nodesVisited - */ - public List getNodesVisited() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("nodes_visited"), nodesVisitedType); - } - - /** - * Gets the nodesVisitedDetails. - * - * @return the nodesVisitedDetails - */ - public List getNodesVisitedDetails() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("nodes_visited_details"), - nodesVisitedDetailsType); - } - - /** - * Sets the logMessages. - * - * @param logMessages the new logMessages - */ - public void setLogMessages(final List logMessages) { - this.put("log_messages", logMessages); - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final List text) { - this.put("text", text); - } - - /** - * Sets the nodesVisited. - * - * @param nodesVisited the new nodesVisited - */ - public void setNodesVisited(final List nodesVisited) { - this.put("nodes_visited", nodesVisited); - } - - /** - * Sets the nodesVisitedDetails. - * - * @param nodesVisitedDetails the new nodesVisitedDetails - */ - public void setNodesVisitedDetails(final List nodesVisitedDetails) { - this.put("nodes_visited_details", nodesVisitedDetails); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Pagination.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Pagination.java deleted file mode 100644 index d8dd67b662e..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Pagination.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The pagination data for the returned objects. - */ -public class Pagination extends GenericModel { - - @SerializedName("refresh_url") - private String refreshUrl; - @SerializedName("next_url") - private String nextUrl; - private Long total; - private Long matched; - @SerializedName("refresh_cursor") - private String refreshCursor; - @SerializedName("next_cursor") - private String nextCursor; - - /** - * 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. - * - * Reserved for future use. - * - * @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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeEntity.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeEntity.java deleted file mode 100644 index 91231632ddb..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeEntity.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * A term from the request that was identified as an entity. - */ -public class RuntimeEntity extends DynamicModel { - private Type entityType = new TypeToken() { - }.getType(); - private Type locationType = new TypeToken>() { - }.getType(); - private Type valueType = new TypeToken() { - }.getType(); - private Type confidenceType = new TypeToken() { - }.getType(); - private Type metadataType = new TypeToken() { - }.getType(); - private Type groupsType = new TypeToken>() { - }.getType(); - - /** - * Gets the entity. - * - * @return the entity - */ - public String getEntity() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("entity"), entityType); - } - - /** - * Gets the location. - * - * @return the location - */ - public List getLocation() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("location"), locationType); - } - - /** - * Gets the value. - * - * @return the value - */ - public String getValue() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("value"), valueType); - } - - /** - * Gets the confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("confidence"), confidenceType); - } - - /** - * Gets the metadata. - * - * @return the metadata - */ - public Map getMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("metadata"), metadataType); - } - - /** - * Gets the groups. - * - * @return the groups - */ - public List getGroups() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("groups"), groupsType); - } - - /** - * Sets the entity. - * - * @param entity the new entity - */ - public void setEntity(final String entity) { - this.put("entity", entity); - } - - /** - * Sets the location. - * - * @param location the new location - */ - public void setLocation(final List location) { - this.put("location", location); - } - - /** - * Sets the value. - * - * @param value the new value - */ - public void setValue(final String value) { - this.put("value", value); - } - - /** - * Sets the confidence. - * - * @param confidence the new confidence - */ - public void setConfidence(final Double confidence) { - this.put("confidence", confidence); - } - - /** - * Sets the metadata. - * - * @param metadata the new metadata - */ - public void setMetadata(final Map metadata) { - this.put("metadata", metadata); - } - - /** - * Sets the groups. - * - * @param groups the new groups - */ - public void setGroups(final List groups) { - this.put("groups", groups); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeIntent.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeIntent.java deleted file mode 100644 index 5f9dc78fb9a..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/RuntimeIntent.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.lang.reflect.Type; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * An intent identified in the user input. - */ -public class RuntimeIntent extends DynamicModel { - private Type intentType = new TypeToken() { - }.getType(); - private Type confidenceType = new TypeToken() { - }.getType(); - - /** - * Gets the intent. - * - * @return the intent - */ - public String getIntent() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("intent"), intentType); - } - - /** - * Gets the confidence. - * - * @return the confidence - */ - public Double getConfidence() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("confidence"), confidenceType); - } - - /** - * Sets the intent. - * - * @param intent the new intent - */ - public void setIntent(final String intent) { - this.put("intent", intent); - } - - /** - * Sets the confidence. - * - * @param confidence the new confidence - */ - public void setConfidence(final Double confidence) { - this.put("confidence", confidence); - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Synonym.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Synonym.java deleted file mode 100644 index ab83f616742..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Synonym.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Synonym. - */ -public class Synonym extends GenericModel { - - @SerializedName("synonym") - private String synonymText; - private Date created; - private Date updated; - - /** - * Gets the synonymText. - * - * The text of the synonym. - * - * @return the synonymText - */ - public String getSynonymText() { - return synonymText; - } - - /** - * Gets the created. - * - * The timestamp for creation of the synonym. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the most recent update to the synonym. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SynonymCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SynonymCollection.java deleted file mode 100644 index 29f6690e928..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SynonymCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SynonymCollection. - */ -public class SynonymCollection extends GenericModel { - - private List synonyms; - private Pagination pagination; - - /** - * Gets the synonyms. - * - * An array of synonyms. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the pagination. - * - * The pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SystemResponse.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SystemResponse.java deleted file mode 100644 index bf9ac131576..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/SystemResponse.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.DynamicModel; - -/** - * For internal use only. - */ -public class SystemResponse extends DynamicModel { - -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateCounterexampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateCounterexampleOptions.java deleted file mode 100644 index c088aff5f92..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateCounterexampleOptions.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateCounterexample options. - */ -public class UpdateCounterexampleOptions extends GenericModel { - - private String workspaceId; - private String text; - private String newText; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String text; - private String newText; - - private Builder(UpdateCounterexampleOptions updateCounterexampleOptions) { - workspaceId = updateCounterexampleOptions.workspaceId; - text = updateCounterexampleOptions.text; - newText = updateCounterexampleOptions.newText; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param text the text - */ - public Builder(String workspaceId, String text) { - this.workspaceId = workspaceId; - this.text = text; - } - - /** - * Builds a UpdateCounterexampleOptions. - * - * @return the updateCounterexampleOptions - */ - public UpdateCounterexampleOptions build() { - return new UpdateCounterexampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateCounterexampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the UpdateCounterexampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the newText. - * - * @param newText the newText - * @return the UpdateCounterexampleOptions builder - */ - public Builder newText(String newText) { - this.newText = newText; - return this; - } - } - - private UpdateCounterexampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - text = builder.text; - newText = builder.newText; - } - - /** - * New builder. - * - * @return a UpdateCounterexampleOptions 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 text. - * - * The text of a user input counterexample (for example, `What are you wearing?`). - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the newText. - * - * The text of a user input counterexample. - * - * @return the newText - */ - public String newText() { - return newText; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateDialogNodeOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateDialogNodeOptions.java deleted file mode 100644 index 014195e46b8..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateDialogNodeOptions.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The UpdateDialogNode options. - */ -public class UpdateDialogNodeOptions extends GenericModel { - - /** - * How the dialog node is processed. - */ - public interface NodeType { - /** 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"; - } - - /** - * Whether this dialog node can be returned to after a digression. - */ - public interface NewDigressOut { - /** 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"; - } - - /** - * How an `event_handler` node is processed. - */ - public interface NewEventName { - /** 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 the user can digress to top-level nodes while filling out slots. - */ - public interface NewDigressOutSlots { - /** not_allowed. */ - String NOT_ALLOWED = "not_allowed"; - /** allow_returning. */ - String ALLOW_RETURNING = "allow_returning"; - /** allow_all. */ - String ALLOW_ALL = "allow_all"; - } - - /** - * Whether this top-level dialog node can be digressed into. - */ - public interface NewDigressIn { - /** not_available. */ - String NOT_AVAILABLE = "not_available"; - /** returns. */ - String RETURNS = "returns"; - /** does_not_return. */ - String DOES_NOT_RETURN = "does_not_return"; - } - - private String workspaceId; - private String dialogNode; - private String nodeType; - private List newActions; - private String newConditions; - private Map newContext; - private String newPreviousSibling; - private String newVariable; - private Map newMetadata; - private String newTitle; - private String newDescription; - private String newDigressOut; - private String newEventName; - private String newDigressOutSlots; - private DialogNodeNextStep newNextStep; - private String newDigressIn; - private Map newOutput; - private String newParent; - private String newDialogNode; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String dialogNode; - private String nodeType; - private List newActions; - private String newConditions; - private Map newContext; - private String newPreviousSibling; - private String newVariable; - private Map newMetadata; - private String newTitle; - private String newDescription; - private String newDigressOut; - private String newEventName; - private String newDigressOutSlots; - private DialogNodeNextStep newNextStep; - private String newDigressIn; - private Map newOutput; - private String newParent; - private String newDialogNode; - - private Builder(UpdateDialogNodeOptions updateDialogNodeOptions) { - workspaceId = updateDialogNodeOptions.workspaceId; - dialogNode = updateDialogNodeOptions.dialogNode; - nodeType = updateDialogNodeOptions.nodeType; - newActions = updateDialogNodeOptions.newActions; - newConditions = updateDialogNodeOptions.newConditions; - newContext = updateDialogNodeOptions.newContext; - newPreviousSibling = updateDialogNodeOptions.newPreviousSibling; - newVariable = updateDialogNodeOptions.newVariable; - newMetadata = updateDialogNodeOptions.newMetadata; - newTitle = updateDialogNodeOptions.newTitle; - newDescription = updateDialogNodeOptions.newDescription; - newDigressOut = updateDialogNodeOptions.newDigressOut; - newEventName = updateDialogNodeOptions.newEventName; - newDigressOutSlots = updateDialogNodeOptions.newDigressOutSlots; - newNextStep = updateDialogNodeOptions.newNextStep; - newDigressIn = updateDialogNodeOptions.newDigressIn; - newOutput = updateDialogNodeOptions.newOutput; - newParent = updateDialogNodeOptions.newParent; - newDialogNode = updateDialogNodeOptions.newDialogNode; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param dialogNode the dialogNode - */ - public Builder(String workspaceId, String dialogNode) { - this.workspaceId = workspaceId; - this.dialogNode = dialogNode; - } - - /** - * Builds a UpdateDialogNodeOptions. - * - * @return the updateDialogNodeOptions - */ - public UpdateDialogNodeOptions build() { - return new UpdateDialogNodeOptions(this); - } - - /** - * Adds an newActions to newActions. - * - * @param newActions the new newActions - * @return the UpdateDialogNodeOptions builder - */ - public Builder addNewActions(DialogNodeAction newActions) { - Validator.notNull(newActions, "newActions cannot be null"); - if (this.newActions == null) { - this.newActions = new ArrayList(); - } - this.newActions.add(newActions); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateDialogNodeOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the dialogNode. - * - * @param dialogNode the dialogNode - * @return the UpdateDialogNodeOptions builder - */ - public Builder dialogNode(String dialogNode) { - this.dialogNode = dialogNode; - return this; - } - - /** - * Set the nodeType. - * - * @param nodeType the nodeType - * @return the UpdateDialogNodeOptions builder - */ - public Builder nodeType(String nodeType) { - this.nodeType = nodeType; - return this; - } - - /** - * Set the newActions. - * Existing newActions will be replaced. - * - * @param newActions the newActions - * @return the UpdateDialogNodeOptions builder - */ - public Builder newActions(List newActions) { - this.newActions = newActions; - return this; - } - - /** - * Set the newConditions. - * - * @param newConditions the newConditions - * @return the UpdateDialogNodeOptions builder - */ - public Builder newConditions(String newConditions) { - this.newConditions = newConditions; - return this; - } - - /** - * Set the newContext. - * - * @param newContext the newContext - * @return the UpdateDialogNodeOptions builder - */ - public Builder newContext(Map newContext) { - this.newContext = newContext; - return this; - } - - /** - * Set the newPreviousSibling. - * - * @param newPreviousSibling the newPreviousSibling - * @return the UpdateDialogNodeOptions builder - */ - public Builder newPreviousSibling(String newPreviousSibling) { - this.newPreviousSibling = newPreviousSibling; - return this; - } - - /** - * Set the newVariable. - * - * @param newVariable the newVariable - * @return the UpdateDialogNodeOptions builder - */ - public Builder newVariable(String newVariable) { - this.newVariable = newVariable; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateDialogNodeOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newTitle. - * - * @param newTitle the newTitle - * @return the UpdateDialogNodeOptions builder - */ - public Builder newTitle(String newTitle) { - this.newTitle = newTitle; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - - /** - * Set the newDigressOut. - * - * @param newDigressOut the newDigressOut - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressOut(String newDigressOut) { - this.newDigressOut = newDigressOut; - return this; - } - - /** - * Set the newEventName. - * - * @param newEventName the newEventName - * @return the UpdateDialogNodeOptions builder - */ - public Builder newEventName(String newEventName) { - this.newEventName = newEventName; - return this; - } - - /** - * Set the newDigressOutSlots. - * - * @param newDigressOutSlots the newDigressOutSlots - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressOutSlots(String newDigressOutSlots) { - this.newDigressOutSlots = newDigressOutSlots; - return this; - } - - /** - * Set the newNextStep. - * - * @param newNextStep the newNextStep - * @return the UpdateDialogNodeOptions builder - */ - public Builder newNextStep(DialogNodeNextStep newNextStep) { - this.newNextStep = newNextStep; - return this; - } - - /** - * Set the newDigressIn. - * - * @param newDigressIn the newDigressIn - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDigressIn(String newDigressIn) { - this.newDigressIn = newDigressIn; - return this; - } - - /** - * Set the newOutput. - * - * @param newOutput the newOutput - * @return the UpdateDialogNodeOptions builder - */ - public Builder newOutput(Map newOutput) { - this.newOutput = newOutput; - return this; - } - - /** - * Set the newParent. - * - * @param newParent the newParent - * @return the UpdateDialogNodeOptions builder - */ - public Builder newParent(String newParent) { - this.newParent = newParent; - return this; - } - - /** - * Set the newDialogNode. - * - * @param newDialogNode the newDialogNode - * @return the UpdateDialogNodeOptions builder - */ - public Builder newDialogNode(String newDialogNode) { - this.newDialogNode = newDialogNode; - return this; - } - } - - private UpdateDialogNodeOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.dialogNode, "dialogNode cannot be empty"); - workspaceId = builder.workspaceId; - dialogNode = builder.dialogNode; - nodeType = builder.nodeType; - newActions = builder.newActions; - newConditions = builder.newConditions; - newContext = builder.newContext; - newPreviousSibling = builder.newPreviousSibling; - newVariable = builder.newVariable; - newMetadata = builder.newMetadata; - newTitle = builder.newTitle; - newDescription = builder.newDescription; - newDigressOut = builder.newDigressOut; - newEventName = builder.newEventName; - newDigressOutSlots = builder.newDigressOutSlots; - newNextStep = builder.newNextStep; - newDigressIn = builder.newDigressIn; - newOutput = builder.newOutput; - newParent = builder.newParent; - newDialogNode = builder.newDialogNode; - } - - /** - * New builder. - * - * @return a UpdateDialogNodeOptions 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, `get_order`). - * - * @return the dialogNode - */ - public String dialogNode() { - return dialogNode; - } - - /** - * Gets the nodeType. - * - * How the dialog node is processed. - * - * @return the nodeType - */ - public String nodeType() { - return nodeType; - } - - /** - * Gets the newActions. - * - * An array of objects describing any actions to be invoked by the dialog node. - * - * @return the newActions - */ - public List newActions() { - return newActions; - } - - /** - * Gets the newConditions. - * - * The condition that will trigger the dialog node. This string cannot contain carriage return, newline, or tab - * characters, and it must be no longer than 2048 characters. - * - * @return the newConditions - */ - public String newConditions() { - return newConditions; - } - - /** - * Gets the newContext. - * - * The context for the dialog node. - * - * @return the newContext - */ - public Map newContext() { - return newContext; - } - - /** - * Gets the newPreviousSibling. - * - * The ID of the previous sibling dialog node. - * - * @return the newPreviousSibling - */ - public String newPreviousSibling() { - return newPreviousSibling; - } - - /** - * Gets the newVariable. - * - * The location in the dialog context where output is stored. - * - * @return the newVariable - */ - public String newVariable() { - return newVariable; - } - - /** - * Gets the newMetadata. - * - * The metadata for the dialog node. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the newTitle - */ - public String newTitle() { - return newTitle; - } - - /** - * Gets the newDescription. - * - * The description of the dialog node. This string cannot contain carriage return, newline, or tab characters, and it - * must be no longer than 128 characters. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } - - /** - * Gets the newDigressOut. - * - * Whether this dialog node can be returned to after a digression. - * - * @return the newDigressOut - */ - public String newDigressOut() { - return newDigressOut; - } - - /** - * Gets the newEventName. - * - * How an `event_handler` node is processed. - * - * @return the newEventName - */ - public String newEventName() { - return newEventName; - } - - /** - * Gets the newDigressOutSlots. - * - * Whether the user can digress to top-level nodes while filling out slots. - * - * @return the newDigressOutSlots - */ - public String newDigressOutSlots() { - return newDigressOutSlots; - } - - /** - * Gets the newNextStep. - * - * The next step to be executed in dialog processing. - * - * @return the newNextStep - */ - public DialogNodeNextStep newNextStep() { - return newNextStep; - } - - /** - * Gets the newDigressIn. - * - * Whether this top-level dialog node can be digressed into. - * - * @return the newDigressIn - */ - public String newDigressIn() { - return newDigressIn; - } - - /** - * Gets the newOutput. - * - * The output of the dialog node. For more information about how to specify dialog node output, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/dialog-overview.html#complex). - * - * @return the newOutput - */ - public Map newOutput() { - return newOutput; - } - - /** - * Gets the newParent. - * - * The ID of the parent dialog node. - * - * @return the newParent - */ - public String newParent() { - return newParent; - } - - /** - * 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. - * - It must be no longer than 1024 characters. - * - * @return the newDialogNode - */ - public String newDialogNode() { - return newDialogNode; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateEntityOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateEntityOptions.java deleted file mode 100644 index 069db06b5dd..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateEntityOptions.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateEntity options. - */ -public class UpdateEntityOptions extends GenericModel { - - private String workspaceId; - private String entity; - private Boolean newFuzzyMatch; - private String newEntity; - private Map newMetadata; - private List newValues; - private String newDescription; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private Boolean newFuzzyMatch; - private String newEntity; - private Map newMetadata; - private List newValues; - private String newDescription; - - private Builder(UpdateEntityOptions updateEntityOptions) { - workspaceId = updateEntityOptions.workspaceId; - entity = updateEntityOptions.entity; - newFuzzyMatch = updateEntityOptions.newFuzzyMatch; - newEntity = updateEntityOptions.newEntity; - newMetadata = updateEntityOptions.newMetadata; - newValues = updateEntityOptions.newValues; - newDescription = updateEntityOptions.newDescription; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - */ - public Builder(String workspaceId, String entity) { - this.workspaceId = workspaceId; - this.entity = entity; - } - - /** - * Builds a UpdateEntityOptions. - * - * @return the updateEntityOptions - */ - public UpdateEntityOptions build() { - return new UpdateEntityOptions(this); - } - - /** - * Adds an value to newValues. - * - * @param value the new value - * @return the UpdateEntityOptions builder - */ - public Builder addValue(CreateValue value) { - Validator.notNull(value, "value cannot be null"); - if (this.newValues == null) { - this.newValues = new ArrayList(); - } - this.newValues.add(value); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateEntityOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateEntityOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the newFuzzyMatch. - * - * @param newFuzzyMatch the newFuzzyMatch - * @return the UpdateEntityOptions builder - */ - public Builder newFuzzyMatch(Boolean newFuzzyMatch) { - this.newFuzzyMatch = newFuzzyMatch; - return this; - } - - /** - * Set the newEntity. - * - * @param newEntity the newEntity - * @return the UpdateEntityOptions builder - */ - public Builder newEntity(String newEntity) { - this.newEntity = newEntity; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateEntityOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newValues. - * Existing newValues will be replaced. - * - * @param newValues the newValues - * @return the UpdateEntityOptions builder - */ - public Builder newValues(List newValues) { - this.newValues = newValues; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateEntityOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - } - - private UpdateEntityOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - newFuzzyMatch = builder.newFuzzyMatch; - newEntity = builder.newEntity; - newMetadata = builder.newMetadata; - newValues = builder.newValues; - newDescription = builder.newDescription; - } - - /** - * New builder. - * - * @return a UpdateEntityOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the newFuzzyMatch. - * - * Whether to use fuzzy matching for the entity. - * - * @return the newFuzzyMatch - */ - public Boolean newFuzzyMatch() { - return newFuzzyMatch; - } - - /** - * 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-`. - * - It must be no longer than 64 characters. - * - * @return the newEntity - */ - public String newEntity() { - return newEntity; - } - - /** - * Gets the newMetadata. - * - * Any metadata related to the entity. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * Gets the newValues. - * - * An array of entity values. - * - * @return the newValues - */ - public List newValues() { - return newValues; - } - - /** - * Gets the newDescription. - * - * The description of the entity. This string cannot contain carriage return, newline, or tab characters, and it must - * be no longer than 128 characters. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateExampleOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateExampleOptions.java deleted file mode 100644 index 4a9a5cc76d7..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateExampleOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateExample options. - */ -public class UpdateExampleOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String text; - private String newText; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String text; - private String newText; - - private Builder(UpdateExampleOptions updateExampleOptions) { - workspaceId = updateExampleOptions.workspaceId; - intent = updateExampleOptions.intent; - text = updateExampleOptions.text; - newText = updateExampleOptions.newText; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - * @param text the text - */ - public Builder(String workspaceId, String intent, String text) { - this.workspaceId = workspaceId; - this.intent = intent; - this.text = text; - } - - /** - * Builds a UpdateExampleOptions. - * - * @return the updateExampleOptions - */ - public UpdateExampleOptions build() { - return new UpdateExampleOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateExampleOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the UpdateExampleOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the text. - * - * @param text the text - * @return the UpdateExampleOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the newText. - * - * @param newText the newText - * @return the UpdateExampleOptions builder - */ - public Builder newText(String newText) { - this.newText = newText; - return this; - } - } - - private UpdateExampleOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - Validator.notEmpty(builder.text, "text cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - text = builder.text; - newText = builder.newText; - } - - /** - * New builder. - * - * @return a UpdateExampleOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return intent; - } - - /** - * Gets the text. - * - * The text of the user input example. - * - * @return the text - */ - public String text() { - return 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. - * - It must be no longer than 1024 characters. - * - * @return the newText - */ - public String newText() { - return newText; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateIntentOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateIntentOptions.java deleted file mode 100644 index 19042b86b13..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateIntentOptions.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateIntent options. - */ -public class UpdateIntentOptions extends GenericModel { - - private String workspaceId; - private String intent; - private String newIntent; - private List newExamples; - private String newDescription; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String intent; - private String newIntent; - private List newExamples; - private String newDescription; - - private Builder(UpdateIntentOptions updateIntentOptions) { - workspaceId = updateIntentOptions.workspaceId; - intent = updateIntentOptions.intent; - newIntent = updateIntentOptions.newIntent; - newExamples = updateIntentOptions.newExamples; - newDescription = updateIntentOptions.newDescription; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param intent the intent - */ - public Builder(String workspaceId, String intent) { - this.workspaceId = workspaceId; - this.intent = intent; - } - - /** - * Builds a UpdateIntentOptions. - * - * @return the updateIntentOptions - */ - public UpdateIntentOptions build() { - return new UpdateIntentOptions(this); - } - - /** - * Adds an example to newExamples. - * - * @param example the new example - * @return the UpdateIntentOptions builder - */ - public Builder addExample(CreateExample example) { - Validator.notNull(example, "example cannot be null"); - if (this.newExamples == null) { - this.newExamples = new ArrayList(); - } - this.newExamples.add(example); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateIntentOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the intent. - * - * @param intent the intent - * @return the UpdateIntentOptions builder - */ - public Builder intent(String intent) { - this.intent = intent; - return this; - } - - /** - * Set the newIntent. - * - * @param newIntent the newIntent - * @return the UpdateIntentOptions builder - */ - public Builder newIntent(String newIntent) { - this.newIntent = newIntent; - return this; - } - - /** - * Set the newExamples. - * Existing newExamples will be replaced. - * - * @param newExamples the newExamples - * @return the UpdateIntentOptions builder - */ - public Builder newExamples(List newExamples) { - this.newExamples = newExamples; - return this; - } - - /** - * Set the newDescription. - * - * @param newDescription the newDescription - * @return the UpdateIntentOptions builder - */ - public Builder newDescription(String newDescription) { - this.newDescription = newDescription; - return this; - } - } - - private UpdateIntentOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.intent, "intent cannot be empty"); - workspaceId = builder.workspaceId; - intent = builder.intent; - newIntent = builder.newIntent; - newExamples = builder.newExamples; - newDescription = builder.newDescription; - } - - /** - * New builder. - * - * @return a UpdateIntentOptions 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 intent. - * - * The intent name. - * - * @return the intent - */ - public String intent() { - return 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-`. - * - It must be no longer than 128 characters. - * - * @return the newIntent - */ - public String newIntent() { - return newIntent; - } - - /** - * Gets the newExamples. - * - * An array of user input examples for the intent. - * - * @return the newExamples - */ - public List newExamples() { - return newExamples; - } - - /** - * Gets the newDescription. - * - * The description of the intent. - * - * @return the newDescription - */ - public String newDescription() { - return newDescription; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateSynonymOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateSynonymOptions.java deleted file mode 100644 index 6cb0f1da324..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateSynonymOptions.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateSynonym options. - */ -public class UpdateSynonymOptions extends GenericModel { - - private String workspaceId; - private String entity; - private String value; - private String synonym; - private String newSynonym; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private String synonym; - private String newSynonym; - - private Builder(UpdateSynonymOptions updateSynonymOptions) { - workspaceId = updateSynonymOptions.workspaceId; - entity = updateSynonymOptions.entity; - value = updateSynonymOptions.value; - synonym = updateSynonymOptions.synonym; - newSynonym = updateSynonymOptions.newSynonym; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - * @param synonym the synonym - */ - public Builder(String workspaceId, String entity, String value, String synonym) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - this.synonym = synonym; - } - - /** - * Builds a UpdateSynonymOptions. - * - * @return the updateSynonymOptions - */ - public UpdateSynonymOptions build() { - return new UpdateSynonymOptions(this); - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateSynonymOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateSynonymOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the UpdateSynonymOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the synonym. - * - * @param synonym the synonym - * @return the UpdateSynonymOptions builder - */ - public Builder synonym(String synonym) { - this.synonym = synonym; - return this; - } - - /** - * Set the newSynonym. - * - * @param newSynonym the newSynonym - * @return the UpdateSynonymOptions builder - */ - public Builder newSynonym(String newSynonym) { - this.newSynonym = newSynonym; - return this; - } - } - - private UpdateSynonymOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - Validator.notEmpty(builder.synonym, "synonym cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - synonym = builder.synonym; - newSynonym = builder.newSynonym; - } - - /** - * New builder. - * - * @return a UpdateSynonymOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the synonym. - * - * The text of the synonym. - * - * @return the synonym - */ - public String synonym() { - return 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. - * - It must be no longer than 64 characters. - * - * @return the newSynonym - */ - public String newSynonym() { - return newSynonym; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateValueOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateValueOptions.java deleted file mode 100644 index b51be1d7893..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateValueOptions.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateValue options. - */ -public class UpdateValueOptions extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - private String workspaceId; - private String entity; - private String value; - private List newSynonyms; - private String valueType; - private Map newMetadata; - private List newPatterns; - private String newValue; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String entity; - private String value; - private List newSynonyms; - private String valueType; - private Map newMetadata; - private List newPatterns; - private String newValue; - - private Builder(UpdateValueOptions updateValueOptions) { - workspaceId = updateValueOptions.workspaceId; - entity = updateValueOptions.entity; - value = updateValueOptions.value; - newSynonyms = updateValueOptions.newSynonyms; - valueType = updateValueOptions.valueType; - newMetadata = updateValueOptions.newMetadata; - newPatterns = updateValueOptions.newPatterns; - newValue = updateValueOptions.newValue; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param workspaceId the workspaceId - * @param entity the entity - * @param value the value - */ - public Builder(String workspaceId, String entity, String value) { - this.workspaceId = workspaceId; - this.entity = entity; - this.value = value; - } - - /** - * Builds a UpdateValueOptions. - * - * @return the updateValueOptions - */ - public UpdateValueOptions build() { - return new UpdateValueOptions(this); - } - - /** - * Adds an synonym to newSynonyms. - * - * @param synonym the new synonym - * @return the UpdateValueOptions builder - */ - public Builder addSynonym(String synonym) { - Validator.notNull(synonym, "synonym cannot be null"); - if (this.newSynonyms == null) { - this.newSynonyms = new ArrayList(); - } - this.newSynonyms.add(synonym); - return this; - } - - /** - * Adds an pattern to newPatterns. - * - * @param pattern the new pattern - * @return the UpdateValueOptions builder - */ - public Builder addPattern(String pattern) { - Validator.notNull(pattern, "pattern cannot be null"); - if (this.newPatterns == null) { - this.newPatterns = new ArrayList(); - } - this.newPatterns.add(pattern); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateValueOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the UpdateValueOptions builder - */ - public Builder entity(String entity) { - this.entity = entity; - return this; - } - - /** - * Set the value. - * - * @param value the value - * @return the UpdateValueOptions builder - */ - public Builder value(String value) { - this.value = value; - return this; - } - - /** - * Set the newSynonyms. - * Existing newSynonyms will be replaced. - * - * @param newSynonyms the newSynonyms - * @return the UpdateValueOptions builder - */ - public Builder newSynonyms(List newSynonyms) { - this.newSynonyms = newSynonyms; - return this; - } - - /** - * Set the valueType. - * - * @param valueType the valueType - * @return the UpdateValueOptions builder - */ - public Builder valueType(String valueType) { - this.valueType = valueType; - return this; - } - - /** - * Set the newMetadata. - * - * @param newMetadata the newMetadata - * @return the UpdateValueOptions builder - */ - public Builder newMetadata(Map newMetadata) { - this.newMetadata = newMetadata; - return this; - } - - /** - * Set the newPatterns. - * Existing newPatterns will be replaced. - * - * @param newPatterns the newPatterns - * @return the UpdateValueOptions builder - */ - public Builder newPatterns(List newPatterns) { - this.newPatterns = newPatterns; - return this; - } - - /** - * Set the newValue. - * - * @param newValue the newValue - * @return the UpdateValueOptions builder - */ - public Builder newValue(String newValue) { - this.newValue = newValue; - return this; - } - } - - private UpdateValueOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - Validator.notEmpty(builder.entity, "entity cannot be empty"); - Validator.notEmpty(builder.value, "value cannot be empty"); - workspaceId = builder.workspaceId; - entity = builder.entity; - value = builder.value; - newSynonyms = builder.newSynonyms; - valueType = builder.valueType; - newMetadata = builder.newMetadata; - newPatterns = builder.newPatterns; - newValue = builder.newValue; - } - - /** - * New builder. - * - * @return a UpdateValueOptions 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 entity. - * - * The name of the entity. - * - * @return the entity - */ - public String entity() { - return entity; - } - - /** - * Gets the value. - * - * The text of the entity value. - * - * @return the value - */ - public String value() { - return value; - } - - /** - * Gets the newSynonyms. - * - * An array of synonyms for the entity value. You can provide either synonyms or patterns (as indicated by **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. - * - It must be no longer than 64 characters. - * - * @return the newSynonyms - */ - public List newSynonyms() { - return newSynonyms; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String valueType() { - return valueType; - } - - /** - * Gets the newMetadata. - * - * Any metadata related to the entity value. - * - * @return the newMetadata - */ - public Map newMetadata() { - return newMetadata; - } - - /** - * Gets the newPatterns. - * - * An array of patterns for the entity value. You can provide either synonyms or patterns (as indicated by **type**), - * but not both. A pattern is a regular expression no longer than 128 characters. For more information about how to - * specify a pattern, see the - * [documentation](https://console.bluemix.net/docs/services/conversation/entities.html#creating-entities). - * - * @return the newPatterns - */ - public List newPatterns() { - return newPatterns; - } - - /** - * 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. - * - It must be no longer than 64 characters. - * - * @return the newValue - */ - public String newValue() { - return newValue; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateWorkspaceOptions.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateWorkspaceOptions.java deleted file mode 100644 index f07d9105439..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/UpdateWorkspaceOptions.java +++ /dev/null @@ -1,432 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateWorkspace options. - */ -public class UpdateWorkspaceOptions extends GenericModel { - - private String workspaceId; - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - private Boolean append; - - /** - * Builder. - */ - public static class Builder { - private String workspaceId; - private String name; - private String description; - private String language; - private List intents; - private List entities; - private List dialogNodes; - private List counterexamples; - private Map metadata; - private Boolean learningOptOut; - private Boolean append; - - private Builder(UpdateWorkspaceOptions updateWorkspaceOptions) { - workspaceId = updateWorkspaceOptions.workspaceId; - name = updateWorkspaceOptions.name; - description = updateWorkspaceOptions.description; - language = updateWorkspaceOptions.language; - intents = updateWorkspaceOptions.intents; - entities = updateWorkspaceOptions.entities; - dialogNodes = updateWorkspaceOptions.dialogNodes; - counterexamples = updateWorkspaceOptions.counterexamples; - metadata = updateWorkspaceOptions.metadata; - learningOptOut = updateWorkspaceOptions.learningOptOut; - append = updateWorkspaceOptions.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 UpdateWorkspaceOptions. - * - * @return the updateWorkspaceOptions - */ - public UpdateWorkspaceOptions build() { - return new UpdateWorkspaceOptions(this); - } - - /** - * Adds an intent to intents. - * - * @param intent the new intent - * @return the UpdateWorkspaceOptions builder - */ - public Builder addIntent(CreateIntent intent) { - Validator.notNull(intent, "intent cannot be null"); - if (this.intents == null) { - this.intents = new ArrayList(); - } - this.intents.add(intent); - return this; - } - - /** - * Adds an entity to entities. - * - * @param entity the new entity - * @return the UpdateWorkspaceOptions builder - */ - public Builder addEntity(CreateEntity entity) { - Validator.notNull(entity, "entity cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entity); - return this; - } - - /** - * Adds an dialogNode to dialogNodes. - * - * @param dialogNode the new dialogNode - * @return the UpdateWorkspaceOptions builder - */ - public Builder addDialogNode(CreateDialogNode dialogNode) { - Validator.notNull(dialogNode, "dialogNode cannot be null"); - if (this.dialogNodes == null) { - this.dialogNodes = new ArrayList(); - } - this.dialogNodes.add(dialogNode); - return this; - } - - /** - * Adds an counterexample to counterexamples. - * - * @param counterexample the new counterexample - * @return the UpdateWorkspaceOptions builder - */ - public Builder addCounterexample(CreateCounterexample counterexample) { - Validator.notNull(counterexample, "counterexample cannot be null"); - if (this.counterexamples == null) { - this.counterexamples = new ArrayList(); - } - this.counterexamples.add(counterexample); - return this; - } - - /** - * Set the workspaceId. - * - * @param workspaceId the workspaceId - * @return the UpdateWorkspaceOptions builder - */ - public Builder workspaceId(String workspaceId) { - this.workspaceId = workspaceId; - return this; - } - - /** - * Set the name. - * - * @param name the name - * @return the UpdateWorkspaceOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the UpdateWorkspaceOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the UpdateWorkspaceOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the intents. - * Existing intents will be replaced. - * - * @param intents the intents - * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the dialogNodes. - * Existing dialogNodes will be replaced. - * - * @param dialogNodes the dialogNodes - * @return the UpdateWorkspaceOptions 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 UpdateWorkspaceOptions builder - */ - public Builder counterexamples(List counterexamples) { - this.counterexamples = counterexamples; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the UpdateWorkspaceOptions builder - */ - public Builder metadata(Map metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the learningOptOut. - * - * @param learningOptOut the learningOptOut - * @return the UpdateWorkspaceOptions builder - */ - public Builder learningOptOut(Boolean learningOptOut) { - this.learningOptOut = learningOptOut; - return this; - } - - /** - * Set the append. - * - * @param append the append - * @return the UpdateWorkspaceOptions builder - */ - public Builder append(Boolean append) { - this.append = append; - return this; - } - } - - private UpdateWorkspaceOptions(Builder builder) { - Validator.notEmpty(builder.workspaceId, "workspaceId cannot be empty"); - workspaceId = builder.workspaceId; - name = builder.name; - description = builder.description; - language = builder.language; - intents = builder.intents; - entities = builder.entities; - dialogNodes = builder.dialogNodes; - counterexamples = builder.counterexamples; - metadata = builder.metadata; - learningOptOut = builder.learningOptOut; - append = builder.append; - } - - /** - * New builder. - * - * @return a UpdateWorkspaceOptions 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, and it must be - * no longer than 64 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, and it - * must be no longer than 128 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 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 defining the entities for the workspace. - * - * @return the entities - */ - public List entities() { - return entities; - } - - /** - * Gets the dialogNodes. - * - * An array of objects defining the nodes in the workspace dialog. - * - * @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 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 append. - * - * Whether the new data is to be appended to the existing data in the workspace. If **append**=`false`, elements - * included in the new data completely replace the corresponding existing elements, including all subelements. For - * example, if the new data 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/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Value.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Value.java deleted file mode 100644 index 811d284a2d2..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Value.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Value. - */ -public class Value extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - @SerializedName("value") - private String valueText; - private Map metadata; - private Date created; - private Date updated; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Gets the valueText. - * - * The text of the entity value. - * - * @return the valueText - */ - public String getValueText() { - return valueText; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity value. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity value. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array containing any patterns for the entity value. - * - * @return the patterns - */ - public List getPatterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String getValueType() { - return valueType; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueCollection.java deleted file mode 100644 index 28852f3574b..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ValueCollection. - */ -public class ValueCollection extends GenericModel { - - private List values; - private Pagination pagination; - - /** - * Gets the values. - * - * An array of entity values. - * - * @return the values - */ - public List getValues() { - return values; - } - - /** - * Gets the pagination. - * - * An object defining the pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueExport.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueExport.java deleted file mode 100644 index 89946dead92..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/ValueExport.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ValueExport. - */ -public class ValueExport extends GenericModel { - - /** - * Specifies the type of value. - */ - public interface ValueType { - /** synonyms. */ - String SYNONYMS = "synonyms"; - /** patterns. */ - String PATTERNS = "patterns"; - } - - @SerializedName("value") - private String valueText; - private Map metadata; - private Date created; - private Date updated; - private List synonyms; - private List patterns; - @SerializedName("type") - private String valueType; - - /** - * Gets the valueText. - * - * The text of the entity value. - * - * @return the valueText - */ - public String getValueText() { - return valueText; - } - - /** - * Gets the metadata. - * - * Any metadata related to the entity value. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the entity value. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the entity value. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the synonyms. - * - * An array containing any synonyms for the entity value. - * - * @return the synonyms - */ - public List getSynonyms() { - return synonyms; - } - - /** - * Gets the patterns. - * - * An array containing any patterns for the entity value. - * - * @return the patterns - */ - public List getPatterns() { - return patterns; - } - - /** - * Gets the valueType. - * - * Specifies the type of value. - * - * @return the valueType - */ - public String getValueType() { - return valueType; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Workspace.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Workspace.java deleted file mode 100644 index 9cd683923c5..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/Workspace.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Workspace. - */ -public class Workspace extends GenericModel { - - private String name; - private String language; - private Date created; - private Date updated; - @SerializedName("workspace_id") - private String workspaceId; - private String description; - private Map metadata; - @SerializedName("learning_opt_out") - private Boolean learningOptOut; - - /** - * Gets the name. - * - * The name of the workspace. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the language. - * - * The language of the workspace. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the created. - * - * The timestamp for creation of the workspace. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the workspace. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the workspaceId. - * - * The workspace ID. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the description. - * - * The description of the workspace. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the metadata. - * - * Any metadata related to the workspace. - * - * @return the metadata - */ - public Map getMetadata() { - 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 isLearningOptOut() { - return learningOptOut; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceCollection.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceCollection.java deleted file mode 100644 index f9d6ffc0d51..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceCollection.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WorkspaceCollection. - */ -public class WorkspaceCollection extends GenericModel { - - private List workspaces; - private Pagination pagination; - - /** - * Gets the workspaces. - * - * An array of objects describing the workspaces associated with the service instance. - * - * @return the workspaces - */ - public List getWorkspaces() { - return workspaces; - } - - /** - * Gets the pagination. - * - * An object defining the pagination data for the returned objects. - * - * @return the pagination - */ - public Pagination getPagination() { - return pagination; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceExport.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceExport.java deleted file mode 100644 index 8539c8ef1fa..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/model/WorkspaceExport.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1.model; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WorkspaceExport. - */ -public class WorkspaceExport extends GenericModel { - - /** - * The current status of the workspace. - */ - 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"; - } - - private String name; - private String description; - private String language; - private Map metadata; - private Date created; - private Date updated; - @SerializedName("workspace_id") - private String workspaceId; - private String status; - @SerializedName("learning_opt_out") - private Boolean learningOptOut; - private List intents; - private List entities; - private List counterexamples; - @SerializedName("dialog_nodes") - private List dialogNodes; - - /** - * Gets the name. - * - * The name of the workspace. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the description. - * - * The description of the workspace. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the language. - * - * The language of the workspace. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the metadata. - * - * Any metadata that is required by the workspace. - * - * @return the metadata - */ - public Map getMetadata() { - return metadata; - } - - /** - * Gets the created. - * - * The timestamp for creation of the workspace. - * - * @return the created - */ - public Date getCreated() { - return created; - } - - /** - * Gets the updated. - * - * The timestamp for the last update to the workspace. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * Gets the workspaceId. - * - * The workspace ID. - * - * @return the workspaceId - */ - public String getWorkspaceId() { - return workspaceId; - } - - /** - * Gets the status. - * - * The current status of the workspace. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the learningOptOut. - * - * Whether training data from the workspace 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 isLearningOptOut() { - return learningOptOut; - } - - /** - * Gets the intents. - * - * An array of intents. - * - * @return the intents - */ - public List getIntents() { - return intents; - } - - /** - * Gets the entities. - * - * An array of entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the counterexamples. - * - * An array of counterexamples. - * - * @return the counterexamples - */ - public List getCounterexamples() { - return counterexamples; - } - - /** - * Gets the dialogNodes. - * - * An array of objects describing the dialog nodes in the workspace. - * - * @return the dialogNodes - */ - public List getDialogNodes() { - return dialogNodes; - } -} diff --git a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/package-info.java b/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/package-info.java deleted file mode 100644 index e9b32a22aa1..00000000000 --- a/conversation/src/main/java/com/ibm/watson/developer_cloud/conversation/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -/** - * Conversation v1. - */ -package com.ibm.watson.developer_cloud.conversation.v1; diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceIT.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceIT.java deleted file mode 100644 index 68bf9dd3858..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceIT.java +++ /dev/null @@ -1,1688 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.ibm.watson.developer_cloud.conversation.v1.model.Context; -import com.ibm.watson.developer_cloud.conversation.v1.model.Counterexample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CounterexampleCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntity; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateExample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntent; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DialogNode; -import com.ibm.watson.developer_cloud.conversation.v1.model.DialogNodeCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.Example; -import com.ibm.watson.developer_cloud.conversation.v1.model.ExampleCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.InputData; -import com.ibm.watson.developer_cloud.conversation.v1.model.Intent; -import com.ibm.watson.developer_cloud.conversation.v1.model.IntentCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.IntentExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListCounterexamplesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListDialogNodesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListExamplesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListIntentsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListLogsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListWorkspacesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.LogCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.LogExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.conversation.v1.model.OutputData; -import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeIntent; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateCounterexampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateExampleOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.Workspace; -import com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.WorkspaceExport; -import com.ibm.watson.developer_cloud.http.ServiceCallback; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import jersey.repackaged.jsr166e.CompletableFuture; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -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 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 Conversation}. - */ -@RunWith(RetryRunner.class) -public class ConversationServiceIT extends ConversationServiceTest { - - private String exampleIntent; - - DateFormat isoDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); - - /** - * Test README. - */ - @Test - public void testReadme() { - // Conversation service = new Conversation(Conversation.VERSION_DATE_2017_05_26); - // service.setUsernameAndPassword("", ""); - - InputData input = new InputData.Builder("Hi").build(); - MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); - MessageResponse response = service.message(options).execute(); - System.out.println(response); - } - - /** - * Test Example. - */ - @Test - public void testExample() { - // Conversation service = new Conversation(Conversation.VERSION_DATE_2017_05_26); - // service.setUsernameAndPassword("", ""); - - InputData input = new InputData.Builder("Hi").build(); - MessageOptions options = new MessageOptions.Builder(workspaceId).input(input).build(); - - // sync - MessageResponse response = service.message(options).execute(); - System.out.println(response); - - // async - service.message(options).enqueue(new ServiceCallback() { - @Override - public void onResponse(MessageResponse response) { - System.out.println(response); - } - - @Override - public void onFailure(Exception e) { - } - }); - - // rx callback - service.message(options).rx().thenApply(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx async callback - service.message(options).rx().thenApplyAsync(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx sync - try { - MessageResponse rxMessageResponse = service.message(options).rx().get(); - System.out.println(rxMessageResponse); - } catch (Exception ex) { - // Handle exception - } - } - - @Test(expected = UnauthorizedException.class) - public void pingBadCredentialsThrowsException() { - Conversation badService = new Conversation("2018-02-16", "foo", "bar"); - MessageOptions options = new MessageOptions.Builder(workspaceId).build(); - badService.message(options).execute(); - } - - /** - * Test start a conversation without message. - */ - @Test() - public void testStartAConversationWithoutMessage() { - MessageOptions options = new MessageOptions.Builder(workspaceId).build(); - service.message(options).execute(); - } - - /** - * Test send messages. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testSendMessages() throws InterruptedException { - final String[] messages = new String[] { "turn ac on", "turn right", "no", "yes" }; - Context context = null; - for (final String message : messages) { - MessageOptions request = new MessageOptions.Builder(workspaceId) - .input(new InputData.Builder(message).build()) - .alternateIntents(true) - .context(context) - .nodesVisitedDetails(true) - .build(); - - if (message.equals("yes")) { - RuntimeIntent offTopic = new RuntimeIntent(); - offTopic.setIntent("off_topic"); - offTopic.setConfidence(1.0); - request = request.newBuilder().addIntent(offTopic).build(); - } - MessageResponse response = service.message(request).execute(); - - assertMessageFromService(response); - assertNotNull(response.getOutput().getNodesVisitedDetails()); - context = new Context(); - context.putAll(response.getContext()); - Thread.sleep(500); - } - } - - /** - * Assert {@link MessageResponse} from service. - * - * @param message the message from the {@link Conversation} - */ - private void assertMessageFromService(MessageResponse message) { - assertNotNull(message); - assertNotNull(message.getEntities()); - assertNotNull(message.getIntents()); - } - - /** - * Test message with null. - */ - @Test(expected = IllegalArgumentException.class) - public void testMessageWithNull() { - service.message(null).execute(); - } - - /** - * Test to string. - */ - @Test - public void testToString() { - assertNotNull(service.toString()); - } - - /** - * 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(); - Counterexample response = service.createCounterexample(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - service.deleteCounterexample(deleteOptions).execute(); - - try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - service.getCounterexample(getOptions).execute(); - fail("deleteCounterexample failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - try { - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .includeAudit(true) - .build(); - Counterexample response = service.getCounterexample(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - /** - * Test listCounterexamples. - */ - @Test - public void testListCounterexamples() { - - 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(); - assertNotNull(ccResponse); - assertNotNull(ccResponse.getCounterexamples()); - assertNotNull(ccResponse.getPagination()); - assertNotNull(ccResponse.getPagination().getRefreshUrl()); - // nextUrl may be null - - Date start = new Date(); - - // Now add a counterexample and make sure we get it back - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.createCounterexample(createOptions).execute(); - - long count = ccResponse.getCounterexamples().size(); - CounterexampleCollection ccResponse2 = service.listCounterexamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()).execute(); - assertNotNull(ccResponse2); - assertNotNull(ccResponse2.getCounterexamples()); - - List counterexamples = ccResponse2.getCounterexamples(); - assertTrue(counterexamples.size() > count); - - Counterexample exResponse = null; - for (Counterexample resp : counterexamples) { - if (resp.getText().equals(counterExampleText)) { - exResponse = resp; - break; - } - } - - assertNotNull(exResponse); - Date now = new Date(); - assertTrue(fuzzyBefore(exResponse.getCreated(), now)); - assertTrue(fuzzyAfter(exResponse.getCreated(), start)); - assertTrue(fuzzyBefore(exResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(exResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - try { - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText).build(); - service.deleteCounterexample(deleteOptions).execute(); - } catch (NotFoundException ex) { - // Okay - } - } - } - - /** - * Test listCounterexamples with paging. - */ - @Test - public void testListCounterexamplesWithPaging() { - - String counterExampleText1 = "alpha" + UUID.randomUUID().toString(); // gotta be unique - String counterExampleText2 = "zeta" + UUID.randomUUID().toString(); // gotta be unique - - // Add two counterexamples - CreateCounterexampleOptions createOptions = new CreateCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); - service.createCounterexample(createOptions).execute(); - service.createCounterexample(createOptions.newBuilder().text(counterExampleText2).build()).execute(); - - try { - ListCounterexamplesOptions listOptions = new ListCounterexamplesOptions.Builder(workspaceId).pageLimit(1L).sort( - "text").build(); - CounterexampleCollection response = service.listCounterexamples(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getCounterexamples()); - assertTrue(response.getCounterexamples().size() == 1); - found1 |= response.getCounterexamples().get(0).getText().equals(counterExampleText1); - found2 |= response.getCounterexamples().get(0).getText().equals(counterExampleText2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listCounterexamples(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText1).build(); - service.deleteCounterexample(deleteOptions).execute(); - service.deleteCounterexample(deleteOptions.newBuilder().text(counterExampleText2).build()).execute(); - } - } - - /** - * 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(); - service.createCounterexample(createOptions).execute(); - - try { - UpdateCounterexampleOptions updateOptions = new UpdateCounterexampleOptions.Builder(workspaceId, - counterExampleText).newText(counterExampleText2) - .build(); - Counterexample response = service.updateCounterexample(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getText()); - assertEquals(response.getText(), counterExampleText2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteCounterexampleOptions deleteOptions = new DeleteCounterexampleOptions.Builder(workspaceId, - counterExampleText2).build(); - service.deleteCounterexample(deleteOptions).execute(); - } - } - - public void createExampleIntent() { - exampleIntent = "Hello"; - try { - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, exampleIntent).description( - "Example Intent").build(); - service.createIntent(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - } - - /** - * 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(); - Example response = service.createExample(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createExample(createOptions).execute(); - - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - - try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText).build(); - service.getExample(getOptions).execute(); - fail("deleteCounterexample failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getExample. - */ - @Test - public void testGetExample() { - - createExampleIntent(); - - Date start = new Date(); - - String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.createExample(createOptions).execute(); - - try { - GetExampleOptions getOptions = new GetExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .includeAudit(true) - .build(); - Example response = service.getExample(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * Test listExamples. - */ - @Test - public void testListExamples() { - - createExampleIntent(); - - String exampleText = "Howdy " + UUID.randomUUID().toString(); // gotta be unique - - try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - assertNotNull(ecResponse.getPagination()); - assertNotNull(ecResponse.getPagination().getRefreshUrl()); - // nextUrl may be null - - Date start = new Date(); - - // Now add an example and make sure we get it back - CreateExampleOptions createOptions = new CreateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.createExample(createOptions).execute(); - - long count = ecResponse.getExamples().size(); - ExampleCollection ecResponse2 = service.listExamples(listOptions.newBuilder() - .pageLimit(count + 1) - .includeAudit(true) - .build()) - .execute(); - assertNotNull(ecResponse2); - assertNotNull(ecResponse2.getExamples()); - - List examples = ecResponse2.getExamples(); - assertTrue(examples.size() > count); - - Example exResponse = null; - for (Example resp : examples) { - if (resp.getExampleText().equals(exampleText)) { - exResponse = resp; - break; - } - } - - assertNotNull(exResponse); - Date now = new Date(); - assertTrue(fuzzyBefore(exResponse.getCreated(), now)); - assertTrue(fuzzyAfter(exResponse.getCreated(), start)); - assertTrue(fuzzyBefore(exResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(exResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .build(); - service.deleteExample(deleteOptions).execute(); - } - - } - - /** - * Test listExamples with paging. - */ - @Test - public void testListExamplesWithPaging() { - - createExampleIntent(); - - 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(); - service.createExample(createOptions).execute(); - service.createExample(createOptions.newBuilder().text(exampleText2).build()).execute(); - - try { - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, exampleIntent).pageLimit(1L).sort( - "-text").build(); - ExampleCollection response = service.listExamples(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExamples()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getExamples()); - assertTrue(response.getExamples().size() == 1); - found1 |= response.getExamples().get(0).getExampleText().equals(exampleText1); - found2 |= response.getExamples().get(0).getExampleText().equals(exampleText2); - assertTrue(found2 || !found1); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listExamples(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText1) - .build(); - service.deleteExample(deleteOptions).execute(); - service.deleteExample(deleteOptions.newBuilder().text(exampleText2).build()).execute(); - } - - } - - /** - * Test updateExample. - */ - @Test - public void testUpdateExample() { - - createExampleIntent(); - - 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(); - service.createExample(createOptions).execute(); - - try { - UpdateExampleOptions updateOptions = new UpdateExampleOptions.Builder(workspaceId, exampleIntent, exampleText) - .newText(exampleText2).build(); - Example response = service.updateExample(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getExampleText()); - assertEquals(response.getExampleText(), exampleText2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteExampleOptions deleteOptions = new DeleteExampleOptions.Builder(workspaceId, exampleIntent, exampleText2) - .build(); - service.deleteExample(deleteOptions).execute(); - } - } - - /** - * Test createIntent. - */ - @Test - public void testCreateIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - Intent response = service.createIntent(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription); - - Date now = new Date(); - - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - - List examples = ecResponse.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * Test deleteIntent. - */ - @Test - public void testDeleteIntent() { - - String intentName = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName).build(); - service.createIntent(createOptions).execute(); - - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - - try { - GetIntentOptions getOptions = new GetIntentOptions.Builder(workspaceId, intentName).build(); - service.getIntent(getOptions).execute(); - fail("deleteIntent failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getIntent. - */ - @Test - public void testGetIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder().workspaceId(workspaceId).intent(intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - try { - GetIntentOptions getOptions = new GetIntentOptions.Builder() - .workspaceId(workspaceId) - .intent(intentName) - .export(true) - .includeAudit(true) - .build(); - IntentExport response = service.getIntent(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription); - assertNotNull(response.getExamples()); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - List examples = response.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * 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(); - IntentCollection response = service.listIntents(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntents()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // Now add an intent and make sure we get it back - String intentDescription = "Description of " + intentName; - String intentExample = "Example of " + intentName; - List intentExamples = new ArrayList(); - intentExamples.add(new CreateExample.Builder().text(intentExample).build()); - - Date start = new Date(); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - long count = response.getIntents().size(); - ListIntentsOptions listOptions2 = new ListIntentsOptions.Builder(workspaceId) - .export(true) - .pageLimit(count + 1) - .includeAudit(true) - .build(); - IntentCollection response2 = service.listIntents(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getIntents()); - - List intents = response2.getIntents(); - assertTrue(intents.size() > count); - - IntentExport ieResponse = null; - for (IntentExport resp : intents) { - if (resp.getIntentName().equals(intentName)) { - ieResponse = resp; - break; - } - } - - assertNotNull(ieResponse); - assertNotNull(ieResponse.getDescription()); - assertEquals(ieResponse.getDescription(), intentDescription); - assertNotNull(ieResponse.getExamples()); - assertTrue(ieResponse.getExamples().size() == 1); - assertEquals(ieResponse.getExamples().get(0).getExampleText(), intentExample); - - Date now = new Date(); - assertTrue(fuzzyBefore(ieResponse.getCreated(), now)); - assertTrue(fuzzyAfter(ieResponse.getCreated(), start)); - assertTrue(fuzzyBefore(ieResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(ieResponse.getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createIntent(createOptions).execute(); - service.createIntent(createOptions.newBuilder().intent(intentName2).build()).execute(); - - try { - ListIntentsOptions listOptions = new ListIntentsOptions.Builder() - .workspaceId(workspaceId) - .export(true) - .pageLimit(1L) - .sort("modified") - .includeAudit(true) - .build(); - IntentCollection response = service.listIntents(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntents()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getIntents()); - assertTrue(response.getIntents().size() == 1); - found1 |= response.getIntents().get(0).getIntentName().equals(intentName1); - found2 |= response.getIntents().get(0).getIntentName().equals(intentName2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listIntents(listOptions.newBuilder().cursor(cursor).build()).execute(); - - } - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName1).build(); - service.deleteIntent(deleteOptions).execute(); - service.deleteIntent(deleteOptions.newBuilder().intent(intentName2).build()).execute(); - } - } - - /** - * Test updateIntent. - */ - @Test - public void testUpdateIntent() { - - 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 CreateExample.Builder().text(intentExample).build()); - - CreateIntentOptions createOptions = new CreateIntentOptions.Builder(workspaceId, intentName) - .description(intentDescription).examples(intentExamples).build(); - service.createIntent(createOptions).execute(); - - try { - String intentDescription2 = "Updated description of " + intentName; - String intentExample2 = "Updated Example of " + intentName; - List intentExamples2 = new ArrayList(); - intentExamples2.add(new CreateExample.Builder().text(intentExample2).build()); - Date start = new Date(); - UpdateIntentOptions updateOptions = new UpdateIntentOptions.Builder(workspaceId, intentName) - .newDescription(intentDescription2).newExamples(intentExamples2).build(); - Intent response = service.updateIntent(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getIntentName()); - assertEquals(response.getIntentName(), intentName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), intentDescription2); - - Date now = new Date(); - - ListExamplesOptions listOptions = new ListExamplesOptions.Builder(workspaceId, intentName) - .includeAudit(true) - .build(); - ExampleCollection ecResponse = service.listExamples(listOptions).execute(); - assertNotNull(ecResponse); - assertNotNull(ecResponse.getExamples()); - - List examples = ecResponse.getExamples(); - assertTrue(examples.size() == 1); - assertEquals(examples.get(0).getExampleText(), intentExample2); - assertTrue(fuzzyBefore(examples.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(examples.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(examples.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteIntentOptions deleteOptions = new DeleteIntentOptions.Builder(workspaceId, intentName).build(); - service.deleteIntent(deleteOptions).execute(); - } - } - - /** - * Test createWorkspace. - */ - @Test - public void testCreateWorkspace() { - - 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 CreateExample.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 entitySource = "Source for " + 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 CreateCounterexample.Builder().text(counterExampleText).build()); - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().name(workspaceName) - .description(workspaceDescription).language(workspaceLanguage).metadata(workspaceMetadata) - .intents(workspaceIntents).entities(workspaceEntities).counterexamples(workspaceCounterExamples).build(); - - String workspaceId = null; - try { - Workspace response = service.createWorkspace(createOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - workspaceId = response.getWorkspaceId(); - assertNotNull(response.getName()); - assertEquals(response.getName(), workspaceName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), workspaceDescription); - assertNotNull(response.getLanguage()); - assertEquals(response.getLanguage(), workspaceLanguage); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); - WorkspaceExport exResponse = service.getWorkspace(getOptions).execute(); - assertNotNull(exResponse); - - // intents - assertNotNull(exResponse.getIntents()); - assertTrue(exResponse.getIntents().size() == 1); - assertNotNull(exResponse.getIntents().get(0).getIntentName()); - assertEquals(exResponse.getIntents().get(0).getIntentName(), 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).getExampleText()); - assertEquals(exResponse.getIntents().get(0).getExamples().get(0).getExampleText(), intentExample); - - // entities - assertNotNull(exResponse.getEntities()); - assertTrue(exResponse.getEntities().size() == 1); - assertNotNull(exResponse.getEntities().get(0).getEntityName()); - assertEquals(exResponse.getEntities().get(0).getEntityName(), 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).getValueText()); - assertEquals(exResponse.getEntities().get(0).getValues().get(0).getValueText(), entityValue); - assertNotNull(exResponse.getEntities().get(0).getValues().get(0).getSynonyms()); - assertTrue(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().size() == 1); - assertEquals(exResponse.getEntities().get(0).getValues().get(0).getSynonyms().get(0), entityValueSynonym); - - // counterexamples - assertNotNull(exResponse.getCounterexamples()); - assertTrue(exResponse.getCounterexamples().size() == 1); - assertNotNull(exResponse.getCounterexamples().get(0).getText()); - assertEquals(exResponse.getCounterexamples().get(0).getText(), counterExampleText); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - } - } - } - - /** - * Test deleteWorkspace. - */ - @Test - public void testDeleteWorkspace() { - - CreateWorkspaceOptions createOptions = new CreateWorkspaceOptions.Builder().build(); - - String workspaceId = null; - try { - Workspace response = service.createWorkspace(createOptions).execute(); - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - workspaceId = response.getWorkspaceId(); - - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId).export(true).build(); - service.getWorkspace(getOptions).execute(); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - workspaceId = null; - } finally { - // Clean up - if (workspaceId != null) { - DeleteWorkspaceOptions deleteOptions = new DeleteWorkspaceOptions.Builder(workspaceId).build(); - service.deleteWorkspace(deleteOptions).execute(); - } - } - } - - /** - * Test getWorkspace. - */ - @Test - public void testGetWorkspace() { - - GetWorkspaceOptions getOptions = new GetWorkspaceOptions.Builder(workspaceId) - .export(false) - .includeAudit(true) - .build(); - WorkspaceExport response = service.getWorkspace(getOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getWorkspaceId()); - assertEquals(response.getWorkspaceId(), workspaceId); - assertNotNull(response.getName()); - assertNotNull(response.getLanguage()); - - Date now = new Date(); - - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - - // metadata, intents, entities, dialogNodes, and counterexamples could be null - - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * Test listWorkspaces. - */ - @Test - public void testListWorkspaces() { - - ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().build(); - WorkspaceCollection response = service.listWorkspaces(listOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getWorkspaces()); - assertTrue(response.getWorkspaces().size() > 0); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - - Workspace wResponse = null; - for (Workspace resp : response.getWorkspaces()) { - if (resp.getWorkspaceId().equals(workspaceId)) { - wResponse = resp; - break; - } - } - - assertNotNull(wResponse); - assertNotNull(wResponse.getName()); - } - - /** - * Test listWorkspaces with paging. - */ - @Test - public void testListWorkspacesWithPaging() { - - ListWorkspacesOptions listOptions = new ListWorkspacesOptions.Builder().pageLimit(1L).sort("-updated").build(); - WorkspaceCollection response = service.listWorkspaces(listOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - - boolean found = false; - while (true) { - assertNotNull(response.getWorkspaces()); - assertTrue(response.getWorkspaces().size() == 1); - found |= response.getWorkspaces().get(0).getWorkspaceId().equals(workspaceId); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listWorkspaces(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertTrue(found); - } - - /** - * Test updateWorkspace. - */ - @Test - public void testUpdateWorkspace() { - - String workspaceName = "testUpdateWorkspace"; - String workspaceDescription = "Description for testUpdateWorkspace"; - - // intents - CreateIntent intent0 = new CreateIntent.Builder("Hello").build(); - CreateIntent intent1 = new CreateIntent.Builder("Goodbye").build(); - - // entities - CreateEntity entity0 = new CreateEntity.Builder("animal").build(); - CreateEntity entity1 = new CreateEntity.Builder("beverage").build(); - - // counterexamples - CreateCounterexample counterexample0 = new CreateCounterexample.Builder("What are you wearing?").build(); - CreateCounterexample counterexample1 = new CreateCounterexample.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(); - - String workspaceId = null; - try { - Workspace createResponse = service.createWorkspace(createOptions).execute(); - - assertNotNull(createResponse); - assertNotNull(createResponse.getWorkspaceId()); - workspaceId = createResponse.getWorkspaceId(); - - String counterExampleText = "What are you drinking"; - CreateCounterexample counterexample2 = new CreateCounterexample.Builder(counterExampleText).build(); - UpdateWorkspaceOptions updateOptions = new UpdateWorkspaceOptions.Builder(workspaceId) - .addCounterexample(counterexample2) - .append(false) - .build(); - Workspace updateResponse = service.updateWorkspace(updateOptions).execute(); - - assertNotNull(updateResponse); - - GetCounterexampleOptions getOptions = new GetCounterexampleOptions.Builder(workspaceId, counterExampleText) - .build(); - Counterexample eResponse = service.getCounterexample(getOptions).execute(); - assertNotNull(eResponse); - assertNotNull(eResponse.getText()); - assertEquals(eResponse.getText(), counterExampleText); - - } 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 - public void testListLogs() { - - try { - ListLogsOptions listOptions = new ListLogsOptions.Builder().workspaceId(workspaceId).build(); - LogCollection response = service.listLogs(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getLogs()); - assertNotNull(response.getPagination()); - // Empirically -- no refresh_url in pagination of listLogs - // assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * Test listLogs with pagination. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - public void testListLogsWithPaging() { - - try { - ListLogsOptions.Builder listOptionsBuilder = new ListLogsOptions.Builder(workspaceId); - listOptionsBuilder.sort("-request_timestamp"); - listOptionsBuilder.filter("request.intents:intent:off_topic"); - listOptionsBuilder.pageLimit(1L); - - LogCollection response = service.listLogs(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getLogs()); - assertNotNull(response.getPagination()); - // Empirically -- no refresh_url in pagination of listLogs - // assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - assertTrue(response.getLogs().size() == 1); - LogExport logEntry1 = response.getLogs().get(0); - - String cursor = response.getPagination().getNextCursor(); - response = service.listLogs(listOptionsBuilder.cursor(cursor).build()).execute(); - - assertNotNull(response.getLogs()); - assertTrue(response.getLogs().size() == 1); - - LogExport logEntry2 = response.getLogs().get(0); - - Date requestDate1 = isoDateFormat.parse(logEntry1.getRequestTimestamp()); - Date requestDate2 = isoDateFormat.parse(logEntry2.getRequestTimestamp()); - - assertTrue(requestDate2.before(requestDate1)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - /** - * 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(); - DialogNode response = service.createDialogNode(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * Test deleteDialogNode. - */ - @Test - public void testDeleteDialogNode() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); // gotta be unique - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.createDialogNode(createOptions).execute(); - - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - - try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.getDialogNode(getOptions).execute(); - fail("deleteDialogNode failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getDialogNode. - */ - @Test - public void testGetDialogNode() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); - String dialogNodeDescription = "Description of " + dialogNodeName; - - Date start = new Date(); - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription).build(); - service.createDialogNode(createOptions).execute(); - - try { - GetDialogNodeOptions getOptions = new GetDialogNodeOptions.Builder() - .workspaceId(workspaceId) - .dialogNode(dialogNodeName) - .includeAudit(true) - .build(); - DialogNode response = service.getDialogNode(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * Test listDialogNodes. - */ - @Test - public void testListDialogNodes() { - String dialogNodeName = "Test" + UUID.randomUUID().toString(); - - try { - ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder(workspaceId).build(); - DialogNodeCollection response = service.listDialogNodes(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodes()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // Now add a dialog node and make sure we get it back - String dialogNodeDescription = "Description of " + dialogNodeName; - - Date start = new Date(); - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder(workspaceId, dialogNodeName) - .description(dialogNodeDescription) - .build(); - service.createDialogNode(createOptions).execute(); - - long count = response.getDialogNodes().size(); - ListDialogNodesOptions listOptions2 = new ListDialogNodesOptions.Builder(workspaceId) - .pageLimit(count + 1) - .includeAudit(true) - .build(); - DialogNodeCollection response2 = service.listDialogNodes(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getDialogNodes()); - - List dialogNodes = response2.getDialogNodes(); - assertTrue(dialogNodes.size() > count); - - DialogNode dialogResponse = null; - for (DialogNode node : dialogNodes) { - if (node.getDialogNodeId().equals(dialogNodeName)) { - dialogResponse = node; - break; - } - } - - assertNotNull(dialogResponse); - assertNotNull(dialogResponse.getDescription()); - assertEquals(dialogResponse.getDescription(), dialogNodeDescription); - - Date now = new Date(); - assertTrue(fuzzyBefore(dialogResponse.getCreated(), now)); - assertTrue(fuzzyAfter(dialogResponse.getCreated(), start)); - assertTrue(fuzzyBefore(dialogResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(dialogResponse.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName).build(); - service.deleteDialogNode(deleteOptions).execute(); - } - } - - /** - * 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(); - service.createDialogNode(createOptions).execute(); - service.createDialogNode(createOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute(); - - try { - ListDialogNodesOptions listOptions = new ListDialogNodesOptions.Builder().workspaceId(workspaceId).pageLimit(1L) - .sort("dialog_node").build(); - DialogNodeCollection response = service.listDialogNodes(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodes()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getDialogNodes()); - assertTrue(response.getDialogNodes().size() == 1); - found1 |= response.getDialogNodes().get(0).getDialogNodeId().equals(dialogNodeName1); - found2 |= response.getDialogNodes().get(0).getDialogNodeId().equals(dialogNodeName2); - assertTrue(found1 || !found2); // verify sort - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listDialogNodes(listOptions.newBuilder().cursor(cursor).build()).execute(); - - } - assertTrue(found1 && found2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteDialogNodeOptions deleteOptions = new DeleteDialogNodeOptions.Builder(workspaceId, dialogNodeName1).build(); - service.deleteDialogNode(deleteOptions).execute(); - service.deleteDialogNode(deleteOptions.newBuilder().dialogNode(dialogNodeName2).build()).execute(); - } - } - - /** - * 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(); - service.createDialogNode(createOptions).execute(); - - 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(); - DialogNode response = service.updateDialogNode(updateOptions).execute(); - assertNotNull(response); - assertNotNull(response.getDialogNodeId()); - assertEquals(response.getDialogNodeId(), dialogNodeName2); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), dialogNodeDescription2); - } 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(); - service.deleteUserData(deleteOptions).execute(); - } catch (Exception ex) { - fail(ex.getMessage()); - } - } -} diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceTest.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceTest.java deleted file mode 100644 index 52872bd2a67..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationServiceTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import java.util.Date; - -import org.junit.Assume; -import org.junit.Before; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; - -public class ConversationServiceTest extends WatsonServiceTest { - - Conversation service; - String workspaceId; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("conversation.v1.username"); - String password = getProperty("conversation.v1.password"); - workspaceId = getProperty("conversation.v1.workspace_id"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new Conversation("2018-02-16"); - service.setEndPoint(getProperty("conversation.v1.url")); - service.setUsernameAndPassword(username, password); - service.setDefaultHeaders(getDefaultHeaders()); - } - - long tolerance = 2000; // 2 secs in ms - - /** - * return `true` if ldate before rdate within tolerance. - */ - public boolean fuzzyBefore(Date ldate, Date rdate) { - return (ldate.getTime() - rdate.getTime()) < tolerance; - } - - /** - * return `true` if ldate after rdate within tolerance. - */ - public boolean fuzzyAfter(Date ldate, Date rdate) { - return (rdate.getTime() - ldate.getTime()) < tolerance; - } - -} diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationTest.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationTest.java deleted file mode 100644 index c88e2fec9c1..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ConversationTest.java +++ /dev/null @@ -1,730 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.conversation.v1.model.Context; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateCounterexample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNode; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntity; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateExample; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntent; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateWorkspaceOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DialogNodeAction; -import com.ibm.watson.developer_cloud.conversation.v1.model.InputData; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListAllLogsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeEntity; -import com.ibm.watson.developer_cloud.conversation.v1.model.RuntimeIntent; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateDialogNodeOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateIntentOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateWorkspaceOptions; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -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.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Unit tests for the {@link Conversation}. - */ -public class ConversationTest extends WatsonServiceUnitTest { - private Conversation service; - private static final String FIXTURE = "src/test/resources/conversation/conversation.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 Conversation("2018-02-16"); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Conversation(null); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Conversation(""); - } - - /** - * Negative - Test conversation with null options. - */ - @Test(expected = IllegalArgumentException.class) - public void testConversationWithNullOptions() { - service.message(null).execute(); - } - - /** - * Negative - Test conversation with null workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testConversationWithNullWorkspaceId() { - MessageOptions options = new MessageOptions.Builder().build(); - service.message(options).execute(); - } - - /** - * Negative - Test conversation with empty workspaceId. - */ - @Test(expected = IllegalArgumentException.class) - public void testConversationWithEmptyWorkspaceId() { - MessageOptions options = new MessageOptions.Builder("").build(); - service.message(options).execute(); - } - - /** - * 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)); - - InputData input = new InputData.Builder(text).build(); - RuntimeIntent intent = new RuntimeIntent(); - intent.setIntent("turn_on"); - intent.setConfidence(0.0); - RuntimeEntity entity = new RuntimeEntity(); - entity.setEntity("genre"); - entity.setValue("jazz"); - 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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=2018-02-16"); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - assertNotNull(serviceResponse.getOutput().getLogMessages()); - assertNotNull(serviceResponse.getOutput().getNodesVisited()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getDialogNode()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getTitle()); - assertNotNull(serviceResponse.getOutput().getNodesVisitedDetails().get(0).getConditions()); - assertEquals(serviceResponse, mockResponse); - } - - /** - * 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)); - - Context contextTemp = new Context(); - contextTemp.put("name", "Myname"); - InputData inputTemp = new InputData.Builder("My text").build(); - - 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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(PATH_MESSAGE, "?", VERSION, "=2018-02-16"); - assertEquals(path, request.getPath()); - assertArrayEquals(new String[] { "Great choice! Playing some jazz for you." }, - serviceResponse.getOutput().getText().toArray(new String[0])); - assertEquals(request.getMethod(), "POST"); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - assertEquals(serviceResponse, mockResponse); - } - - /** - * 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"; - - InputData input = new InputData.Builder(text).build(); - MessageOptions options = new MessageOptions.Builder().input(input).alternateIntents(true).build(); - - service.message(options).execute(); - } - - /** - * Test CreateWorkspace builder. - */ - @Test - public void testCreateWorkspaceBuilder() { - - String workspaceName = "Builder Test"; - String workspaceDescription = "Description of " + workspaceName; - String workspaceLanguage = "en"; - - // 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 - CreateCounterexample testCounterexample0 = new CreateCounterexample.Builder("testCounterexample0").build(); - CreateCounterexample testCounterexample1 = new CreateCounterexample.Builder("testCounterexample1").build(); - - // dialognodes - CreateDialogNode testDialogNode0 = new CreateDialogNode.Builder("dialogNode0").build(); - CreateDialogNode testDialogNode1 = new CreateDialogNode.Builder("dialogNode1").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - 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) - .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(1), testDialogNode1); - - CreateWorkspaceOptions.Builder builder = createOptions.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build(); - CreateDialogNode testDialogNode2 = new CreateDialogNode.Builder("dialogNode2").build(); - - builder.intents(Arrays.asList(testIntent2)); - builder.entities(Arrays.asList(testEntity2)); - builder.counterexamples(Arrays.asList(testCounterexample2)); - builder.dialogNodes(Arrays.asList(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 - CreateCounterexample testCounterexample = new CreateCounterexample.Builder("testCounterexample").build(); - - // dialognodes - CreateDialogNode testDialogNode = new CreateDialogNode.Builder("dialogNode").build(); - - // metadata - Map workspaceMetadata = new HashMap(); - String metadataValue = "value for " + workspaceName; - workspaceMetadata.put("key", metadataValue); - - 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); - - 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); - - UpdateWorkspaceOptions.Builder builder2 = options.newBuilder(); - - CreateIntent testIntent2 = new CreateIntent.Builder("testIntent2").build(); - CreateEntity testEntity2 = new CreateEntity.Builder("testEntity2").build(); - CreateCounterexample testCounterexample2 = new CreateCounterexample.Builder("testCounterexample2").build(); - CreateDialogNode testDialogNode2 = new CreateDialogNode.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 CreateIntentOptions builder. - */ - @Test - public void testCreateIntentOptionsBuilder() { - String intent = "anIntent"; - CreateExample intentExample0 = new CreateExample.Builder().text("intentExample0").build(); - CreateExample intentExample1 = new CreateExample.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(); - - CreateExample intentExample2 = new CreateExample.Builder().text("intentExample2").build(); - builder.examples(Arrays.asList(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"; - CreateExample intentExample0 = new CreateExample.Builder().text("intentExample0").build(); - CreateExample intentExample1 = new CreateExample.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(); - - CreateExample intentExample2 = new CreateExample.Builder().text("intentExample2").build(); - builder.newExamples(Arrays.asList(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) - .addValue(entityValue0).addValue(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(Arrays.asList(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(Arrays.asList(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) - .valueType(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.valueType(), valueType); - - CreateValueOptions.Builder builder = createOptions.newBuilder(); - - String valueSynonym2 = "valueSynonym2"; - String valuePattern2 = "valuePattern2"; - builder.synonyms(Arrays.asList(valueSynonym2)); - builder.patterns(Arrays.asList(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(Arrays.asList(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(); - action0.setName("action0"); - action0.setCredentials("credential0"); - DialogNodeAction action1 = new DialogNodeAction(); - action1.setName("action1"); - action1.setCredentials("credential1"); - - CreateDialogNodeOptions createOptions = new CreateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .addActions(action0).addActions(action1) - .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).getCredentials(), "credential0"); - assertEquals(createOptions.actions().get(1), action1); - assertEquals(createOptions.actions().get(1).getCredentials(), "credential1"); - } - - /** - * Test UpdateDialogNodeOptions builder. - */ - @Test - public void testUpdateDialogNodeOptionsBuilder() { - String dialogNodeName = "aDialogNode"; - String newDialogNodeName = "renamedDialogNode"; - DialogNodeAction action0 = new DialogNodeAction(); - action0.setName("action0"); - action0.setCredentials("credential0"); - DialogNodeAction action1 = new DialogNodeAction(); - action1.setName("action1"); - action1.setCredentials("credential1"); - - UpdateDialogNodeOptions updateOptions = new UpdateDialogNodeOptions.Builder() - .workspaceId(WORKSPACE_ID) - .dialogNode(dialogNodeName) - .newDialogNode(newDialogNodeName) - .addNewActions(action0).addNewActions(action1) - .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).getCredentials(), "credential0"); - assertEquals(updateOptions.newActions().get(1), action1); - assertEquals(updateOptions.newActions().get(1).getCredentials(), "credential1"); - } - - /** - * 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); - } -} diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/EntitiesIT.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/EntitiesIT.java deleted file mode 100644 index 64cb40873a2..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/EntitiesIT.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValue; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.EntityCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.EntityExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.Entity; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListEntitiesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; - -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 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; - -@RunWith(RetryRunner.class) -public class EntitiesIT extends ConversationServiceTest { - - /** - * Test createEntity. - */ - @Test - public void testCreateEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - Map entityMetadata = new HashMap(); - String metadataValue = "value for " + entity; - entityMetadata.put("key", metadataValue); - - CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); - optionsBuilder.workspaceId(workspaceId); - optionsBuilder.entity(entity); - optionsBuilder.description(entityDescription); - optionsBuilder.metadata(entityMetadata); - optionsBuilder.fuzzyMatch(true); // default is false - Entity response = service.createEntity(optionsBuilder.build()).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription); - - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - assertNotNull(response.isFuzzyMatch()); - assertTrue(response.isFuzzyMatch()); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test deleteEntity. - */ - @Test - public void testDeleteEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - CreateEntityOptions options = new CreateEntityOptions.Builder(workspaceId, entity).build(); - Entity response = service.createEntity(options).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNull(response.getDescription()); - assertNull(response.getMetadata()); - assertTrue(response.isFuzzyMatch() == null || response.isFuzzyMatch().equals(Boolean.FALSE)); - } catch (Exception ex) { - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - - try { - GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity).build(); - service.getEntity(getOptions).execute(); - fail("deleteEntity failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getEntity. - */ - @Test - public void testGetEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - String entityValue = "Value of " + entity; - List entityValues = new ArrayList(); - entityValues.add(new CreateValue.Builder().value(entityValue).build()); - - CreateEntityOptions.Builder optionsBuilder = new CreateEntityOptions.Builder(); - optionsBuilder.workspaceId(workspaceId); - optionsBuilder.entity(entity); - optionsBuilder.description(entityDescription); - optionsBuilder.values(entityValues); - service.createEntity(optionsBuilder.build()).execute(); - - Date start = new Date(); - - try { - GetEntityOptions getOptions = new GetEntityOptions.Builder(workspaceId, entity) - .export(true) - .includeAudit(true) - .build(); - EntityExport response = service.getEntity(getOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription); - assertNotNull(response.getValues()); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - List values = response.getValues(); - assertTrue(values.size() == 1); - assertEquals(values.get(0).getValueText(), entityValue); - assertTrue(fuzzyBefore(values.get(0).getCreated(), now)); - assertTrue(fuzzyAfter(values.get(0).getCreated(), start)); - assertTrue(fuzzyBefore(values.get(0).getUpdated(), now)); - assertTrue(fuzzyAfter(values.get(0).getUpdated(), start)); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test listEntities. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - public void testListEntities() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - - try { - ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId).build(); - EntityCollection response = service.listEntities(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntities()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - - // 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) - .addValue(new CreateValue.Builder(entityValue).build()) - .build(); - service.createEntity(options).execute(); - - ListEntitiesOptions listOptions2 = listOptions.newBuilder() - .sort("-updated").pageLimit(5L).export(true).build(); - EntityCollection response2 = service.listEntities(listOptions2).execute(); - assertNotNull(response2); - assertNotNull(response2.getEntities()); - - List entities = response2.getEntities(); - EntityExport ieResponse = null; - for (EntityExport resp : entities) { - if (resp.getEntityName().equals(entity)) { - ieResponse = resp; - break; - } - } - - assertNotNull(ieResponse); - assertNotNull(ieResponse.getDescription()); - assertEquals(ieResponse.getDescription(), entityDescription); - assertNotNull(ieResponse.getValues()); - assertTrue(ieResponse.getValues().size() == 1); - assertTrue(ieResponse.getValues().get(0).getValueText().equals(entityValue)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity).build(); - service.deleteEntity(deleteOptions).execute(); - } - } - - /** - * Test listEntities with pagination. - */ - @Test - @Ignore("To be run locally until we fix the Rate limitation issue") - 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(); - service.createEntity(createOptions).execute(); - service.createEntity(createOptions.newBuilder().entity(entity2).build()).execute(); - - try { - ListEntitiesOptions listOptions = new ListEntitiesOptions.Builder(workspaceId) - .sort("entity") - .pageLimit(1L) - .build(); - EntityCollection response = service.listEntities(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getEntities()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - assertTrue(!response.getEntities().get(0).getEntityName().equals(entity1)); - - EntityExport ieResponse = null; - while (response.getPagination().getNextCursor() != null) { - assertNotNull(response.getEntities()); - assertTrue(response.getEntities().size() == 1); - if (response.getEntities().get(0).getEntityName().equals(entity1)) { - ieResponse = response.getEntities().get(0); - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listEntities(listOptions.newBuilder().cursor(cursor).build()).execute(); - } - - assertNotNull(ieResponse); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity1).build(); - service.deleteEntity(deleteOptions).execute(); - service.deleteEntity(deleteOptions.newBuilder().entity(entity2).build()).execute(); - } - } - - /** - * Test updateEntity. - */ - @Test - public void testUpdateEntity() { - - String entity = "Hello" + UUID.randomUUID().toString(); // gotta be unique - String entity2 = "Goodbye" + UUID.randomUUID().toString(); // gotta be unique - String entityDescription = "Description of " + entity; - - CreateEntityOptions.Builder createOptionsBuilder = new CreateEntityOptions.Builder(); - createOptionsBuilder.workspaceId(workspaceId); - createOptionsBuilder.entity(entity); - createOptionsBuilder.description(entityDescription); - service.createEntity(createOptionsBuilder.build()).execute(); - - try { - String entityDescription2 = "Description of " + entity2; - String entityValue2 = "Value of " + entity2; - Map entityMetadata2 = new HashMap(); - String metadataValue2 = "value for " + entity2; - entityMetadata2.put("key", metadataValue2); - - UpdateEntityOptions.Builder updateOptionsBuilder = new UpdateEntityOptions.Builder(workspaceId, entity); - updateOptionsBuilder.newEntity(entity2); - updateOptionsBuilder.newDescription(entityDescription2); - updateOptionsBuilder.addValue(new CreateValue.Builder().value(entityValue2).build()); - updateOptionsBuilder.newMetadata(entityMetadata2); - updateOptionsBuilder.newFuzzyMatch(true); - - Entity response = service.updateEntity(updateOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getEntityName()); - assertEquals(response.getEntityName(), entity2); - assertNotNull(response.getDescription()); - assertEquals(response.getDescription(), entityDescription2); - - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue2); - - assertNotNull(response.isFuzzyMatch()); - assertTrue(response.isFuzzyMatch()); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteEntityOptions deleteOptions = new DeleteEntityOptions.Builder(workspaceId, entity2).build(); - service.deleteEntity(deleteOptions).execute(); - } - } -} diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/SynonymsIT.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/SynonymsIT.java deleted file mode 100644 index 48258131202..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/SynonymsIT.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetSynonymOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListSynonymsOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.SynonymCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.Synonym; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateSynonymOptions; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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; - -@RunWith(RetryRunner.class) -public class SynonymsIT extends ConversationServiceTest { - - /** - * Test createSynonym. - */ - @Test - public void testCreateSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - Synonym response = service.createSynonym(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } - - /** - * Test deleteSynonym. - */ - @Test - public void testDeleteSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - Synonym response = service.createSynonym(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - } catch (Exception ex) { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .synonym(synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - - try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym).build(); - service.getSynonym(getOptions).execute(); - fail("deleteSynonym failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getSynonym. - */ - @Test - public void testGetSynonym() { - - String entity = "beverage"; - String entityValue = "orange juice"; - String synonym = "OJ"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - Date start = new Date(); - - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.createSynonym(createOptions).execute(); - - try { - GetSynonymOptions getOptions = new GetSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .includeAudit(true) - .build(); - Synonym response = service.getSynonym(getOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } - - /** - * Test listSynonyms. - */ - @Test - public void testListSynonyms() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.createSynonym(createOptions).execute(); - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute(); - } 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(); - final SynonymCollection response = service.listSynonyms(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getSynonyms()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - - assertTrue(response.getSynonyms().size() >= 2); - - // 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); - boolean found1 = false, found2 = false; - for (Synonym synonymResponse : response.getSynonyms()) { - found1 |= synonymResponse.getSynonymText().equals(synonym1); - found2 |= synonymResponse.getSynonymText().equals(synonym2); - } - assertTrue(found1 && found2); - } - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.deleteSynonym(deleteOptions).execute(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute(); - } - } - - /** - * Test listSynonyms with pagination. - */ - @Test - public void testListSynonymsWithPaging() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } 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(); - try { - service.createSynonym(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - try { - service.createSynonym(createOptions.newBuilder().synonym(synonym2).build()).execute(); - } 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); - listOptionsBuilder.sort("modified"); - listOptionsBuilder.pageLimit(1L); - - SynonymCollection response = service.listSynonyms(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getSynonyms()); - assertTrue(response.getSynonyms().size() == 1); - found1 |= response.getSynonyms().get(0).getSynonymText().equals(synonym1); - found2 |= response.getSynonyms().get(0).getSynonymText().equals(synonym2); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listSynonyms(listOptionsBuilder.cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.deleteSynonym(deleteOptions).execute(); - service.deleteSynonym(deleteOptions.newBuilder().synonym(synonym2).build()).execute(); - } - } - - /** - * Test updateSynonym. - */ - @Test - public void testUpdateSynonym() { - - String entity = "beverage"; - String entityValue = "coffee"; - String synonym1 = "joe"; - String synonym2 = "mud"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateSynonymOptions createOptions = new CreateSynonymOptions.Builder(workspaceId, entity, entityValue, synonym1) - .build(); - service.createSynonym(createOptions).execute(); - } 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(); - Synonym response = service.updateSynonym(updateOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getSynonymText()); - assertEquals(response.getSynonymText(), synonym2); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteSynonymOptions deleteOptions = new DeleteSynonymOptions.Builder(workspaceId, entity, entityValue, synonym2) - .build(); - service.deleteSynonym(deleteOptions).execute(); - } - } -} diff --git a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ValuesIT.java b/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ValuesIT.java deleted file mode 100644 index 6238b78b6a7..00000000000 --- a/conversation/src/test/java/com/ibm/watson/developer_cloud/conversation/v1/ValuesIT.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.conversation.v1; - -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateEntityOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.CreateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.DeleteValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.GetValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ListValuesOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.UpdateValueOptions; -import com.ibm.watson.developer_cloud.conversation.v1.model.ValueCollection; -import com.ibm.watson.developer_cloud.conversation.v1.model.ValueExport; -import com.ibm.watson.developer_cloud.conversation.v1.model.Value; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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 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; - -@RunWith(RetryRunner.class) -public class ValuesIT extends ConversationServiceTest { - - /** - * Test createValue. - */ - @Test - public void testCreateValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - - // metadata - Map valueMetadata = new HashMap(); - String metadataValue = "value for " + entityValue; - valueMetadata.put("key", metadataValue); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - Value response = service.createValue(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNotNull(response.getMetadata()); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - } - } - - /** - * Test deleteValue. - */ - @Test - public void testDeleteValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - Value response = service.createValue(createOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNull(response.getMetadata()); - } catch (Exception ex) { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - fail(ex.getMessage()); - } - - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder() - .workspaceId(workspaceId) - .entity(entity) - .value(entityValue) - .build(); - service.deleteValue(deleteOptions).execute(); - - try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.getValue(getOptions).execute(); - fail("deleteValue failed"); - } catch (Exception ex) { - // Expected result - assertTrue(ex instanceof NotFoundException); - } - } - - /** - * Test getValue. - */ - @Test - public void testGetValue() { - - String entity = "beverage"; - String entityValue = "coffee" + UUID.randomUUID().toString(); - String synonym1 = "java"; - String synonym2 = "joe"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - service.createValue(createOptions).execute(); - - Date start = new Date(); - - try { - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue) - .export(true) - .includeAudit(true) - .build(); - ValueExport response = service.getValue(getOptions).execute(); - - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue); - assertNotNull(response.getCreated()); - assertNotNull(response.getUpdated()); - - Date now = new Date(); - assertTrue(fuzzyBefore(response.getCreated(), now)); - assertTrue(fuzzyAfter(response.getCreated(), start)); - assertTrue(fuzzyBefore(response.getUpdated(), now)); - assertTrue(fuzzyAfter(response.getUpdated(), start)); - - assertNotNull(response.getSynonyms()); - assertTrue(response.getSynonyms().size() == 2); - assertTrue(response.getSynonyms().contains(synonym1)); - assertTrue(response.getSynonyms().contains(synonym2)); - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue).build(); - service.deleteValue(deleteOptions).execute(); - } - } - - /** - * Test listValues. - */ - @Test - public void testListValues() { - - String entity = "beverage"; - String entityValue1 = "coffee"; - String entityValue2 = "orange juice"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - try { - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute(); - } 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(); - final ValueCollection response = service.listValues(listOptions).execute(); - assertNotNull(response); - assertNotNull(response.getValues()); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - // nextUrl may be null - if (response.getPagination().getNextUrl() == null) { - assertNull(response.getPagination().getNextCursor()); - } else { - assertNotNull(response.getPagination().getNextCursor()); - } - - assertTrue(response.getValues().size() >= 2); - - // 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); - boolean found1 = false, found2 = false; - for (ValueExport valueResponse : response.getValues()) { - found1 |= valueResponse.getValueText().equals(entityValue1); - found2 |= valueResponse.getValueText().equals(entityValue2); - } - assertTrue(found1 && found2); - } - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.deleteValue(deleteOptions).execute(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute(); - } - } - - /** - * Test listValues with pagination. - */ - @Test - public void testListValuesWithPaging() { - - String entity = "beverage"; - String entityValue1 = "coffee"; - String entityValue2 = "orange juice"; - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } 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(); - try { - service.createValue(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - service.createValue(createOptions.newBuilder().value(entityValue2).build()).execute(); - } 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); - listOptionsBuilder.sort("updated"); - listOptionsBuilder.pageLimit(1L); - listOptionsBuilder.export(true); - - ValueCollection response = service.listValues(listOptionsBuilder.build()).execute(); - assertNotNull(response); - assertNotNull(response.getPagination()); - assertNotNull(response.getPagination().getRefreshUrl()); - assertNotNull(response.getPagination().getNextUrl()); - assertNotNull(response.getPagination().getNextCursor()); - - boolean found1 = false, found2 = false; - while (true) { - assertNotNull(response.getValues()); - assertTrue(response.getValues().size() == 1); - found1 |= response.getValues().get(0).getValueText().equals(entityValue1); - found2 |= response.getValues().get(0).getValueText().equals(entityValue2); - if (response.getPagination().getNextCursor() == null) { - break; - } - String cursor = response.getPagination().getNextCursor(); - response = service.listValues(listOptionsBuilder.cursor(cursor).build()).execute(); - } - - assertTrue(found1 && found2); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.deleteValue(deleteOptions).execute(); - service.deleteValue(deleteOptions.newBuilder().value(entityValue2).build()).execute(); - } - } - - /** - * Test updateValue. - */ - @Test - public void testUpdateValue() { - - String entity = "beverage"; - String entityValue1 = "coffee" + UUID.randomUUID().toString(); - String entityValue2 = "coffee" + UUID.randomUUID().toString(); - String synonym1 = "java"; - String synonym2 = "joe"; - - // metadata - Map valueMetadata = new HashMap(); - String metadataValue = "value for " + entityValue2; - valueMetadata.put("key", metadataValue); - - try { - CreateEntityOptions createOptions = new CreateEntityOptions.Builder(workspaceId, entity).build(); - service.createEntity(createOptions).execute(); - } catch (Exception ex) { - // Exception is okay if is for Unique Violation - assertTrue(ex.getLocalizedMessage().startsWith("Unique Violation")); - } - - try { - CreateValueOptions createOptions = new CreateValueOptions.Builder(workspaceId, entity, entityValue1).build(); - service.createValue(createOptions).execute(); - } 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(); - Value response = service.updateValue(updateOptions).execute(); - - try { - assertNotNull(response); - assertNotNull(response.getValueText()); - assertEquals(response.getValueText(), entityValue2); - - GetValueOptions getOptions = new GetValueOptions.Builder(workspaceId, entity, entityValue2) - .export(true) - .includeAudit(true) - .build(); - ValueExport vResponse = service.getValue(getOptions).execute(); - - assertNotNull(vResponse); - assertNotNull(vResponse.getValueText()); - assertEquals(vResponse.getValueText(), entityValue2); - assertNotNull(vResponse.getCreated()); - assertNotNull(vResponse.getUpdated()); - - assertNotNull(vResponse.getSynonyms()); - assertTrue(vResponse.getSynonyms().size() == 2); - assertTrue(vResponse.getSynonyms().contains(synonym1)); - assertTrue(vResponse.getSynonyms().contains(synonym2)); - - // metadata - assertNotNull(response.getMetadata()); - assertNotNull(response.getMetadata().get("key")); - assertEquals(response.getMetadata().get("key"), metadataValue); - - } catch (Exception ex) { - fail(ex.getMessage()); - } finally { - // Clean up - DeleteValueOptions deleteOptions = new DeleteValueOptions.Builder(workspaceId, entity, entityValue2).build(); - service.deleteValue(deleteOptions).execute(); - } - } -} diff --git a/conversation/src/test/resources/conversation/conversation.json b/conversation/src/test/resources/conversation/conversation.json deleted file mode 100644 index 4ece4091566..00000000000 --- a/conversation/src/test/resources/conversation/conversation.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "intents": [ - { - "intent": "turn_on", - "confidence": 0.9842960834503174 - } - ], - "entities": [ - { - "entity": "genre", - "location": [ - 26, - 30 - ], - "value": "jazz", - "confidence": 1 - }, - { - "entity": "genre_bad", - "location": [ - 31, - 36 - ], - "value": "Soundtrack", - "confidence": 0.7 - }, - { - "entity": "appliance", - "location": [ - 31, - 36 - ], - "value": "music", - "confidence": 1 - } - ], - "input": { - "text": "I would love to hear some jazz music." - }, - "output": { - "text": [ - "Great choice! Playing some jazz for you." - ], - "nodes_visited": [ - "Entry Point For On Off Commands", - "node_5_1469049934217", - "Genre On Off Check", - "node_3_1484628332751" - ], - "action": { - "music_on": "jazz" - }, - "nodes_visited_details": [ - { - "dialog_node": "Entry Point For On Off Commands", - "title": "Entry Point For On Off Commands", - "conditions": "#turn_on" - }, - { - "dialog_node": "node_5_1469049934217", - "title": null, - "conditions": "@genre" - }, - { - "dialog_node": "Genre On Off Check", - "title": "Genre On Off Check", - "conditions": "true" - }, - { - "dialog_node": "node_3_1484628332751", - "title": null, - "conditions": "$appl_action == \"on\"" - } - ], - "log_messages": [] - }, - "context": { - "conversation_id": "ed55c019-83b0-4d24-9d7c-99ee85e4e7a7", - "system": { - "dialog_stack": [ - { - "dialog_node": "root" - } - ], - "dialog_turn_counter": 2, - "dialog_request_counter": 2, - "_node_output_map": { - "Start And Initialize Context": [ - 0, - 0 - ], - "node_3_1484628332751": [ - 0, - 0 - ] - }, - "branch_exited": true, - "branch_exited_reason": "completed" - }, - "AConoff": "off", - "lightonoff": "off", - "musiconoff": "on", - "appl_action": "on", - "heateronoff": "off", - "volumeonoff": "off", - "wipersonoff": "off", - "default_counter": 0, - "previous_cuisine": "", - "previous_restaurant_date": "", - "previous_restaurant_time": "" - } -} diff --git a/core/build.gradle b/core/build.gradle deleted file mode 100644 index 35f3d5f52e2..00000000000 --- a/core/build.gradle +++ /dev/null @@ -1,132 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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 -} - - task testJar(type: Jar) { - classifier = 'tests' - from sourceSets.test.output - } - - configurations { - tests - } - - artifacts { - tests testJar - } - -dependencies { - compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.8.0' - compile group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '3.8.0' - compile group: 'com.squareup.okhttp3', name: 'okhttp-urlconnection', version: '3.8.0' - compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0' - compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.5' - compile group: 'org.glassfish.jersey.bundles.repackaged', name: 'jersey-jsr166e', version: '2.25.1' - testCompile group: 'simple-jndi', name: 'simple-jndi', version: '0.11.4.1' - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' - -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'core' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Services' - url 'https://www.ibm.com/watson/developer' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/Headers.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/Headers.java deleted file mode 100644 index f365079124f..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/Headers.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.ibm.watson.developer_cloud.http; - -import java.util.List; -import java.util.Set; - -/** - * Wrapper class for the internal HTTP headers class. - */ -public class Headers { - - private okhttp3.Headers headers; - - public Headers(okhttp3.Headers headers) { - this.headers = headers; - } - - /** - * Returns true if other is a Headers object with the same headers, with the same casing, in the same order. - * - * @param other the other object to compare - * @return whether the two objects are equal or not - */ - public boolean equals(Object other) { - return this.headers.equals(other); - } - - public int hashCode() { - return this.headers.hashCode(); - } - - public String toString() { - return this.headers.toString(); - } - - /** - * Returns an immutable, case-insensitive set of header names. - * - * @return the list of header names - */ - public Set names() { - return this.headers.names(); - } - - /** - * Returns an immutable list of the header values for the specified name. - * - * @param name the name of the specified header - * @return the values associated with the name - */ - public List values(String name) { - return this.headers.values(name); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpClientSingleton.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpClientSingleton.java deleted file mode 100644 index 62de2c36446..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpClientSingleton.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.DelegatingSSLSocketFactory; -import com.ibm.watson.developer_cloud.util.HttpLogging; -import okhttp3.ConnectionSpec; -import okhttp3.OkHttpClient; -import okhttp3.OkHttpClient.Builder; -import okhttp3.TlsVersion; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; -import java.io.IOException; -import java.net.CookieManager; -import java.net.CookiePolicy; -import java.security.KeyManagementException; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * This class encapsulate the {@link OkHttpClient} instance in a singleton pattern. OkHttp performs best when you create - * a single OkHttpClient instance and reuse it for all of your HTTP calls. This is because each client holds its own - * connection pool and thread pools. Reusing connections and threads reduces latency and saves memory. Conversely, - * creating a client for each request wastes resources on idle pools. - */ -public class HttpClientSingleton { - private static HttpClientSingleton instance = null; - - private static final Logger LOG = Logger.getLogger(WatsonService.class.getName()); - - /** - * Gets the single instance of HttpClientSingleton. - * - * @return single instance of HttpClientSingleton - */ - public static HttpClientSingleton getInstance() { - if (instance == null) { - instance = new HttpClientSingleton(); - } - return instance; - } - - private OkHttpClient okHttpClient; - - /** - * Instantiates a new HTTP client singleton. - */ - protected HttpClientSingleton() { - this.okHttpClient = configureHttpClient(); - } - - /** - * Configures the HTTP client. - * - * @return the HTTP client - */ - private OkHttpClient configureHttpClient() { - final OkHttpClient.Builder builder = new OkHttpClient.Builder(); - - addCookieJar(builder); - - builder.connectTimeout(60, TimeUnit.SECONDS); - builder.writeTimeout(60, TimeUnit.SECONDS); - builder.readTimeout(90, TimeUnit.SECONDS); - - builder.addNetworkInterceptor(HttpLogging.getLoggingInterceptor()); - - ConnectionSpec spec = new ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS).allEnabledCipherSuites().build(); - builder.connectionSpecs(Arrays.asList(spec, ConnectionSpec.CLEARTEXT)); - - setupTLSProtocol(builder); - - return builder.build(); - } - - /** - * Adds the cookie jar. - * - * @param builder the builder - */ - private void addCookieJar(final OkHttpClient.Builder builder) { - final CookieManager cookieManager = new CookieManager(); - cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL); - - builder.cookieJar(new WatsonCookieJar(cookieManager)); - } - - - /** - * Specifically enable all TLS protocols. See: https://github.com/watson-developer-cloud/java-sdk/issues/610 - * - * @param builder the {@link OkHttpClient} builder. - */ - private void setupTLSProtocol(final OkHttpClient.Builder builder) { - try { - TrustManagerFactory trustManagerFactory = - TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - trustManagerFactory.init((KeyStore) null); - TrustManager[] trustManagers = trustManagerFactory.getTrustManagers(); - - if (trustManagers.length != 1 || !(trustManagers[0] instanceof X509TrustManager)) { - throw new IllegalStateException("Unexpected default trust managers:" + Arrays.toString(trustManagers)); - } - - X509TrustManager trustManager = (X509TrustManager) trustManagers[0]; - - System.setProperty("com.ibm.jsse2.overrideDefaultTLS", "true"); - SSLContext sslContext = SSLContext.getInstance("TLSv1.2"); - - sslContext.init(null, new TrustManager[] { trustManager }, null); - SSLSocketFactory sslSocketFactory = new DelegatingSSLSocketFactory(sslContext.getSocketFactory()) { - @Override - protected SSLSocket configureSocket(SSLSocket socket) throws IOException { - socket.setEnabledProtocols(new String[] { TlsVersion.TLS_1_0.javaName(), TlsVersion.TLS_1_1.javaName(), - TlsVersion.TLS_1_2.javaName() }); - - return socket; - } - }; - - builder.sslSocketFactory(sslSocketFactory, trustManager); - - } catch (NoSuchAlgorithmException e) { - LOG.log(Level.SEVERE, "The cryptographic algorithm requested is not available in the environment.", e); - } catch (KeyStoreException e) { - LOG.log(Level.SEVERE, "Error using the keystore.", e); - } catch (KeyManagementException e) { - LOG.log(Level.SEVERE, "Error initializing the SSL Context.", e); - } - } - - /** - * Creates an {@link OkHttpClient} instance with a new {@link WatsonCookieJar}. - * - * @return the client - */ - public OkHttpClient createHttpClient() { - Builder builder = okHttpClient.newBuilder(); - addCookieJar(builder); - return builder.build(); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java deleted file mode 100644 index 18955c0f9e0..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpHeaders.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -/** - * HTTP constant headers. - */ -public interface HttpHeaders { - - /** - * See HTTP/1.1 documentation. - */ - String ACCEPT = "Accept"; - - /** - * See HTTP/1.1 documentation. - */ - String ACCEPT_CHARSET = "Accept-Charset"; - - /** - * See HTTP/1.1 documentation. - */ - String ACCEPT_ENCODING = "Accept-Encoding"; - - /** - * See HTTP/1.1 documentation. - */ - String ACCEPT_LANGUAGE = "Accept-Language"; - - /** - * See HTTP/1.1 documentation. - */ - String AUTHORIZATION = "Authorization"; - - /** - * See HTTP/1.1 documentation. - */ - String CACHE_CONTROL = "Cache-Control"; - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_ENCODING = "Content-Encoding"; - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_LANGUAGE = "Content-Language"; - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_DISPOSITION = "Content-Disposition"; - - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_LENGTH = "Content-Length"; - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_LOCATION = "Content-Location"; - - /** - * See HTTP/1.1 documentation. - */ - String CONTENT_TYPE = "Content-Type"; - - /** - * See IETF RFC 2109. - */ - String COOKIE = "Cookie"; - - /** - * See HTTP/1.1 documentation. - */ - String DATE = "Date"; - - /** - * See HTTP/1.1 documentation. - */ - String ETAG = "ETag"; - - /** - * See HTTP/1.1 documentation. - */ - String EXPIRES = "Expires"; - - /** - * See HTTP/1.1 documentation. - */ - String HOST = "Host"; - - /** - * See HTTP/1.1 documentation. - */ - String IF_MATCH = "If-Match"; - - /** - * See HTTP/1.1 documentation. - */ - String IF_MODIFIED_SINCE = "If-Modified-Since"; - - /** - * See HTTP/1.1 documentation. - */ - String IF_NONE_MATCH = "If-None-Match"; - - /** - * See HTTP/1.1 documentation. - */ - String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; - - /** - * See HTTP/1.1 documentation. - */ - String LAST_MODIFIED = "Last-Modified"; - - /** - * See HTTP/1.1 documentation. - */ - String LOCATION = "Location"; - - /** - * See IETF RFC 2109. - */ - String SET_COOKIE = "Set-Cookie"; - - /** - * See HTTP/1.1 documentation. - */ - String USER_AGENT = "User-Agent"; - - /** - * See HTTP/1.1 documentation. - */ - String VARY = "Vary"; - - /** - * See HTTP/1.1 documentation. - */ - String WWW_AUTHENTICATE = "WWW-Authenticate"; - - /** The Authorization token header. */ - String X_WATSON_AUTHORIZATION_TOKEN = "X-Watson-Authorization-Token"; - - /** Allow Watson to collect the payload. */ - String X_WATSON_LEARNING_OPT_OUT = "X-Watson-Learning-Opt-Out"; - - /** Mark Bluemix interactions from tests. */ - String X_WATSON_TEST = "X-Watson-Test"; - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpMediaType.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpMediaType.java deleted file mode 100644 index 1c85fcd5374..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpMediaType.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import okhttp3.MediaType; - -/** - * An abstraction for a media type. Instances are immutable. - * - * @see HTTP/1.1 section 3.7 - */ -public final class HttpMediaType { - - private HttpMediaType() { - // This is a utility class - no instantiation allowed. - } - - /** - * Field APPLICATION_ATOM_XML. (value is "application/atom+xml") - */ - public static final String APPLICATION_ATOM_XML = "application/atom+xml"; - /** - * Field APPLICATION_FORM_URLENCODED. (value is "application/x-www-form-urlencoded") - */ - public static final String APPLICATION_FORM_URLENCODED = "application/x-www-form-urlencoded"; - /** - * Field APPLICATION_JSON. (value is "application/json") - */ - public static final String APPLICATION_JSON = "application/json"; - /** - * Field APPLICATION_MS_WORD. (value is "application/msword") - */ - public static final String APPLICATION_MS_WORD = "application/msword"; - - /** - * Field APPLICATION_MS_WORD_DOCX. (value is - * "application/vnd.openxmlformats-officedocument.wordprocessingml.document") - */ - public static final String APPLICATION_MS_WORD_DOCX = - "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; - - /** - * Field APPLICATION_OCTET_STREAM. (value is "application/octet-stream") - */ - public static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; - /** - * Field APPLICATION_PDF. (value is "application/pdf") - */ - public static final String APPLICATION_PDF = "application/pdf"; - /** - * Field APPLICATION_SVG_XML. (value is "application/svg+xml") - */ - public static final String APPLICATION_SVG_XML = "application/svg+xml"; - /** - * Field APPLICATION_XHTML_XML. (value is "application/xhtml+xml") - */ - public static final String APPLICATION_XHTML_XML = "application/xhtml+xml"; - /** - * Field APPLICATION_ZIP. (value is "application/zip") - */ - public static final String APPLICATION_ZIP = "application/zip"; - - /** - * Field APPLICATION_XML. (value is "application/xml") - */ - public static final String APPLICATION_XML = "application/xml"; - /** - * Field AUDIO_OGG. (value is "audio/ogg; codecs=opus") - */ - public static final String AUDIO_OGG = "audio/ogg; codecs=opus"; - - /** - * Field AUDIO_OGG_VORBIS. (value is "audio/ogg; codecs=vorbis") - */ - public static final String AUDIO_OGG_VORBIS = "audio/ogg; codecs=vorbis"; - - /** - * Field AUDIO_WAV. (value is "audio/wav") - */ - public static final String AUDIO_WAV = "audio/wav"; - - /** - * Field AUDIO_WEBM. (value is "audio/webm") - */ - public static final String AUDIO_WEBM = "audio/webm"; - - /** - * Field AUDIO_WEBM_VORBIS. (value is "audio/webm; codecs=vorbis") - */ - public static final String AUDIO_WEBM_VORBIS = "audio/webm; codecs=vorbis"; - - /** - * Field AUDIO_WEBM_OPUS. (value is "audio/webm; codecs=opus") - */ - public static final String AUDIO_WEBM_OPUS = "audio/webm; codecs=opus"; - - /** - * Field AUDIO_PCM. (value is "audio/l16") - */ - public static final String AUDIO_PCM = "audio/l16"; - - /** - * Field AUDIO_BASIC. (value is "audio/basic") - */ - public static final String AUDIO_BASIC = "audio/basic"; - - /** - * Field AUDIO_FLAC. (value is "audio/flac") - */ - public static final String AUDIO_FLAC = "audio/flac"; - - /** - * Field AUDIO_MULAW. (value is "audio/mulaw") - */ - public static final String AUDIO_MULAW = "audio/mulaw"; - - /** - * Field AUDIO_MP3. (value is "audio/mp3") - */ - public static final String AUDIO_MP3 = "audio/mp3"; - - /** - * Field AUDIO_MPEG. (value is "audio/mpeg") - */ - public static final String AUDIO_MPEG = "audio/mpeg"; - - /** - * Field AUDIO_RAW. (value is "audio/l16")
- * When using in Speech to Text a sample rate must be provided - */ - public static final String AUDIO_RAW = "audio/l16"; - - /** - * Creates an audio/l16 media type that includes sample rate. - * - * @param rate The sample rate - * @return audio/l16; rate={rate} - */ - public static String createAudioRaw(int rate) { - return AUDIO_RAW + "; rate=" + rate; - }; - - /** - * Field BINARY_FILE. (value is "application/octet-stream") - */ - public static final MediaType BINARY_FILE = MediaType.parse(APPLICATION_OCTET_STREAM); - - /** - * Field BINARY_OCTET_STREAM. (value is "binary/octet-stream") - */ - public static final String BINARY_OCTET_STREAM = "binary/octet-stream"; - - /** - * Field JSON. (value is "application/json; charset=utf-8") - */ - public static final MediaType JSON = MediaType.parse(APPLICATION_JSON + "; charset=utf-8"); - /** - * Field MEDIA_TYPE_WILDCARD. (value is "*") - */ - public static final String MEDIA_TYPE_WILDCARD = "*"; - /** - * Field MULTIPART_FORM_DATA. (value is "multipart/form-data") - */ - public static final String MULTIPART_FORM_DATA = "multipart/form-data"; - /** - * Field TEXT_CSV. (value is "text/csv") - */ - public static final String TEXT_CSV = "text/csv"; - - /** - * Field TEXT_HTML. (value is "text/html") - */ - public static final String TEXT_HTML = "text/html"; - - /** - * Field TEXT_PLAIN. (value is "text/plain") - */ - public static final String TEXT_PLAIN = "text/plain"; - - /** - * Field TEXT. (value is "text/plain; charset=utf-8") - */ - public static final MediaType TEXT = MediaType.parse(TEXT_PLAIN + "; charset=utf-8"); - - /** - * Field TEXT_XML. (value is "text/xml") - */ - public static final String TEXT_XML = "text/xml"; - - /** - * Field WILDCARD. (value is "*\/*") - */ - public static final String WILDCARD = "*/*"; - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpStatus.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpStatus.java deleted file mode 100644 index db0d8937204..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/HttpStatus.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -/** - * Constants enumerating the HTTP status codes. All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and - * RFC2518 (WebDAV) are listed. - * - * Adapted from the Apache Software Foundation - */ -public interface HttpStatus { - - /** 202 Accepted (HTTP/1.0 - RFC 1945). */ - int ACCEPTED = 202; - - // --- 2xx Success --- - - /** 502 Bad Gateway (HTTP/1.0 - RFC 1945). */ - int BAD_GATEWAY = 502; - /** 400 Bad Request (HTTP/1.1 - RFC 2616). */ - int BAD_REQUEST = 400; - /** 409 Conflict (HTTP/1.1 - RFC 2616). */ - int CONFLICT = 409; - /** 100 Continue (HTTP/1.1 - RFC 2616). */ - int CONTINUE = 100; - /** 201 Created (HTTP/1.0 - RFC 1945). */ - int CREATED = 201; - /** 417 Expectation Failed (HTTP/1.1 - RFC 2616). */ - int EXPECTATION_FAILED = 417; - /** 424 Failed Dependency (WebDAV - RFC 2518). */ - int FAILED_DEPENDENCY = 424; - - /** 403 Forbidden (HTTP/1.0 - RFC 1945). */ - int FORBIDDEN = 403; - - // --- 3xx Redirection --- - - /** 504 Gateway Timeout (HTTP/1.1 - RFC 2616). */ - int GATEWAY_TIMEOUT = 504; - /** 410 Gone (HTTP/1.1 - RFC 2616). */ - int GONE = 410; - /** 505 HTTP Version Not Supported (HTTP/1.1 - RFC 2616). */ - int HTTP_VERSION_NOT_SUPPORTED = 505; - /** 507 Insufficient Storage (WebDAV - RFC 2518). */ - int INSUFFICIENT_STORAGE = 507; - /** 500 Server Error (HTTP/1.0 - RFC 1945). */ - int INTERNAL_SERVER_ERROR = 500; - /** 411 Length Required (HTTP/1.1 - RFC 2616). */ - int LENGTH_REQUIRED = 411; - /** 423 Locked (WebDAV - RFC 2518). */ - int LOCKED = 423; - - // --- 4xx Client Error --- - - /** 405 Method Not Allowed (HTTP/1.1 - RFC 2616). */ - int METHOD_NOT_ALLOWED = 405; - /** 301 Moved Permanently (HTTP/1.0 - RFC 1945). */ - int MOVED_PERMANENTLY = 301; - /** 302 Moved Temporarily (Sometimes Found) (HTTP/1.0 - RFC 1945). */ - int MOVED_TEMPORARILY = 302; - /** - * 207 Multi-Status (WebDAV - RFC 2518) or 207 Partial Update OK (HTTP/1.1 - draft-ietf-http-v11-spec-rev-01?). - */ - int MULTI_STATUS = 207; - /** 300 Mutliple Choices (HTTP/1.1 - RFC 2616). */ - int MULTIPLE_CHOICES = 300; - /** 204 No Content (HTTP/1.0 - RFC 1945). */ - int NO_CONTENT = 204; - /** 203 Non Authoritative Information (HTTP/1.1 - RFC 2616). */ - int NON_AUTHORITATIVE_INFORMATION = 203; - /** 406 Not Acceptable (HTTP/1.1 - RFC 2616). */ - int NOT_ACCEPTABLE = 406; - /** 404 Not Found (HTTP/1.0 - RFC 1945). */ - int NOT_FOUND = 404; - /** 501 Not Implemented (HTTP/1.0 - RFC 1945). */ - int NOT_IMPLEMENTED = 501; - /** 304 Not Modified (HTTP/1.0 - RFC 1945). */ - int NOT_MODIFIED = 304; - /** 200 OK (HTTP/1.0 - RFC 1945). */ - int OK = 200; - /** 206 Partial Content (HTTP/1.1 - RFC 2616). */ - int PARTIAL_CONTENT = 206; - /** 402 Payment Required (HTTP/1.1 - RFC 2616). */ - int PAYMENT_REQUIRED = 402; - /** 412 Precondition Failed (HTTP/1.1 - RFC 2616). */ - int PRECONDITION_FAILED = 412; - /** 407 Proxy Authentication Required (HTTP/1.1 - RFC 2616). */ - int PROXY_AUTHENTICATION_REQUIRED = 407; - /** 408 Request Timeout (HTTP/1.1 - RFC 2616). */ - int REQUEST_TIMEOUT = 408; - /** 413 Request Entity Too Large (HTTP/1.1 - RFC 2616). */ - int REQUEST_TOO_LONG = 413; - - /** 414 Request-URI Too Long (HTTP/1.1 - RFC 2616). */ - int REQUEST_URI_TOO_LONG = 414; - - /** 416 Requested Range Not Satisfiable (HTTP/1.1 - RFC 2616). */ - int REQUESTED_RANGE_NOT_SATISFIABLE = 416; - - /** 205 Reset Content (HTTP/1.1 - RFC 2616). */ - int RESET_CONTENT = 205; - - /** 303 See Other (HTTP/1.1 - RFC 2616). */ - int SEE_OTHER = 303; - - // --- 5xx Server Error --- - - /** 503 Service Unavailable (HTTP/1.0 - RFC 1945). */ - int SERVICE_UNAVAILABLE = 503; - /** 307 Temporary Redirect (HTTP/1.1 - RFC 2616). */ - int TEMPORARY_REDIRECT = 307; - /** 429 Too Many Requests. */ - int TOO_MANY_REQUESTS = 429; - /** 401 Unauthorized (HTTP/1.0 - RFC 1945). */ - int UNAUTHORIZED = 401; - /** 422 Unprocessable Entity (WebDAV - RFC 2518). */ - int UNPROCESSABLE_ENTITY = 422; - /** 415 Unsupported Media Type (HTTP/1.1 - RFC 2616). */ - int UNSUPPORTED_MEDIA_TYPE = 415; - - /** 305 Use Proxy (HTTP/1.1 - RFC 2616). */ - int USE_PROXY = 305; - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/InputStreamRequestBody.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/InputStreamRequestBody.java deleted file mode 100644 index 50f9198b646..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/InputStreamRequestBody.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import java.io.IOException; -import java.io.InputStream; - -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.internal.Util; -import okio.BufferedSink; -import okio.Okio; -import okio.Source; - -/** - * RequestBody that takes an {@link InputStream}. - * - */ -public class InputStreamRequestBody extends RequestBody { - - private InputStream inputStream; - private MediaType mediaType; - - /** - * Creates the @link {@link RequestBody} from an @link {@link InputStream}. - * - * @param mediaType the media type - * @param inputStream the input stream - * @return the request body - */ - public static RequestBody create(final MediaType mediaType, final InputStream inputStream) { - return new InputStreamRequestBody(inputStream, mediaType); - } - - private InputStreamRequestBody(InputStream inputStream, MediaType mediaType) { - this.inputStream = inputStream; - this.mediaType = mediaType; - } - - /* - * (non-Javadoc) - * - * @see com.squareup.okhttp.RequestBody#contentType() - */ - @Override - public MediaType contentType() { - return mediaType; - } - - /* - * (non-Javadoc) - * - * @see com.squareup.okhttp.RequestBody#writeTo(okio.BufferedSink) - */ - @Override - public void writeTo(BufferedSink sink) throws IOException { - Source source = null; - try { - source = Okio.source(inputStream); - sink.writeAll(source); - } finally { - Util.closeQuietly(source); - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/NameValue.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/NameValue.java deleted file mode 100644 index 6423846987a..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/NameValue.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * A name / value pair parameter used as an element of HTTP messages. - * - *
- * parameter = attribute "=" value
- * attribute = token
- * value     = token | quoted-string
- * 
- * - */ -public class NameValue { - - /** The name. */ - private final String name; - - /** The value. */ - private final String value; - - /** - * Default Constructor taking a name and a value. The value may be null. - * - * @param name The name. - * @param value The value. - */ - public NameValue(final String name, final String value) { - super(); - Validator.notNull(name, "name cannot be null"); - - this.name = name; - this.value = value; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if ((o == null) || (getClass() != o.getClass())) { - return false; - } - - NameValue nameValue = (NameValue) o; - - if (!name.equals(nameValue.name)) { - return false; - } - return value != null ? value.equals(nameValue.value) : nameValue.value == null; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the value. - * - * @return the value - */ - public String getValue() { - return value; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = (prime * result) + name.hashCode(); - result = (prime * result) + ((value == null) ? 0 : value.hashCode()); - return result; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - - if (value == null) { - return name; - } else { - return name + "=" + value; - } - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/RequestBuilder.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/RequestBuilder.java deleted file mode 100644 index 6d1b6c02edc..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/RequestBuilder.java +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.FormBody; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.Request; -import okhttp3.RequestBody; - -import java.util.ArrayList; -import java.util.List; - -/** - * Convenience class for constructing HTTP/HTTPS requests. - */ -public class RequestBuilder { - - private enum HTTPMethod { - DELETE, GET, POST, PUT - } - - /** - * The DELETE method requests that the origin server delete the resource identified by the Request-URI. - * - * @param url the URL - * - * @return this - */ - public static RequestBuilder delete(HttpUrl url) { - return new RequestBuilder(HTTPMethod.DELETE, url); - } - - /** - * The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. - * - * @param url the URL - * - * @return this - */ - public static RequestBuilder get(HttpUrl url) { - return new RequestBuilder(HTTPMethod.GET, url); - } - - /** - * The POST request method is designed to request that a web server accept the data enclosed in the request message's - * body for storage. It is often used when uploading a file or submitting a completed web form. - * - * @param url the URL - * - * @return this - */ - public static RequestBuilder post(HttpUrl url) { - return new RequestBuilder(HTTPMethod.POST, url); - } - - /** - * The PUT method requests that the enclosed entity be stored under the supplied Request-URI. - * - * @param url the URL - * - * @return this - */ - public static RequestBuilder put(HttpUrl url) { - return new RequestBuilder(HTTPMethod.PUT, url); - } - - /** - * Creates a properly encoded HttpUrl object with no path parameters. - * - * @param endPoint the API end point - * @param pathSegments the path segments for a specific API call - * @return the HttpUrl object - */ - public static HttpUrl constructHttpUrl(String endPoint, String[] pathSegments) { - HttpUrl.Builder httpUrlBuilder = HttpUrl.parse(endPoint).newBuilder(); - for (String segment : pathSegments) { - httpUrlBuilder.addPathSegments(segment); - } - return httpUrlBuilder.build(); - } - - /** - * Creates a properly encoded HttpUrl object with path parameters. - * - * @param endPoint the API end point - * @param pathSegments the path segments for a specific API call - * @param pathParameters the path parameters for a specific API call - * @return the HttpUrl object - */ - public static HttpUrl constructHttpUrl(String endPoint, String[] pathSegments, String[] pathParameters) { - HttpUrl.Builder httpUrlBuilder = HttpUrl.parse(endPoint).newBuilder(); - for (int i = 0; i < pathSegments.length; i++) { - httpUrlBuilder.addPathSegments(pathSegments[i]); - if (i < pathParameters.length) { - httpUrlBuilder.addPathSegment(pathParameters[i]); - } - } - return httpUrlBuilder.build(); - } - - private RequestBody body; - private HttpUrl httpUrl; - private final List formParams = new ArrayList(); - private final List headers = new ArrayList(); - private final HTTPMethod method; - private final List queryParams = new ArrayList(); - - /** - * Instantiates a new request. - * - * @param method the method, PUT, POST, GET or DELETE - * @param url the request URL - */ - private RequestBuilder(HTTPMethod method, HttpUrl url) { - this.method = method; - if (url == null) { - throw new IllegalArgumentException("url cannot be null"); - } - - this.httpUrl = url; - } - - /** - * Adds a key/value pair. - * - *
-   * 
-   * Request r = new Request.get("https://foo.bar").add("singleParam", "value")
-   *   .add("multiParam", new String[] { "1", "2", "3" })
-   *   .add("singleParamWithOutValue", null);
-   * 
-   * 
- * - * @param params the parameters - * @param name the parameter name - * @param value the value to set, will be obtained via {@link String#valueOf(boolean)}. If null, only the parameter is - * set. It can also be a collection or array, in which case all elements are added as query parameters - * - * @return this - */ - private RequestBuilder add(List params, String name, Object value) { - if (value instanceof Iterable) { - for (final Object o : (Iterable) value) { - addParam(params, name, o); - } - } else if (value instanceof Object[]) { - for (final Object o : (Object[]) value) { - addParam(params, name, o); - } - } else { - addParam(params, name, value); - } - return this; - } - - /** - * Adds the name, value par to the parameter list as BasicNameValue. - * - * @param params the parameter list - * @param name the parameter name - * @param value the parameter value - */ - private void addParam(List params, String name, Object value) { - params.add(new NameValue(name, value == null ? null : String.valueOf(value))); - } - - /** - * Builds the. - * - * @return the request - */ - public Request build() { - final Request.Builder builder = new Request.Builder(); - // URL - builder.url(toUrl()); - - if (method == HTTPMethod.GET) { - Validator.isNull(body, "cannot send a RequestBody in a GET request"); - } else if (!formParams.isEmpty()) { - // The current behaviour of the RequestBuilder is to replace the body when formParams is - // present - final FormBody.Builder formBody = new FormBody.Builder(); - for (final NameValue param : formParams) { - final String value = param.getValue() != null ? param.getValue() : ""; - formBody.add(param.getName(), value); - } - body = formBody.build(); - } else if (body == null) { - // POST/PUT require a body so send an empty body if the actual is null - // DELETE allows an empty request body - body = RequestBody.create(null, new byte[0]); - } - builder.method(method.name(), body); - - // accept application/json by default - builder.header(HttpHeaders.ACCEPT, HttpMediaType.APPLICATION_JSON); - - for (final NameValue header : headers) { - builder.header(header.getName(), header.getValue()); - } - - return builder.build(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "RequestBuilder [method=" + method + ", formParams=" + formParams + ", headers=" + headers + ", queryParams=" - + queryParams + ", httpUrl=" + httpUrl.toString() + "]"; - } - - /** - * Return the request url including query parameters. - * - * @return the string - */ - private String toUrl() { - final HttpUrl.Builder builder = httpUrl.newBuilder(); - for (final NameValue param : queryParams) { - builder.addQueryParameter(param.getName(), param.getValue()); - } - return builder.build().uri().toString(); - } - - /** - * Adds a name-value par to a given list. - * - * @param params a list of parameters - * @param args a list of arguments - * - * @return this - */ - private RequestBuilder with(List params, Object... args) { - if (args != null) { - Validator.isTrue((args.length % 2) == 0, "need even number of arguments"); - for (int i = 0; i < args.length; i += 2) { - add(params, args[i].toString(), args[i + 1]); - } - } - return this; - } - - /** - * Sets the body. - * - * @param body the body - * @return the request builder - */ - public RequestBuilder body(RequestBody body) { - this.body = body; - return this; - } - - /** - * Sets the string content to the request (used with POST/PUT). This will encapsulate the string into a - * {@link RequestBody} encoded with UTF-8 - * - * @param content the content to POST/PUT - * @param contentType the HTTP contentType to use. - * - * @return this - */ - public RequestBuilder bodyContent(String content, String contentType) { - body = RequestBody.create(MediaType.parse(contentType), content); - return this; - } - - /** - * Adds a JSON content to the request (used with POST/PUT). This will encapsulate the json into a {@link RequestBody} - * encoded with UTF-8 and use {@code "application/json"} as Content-Type - * - * @param json the JsonObject json - * - * @return this - */ - public RequestBuilder bodyJson(JsonObject json) { - return bodyContent(json.toString(), HttpMediaType.APPLICATION_JSON); - } - - /** - * Adds form parameters. - * - * @param args a list of name-value form parameters - * - * @return this - */ - public RequestBuilder form(Object... args) { - return with(formParams, args); - } - - /** - * Adds header parameters. - * - * @param args a list of name-value headers - * - * @return this - */ - public RequestBuilder header(Object... args) { - return with(headers, args); - } - - /** - * Adds query parameters. - * - * @param args a list of name-value query parameters - * - * @return this - */ - public RequestBuilder query(Object... args) { - return with(queryParams, args); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/Response.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/Response.java deleted file mode 100644 index b703ec0840a..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/Response.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -/** - * Class holding the converted service call result along with some HTTP response data. - * - * @param the generic type - */ -public class Response { - - private T result; - private Headers headers; - - public Response(T result, okhttp3.Response httpResponse) { - this.result = result; - this.headers = new Headers(httpResponse.headers()); - } - - public T getResult() { - return this.result; - } - - public Headers getHeaders() { - return this.headers; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/ResponseConverter.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/ResponseConverter.java deleted file mode 100644 index d25196c7e0c..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/ResponseConverter.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import okhttp3.Response; - -/** - * The Interface ResponseConverter. - * - * @param the generic type - */ -public interface ResponseConverter { - - /** - * Converts a response into a generic type to be defined. - * - * @param response the response - * @return the the generic type - */ - T convert(Response response); -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCall.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCall.java deleted file mode 100644 index 9f941e86d4b..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCall.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import jersey.repackaged.jsr166e.CompletableFuture; - -/** - * Service Call. - * - * @param the generic type - */ -public interface ServiceCall { - - /** - * Add a header to the request before executing. - * - * @param name the name of the header - * @param value the value of the header - * @return the ServiceCall with updated headers - */ - ServiceCall addHeader(String name, String value); - - /** - * Synchronous request. - * - * @return the generic type - * @throws RuntimeException the exception from HTTP request - */ - T execute() throws RuntimeException; - - /** - * Synchronous request with added HTTP information. - * - * @return a Response object with the generic response model and various HTTP information fields - * @throws RuntimeException the exception from the HTTP request - */ - Response executeWithDetails() throws RuntimeException; - - /** - * Asynchronous requests, in this case, you receive a callback when the data has been received. - * - * @param callback the callback - */ - void enqueue(ServiceCallback callback); - - /** - * Asynchronous requests with added HTTP information. In this case, you receive a callback when the data has been - * received. - * - * @param callback the callback - */ - void enqueueWithDetails(ServiceCallbackWithDetails callback); - - /** - * Reactive requests, in this case, you could take advantage both synchronous and asynchronous. - * - * @return a CompletableFuture wrapper for your response - */ - CompletableFuture rx(); - - /** - * Reactive requests with added HTTP information. In this case, you could take advantage both synchronous and - * asynchronous. - * - * @return a CompletableFuture wrapper for your response - */ - CompletableFuture> rxWithDetails(); -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallback.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallback.java deleted file mode 100644 index 004fe8bc618..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallback.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -/** - * Callback with the response for an Asynchronous request. - * - * @param the generic type - */ -public interface ServiceCallback { - - /** - * Called with the response. - * - * @param response the response - */ - void onResponse(T response); - - /** - * Called if there is an error during the request. - * - * @param e the exception thrown during the request - */ - void onFailure(Exception e); -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallbackWithDetails.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallbackWithDetails.java deleted file mode 100644 index 3b5eaf00364..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/ServiceCallbackWithDetails.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -/** - * Callback with the response for an Asynchronous request that also provides additional HTTP response information. - * - * @param the generic type - */ -public interface ServiceCallbackWithDetails { - - /** - * Called with the response. - * - * @param response the response - */ - void onResponse(Response response); - - /** - * Called if there is an error during the request. - * - * @param e the exception thrown during the request - */ - void onFailure(Exception e); -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/WatsonCookieJar.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/WatsonCookieJar.java deleted file mode 100644 index e6a185d840e..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/WatsonCookieJar.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import java.net.CookieHandler; -import java.util.ArrayList; -import java.util.List; - -import okhttp3.Cookie; -import okhttp3.CookieJar; -import okhttp3.HttpUrl; -import okhttp3.JavaNetCookieJar; - -/** - * This is an adapter that uses {@link JavaNetCookieJar} and ignore Speech to Text sessions for session less requests. - * - */ -public final class WatsonCookieJar implements CookieJar { - private static final String SESSIONID = "SESSIONID"; - private static final String SESSIONS = "sessions"; - private static final String SPEECH_TO_TEXT = "speech-to-text"; - private JavaNetCookieJar adapter; - - /** - * Instantiates a new Watson cookie jar. - * - * @param cookieHandler the cookie handler - */ - public WatsonCookieJar(CookieHandler cookieHandler) { - this.adapter = new JavaNetCookieJar(cookieHandler); - } - - /* - * (non-Javadoc) - * - * @see okhttp3.CookieJar#saveFromResponse(okhttp3.HttpUrl, java.util.List) - */ - @Override - public void saveFromResponse(HttpUrl url, List cookies) { - this.adapter.saveFromResponse(url, cookies); - } - - - /* - * (non-Javadoc) - * - * @see okhttp3.CookieJar#loadForRequest(okhttp3.HttpUrl) - */ - @Override - public List loadForRequest(HttpUrl url) { - List cookies = this.adapter.loadForRequest(url); - - // TODO: Removes the SESSIONID for speech to text session lest requests - if (url.encodedPathSegments().contains(SPEECH_TO_TEXT) && !url.encodedPathSegments().contains(SESSIONS)) { - List sessionLessCookies = new ArrayList(); - for (Cookie cookie : cookies) { - if (!cookie.name().equalsIgnoreCase(SESSIONID)) { - sessionLessCookies.add(cookie); - } - } - cookies = sessionLessCookies; - } - return cookies; - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/http/package-info.java b/core/src/main/java/com/ibm/watson/developer_cloud/http/package-info.java deleted file mode 100644 index 7159b106915..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/http/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -/** - * This package contains interfaces, enumerations and implementations to work with HTTP requests and responses. - */ -package com.ibm.watson.developer_cloud.http; - diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java deleted file mode 100644 index 94f72c98a4f..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/WatsonService.java +++ /dev/null @@ -1,590 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.HttpClientSingleton; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.HttpStatus; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ResponseConverter; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.http.ServiceCallback; -import com.ibm.watson.developer_cloud.http.ServiceCallbackWithDetails; -import com.ibm.watson.developer_cloud.service.exception.BadRequestException; -import com.ibm.watson.developer_cloud.service.exception.ConflictException; -import com.ibm.watson.developer_cloud.service.exception.ForbiddenException; -import com.ibm.watson.developer_cloud.service.exception.InternalServerErrorException; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.service.exception.RequestTooLargeException; -import com.ibm.watson.developer_cloud.service.exception.ServiceResponseException; -import com.ibm.watson.developer_cloud.service.exception.ServiceUnavailableException; -import com.ibm.watson.developer_cloud.service.exception.TooManyRequestsException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.service.exception.UnsupportedException; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.service.security.IamTokenManager; -import com.ibm.watson.developer_cloud.util.CredentialUtils; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.ResponseUtils; -import jersey.repackaged.jsr166e.CompletableFuture; -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.Credentials; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Request.Builder; -import okhttp3.Response; - -import java.io.IOException; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Watson service abstract common functionality of various Watson Services. It handle authentication and default url. - * - * @see IBM Watson Developer Cloud - */ -public abstract class WatsonService { - - private static final String URL = "url"; - private static final String PATH_AUTHORIZATION_V1_TOKEN = "/v1/token"; - private static final String AUTHORIZATION = "authorization"; - private static final String MESSAGE_ERROR_3 = "message"; - private static final String MESSAGE_ERROR_2 = "error_message"; - private static final String BASIC = "Basic "; - private static final String BEARER = "Bearer "; - private static final Logger LOG = Logger.getLogger(WatsonService.class.getName()); - private String apiKey; - private String username; - private String password; - private String endPoint; - private String defaultEndPoint; - private final String name; - private IamTokenManager tokenManager; - - private OkHttpClient client; - - /** The default headers. */ - protected Headers defaultHeaders = null; - - /** The skip authentication. */ - protected boolean skipAuthentication = false; - - /** The Constant MESSAGE_CODE. */ - protected static final String MESSAGE_CODE = "code"; - - /** The Constant MESSAGE_ERROR. */ - protected static final String MESSAGE_ERROR = "error"; - - /** The Constant VERSION. */ - protected static final String VERSION = "version"; - - /** - * Instantiates a new Watson service. - * - * @param name the service name - */ - public WatsonService(final String name) { - this.name = name; - String iamApiKey = CredentialUtils.getIAMKey(name); - String iamUrl = CredentialUtils.getIAMUrl(name); - if (iamApiKey != null) { - IamOptions iamOptions = new IamOptions.Builder() - .apiKey(iamApiKey) - .url(iamUrl) - .build(); - tokenManager = new IamTokenManager(iamOptions); - } - apiKey = CredentialUtils.getAPIKey(name); - String url = CredentialUtils.getAPIUrl(name); - if ((url != null) && !url.isEmpty()) { - // The VCAP_SERVICES will typically contain a url. If present use it. - setEndPoint(url); - } - - client = configureHttpClient(); - } - - /** - * Configure the {@link OkHttpClient}. This method will be called by the constructor and can be used to customize the - * client that the service will use to perform the http calls. - * - * @return the {@link OkHttpClient} - */ - protected OkHttpClient configureHttpClient() { - return HttpClientSingleton.getInstance().createHttpClient(); - } - - /** - * Execute the HTTP request. Okhttp3 compliant. - * - * @param request the HTTP request - * - * @return the HTTP response - */ - private Call createCall(final Request request) { - final Request.Builder builder = request.newBuilder(); - - setDefaultHeaders(builder); - - setAuthentication(builder); - - final Request newRequest = builder.build(); - return client.newCall(newRequest); - } - - /** - * Sets the default headers including User-Agent. - * - * @param builder the new default headers - */ - protected void setDefaultHeaders(final Request.Builder builder) { - String userAgent = RequestUtils.getUserAgent(); - - if (defaultHeaders != null) { - for (String key : defaultHeaders.names()) { - builder.header(key, defaultHeaders.get(key)); - } - if (defaultHeaders.get(HttpHeaders.USER_AGENT) != null) { - userAgent += " " + defaultHeaders.get(HttpHeaders.USER_AGENT); - } - } - builder.header(HttpHeaders.USER_AGENT, userAgent); - } - - /** - * Creates the service call. - * - * @param the generic type - * @param request the request - * @param converter the converter - * @return the service call - */ - protected final ServiceCall createServiceCall(final Request request, final ResponseConverter converter) { - final Call call = createCall(request); - return new WatsonServiceCall<>(call, converter); - } - - /** - * Gets the API key. - * - * - * @return the API key - */ - protected String getApiKey() { - return apiKey; - } - - /** - * Gets the username. - * - * - * @return the username - */ - protected String getUsername() { - return username; - } - - /** - * Gets the password. - * - * - * @return the password - */ - protected String getPassword() { - return password; - } - - /** - * Gets the API end point. - * - * - * @return the API end point - */ - public String getEndPoint() { - return endPoint; - } - - /** - * Gets an authorization token that can be use to authorize API calls. - * - * - * @return the token - */ - public ServiceCall getToken() { - HttpUrl url = HttpUrl.parse(getEndPoint()).newBuilder() - .setPathSegment(0, AUTHORIZATION) - .addPathSegment(PATH_AUTHORIZATION_V1_TOKEN) - .build(); - Request request = RequestBuilder.get(url) - .header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_PLAIN).query(URL, getEndPoint()).build(); - - return createServiceCall(request, ResponseConverterUtils.getString()); - } - - /** - * Checks the status of the tokenManager. - * - * @return true if the tokenManager has been set - */ - protected boolean isTokenManagerSet() { - return tokenManager != null; - } - - /** - * Gets the error message from a JSON response. - * - *
-   * {
-   *   code: 400
-   *   error: 'bad request'
-   * }
-   * 
- * - * @param response the HTTP response - * @return the error message from the JSON object - */ - private String getErrorMessage(Response response) { - String error = ResponseUtils.getString(response); - try { - - final JsonObject jsonObject = ResponseUtils.getJsonObject(error); - if (jsonObject.has(MESSAGE_ERROR)) { - error = jsonObject.get(MESSAGE_ERROR).getAsString(); - } else if (jsonObject.has(MESSAGE_ERROR_2)) { - error = jsonObject.get(MESSAGE_ERROR_2).getAsString(); - } else if (jsonObject.has(MESSAGE_ERROR_3)) { - error = jsonObject.get(MESSAGE_ERROR_3).getAsString(); - } - } catch (final Exception e) { - // Ignore any kind of exception parsing the json and use fallback String version of response - } - - return error; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets the API key. - * - * @param apiKey the new API key - */ - public void setApiKey(String apiKey) { - if (this.endPoint.equals(this.defaultEndPoint)) { - this.endPoint = "https://gateway-a.watsonplatform.net/visual-recognition/api"; - } - this.apiKey = apiKey; - } - - /** - * Sets the authentication. Okhttp3 compliant. - * - * @param builder the new authentication - */ - protected void setAuthentication(final Builder builder) { - if (tokenManager != null) { - String accessToken = tokenManager.getToken(); - builder.addHeader(HttpHeaders.AUTHORIZATION, BEARER + accessToken); - } else if (getApiKey() == null) { - if (skipAuthentication) { - return; // chosen to skip authentication with the service - } - throw new IllegalArgumentException("apiKey or username and password were not specified"); - } else { - builder.addHeader(HttpHeaders.AUTHORIZATION, apiKey.startsWith(BASIC) ? apiKey : BASIC + apiKey); - } - } - - /** - * Sets the end point. - * - * @param endPoint the new end point. Will be ignored if empty or null - */ - public void setEndPoint(final String endPoint) { - if ((endPoint != null) && !endPoint.isEmpty()) { - String newEndPoint = endPoint.endsWith("/") ? endPoint.substring(0, endPoint.length() - 1) : endPoint; - if (this.endPoint == null) { - this.defaultEndPoint = newEndPoint; - } - this.endPoint = newEndPoint; - } - } - - /** - * Sets the username and password. - * - * @param username the username - * @param password the password - */ - public void setUsernameAndPassword(final String username, final String password) { - this.username = username; - this.password = password; - apiKey = Credentials.basic(username, password); - } - - /** - * Set the default headers to be used on every HTTP request. - * - * @param headers name value pairs of headers - */ - public void setDefaultHeaders(final Map headers) { - if (headers == null) { - defaultHeaders = null; - } else { - defaultHeaders = Headers.of(headers); - } - } - - /** - * Sets IAM information. - * - * Be aware that if you pass in an access token using this method, you accept responsibility for managing the access - * token yourself. You must set a new access token before this one expires. Failing to do so will result in - * authentication errors after this token expires. - * - * @param iamOptions object containing values to be used for authenticating with IAM - */ - public void setIamCredentials(IamOptions iamOptions) { - this.tokenManager = new IamTokenManager(iamOptions); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - final StringBuilder builder = new StringBuilder().append(name).append(" ["); - - if (endPoint != null) { - builder.append("endPoint=").append(endPoint); - } - - return builder.append(']').toString(); - } - - - /** - * Process service call. - * - * @param the generic type - * @param converter the converter - * @param response the response - * @return the t - */ - protected T processServiceCall(final ResponseConverter converter, final Response response) { - if (response.isSuccessful()) { - return converter.convert(response); - } - - // There was a Client Error 4xx or a Server Error 5xx - // Get the error message and create the exception - final String error = getErrorMessage(response); - LOG.log(Level.SEVERE, response.request().method() + " " + response.request().url().toString() + ", status: " - + response.code() + ", error: " + error); - - switch (response.code()) { - case HttpStatus.BAD_REQUEST: // HTTP 400 - throw new BadRequestException(error != null ? error : "Bad Request", response); - case HttpStatus.UNAUTHORIZED: // HTTP 401 - throw new UnauthorizedException("Unauthorized: Access is denied due to invalid credentials. " - + "Tip: Did you set the Endpoint?", response); - case HttpStatus.FORBIDDEN: // HTTP 403 - throw new ForbiddenException(error != null ? error : "Forbidden: Service refuse the request", response); - case HttpStatus.NOT_FOUND: // HTTP 404 - throw new NotFoundException(error != null ? error : "Not found", response); - case HttpStatus.NOT_ACCEPTABLE: // HTTP 406 - throw new ForbiddenException(error != null ? error : "Forbidden: Service refuse the request", response); - case HttpStatus.CONFLICT: // HTTP 409 - throw new ConflictException(error != null ? error : "", response); - case HttpStatus.REQUEST_TOO_LONG: // HTTP 413 - throw new RequestTooLargeException(error != null ? error - : "Request too large: " + "The request entity is larger than the server is able to process", response); - case HttpStatus.UNSUPPORTED_MEDIA_TYPE: // HTTP 415 - throw new UnsupportedException(error != null ? error : "Unsupported Media Type", response); - case HttpStatus.TOO_MANY_REQUESTS: // HTTP 429 - throw new TooManyRequestsException(error != null ? error : "Too many requests", response); - case HttpStatus.INTERNAL_SERVER_ERROR: // HTTP 500 - throw new InternalServerErrorException(error != null ? error : "Internal Server Error", response); - case HttpStatus.SERVICE_UNAVAILABLE: // HTTP 503 - throw new ServiceUnavailableException(error != null ? error : "Service Unavailable", response); - default: // other errors - throw new ServiceResponseException(response.code(), error, response); - } - } - - /** - * Sets the skip authentication. - * - * @param skipAuthentication the new skip authentication - */ - public void setSkipAuthentication(final boolean skipAuthentication) { - this.skipAuthentication = skipAuthentication; - } - - /** - * Defines implementation for modifying and executing service calls. - * - * @param the generic type - */ - class WatsonServiceCall implements ServiceCall { - private Call call; - private ResponseConverter converter; - - WatsonServiceCall(Call call, ResponseConverter converter) { - this.call = call; - this.converter = converter; - } - - @Override - public ServiceCall addHeader(String name, String value) { - Request.Builder builder = call.request().newBuilder(); - builder.header(name, value); - call = client.newCall(builder.build()); - return this; - } - - @Override - public T execute() { - try { - Response response = call.execute(); - return processServiceCall(converter, response); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public com.ibm.watson.developer_cloud.http.Response executeWithDetails() throws RuntimeException { - try { - Response httpResponse = call.execute(); - T responseModel = processServiceCall(converter, httpResponse); - return new com.ibm.watson.developer_cloud.http.Response<>(responseModel, httpResponse); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - @Override - public void enqueue(final ServiceCallback callback) { - call.enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - callback.onFailure(e); - } - - @Override - public void onResponse(Call call, Response response) { - try { - callback.onResponse(processServiceCall(converter, response)); - } catch (Exception e) { - callback.onFailure(e); - } - } - }); - } - - @Override - public void enqueueWithDetails(final ServiceCallbackWithDetails callback) { - call.enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - callback.onFailure(e); - } - - @Override - public void onResponse(Call call, Response response) { - try { - T responseModel = processServiceCall(converter, response); - callback.onResponse(new com.ibm.watson.developer_cloud.http.Response<>(responseModel, response)); - } catch (Exception e) { - callback.onFailure(e); - } - } - }); - } - - @Override - public CompletableFuture rx() { - final CompletableFuture completableFuture = new CompletableFuture(); - - call.enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - completableFuture.completeExceptionally(e); - } - - @Override - public void onResponse(Call call, Response response) { - try { - completableFuture.complete(processServiceCall(converter, response)); - } catch (Exception e) { - completableFuture.completeExceptionally(e); - } - } - }); - - return completableFuture; - } - - @Override - public CompletableFuture> rxWithDetails() { - final CompletableFuture> completableFuture - = new CompletableFuture<>(); - - call.enqueue(new Callback() { - @Override - public void onFailure(Call call, IOException e) { - completableFuture.completeExceptionally(e); - } - - @Override - public void onResponse(Call call, Response response) { - try { - T responseModel = processServiceCall(converter, response); - completableFuture.complete(new com.ibm.watson.developer_cloud.http.Response<>(responseModel, response)); - } catch (Exception e) { - completableFuture.completeExceptionally(e); - } - } - }); - - return completableFuture; - } - - @Override - protected void finalize() throws Throwable { - super.finalize(); - - if (!call.isExecuted()) { - final Request r = call.request(); - LOG.warning(r.method() + " request to " + r.url() + " has not been sent. Did you forget to call execute()?"); - } - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/BadRequestException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/BadRequestException.java deleted file mode 100644 index b170dfb65d8..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/BadRequestException.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 400 Bad Request (HTTP/1.1 - RFC 2616). - */ -public class BadRequestException extends ServiceResponseException { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new BadRequest Exception. HTTP 400 - * - * @param message the error message - * @param response the HTTP response - */ - public BadRequestException(String message, Response response) { - super(HttpStatus.BAD_REQUEST, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ConflictException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ConflictException.java deleted file mode 100644 index 5deaeb21177..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ConflictException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 409 Conflict (HTTP/1.1 - RFC 2616). - */ -public class ConflictException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Forbidden Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public ConflictException(String message, Response response) { - super(HttpStatus.CONFLICT, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ForbiddenException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ForbiddenException.java deleted file mode 100644 index 5e56a7b08ad..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ForbiddenException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 403 Forbidden (HTTP/1.0 - RFC 1945). - */ -public class ForbiddenException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Forbidden Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public ForbiddenException(String message, Response response) { - super(HttpStatus.FORBIDDEN, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/InternalServerErrorException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/InternalServerErrorException.java deleted file mode 100644 index 6cf89775a8e..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/InternalServerErrorException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 500 Server Error (HTTP/1.0 - RFC 1945). - */ -public class InternalServerErrorException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Internal Server Error Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public InternalServerErrorException(String message, Response response) { - super(HttpStatus.INTERNAL_SERVER_ERROR, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/NotFoundException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/NotFoundException.java deleted file mode 100644 index 0e31bf66065..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/NotFoundException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 404 Not Found (HTTP/1.0 - RFC 1945). - */ -public class NotFoundException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new not found exception. - * - * @param message the message - * @param response the HTTP response - */ - public NotFoundException(String message, Response response) { - super(HttpStatus.NOT_FOUND, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/RequestTooLargeException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/RequestTooLargeException.java deleted file mode 100644 index 8df82186e1f..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/RequestTooLargeException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 413 Request Entity Too Large (HTTP/1.1 - RFC 2616). - */ -public class RequestTooLargeException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Request Too Large Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public RequestTooLargeException(String message, Response response) { - super(HttpStatus.REQUEST_TOO_LONG, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceResponseException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceResponseException.java deleted file mode 100644 index 1e8378be2bb..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceResponseException.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import okhttp3.Response; - -/** - * Generic Service Response Exception. - */ -public class ServiceResponseException extends RuntimeException { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The status code. */ - private final int statusCode; - - /** The HTTP response. */ - private final Response response; - - /** - * Instantiates a new Service Response Exception. - * - * @param statusCode the status code - * @param message the error message - * @param response the HTTP response - */ - public ServiceResponseException(int statusCode, String message, Response response) { - super(message); - this.statusCode = statusCode; - this.response = response; - } - - /** - * Gets the HTTP status code. - * - * @return the http status code - */ - public int getStatusCode() { - return statusCode; - } - - /** - * Gets the HTTP response. - * - * @return the HTTP response - */ - public Response getResponse() { - return response; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceUnavailableException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceUnavailableException.java deleted file mode 100644 index 639ffecfda3..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/ServiceUnavailableException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 503 Service Unavailable (HTTP/1.0 - RFC 1945). - */ -public class ServiceUnavailableException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Service Unavailable Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public ServiceUnavailableException(String message, Response response) { - super(HttpStatus.SERVICE_UNAVAILABLE, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/TooManyRequestsException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/TooManyRequestsException.java deleted file mode 100644 index f165ccca758..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/TooManyRequestsException.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import okhttp3.Response; - -/** - * 429 Too Many Requests (HTTP/1.1 - RFC 6585). - */ -public class TooManyRequestsException extends ServiceResponseException { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 1L; - - /** The Constant TOO_MANY_REQUESTS. */ - private static final int TOO_MANY_REQUESTS = 429; - - /** - * Instantiates a new Too Many Requests Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public TooManyRequestsException(String message, Response response) { - super(TOO_MANY_REQUESTS, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnauthorizedException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnauthorizedException.java deleted file mode 100644 index b8926194fac..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnauthorizedException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 401 Unauthorized (HTTP/1.0 - RFC 1945). - */ -public class UnauthorizedException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new Unauthorized Exception. - * - * @param message the error message - * @param response the HTTP response - */ - public UnauthorizedException(String message, Response response) { - super(HttpStatus.UNAUTHORIZED, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnsupportedException.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnsupportedException.java deleted file mode 100644 index 43970ff53d4..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/UnsupportedException.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.exception; - -import com.ibm.watson.developer_cloud.http.HttpStatus; - -import okhttp3.Response; - -/** - * 415 Unsupported Media Type (HTTP/1.1 - RFC 2616). - */ -public class UnsupportedException extends ServiceResponseException { - - /** - * The Constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new unsupported Exception. - * - * @param message the message - * @param response the HTTP response - */ - public UnsupportedException(String message, Response response) { - super(HttpStatus.UNSUPPORTED_MEDIA_TYPE, message, response); - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/package-info.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/package-info.java deleted file mode 100644 index 610077075e4..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/exception/package-info.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -/** - * This package contains a collection of runtime exceptions thrown by the Watson services. - */ -package com.ibm.watson.developer_cloud.service.exception; - diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/DynamicModel.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/model/DynamicModel.java deleted file mode 100644 index 305e8c89a0c..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/DynamicModel.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.ibm.watson.developer_cloud.service.model; - -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -import java.util.HashMap; - -/** - * Abstract model class for objects which may have dynamic properties attached to them, - * which is represented with an internal map. - */ -public abstract class DynamicModel extends HashMap implements ObjectModel { - - /* - * (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if ((o == null) || (getClass() != o.getClass())) { - return false; - } - - final DynamicModel other = (DynamicModel) o; - - return toString().equals(other.toString()); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return toString().hashCode(); - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return GsonSingleton.getGson().toJson(this); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/GenericModel.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/model/GenericModel.java deleted file mode 100644 index 5ef2919a849..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/GenericModel.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.model; - -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -/** - * Abstract model class to provide a default toString() method in model classes. - */ -public abstract class GenericModel implements ObjectModel { - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if ((o == null) || (getClass() != o.getClass())) { - return false; - } - - final GenericModel other = (GenericModel) o; - - return toString().equals(other.toString()); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return toString().hashCode(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return GsonSingleton.getGson().toJson(this); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/ObjectModel.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/model/ObjectModel.java deleted file mode 100644 index 9f7266d0fad..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/model/ObjectModel.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.ibm.watson.developer_cloud.service.model; - -/** - * Interface for both generic and dynamic model classes. - */ -public interface ObjectModel { - @Override - boolean equals(Object o); - - @Override - int hashCode(); - - @Override - String toString(); -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/DelegatingSSLSocketFactory.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/security/DelegatingSSLSocketFactory.java deleted file mode 100644 index 9f6b9e326b7..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/DelegatingSSLSocketFactory.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2014 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 com.ibm.watson.developer_cloud.service.security; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.Socket; -import javax.net.ssl.SSLSocket; -import javax.net.ssl.SSLSocketFactory; - -/** - * A {@link SSLSocketFactory} that delegates calls. Sockets can be configured after creation by - * overriding {@link #configureSocket(javax.net.ssl.SSLSocket)}. - */ -public class DelegatingSSLSocketFactory extends SSLSocketFactory { - - private final SSLSocketFactory delegate; - - public DelegatingSSLSocketFactory(SSLSocketFactory delegate) { - this.delegate = delegate; - } - - @Override public SSLSocket createSocket() throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(); - return configureSocket(sslSocket); - } - - @Override public SSLSocket createSocket(String host, int port) throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(host, port); - return configureSocket(sslSocket); - } - - @Override public SSLSocket createSocket( - String host, int port, InetAddress localAddress, int localPort) throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(host, port, localAddress, localPort); - return configureSocket(sslSocket); - } - - @Override public SSLSocket createSocket(InetAddress host, int port) throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(host, port); - return configureSocket(sslSocket); - } - - @Override public SSLSocket createSocket( - InetAddress host, int port, InetAddress localAddress, int localPort) throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(host, port, localAddress, localPort); - return configureSocket(sslSocket); - } - - @Override public String[] getDefaultCipherSuites() { - return delegate.getDefaultCipherSuites(); - } - - @Override public String[] getSupportedCipherSuites() { - return delegate.getSupportedCipherSuites(); - } - - @Override public SSLSocket createSocket( - Socket socket, String host, int port, boolean autoClose) throws IOException { - SSLSocket sslSocket = (SSLSocket) delegate.createSocket(socket, host, port, autoClose); - return configureSocket(sslSocket); - } - - protected SSLSocket configureSocket(SSLSocket sslSocket) throws IOException { - // No-op by default. - return sslSocket; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamOptions.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamOptions.java deleted file mode 100644 index 3aa34f43027..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamOptions.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.security; - -/** - * Options for authenticating using IAM. - */ -public class IamOptions { - private String apiKey; - private String accessToken; - private String url; - - public String getApiKey() { - return apiKey; - } - - public String getAccessToken() { - return accessToken; - } - - public String getUrl() { - return url; - } - - public static class Builder { - private String apiKey; - private String accessToken; - private String url; - - public IamOptions build() { - return new IamOptions(this); - } - - public Builder apiKey(String apiKey) { - this.apiKey = apiKey; - return this; - } - - public Builder accessToken(String accessToken) { - this.accessToken = accessToken; - return this; - } - - public Builder url(String url) { - this.url = url; - return this; - } - } - - private IamOptions(Builder builder) { - this.apiKey = builder.apiKey; - this.accessToken = builder.accessToken; - this.url = builder.url; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamToken.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamToken.java deleted file mode 100644 index ed09149863a..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamToken.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.security; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.ObjectModel; - -/** - * Represents response from IAM API. - */ -public class IamToken implements ObjectModel { - @SerializedName("access_token") - private String accessToken; - @SerializedName("refresh_token") - private String refreshToken; - @SerializedName("token_type") - private String tokenType; - @SerializedName("expires_in") - private Long expiresIn; - private Long expiration; - - public String getAccessToken() { - return accessToken; - } - - public String getRefreshToken() { - return refreshToken; - } - - public String getTokenType() { - return tokenType; - } - - public Long getExpiresIn() { - return expiresIn; - } - - public Long getExpiration() { - return expiration; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamTokenManager.java b/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamTokenManager.java deleted file mode 100644 index 3f403a0932c..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/service/security/IamTokenManager.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service.security; - -import com.ibm.watson.developer_cloud.http.HttpClientSingleton; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ResponseConverter; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import okhttp3.Call; -import okhttp3.FormBody; -import okhttp3.Request; - -import java.io.IOException; - -/** - * Retrieves, stores, and refreshes IAM tokens. - */ -public class IamTokenManager { - private String userManagedAccessToken; - private String apiKey; - private String url; - private IamToken tokenData; - - private static final String DEFAULT_AUTHORIZATION = "Basic Yng6Yng="; - private static final String DEFAULT_IAM_URL = "https://iam.bluemix.net/identity/token"; - private static final String GRANT_TYPE = "grant_type"; - private static final String REQUEST_GRANT_TYPE = "urn:ibm:params:oauth:grant-type:apikey"; - private static final String REFRESH_GRANT_TYPE = "refresh_token"; - private static final String API_KEY = "apikey"; - private static final String RESPONSE_TYPE = "response_type"; - private static final String CLOUD_IAM = "cloud_iam"; - private static final String REFRESH_TOKEN = "refresh_token"; - - public IamTokenManager(IamOptions options) { - this.apiKey = options.getApiKey(); - this.url = (options.getUrl() != null) ? options.getUrl() : DEFAULT_IAM_URL; - this.userManagedAccessToken = options.getAccessToken(); - tokenData = new IamToken(); - } - - /** - * This function returns an access token. The source of the token is determined by the following logic: - * 1. If user provides their own managed access token, assume it is valid and send it - * 2. If this class is managing tokens and does not yet have one, or the refresh token is expired, make a request - * for one - * 3. If this class is managing tokens and the token has expired, refresh it - * 4. If this class is managing tokens and has a valid token stored, send it - * - * @return the valid access token - */ - public String getToken() { - String token; - - if (userManagedAccessToken != null) { - // use user-managed access token - token = userManagedAccessToken; - } else if (tokenData.getAccessToken() == null || isRefreshTokenExpired()) { - // request new token - token = requestToken(); - } else if (isAccessTokenExpired()) { - // refresh current token - token = refreshToken(); - } else { - // use valid managed token - token = tokenData.getAccessToken(); - } - - return token; - } - - /** - * Request an IAM token using an API key. Also updates internal managed IAM token information. - * - * @return the new access token - */ - private String requestToken() { - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(url, new String[0])); - - builder.header(HttpHeaders.CONTENT_TYPE, HttpMediaType.APPLICATION_FORM_URLENCODED); - builder.header(HttpHeaders.AUTHORIZATION, DEFAULT_AUTHORIZATION); - - FormBody formBody = new FormBody.Builder() - .add(GRANT_TYPE, REQUEST_GRANT_TYPE) - .add(API_KEY, apiKey) - .add(RESPONSE_TYPE, CLOUD_IAM) - .build(); - builder.body(formBody); - - tokenData = callIamApi(builder.build()); - return tokenData.getAccessToken(); - } - - /** - * Refresh an IAM token using a refresh token. Also updates internal managed IAM token information. - * - * @return the new access token - */ - private String refreshToken() { - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(url, new String[0])); - - builder.header(HttpHeaders.CONTENT_TYPE, HttpMediaType.APPLICATION_FORM_URLENCODED); - builder.header(HttpHeaders.AUTHORIZATION, DEFAULT_AUTHORIZATION); - - FormBody formBody = new FormBody.Builder() - .add(GRANT_TYPE, REFRESH_GRANT_TYPE) - .add(REFRESH_TOKEN, tokenData.getRefreshToken()) - .build(); - builder.body(formBody); - - tokenData = callIamApi(builder.build()); - return tokenData.getAccessToken(); - } - - /** - * Check if currently stored access token is expired. - * - * Using a buffer to prevent the edge case of the - * token expiring before the request could be made. - * - * The buffer will be a fraction of the total TTL. Using 80%. - * - * @return whether the current managed access token is expired or not - */ - private boolean isAccessTokenExpired() { - if (tokenData.getExpiresIn() == null || tokenData.getExpiration() == null) { - return true; - } - - Double fractionOfTimeToLive = 0.8; - Long timeToLive = tokenData.getExpiresIn(); - Long expirationTime = tokenData.getExpiration(); - Double refreshTime = expirationTime - (timeToLive * (1.0 - fractionOfTimeToLive)); - Double currentTime = Math.floor(System.currentTimeMillis() / 1000); - - return refreshTime < currentTime; - } - - /** - * Used as a fail-safe to prevent the condition of a refresh token expiring, - * which could happen after around 30 days. This function will return true - * if it has been at least 7 days and 1 hour since the last token was - * retrieved. - * - * @returns whether the current managed refresh token is expired or not - */ - private boolean isRefreshTokenExpired() { - if (tokenData.getExpiration() == null) { - return true; - } - - int sevenDays = 7 * 24 * 3600; - Double currentTime = Math.floor(System.currentTimeMillis() / 1000); - Long newTokenTime = tokenData.getExpiration() + sevenDays; - return newTokenTime < currentTime; - } - - /** - * Executes call to IAM API and returns IamToken object representing the response. - * - * @param request the request for the IAM API - * @return object containing requested IAM token information - */ - private IamToken callIamApi(Request request) { - Call call = HttpClientSingleton.getInstance().createHttpClient().newCall(request); - ResponseConverter converter = ResponseConverterUtils.getObject(IamToken.class); - - try { - okhttp3.Response response = call.execute(); - return converter.convert(response); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/BooleanToStringTypeAdapter.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/BooleanToStringTypeAdapter.java deleted file mode 100644 index 6a030a52708..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/BooleanToStringTypeAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.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; - -/** - * This TypeAdapter converts "yes", "no", "true", and "false" to Booleans and vice versa. - */ -public class BooleanToStringTypeAdapter extends TypeAdapter { - - private static final String YES = "yes"; - - private static final String TRUE = "true"; - - private static final String NO = "no"; - - private static final String FALSE = "false"; - - /* - * (non-Javadoc) - * - * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) - */ - @Override - public void write(JsonWriter out, Boolean value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(value ? YES : NO); - } - } - - /* - * (non-Javadoc) - * - * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader) - */ - @Override - public Boolean read(JsonReader in) throws IOException { - if (in.peek() == JsonToken.NULL) { - in.nextNull(); - return null; - } else { - final String value = in.nextString(); - - if (YES.equals(value) || TRUE.equals(value)) { - return Boolean.TRUE; - } else if (NO.equals(value) || FALSE.equals(value)) { - return Boolean.FALSE; - } else if (value.isEmpty()) { - return null; - } - - throw new IllegalArgumentException("Cannot parse JSON value '" + value + "' to Boolean."); - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java deleted file mode 100644 index a1af0bd0018..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/CredentialUtils.java +++ /dev/null @@ -1,429 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.Hashtable; -import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.naming.Context; -import javax.naming.InitialContext; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.JsonSyntaxException; - -import okhttp3.Credentials; - -/** - * CredentialUtils retrieves service credentials from the environment. - */ -public final class CredentialUtils { - - /** - * A util class to easily store service credentials. - * - */ - public static class ServiceCredentials { - private String password; - private String username; - - private ServiceCredentials(String username, String password) { - this.username = username; - this.password = password; - } - - /** - * Gets the password. - * - * @return the password - */ - public String getPassword() { - return password; - } - - /** - * Gets the username. - * - * @return the username - */ - public String getUsername() { - return username; - } - } - - /** The Constant ALCHEMY_API. */ - private static final String ALCHEMY_API = "alchemy_api"; - - /** The Constant VISUAL_RECOGNITION. */ - private static final String VISUAL_RECOGNITION = "watson_vision_combined"; - - /** The Constant VCAP_SERVICES. */ - private static final String VCAP_SERVICES = "VCAP_SERVICES"; - - /** The Constant APIKEY. */ - private static final String APIKEY = "apikey"; - - /** The Constant IAM_API_KEY_NAME. */ - private static final String IAM_API_KEY_NAME = "iam_apikey_name"; - - /** The Constant CREDENTIALS. */ - private static final String CREDENTIALS = "credentials"; - - /** The Constant log. */ - private static final Logger log = Logger.getLogger(CredentialUtils.class.getName()); - - /** The Constant PASSWORD. */ - private static final String PASSWORD = "password"; - - /** The Constant PLAN. */ - private static final String PLAN = "plan"; - - /** The services. */ - private static String services; - - /** The context. */ - private static Context context; - - /** The Constant USERNAME. */ - private static final String USERNAME = "username"; - - /** The Constant URL. */ - private static final String URL = "url"; - - /** The Constant IAM_URL. */ - private static final String IAM_URL = "iam_url"; - - /** The Constant PLAN_EXPERIMENTAL. */ - public static final String PLAN_EXPERIMENTAL = "experimental"; - - /** The Constant PLAN_FREE. */ - public static final String PLAN_FREE = "free"; - - /** The Constant PLAN_STANDARD. */ - public static final String PLAN_STANDARD = "standard"; - - /** The Constant API_KEY. */ - private static final String API_KEY = "api_key"; - - /** The Constant LOOKUP_NAME_EXTENSION_API_KEY. */ - private static final String LOOKUP_NAME_EXTENSION_API_KEY = "/credentials"; - - /** The Constant LOOKUP_NAME_EXTENSION_URL. */ - private static final String LOOKUP_NAME_EXTENSION_URL = "/url"; - - private CredentialUtils() { - // This is a utility class - no instantiation allowed. - } - - /** - * Builds the lookup name to be searched for in JDNI - * and uses it to call the overloaded JDNI method. - * - * @param serviceName Name of the bluemix service - * @param lookupNameExtension Extension to determine which value should be retrieved through JDNI - * @return The encoded desired value - */ - private static String getJDNIValue(String serviceName, String lookupNameExtension) { - return getJDNIValue("watson-developer-cloud/" + serviceName + lookupNameExtension); - } - - /** - * Attempt to get the Base64-encoded value through JNDI. - * - * This method should always return null on Android due to the javax functions being unsupported - * - * @param lookupName Key to lookup in JDNI - * @return The encoded desired value - */ - private static String getJDNIValue(String lookupName) { - if (!isClassAvailable("javax.naming.Context") || !isClassAvailable("javax.naming.InitialContext")) { - log.info("JNDI string lookups is not available."); - return null; - } - - try { - if (context == null) { - context = new InitialContext(); - } - return (String) context.lookup(lookupName); - } catch (Exception e) { - log.fine("JNDI " + lookupName + " not found."); - return null; - } - } - - private static boolean isClassAvailable(String className) { - try { - Class.forName(className); - return true; - } catch (Throwable e) { - return false; - } - } - - /** - * Gets the VCAP_SERVICES environment variable and return it as a {@link JsonObject}. - * - * @return the VCAP_SERVICES as a {@link JsonObject}. - */ - private static JsonObject getVCAPServices() { - final String envServices = services != null ? services : System.getenv(VCAP_SERVICES); - if (envServices == null) { - return null; - } - - JsonObject vcapServices = null; - - try { - final JsonParser parser = new JsonParser(); - vcapServices = (JsonObject) parser.parse(envServices); - } catch (final JsonSyntaxException e) { - log.log(Level.INFO, "Error parsing VCAP_SERVICES", e); - } - return vcapServices; - } - - /** - * Returns the IAM API key from the VCAP_SERVICES, or null if it doesn't exist. - * - * @param serviceName the service name - * @return the IAM API key or null if the service cannot be found - */ - public static String getIAMKey(String serviceName) { - final JsonObject services = getVCAPServices(); - - if (serviceName == null || services == null) { - return null; - } - - final JsonObject credentials = getCredentialsObject(services, serviceName, null); - if (credentials != null && credentials.get(APIKEY) != null && credentials.get(IAM_API_KEY_NAME) != null) { - return credentials.get(APIKEY).getAsString(); - } - - return null; - } - - /** - * Returns the apiKey from the VCAP_SERVICES or null if doesn't exists. - * - * @param serviceName the service name - * @return the API key or null if the service cannot be found. - */ - public static String getAPIKey(String serviceName) { - return getAPIKey(serviceName, null); - } - - /** - * Returns the apiKey from the VCAP_SERVICES or null if doesn't exists. If plan is specified, then only credentials - * for the given plan will be returned. - * - * @param serviceName the service name - * @param plan the service plan: standard, free or experimental - * @return the API key - */ - public static String getAPIKey(String serviceName, String plan) { - if ((serviceName == null) || serviceName.isEmpty()) { - return null; - } - - final JsonObject services = getVCAPServices(); - if (services == null) { - return getJDNIValue(serviceName, LOOKUP_NAME_EXTENSION_API_KEY); - } - if (serviceName.equalsIgnoreCase(ALCHEMY_API)) { - final JsonObject credentials = getCredentialsObject(services, serviceName, plan); - if (credentials != null) { - return credentials.get(APIKEY).getAsString(); - } - } else if (serviceName.equalsIgnoreCase(VISUAL_RECOGNITION)) { - final JsonObject credentials = getCredentialsObject(services, serviceName, plan); - if (credentials != null) { - return credentials.get(API_KEY).getAsString(); - } - } else { - ServiceCredentials credentials = getUserNameAndPassword(serviceName, plan); - if (credentials != null) { - return Credentials.basic(credentials.getUsername(), credentials.getPassword()); - } - } - return null; - } - - /** - * Returns the username and password as defined in the VCAP_SERVICES or null if they do not exist or are not - * accessible. This is a utility method for {@link #getUserNameAndPassword(String, String)}. Invoking this method is - * identical to calling getUserNameAndPassword(serviceName, null); - * - * @param serviceName the name of the service whose credentials are sought - * @return an object representing the service's credentials - */ - public static ServiceCredentials getUserNameAndPassword(String serviceName) { - return getUserNameAndPassword(serviceName, null); - } - - /** - * Returns the username and password as defined in the VCAP_SERVICES or null if they do not exist or are not - * accessible. If a plan is provided then only the credentials for that plan (and service) will be returned. Null will - * be returned if the plan does not exist. - * - * @param serviceName the name of the service whose credentials are sought - * @param plan the plan name - * @return an object representing the service's credentials - */ - public static ServiceCredentials getUserNameAndPassword(String serviceName, String plan) { - if ((serviceName == null) || serviceName.isEmpty()) { - return null; - } - - final JsonObject services = getVCAPServices(); - if (services == null) { - return null; - } - - JsonObject jsonCredentials = getCredentialsObject(services, serviceName, plan); - if (jsonCredentials != null) { - String username = null; - if (jsonCredentials.has(USERNAME)) { - username = jsonCredentials.get(USERNAME).getAsString(); - } - String password = null; - if (jsonCredentials.has(PASSWORD)) { - password = jsonCredentials.get(PASSWORD).getAsString(); - } - if ((username != null) || (password != null)) { - // both will be null in the case of Alchemy API - return new ServiceCredentials(username, password); - } - } - return null; - } - - /** - * A helper method to retrieve the appropriate 'credentials' JSON property value from the VCAP_SERVICES. - * - * @param vcapServices JSON object representing the VCAP_SERVICES - * @param serviceName the name of the service whose credentials are sought - * @param plan the name of the plan for which the credentials are sought, e.g. 'standard', 'beta' etc, may be null - * @return the first set of credentials that match the search criteria, service name and plan. May return null - */ - private static JsonObject getCredentialsObject(JsonObject vcapServices, String serviceName, String plan) { - for (final Entry entry : vcapServices.entrySet()) { - final String key = entry.getKey(); - if (key.startsWith(serviceName)) { - final JsonArray servInstances = vcapServices.getAsJsonArray(key); - for (final JsonElement instance : servInstances) { - final JsonObject service = instance.getAsJsonObject(); - final String instancePlan = service.get(PLAN).getAsString(); - if ((plan == null) || plan.equalsIgnoreCase(instancePlan)) { - return instance.getAsJsonObject().getAsJsonObject(CREDENTIALS); - } - } - } - } - return null; - } - - /** - * Gets the API url. - * - * @param serviceName the service name - * @return the API url - */ - - public static String getAPIUrl(String serviceName) { - return getAPIUrl(serviceName, null); - } - - /** - * Returns the API URL from the VCAP_SERVICES, JDNI, or null if doesn't exists. If plan is specified, then only - * credentials for the given plan will be returned. - * - * @param serviceName the service name - * @param plan the service plan: standard, free or experimental - * @return the API URL - */ - public static String getAPIUrl(String serviceName, String plan) { - if ((serviceName == null) || serviceName.isEmpty()) { - return null; - } - - final JsonObject services = getVCAPServices(); - if (services == null) { - return getJDNIValue(serviceName, LOOKUP_NAME_EXTENSION_URL); - } - - final JsonObject credentials = getCredentialsObject(services, serviceName, plan); - if ((credentials != null) && credentials.has(URL)) { - return credentials.get(URL).getAsString(); - } - - return null; - } - - public static String getIAMUrl(String serviceName) { - final JsonObject services = getVCAPServices(); - - if (serviceName == null || services == null) { - return null; - } - - final JsonObject credentials = getCredentialsObject(services, serviceName, null); - if (credentials != null && credentials.get(IAM_URL) != null) { - return credentials.get(IAM_URL).getAsString(); - } - - return null; - } - - /** - * Sets the VCAP_SERVICES variable. This is utility variable for testing - * - * @param services the VCAP_SERVICES - */ - public static void setServices(String services) { - CredentialUtils.services = services; - } - - /** - * Sets the context variable for JDNI. This is a utility method for testing. - * - * @param env Configuration options for the context - */ - public static void setContext(Hashtable env) { - try { - CredentialUtils.context = new InitialContext(env); - } catch (Exception e) { - log.fine("Error setting up JDNI context: " + e.getMessage()); - } - } - - /** - * Method for testing the getAPIUrl method that bypasses the VCAP - * services to ensure retrieval from JDNI. - * - * @param serviceName the service name - * @return the API URL - */ - public static String getAPIUrlTest(String serviceName) { - if ((serviceName == null) || serviceName.isEmpty()) { - return null; - } - - return getJDNIValue("jdni/watson-developer-cloud/" + serviceName + LOOKUP_NAME_EXTENSION_URL); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java deleted file mode 100644 index c9f919806f6..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/DateDeserializer.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.lang.reflect.Type; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; - -/** - * Date deserializer for different date format across all the Watson APIs. - */ -public class DateDeserializer implements JsonDeserializer { - private static final String DATE_FROM_ALCHEMY = "yyyyMMdd'T'HHmmss"; - private static final String DATE_FROM_DIALOG = "yyyy-MM-dd HH:mm:ss"; - - /** The Constant DATE_UTC. */ - public static final String DATE_UTC = "yyyy-MM-dd'T'HH:mm:ss.SSS"; - private static final String DATE_WITHOUT_SECONDS = "yyyy-MM-dd'T'HH:mm:ssZ"; - private static final String DATE_WITH_SECONDS = "yyyy-MM-dd'T'HH:mm:ss"; - private static final String DATE_822 = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"; - private static final String DATE_822_WITHOUT_MS = "yyyy-MM-dd'T'HH:mm:ssZ"; - - // SimpleDateFormat is NOT thread safe - they require private visibility and synchronized access - private final SimpleDateFormat alchemyDateFormatter = new SimpleDateFormat(DATE_FROM_ALCHEMY); - private final SimpleDateFormat dialogDateFormatter = new SimpleDateFormat(DATE_FROM_DIALOG); - private final SimpleDateFormat utcDateFormatter = new SimpleDateFormat(DATE_UTC); - private final SimpleDateFormat utcWithoutSecondsDateFormatter = new SimpleDateFormat(DATE_WITHOUT_SECONDS); - private final SimpleDateFormat utcWithSecondsDateFormatter = new SimpleDateFormat(DATE_WITH_SECONDS); - private final SimpleDateFormat rfc822DateFormatter = new SimpleDateFormat(DATE_822); - private final SimpleDateFormat rfc822WithoutMsDateFormatter = new SimpleDateFormat(DATE_822_WITHOUT_MS); - - private final List dateFormatters = - Arrays.asList(utcDateFormatter, utcWithoutSecondsDateFormatter, dialogDateFormatter, - alchemyDateFormatter, utcWithSecondsDateFormatter); - - private final List rfc822Formatters = - Arrays.asList(rfc822DateFormatter, rfc822WithoutMsDateFormatter); - - private static final Logger LOG = Logger.getLogger(DateDeserializer.class.getName()); - - /* - * (non-Javadoc) - * - * @see com.google.gson.JsonDeserializer#deserialize(com.google.gson.JsonElement, java.lang.reflect.Type, - * com.google.gson.JsonDeserializationContext) - */ - @Override - public synchronized Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) - throws JsonParseException { - - if (json.isJsonNull() || json.getAsString().isEmpty()) { - return null; - } - - String dateAsString = json.getAsJsonPrimitive().getAsString(); - ParseException e = null; - - if (dateAsString.endsWith("Z")) { - String dateWithTz = dateAsString.replaceAll("Z$", "+0000"); - for (SimpleDateFormat format : rfc822Formatters) { - try { - return format.parse(dateWithTz); - } catch (ParseException e1) { - e = e1; - } - } - } - - for (SimpleDateFormat format : dateFormatters) { - try { - return format.parse(dateAsString); - } catch (ParseException e1) { - e = e1; - } - } - - Pattern isJustNumber = Pattern.compile("^\\d+$"); - Matcher foundMatch = isJustNumber.matcher(dateAsString); - if (foundMatch.find()) { - Long timeAsLong = Long.parseLong(dateAsString); - Long msCheck = 100000000000L; - - // are we ms or seconds maybe? - if (timeAsLong < msCheck) { - // assuming in seconds - timeAsLong = timeAsLong * 1000; - } - return new Date(timeAsLong); - } - - LOG.log(Level.SEVERE, "Error parsing: " + dateAsString, e); - return null; - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/DateSerializer.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/DateSerializer.java deleted file mode 100644 index b0da0d7c0bc..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/DateSerializer.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.lang.reflect.Type; -import java.text.SimpleDateFormat; -import java.util.Date; - -import com.google.gson.JsonElement; -import com.google.gson.JsonNull; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; - -/** - * Date serializer. - */ -public class DateSerializer implements JsonSerializer { - - // SimpleDateFormat is NOT thread safe - they require private visibility and synchronized access - private final SimpleDateFormat utc = new SimpleDateFormat(DateDeserializer.DATE_UTC); - - /* - * (non-Javadoc) - * - * @see com.google.gson.JsonSerializer#serialize(java.lang.Object, java.lang.reflect.Type, - * com.google.gson.JsonSerializationContext) - */ - @Override - // DateSerializer.serialize() is NOT thread safe because of the underlying SimpleDateFormats. - public synchronized JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) { - return src == null ? JsonNull.INSTANCE : new JsonPrimitive(utc.format(src)); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSerializationHelper.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSerializationHelper.java deleted file mode 100644 index eed5d2ebfee..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSerializationHelper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.ibm.watson.developer_cloud.util; - -import java.lang.reflect.Type; - -/** - * Utility class to help with serialization in models which extend - * {@link com.ibm.watson.developer_cloud.service.model.DynamicModel}. - * - * @see com.ibm.watson.developer_cloud.service.model.DynamicModel - */ -public class GsonSerializationHelper { - - private GsonSerializationHelper() { - // This is a utility class - no instantiation allowed. - } - - /** - * Takes a property of an object extending {@link com.ibm.watson.developer_cloud.service.model.DynamicModel} and - * serializes it to the desired type. Without this conversion, properties which also happen to - * extend {@link com.ibm.watson.developer_cloud.service.model.DynamicModel} throw an exception when - * trying to cast to their concrete type from the default Gson serialization. - * - * @param property property of a DynamicModel - * @param type the type we wish to convert the property to - * @param the generic type - * @return the properly converted object - */ - public static T serializeDynamicModelProperty(Object property, Type type) { - return GsonSingleton.getGson().fromJson(GsonSingleton.getGson().toJsonTree(property), type); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java deleted file mode 100644 index 7aee6ec391c..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/GsonSingleton.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.Date; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -/** - * Gson singleton to be use when transforming from JSON to Java Objects and vise versa. It handles date formatting and - * pretty print the result - */ -public final class GsonSingleton { - - private static Gson gson; - private static Gson gsonWithoutPrinting; - - private GsonSingleton() { - // This is a utility class - no instantiation allowed. - } - - /** - * Creates a {@link com.google.gson.Gson} object that can be use to serialize and deserialize Java objects. - * - * @param prettyPrint if true the JSON will be pretty printed - * @return the {@link Gson} - */ - private static Gson createGson(Boolean prettyPrint) { - GsonBuilder builder = new GsonBuilder(); - - registerTypeAdapters(builder); - - if (prettyPrint) { - builder.setPrettyPrinting(); - } - builder.disableHtmlEscaping(); - return builder.create(); - } - - private static void registerTypeAdapters(GsonBuilder builder) { - // Date serializer and deserializer - builder.registerTypeAdapter(Date.class, new DateDeserializer()); - builder.registerTypeAdapter(Date.class, new DateSerializer()); - } - - /** - * Gets the Gson instance. - * - * @return the Gson - */ - public static synchronized Gson getGson() { - if (gson == null) { - gson = createGson(true); - } - return gson; - } - - /** - * Gets the Gson instance. - * - * @return the Gson - */ - public static synchronized Gson getGsonWithoutPrettyPrinting() { - if (gsonWithoutPrinting == null) { - gsonWithoutPrinting = createGson(false); - } - return gsonWithoutPrinting; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/HttpLogging.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/HttpLogging.java deleted file mode 100644 index ede88248edc..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/HttpLogging.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.logging.Logger; - -import okhttp3.logging.HttpLoggingInterceptor; -import okhttp3.logging.HttpLoggingInterceptor.Level; - -/** - * HttpLogging logs HTTP request and response data. - * - * Instantiates a new HTTP logging. The logging level will be determinate by the {@link Logger} used in this class. - * Basic HTTP request response will be log if Level is INFO, HEADERS if level is FINE and all the bodies if Level is - * ALL. - */ -public class HttpLogging { - private static final Logger LOG = Logger.getLogger(HttpLogging.class.getName()); - - private HttpLogging() { } - - private static final HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); - static { - if (LOG.isLoggable(java.util.logging.Level.ALL)) { - loggingInterceptor.setLevel(Level.BODY); - } else if (LOG.isLoggable(java.util.logging.Level.FINE)) { - loggingInterceptor.setLevel(Level.HEADERS); - } else if (LOG.isLoggable(java.util.logging.Level.INFO)) { - loggingInterceptor.setLevel(Level.BASIC); - } - } - - public static HttpLoggingInterceptor getLoggingInterceptor() { - return loggingInterceptor; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/LongToDateTypeAdapter.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/LongToDateTypeAdapter.java deleted file mode 100644 index c218bbee4bc..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/LongToDateTypeAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.io.IOException; -import java.util.Date; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; - -/** - * This TypeAdapter converts unix timestamps (in numeric or String form) to Java Dates and vice versa. - */ -public class LongToDateTypeAdapter extends TypeAdapter { - - /* - * (non-Javadoc) - * - * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) - */ - @Override - public void write(JsonWriter out, Date value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(value.getTime()); - } - } - - /* - * (non-Javadoc) - * - * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader) - */ - @Override - public Date read(JsonReader in) throws IOException { - if (in.peek() == JsonToken.NULL) { - in.nextNull(); - return null; - } else { - // nextLong() tries to parse Strings to Longs as well - return new Date(in.nextLong()); - } - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java deleted file mode 100644 index 4f1c8288b05..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/RequestUtils.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.InputStreamRequestBody; -import okhttp3.MediaType; -import okhttp3.RequestBody; - -import java.io.File; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Utility functions to use when creating a {@link com.ibm.watson.developer_cloud.http.RequestBuilder }. - * - */ -public final class RequestUtils { - - private static final Logger LOG = Logger.getLogger(RequestUtils.class.getName()); - - private static final String[] properties = - new String[] { "java.vendor", "java.version", "os.arch", "os.name", "os.version" }; - private static String userAgent; - - private RequestUtils() { - // This is a utility class - no instantiation allowed. - } - - /** - * Encode a string into a valid URL string. - * - * @param content the content - * @return the string - */ - public static String encode(String content) { - try { - return URLEncoder.encode(content, "UTF-8"); - } catch (final UnsupportedEncodingException e) { - throw new AssertionError(e); - } - } - - /** - * Return a copy of a {@link Map} excluding the given key, or array of keys. - * - * @param params the parameters - * @param toOmit the keys to omit - * @return the map with the omitted key-value pars, or null if params is null - */ - public static Map omit(Map params, String... toOmit) { - if (params == null) { - return null; - } - - final Map ret = new HashMap(params); - - if (toOmit != null) { - ret.keySet().removeAll(Arrays.asList(toOmit)); - } - - return ret; - } - - - /** - * Return a copy of a {@link Map} with only the specified given key, or array of keys. If {@code toPick} is empty all - * keys will remain in the Map. - * - * @param params the parameters - * @param toPick the keys to pick - * @return the map with the picked key-value pars, or null if params is null - */ - - public static Map pick(Map params, String... toPick) { - if (params == null) { - return null; - } - - final Map ret = new HashMap(params); - - if ((toPick != null) && (toPick.length > 0)) { - ret.keySet().retainAll(Arrays.asList(toPick)); - } - - return ret; - } - - /** - * Creates a String of all elements of an array, separated by a separator. - * - * @param the generic type - * @param array the array - * @param separator the separator - * @return the joined String - */ - public static String join(T[] array, String separator) { - return join(Arrays.asList(array), separator); - } - - /** - * Creates a String of all elements of an iterable, separated by a separator. - * - * @param iterable the iterable - * @param separator the separator - * @return the joined String - */ - public static String join(Iterable iterable, String separator) { - final StringBuilder sb = new StringBuilder(); - boolean first = true; - - for (Object item : iterable) { - if (first) { - first = false; - } else { - sb.append(separator); - } - - sb.append(item.toString()); - } - - return sb.toString(); - } - - /** - * Gets the user agent. - * - * @return the user agent - */ - public static synchronized String getUserAgent() { - if (userAgent == null) { - userAgent = buildUserAgent(); - } - return userAgent; - } - - private static String loadSdkVersion() { - ClassLoader classLoader = RequestUtils.class.getClassLoader(); - InputStream inputStream = classLoader.getResourceAsStream("version.properties"); - Properties properties = new Properties(); - - try { - properties.load(inputStream); - } catch (Exception e) { - LOG.log(Level.WARNING, "Could not load version.properties", e); - } - - return properties.getProperty("version", "unknown-version"); - } - - /** - * Builds the user agent using System properties. - * - * @return the string that represents the user agent - */ - private static String buildUserAgent() { - final List details = new ArrayList(); - for (String propertyName : properties) { - details.add(propertyName + "=" + System.getProperty(propertyName)); - } - - return "watson-apis-java-sdk/" + loadSdkVersion() + " (" + RequestUtils.join(details, "; ") + ")"; - } - - /** - * Returns a request body that encapsulates the specified file qualified with the specified content type. - * - * @param file the file content to POST/PUT - * @param contentType the HTTP contentType to use. - * - * @return {@link RequestBody} - */ - public static RequestBody fileBody(File file, String contentType) { - MediaType mediaType = (contentType != null) ? MediaType.parse(contentType) : HttpMediaType.BINARY_FILE; - return RequestBody.create(mediaType, file); - } - - /** - * Returns a request body the encapsulates the specified input stream qualified with the specified content type. - * - * @param stream the input stream content to POST/PUT - * @param contentType the HTTP contentType to use. - * - * @return {@link RequestBody} - */ - public static RequestBody inputStreamBody(InputStream stream, String contentType) { - MediaType mediaType = (contentType != null) ? MediaType.parse(contentType) : HttpMediaType.BINARY_FILE; - return InputStreamRequestBody.create(mediaType, stream); - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseConverterUtils.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseConverterUtils.java deleted file mode 100644 index f8b4dbf40c1..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseConverterUtils.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.io.InputStream; -import java.lang.reflect.Type; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.ResponseConverter; - -import com.ibm.watson.developer_cloud.service.model.ObjectModel; -import okhttp3.Response; - -/** - * Utility class to convert service responses into a {@link ResponseConverter}. - * - * @see ResponseConverter - */ -public final class ResponseConverterUtils { - - private ResponseConverterUtils() { - // This is a utility class - no instantiation allowed. - } - - /** - * Creates a generic {@link ResponseConverter} for a generic class. - * - * @param the generic type - * @param type the type - * @param property the property - * @return the object converter - */ - public static ResponseConverter getGenericObject(final Type type, final String property) { - return new ResponseConverter() { - @Override - public T convert(Response response) { - JsonObject json = ResponseUtils.getJsonObject(response); - return GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(json.get(property), type); - } - }; - } - - /** - * Creates an {@link InputStream} converter. - * - * @return the input stream converter - */ - public static ResponseConverter getInputStream() { - return new ResponseConverter() { - @Override - public InputStream convert(Response response) { - return ResponseUtils.getInputStream(response); - } - }; - } - - /** - * Creates a generic {@link ResponseConverter} for a POJO class.
- * It should extend {@link ObjectModel} - * - * @param the generic type - * @param type the type - * @return the response converter - */ - public static ResponseConverter getObject(final Class type) { - return new ResponseConverter() { - @Override - public T convert(Response response) { - return ResponseUtils.getObject(response, type); - } - }; - } - - /** - * Creates a generic {@link ResponseConverter} for a String response. - * - * @return the string - */ - public static ResponseConverter getString() { - return new ResponseConverter() { - @Override - public String convert(Response response) { - return ResponseUtils.getString(response); - } - }; - } - - /** - * Gets the void converter. - * - * @return the void converter - */ - public static ResponseConverter getVoid() { - return new ResponseConverter() { - @Override - public Void convert(Response response) { - ResponseUtils.getString(response); // read the response to prevent a connection leak - return null; - } - }; - } -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtils.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtils.java deleted file mode 100644 index e6e483df488..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/ResponseUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.stream.JsonReader; - -import com.ibm.watson.developer_cloud.service.model.ObjectModel; -import okhttp3.Response; - -/** - * Utility class to manage service responses. - * - * @see Response - */ -public final class ResponseUtils { - private static final String ERROR_MESSAGE = "Error reading the http response"; - private static final Logger LOG = Logger.getLogger(ResponseUtils.class.getName()); - - private ResponseUtils() { - // This is a utility class - no instantiation allowed. - } - - /** - * Returns the HTTP Response {@link InputStream}. - * - * @param response an HTTP response - * @return the content body as an InputStream - */ - public static InputStream getInputStream(Response response) { - return response.body().byteStream(); - } - - /** - * Return a {@link JsonElement} representation of the response. - * - * @param response the Response - * @return the content body as JSON - */ - public static JsonElement getJsonElement(Response response) { - return new JsonParser().parse(response.body().charStream()); - } - - /** - * Returns a {@link JsonObject} representation of the response. - * - * @param response an HTTP response - * @return the content body as JSONArray - */ - public static JsonObject getJsonObject(Response response) { - return getJsonElement(response).getAsJsonObject(); - } - - /** - * Returns a {@link JsonObject} representation of the provided JSON String. - * - * @param jsonString the JSON String - * @return the content body as a JsonObject - */ - public static JsonObject getJsonObject(String jsonString) { - return new JsonParser().parse(jsonString).getAsJsonObject(); - } - - /** - * Parses the {@link Response} into the POJO representation. - * - * @param the generic type to use when parsing the response - * @param response the HTTP response - * @param type the type of the response - * @return the POJO - */ - public static T getObject(Response response, Class type) { - JsonReader reader; - try { - reader = new JsonReader(response.body().charStream()); - return GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(reader, type); - } finally { - response.body().close(); - } - } - - /** - * Returns a String representation of the response. - * - * @param response an HTTP response - * @return the content body as String - */ - public static String getString(Response response) { - try { - return response.body().string(); - } catch (final IOException e) { - LOG.log(Level.SEVERE, ERROR_MESSAGE, e); - throw new RuntimeException(ERROR_MESSAGE, e); - } - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/Validator.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/Validator.java deleted file mode 100644 index 60ff4b73aeb..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/Validator.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.Collection; - -/** - * This class assists in validating arguments.
- * If an argument value is deemed invalid, an IllegalArgumentException is thrown. - */ -@SuppressWarnings("rawtypes") -public final class Validator { - - private Validator() { - // This is a utility class - no instantiation allowed. - } - - /** - * Validates that the argument condition is true; otherwise throwing an exception with the specified - * message. This method is useful when validating according to an arbitrary boolean expression, such as validating a - * primitive number or using your own custom validation expression. - * - * - * @param expression the boolean expression to check - * @param message the exception message if invalid - * @throws IllegalArgumentException if expression is false - */ - public static void isTrue(boolean expression, String message) { - if (!expression) { - throw new IllegalArgumentException(message); - } - } - - /** - * Validates that the specified argument collection is neither null nor a size of zero (no elements); - * otherwise throwing an exception with the specified message. - * - * @param collection the collection to check - * @param message the exception message if invalid - * @throws IllegalArgumentException if the collection is empty - */ - public static void notEmpty(Collection collection, String message) { - if ((collection == null) || collection.isEmpty()) { - throw new IllegalArgumentException(message); - } - } - - - /** - * Validates that the specified argument array is neither null nor a length of zero (no elements); - * otherwise throwing an exception with the specified message. - * - * @param array the array to check - * @param message the exception message if invalid - * @throws IllegalArgumentException if the array is empty - */ - public static void notEmpty(Object[] array, String message) { - if ((array == null) || (array.length == 0)) { - throw new IllegalArgumentException(message); - } - } - - /** - * Validator that the specified argument string is neither null nor a length of zero (no characters); - * otherwise throwing an exception with the specified message. - * - * @param string the string to check - * @param message the exception message if invalid - * @throws IllegalArgumentException if the string is empty - */ - public static void notEmpty(String string, String message) { - if ((string == null) || (string.length() == 0)) { - throw new IllegalArgumentException(message); - } - } - - /** - * Validates that the specified argument is not null; otherwise throwing an exception with the specified - * message. - * - * @param object the object to check - * @param message the exception message if invalid - */ - public static void notNull(Object object, String message) { - if (object == null) { - throw new IllegalArgumentException(message); - } - } - - /** - * Validates that the specified argument is null; otherwise throwing an exception with the specified - * message. - * - * @param object the object to check - * @param message the exception message if invalid - */ - public static void isNull(Object object, String message) { - if (object != null) { - throw new IllegalArgumentException(message); - } - } - -} diff --git a/core/src/main/java/com/ibm/watson/developer_cloud/util/package-info.java b/core/src/main/java/com/ibm/watson/developer_cloud/util/package-info.java deleted file mode 100644 index c7c62bed958..00000000000 --- a/core/src/main/java/com/ibm/watson/developer_cloud/util/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -/** - * Utility classes to detect media types and convert files into input streams. - */ -package com.ibm.watson.developer_cloud.util; - diff --git a/core/src/main/resources/version.properties b/core/src/main/resources/version.properties deleted file mode 100644 index f5dcf19df63..00000000000 --- a/core/src/main/resources/version.properties +++ /dev/null @@ -1,2 +0,0 @@ -version=@pom.version@ -build.date=@build.date@ diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceUnitTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceUnitTest.java deleted file mode 100644 index 076ea2243ca..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/WatsonServiceUnitTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud; - -import java.io.IOException; - -import org.apache.commons.lang3.StringUtils; -import org.junit.After; - -import com.google.gson.Gson; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; - -/** - * Utility class to Mock the Watson Services. - * - */ -public abstract class WatsonServiceUnitTest extends WatsonServiceTest { - - /** The Constant DELETE. */ - protected static final String DELETE = "DELETE"; - - /** The Constant GET. */ - protected static final String GET = "GET"; - - /** The Constant POST. */ - protected static final String POST = "POST"; - - /** The Constant PUT. */ - protected static final String PUT = "PUT"; - - private static final Gson GSON = GsonSingleton.getGson(); - - /** The server. */ - protected MockWebServer server; - - /** - * Setups and starts the mock server. - * - * @throws Exception the exception - */ - @Override - public void setUp() throws Exception { - server = new MockWebServer(); - server.start(); - } - - /** - * Tear down. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @After - public void tearDown() throws IOException { - server.shutdown(); - } - - /** - * Gets the mock web server url. - * - * @return the server url - */ - protected String getMockWebServerUrl() { - return StringUtils.chop(server.url("/").toString()); - } - - /** - * Create a MockResponse with JSON content type and the object serialized to JSON as body. - * - * @param body the body - * @return the mock response - */ - protected static MockResponse jsonResponse(Object body) { - return new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(body)); - } - -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/http/NameValueTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/http/NameValueTest.java deleted file mode 100644 index 62978c29096..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/http/NameValueTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.http; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Test; - -/** - * The Class NameValueTest. - */ -public class NameValueTest { - - private NameValue fooBar; - private NameValue foo; - private NameValue fooBuzz; - - /** - * Sets the up. - * - * @throws Exception the exception - */ - @Before - public void setUp() throws Exception { - fooBar = new NameValue("foo", "bar"); - foo = new NameValue("foo", null); - fooBuzz = new NameValue("foo", "buzz"); - } - - /** - * Test name null. - */ - @Test(expected = IllegalArgumentException.class) - public void testNameNull() { - new NameValue(null, null); - } - - /** - * Test name equals. - */ - @Test - public void testEquals() { - assertNameValueEquals(fooBar, new NameValue("foo", "bar")); - assertNameValueEquals(foo, new NameValue("foo", null)); - } - - /** - * Test inequality. - */ - @Test - public void testNotEquals() { - assertNotEquals(fooBar, fooBuzz); - } - - /** - * Test value null. - */ - @Test - public void testNull() { - assertEquals(foo.getName(), "foo"); - assertNull(foo.getValue()); - assertNotEquals(foo.hashCode(), fooBar.hashCode()); - assertNotEquals(foo, fooBar); - } - - /** - * Test toString(). - */ - @Test - public void testToString() { - assertEquals("foo=bar", fooBar.toString()); - assertEquals("foo", foo.toString()); - } - - /** - * Assert equals. - */ - private static void assertNameValueEquals(NameValue a, NameValue b) { - assertEquals(a, b); - assertEquals(a.toString(), b.toString()); - assertEquals(a.hashCode(), b.hashCode()); - assertTrue(a.equals(b)); - } - -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/service/ErrorResponseTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/service/ErrorResponseTest.java deleted file mode 100644 index 44e4f130cb1..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/service/ErrorResponseTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.exception.BadRequestException; -import com.ibm.watson.developer_cloud.service.exception.ConflictException; -import com.ibm.watson.developer_cloud.service.exception.ForbiddenException; -import com.ibm.watson.developer_cloud.service.exception.InternalServerErrorException; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.service.exception.RequestTooLargeException; -import com.ibm.watson.developer_cloud.service.exception.ServiceUnavailableException; -import com.ibm.watson.developer_cloud.service.exception.TooManyRequestsException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.service.exception.UnsupportedException; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class ErrorResponseTest extends WatsonServiceUnitTest { - - public class TestService extends WatsonService { - - private static final String SERVICE_NAME = "test"; - - public TestService() { - super(SERVICE_NAME); - } - - public ServiceCall testMethod() { - RequestBuilder builder = RequestBuilder.get(HttpUrl.parse(getEndPoint() + "/v1/test")); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(GenericModel.class)); - } - } - - TestService service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new TestService(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - } - - /** - * Test HTTP status code 400 (Bad Request) error response. - */ - @Test - public void testBadRequest() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(400) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof BadRequestException); - BadRequestException ex = (BadRequestException) e; - assertEquals(400, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 401 (Unauthorized) error response. - */ - @Test - public void testUnauthorized() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(401) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof UnauthorizedException); - UnauthorizedException ex = (UnauthorizedException) e; - assertEquals(401, ex.getStatusCode()); - assertTrue(ex.getMessage().startsWith("Unauthorized: Access is denied due to invalid credentials.")); - } - } - - /** - * Test HTTP status code 403 (Forbidden) error response. - */ - @Test - public void testForbidden() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(403) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof ForbiddenException); - ForbiddenException ex = (ForbiddenException) e; - assertEquals(403, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 404 (NotFound) error response. - */ - @Test - public void testNotFound() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(404) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof NotFoundException); - NotFoundException ex = (NotFoundException) e; - assertEquals(404, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 409 (Conflict) error response. - */ - @Test - public void testConflict() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(409) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof ConflictException); - ConflictException ex = (ConflictException) e; - assertEquals(409, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 413 (RequestTooLarge) error response. - */ - @Test - public void testRequestTooLarge() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(413) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof RequestTooLargeException); - RequestTooLargeException ex = (RequestTooLargeException) e; - assertEquals(413, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 415 (Unsupported Media Type) error response. - */ - @Test - public void testUnsupported() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(415) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof UnsupportedException); - UnsupportedException ex = (UnsupportedException) e; - assertEquals(415, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 429 (TooManyRequests) error response. - */ - @Test - public void testTooManyRequests() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(429) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof TooManyRequestsException); - TooManyRequestsException ex = (TooManyRequestsException) e; - assertEquals(429, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 500 (InternalServerError) error response. - */ - @Test - public void testInternalServerError() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(500) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof InternalServerErrorException); - InternalServerErrorException ex = (InternalServerErrorException) e; - assertEquals(500, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } - - /** - * Test HTTP status code 503 (ServiceUnavailable) error response. - */ - @Test - public void testServiceUnavailable() { - - String message = "The request failed because the moon is full."; - server.enqueue(new MockResponse() - .setResponseCode(503) - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"error\": \"" + message + "\"}")); - - try { - GenericModel response = service.testMethod().execute(); - } catch (Exception e) { - assertTrue(e instanceof ServiceUnavailableException); - ServiceUnavailableException ex = (ServiceUnavailableException) e; - assertEquals(503, ex.getStatusCode()); - assertEquals(message, ex.getMessage()); - } - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/service/HeadersTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/service/HeadersTest.java deleted file mode 100644 index 8a2873bf9c1..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/service/HeadersTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - -public class HeadersTest extends WatsonServiceUnitTest { - - public class TestModel extends GenericModel { } - - public class TestService extends WatsonService { - - private static final String SERVICE_NAME = "test"; - - public TestService() { - super(SERVICE_NAME); - } - - public ServiceCall testMethod() { - RequestBuilder builder = RequestBuilder.get(HttpUrl.parse(getEndPoint() + "/v1/test")); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TestModel.class)); - } - } - - TestService service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new TestService(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - } - - /** - * Test adding a custom header to a request. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testAddHeader() throws InterruptedException { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody("{\"test_key\": \"test_value\"}")); - - String headerName = "X-Test"; - TestModel response = service.testMethod() - .addHeader(headerName, "test") - .execute(); - final RecordedRequest request = server.takeRequest(); - assertTrue(request.getHeader(headerName) != null); - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/service/IamManagerTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/service/IamManagerTest.java deleted file mode 100644 index a3990c28c7f..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/service/IamManagerTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.service.security.IamToken; -import com.ibm.watson.developer_cloud.service.security.IamTokenManager; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class IamManagerTest extends WatsonServiceUnitTest { - - private IamToken expiredTokenData; - private IamToken validTokenData; - private String url; - - private static final String ACCESS_TOKEN = "abcd-1234"; - private static final String API_KEY = "123456789"; - - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - url = getMockWebServerUrl(); - expiredTokenData = loadFixture("src/test/resources/expired_iam_token.json", IamToken.class); - validTokenData = loadFixture("src/test/resources/valid_iam_token.json", IamToken.class); - } - - /** - * Tests that if a user passes in an access token during initial IAM setup, that access token is passed back - * during later retrieval. - */ - @Test - public void getUserManagedTokenFromConstructor() { - IamOptions options = new IamOptions.Builder() - .accessToken(ACCESS_TOKEN) - .url(url) - .build(); - IamTokenManager manager = new IamTokenManager(options); - - String token = manager.getToken(); - assertEquals(ACCESS_TOKEN, token); - } - - /** - * Tests that if only an API key is stored, the user can get back a valid access token. - */ - @Test - public void getTokenFromApiKey() throws InterruptedException { - server.enqueue(jsonResponse(validTokenData)); - - IamOptions options = new IamOptions.Builder() - .apiKey(API_KEY) - .url(url) - .build(); - IamTokenManager manager = new IamTokenManager(options); - - String token = manager.getToken(); - assertEquals(validTokenData.getAccessToken(), token); - } - - /** - * Tests that if the stored access token is expired, it can be refreshed properly. - */ - @Test - public void getTokenAfterRefresh() { - server.enqueue(jsonResponse(expiredTokenData)); - - IamOptions options = new IamOptions.Builder() - .apiKey(API_KEY) - .url(url) - .build(); - IamTokenManager manager = new IamTokenManager(options); - - // setting expired token - manager.getToken(); - - // getting valid token - server.enqueue(jsonResponse(validTokenData)); - String newToken = manager.getToken(); - - assertEquals(validTokenData.getAccessToken(), newToken); - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/service/RequestBuilderTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/service/RequestBuilderTest.java deleted file mode 100644 index 4781d3a5654..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/service/RequestBuilderTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.Request; -import okhttp3.RequestBody; -import okio.Buffer; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * The Class RequestBuilderTest. - */ -public class RequestBuilderTest { - - private static final String X_TOKEN = "x-token"; - - /** The url. */ - private final String url = "http://www.example.com/"; - - /** The url with query. */ - private final String urlWithQuery = url + "?foo=bar&p2=p2"; - - /** - * Test build. - */ - @Test - public void testBuild() { - final String xToken = X_TOKEN; - final RequestBuilder builder = - RequestBuilder.post(HttpUrl.parse(urlWithQuery)) - .bodyContent("body1", HttpMediaType.TEXT_PLAIN) - .header(X_TOKEN, "token1"); - final Request request = builder.build(); - - assertEquals("POST", request.method()); - assertEquals("token1", request.header(xToken)); - assertNotNull(builder.toString()); - } - - /** - * Test request with null url. - */ - @Test(expected = IllegalArgumentException.class) - public void testUrlNull() { - RequestBuilder.get(null); - } - - /** - * Test delete. - */ - @Test - public void testDelete() { - final Request request = RequestBuilder.delete(HttpUrl.parse(urlWithQuery)).build(); - assertEquals("DELETE", request.method()); - assertEquals(urlWithQuery, request.url().toString()); - } - - /** - * Test get. - */ - @Test - public void testGet() { - final Request request = RequestBuilder.get(HttpUrl.parse(urlWithQuery)).build(); - assertEquals("GET", request.method()); - assertEquals(urlWithQuery, request.url().toString()); - } - - /** - * Test illegal argument exception. - */ - @Test(expected = IllegalArgumentException.class) - public void testIllegalArgumentException() { - RequestBuilder.delete(null); - } - - /** - * Test illegal argument exception even numbers. - */ - @Test(expected = IllegalArgumentException.class) - public void testIllegalArgumentExceptionEvenNumbers() { - RequestBuilder.put(HttpUrl.parse(url)).form("1", "2", "3").build(); - } - - - /** - * Test post. - */ - @Test - public void testPost() { - final Request request = RequestBuilder.post(HttpUrl.parse(url)).build(); - assertEquals("POST", request.method()); - assertEquals(url, request.url().toString()); - } - - /** - * Test put. - */ - @Test - public void testPut() { - final Request request = RequestBuilder.put(HttpUrl.parse(urlWithQuery)).build(); - assertEquals("PUT", request.method()); - assertEquals(urlWithQuery, request.url().toString()); - } - - /** - * Test with body. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testWithBody() throws IOException { - final File test = new File("src/test/resources/car.png"); - - final Request request = - RequestBuilder.post(HttpUrl.parse(urlWithQuery)) - .body(RequestBody.create(HttpMediaType.BINARY_FILE, test)) - .build(); - - final RequestBody requestedBody = request.body(); - - assertEquals(test.length(), requestedBody.contentLength()); - assertEquals(HttpMediaType.BINARY_FILE, requestedBody.contentType()); - } - - /** - * Test with body JSON object. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testWithBodyJsonJsonObject() throws IOException { - final JsonObject json = new JsonObject(); - json.addProperty("status", "ok"); - final Request request = RequestBuilder.post(HttpUrl.parse(urlWithQuery)).bodyJson(json).build(); - - final RequestBody requestedBody = request.body(); - final Buffer buffer = new Buffer(); - requestedBody.writeTo(buffer); - - assertEquals(json.toString(), buffer.readUtf8()); - assertEquals(HttpMediaType.JSON, requestedBody.contentType()); - } - - /** - * Test with content string. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testWithContentString() throws IOException { - final String body = "test2"; - final Request request = RequestBuilder.post(HttpUrl.parse(urlWithQuery)) - .bodyContent(body, HttpMediaType.TEXT_PLAIN).build(); - - final RequestBody requestedBody = request.body(); - final Buffer buffer = new Buffer(); - requestedBody.writeTo(buffer); - - assertEquals(body, buffer.readUtf8()); - assertEquals(HttpMediaType.TEXT, requestedBody.contentType()); - - } - - /** - * Test with form object array. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testWithFormObjectArray() throws IOException { - final String body = "foo=bar&test1=test2"; - final Request request = RequestBuilder.post(HttpUrl.parse(urlWithQuery)) - .form("foo", "bar", "test1", "test2") - .build(); - - final RequestBody requestedBody = request.body(); - - final Buffer buffer = new Buffer(); - requestedBody.writeTo(buffer); - - assertEquals(body, buffer.readUtf8()); - assertEquals(MediaType.parse(HttpMediaType.APPLICATION_FORM_URLENCODED), requestedBody.contentType()); - } - - /** - * Test with query object array. - */ - @Test - public void testWithQueryObjectArray() { - final Request request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", "bar", "p2", "p2").build(); - assertEquals(urlWithQuery, request.url().toString()); - } - - /** - * Test with nested arrays. - */ - @Test - public void testWithNestedArray() { - Request request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", new String[] { "bar", "bar2" }).build(); - assertEquals(url + "?foo=bar&foo=bar2", request.url().toString()); - - request = RequestBuilder.post(HttpUrl.parse(url)).query("foo", Arrays.asList("bar", "bar2")).build(); - assertEquals(url + "?foo=bar&foo=bar2", request.url().toString()); - } - - /** - * Test requests with special characters in the query string. - */ - @Test - public void testSpecialCharacterQuery() { - final Request request = RequestBuilder.get(HttpUrl.parse(url)).query("ä&ö", "ö=ü").build(); - assertEquals(url + "?%C3%A4%26%C3%B6=%C3%B6%3D%C3%BC", request.url().toString()); - } - - /** - * Test user agent. - */ - @Test - public void testUserAgent() { - assertNotNull(RequestUtils.getUserAgent()); - assertTrue(RequestUtils.getUserAgent().startsWith("watson-apis-java-sdk/")); - } - -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/service/ResponseTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/service/ResponseTest.java deleted file mode 100644 index b6badb082ca..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/service/ResponseTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.service; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.Response; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.http.ServiceCallbackWithDetails; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import jersey.repackaged.jsr166e.CompletableFuture; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import org.junit.Before; -import org.junit.Test; - -import java.util.concurrent.ExecutionException; - -import static org.junit.Assert.assertNotNull; - -public class ResponseTest extends WatsonServiceUnitTest { - - public class TestModel extends GenericModel { } - - public class TestService extends WatsonService { - - private static final String SERVICE_NAME = "test"; - - public TestService() { - super(SERVICE_NAME); - } - - public ServiceCall testMethod() { - RequestBuilder builder = RequestBuilder.get(HttpUrl.parse(getEndPoint() + "/v1/test")); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TestModel.class)); - } - } - - TestService service; - - /* - * (non-Javadoc) - * - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - service = new TestService(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - } - - /** - * Test that all fields are populated when calling executeWithDetails(). - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testExecuteWithDetails() throws InterruptedException { - server.enqueue(new MockResponse().setBody("{\"test_key\": \"test_value\"}")); - - Response response = service.testMethod().executeWithDetails(); - assertNotNull(response.getResult()); - assertNotNull(response.getHeaders()); - } - - /** - * Test that all fields are populated when calling enqueueWithDetails(). - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testEnqueueWithDetails() throws InterruptedException { - server.enqueue(new MockResponse().setBody("{\"test_key\": \"test_value\"}")); - - service.testMethod().enqueueWithDetails(new ServiceCallbackWithDetails() { - @Override - public void onResponse(Response response) { - assertNotNull(response.getResult()); - assertNotNull(response.getHeaders()); - } - - @Override - public void onFailure(Exception e) { } - }); - } - - /** - * Test that all fields are populated when calling rxWithDetails() using a callback. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRxWithDetailsCallback() throws InterruptedException { - server.enqueue(new MockResponse().setBody("{\"test_key\": \"test_value\"}")); - - service.testMethod().rxWithDetails().thenAccept(new CompletableFuture.Action>() { - @Override - public void accept(Response response) { - assertNotNull(response.getResult()); - assertNotNull(response.getHeaders()); - } - }); - } - - /** - * Test that all fields are populated when calling rxWithDetails() using an asynchronous callback. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRxWithDetailsAsync() throws InterruptedException { - server.enqueue(new MockResponse().setBody("{\"test_key\": \"test_value\"}")); - - service.testMethod().rxWithDetails().thenAcceptAsync(new CompletableFuture.Action>() { - @Override - public void accept(Response response) { - assertNotNull(response.getResult()); - assertNotNull(response.getHeaders()); - } - }); - } - - /** - * Test that all fields are populated when calling rxWjthDetails() synchronously. - * - * @throws InterruptedException the interrupted exception - * @throws ExecutionException the execution exception - */ - @Test - public void testRxWithDetailsSync() throws InterruptedException, ExecutionException { - server.enqueue(new MockResponse().setBody("{\"test_key\": \"test_value\"}")); - - Response response = service.testMethod().rxWithDetails().get(); - assertNotNull(response.getResult()); - assertNotNull(response.getHeaders()); - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java deleted file mode 100644 index ee1e0437a7d..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/CredentialUtilsTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.util.CredentialUtils.ServiceCredentials; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.InputStream; -import java.util.Hashtable; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * The Class CredentialUtilsTest. - */ -public class CredentialUtilsTest extends WatsonServiceTest { - - /** The Constant API_KEY_FREE. */ - private static final String API_KEY_FREE = "Basic bm90LWEtZnJlZS11c2VybmFtZTpub3QtYS1mcmVlLXBhc3N3b3Jk"; - - /** The Constant API_KEY_STANDARD. */ - private static final String API_KEY_STANDARD = "Basic bm90LWEtdXNlcm5hbWU6bm90LWEtcGFzc3dvcmQ="; - - /** The Constant SERVICE_NAME. */ - private static final String SERVICE_NAME = "personality_insights"; - - /** The Constant VCAP_SERVICES. */ - private static final String VCAP_SERVICES = "vcap_services.json"; - - private static final String NOT_A_USERNAME = "not-a-username"; - private static final String NOT_A_PASSWORD = "not-a-password"; - private static final String NOT_A_FREE_USERNAME = "not-a-free-username"; - private static final String NOT_A_FREE_PASSWORD = "not-a-free-password"; - private static final String PLAN = "standard"; - - private static final String VISUAL_RECOGNITION = "watson_vision_combined"; - - private static final String PERSONALITY_INSIGHTS_URL = "https://gateway.watsonplatform.net/personality-insights/api"; - - private static final String IAM_SERVICE_NAME = "language_translator"; - private static final String IAM_KEY_TEST_VALUE = "123456789"; - - /** - * Setup. - */ - @Before - public void setup() { - final InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(VCAP_SERVICES); - final String vcapServices = getStringFromInputStream(in); - CredentialUtils.setServices(vcapServices); - - final Hashtable env = new Hashtable<>(); - env.put("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory"); - env.put("org.osjava.sj.delimiter", "/"); - env.put("org.osjava.sj.root", "src/test/resources"); - - CredentialUtils.setContext(env); - } - - /** - * Test get api key with null or empty service. There are two instances of Personality Insights: ['free', 'standard'] - */ - @Test - public void testGetAPIKeyWithNullOrEmptyService() { - assertNull(CredentialUtils.getAPIKey(null, null)); - assertNull(CredentialUtils.getAPIKey("", "")); - - assertEquals(API_KEY_FREE, CredentialUtils.getAPIKey(SERVICE_NAME, null)); - assertEquals(API_KEY_FREE, CredentialUtils.getAPIKey(SERVICE_NAME, CredentialUtils.PLAN_FREE)); - assertEquals(API_KEY_STANDARD, CredentialUtils.getAPIKey(SERVICE_NAME, CredentialUtils.PLAN_STANDARD)); - } - - /** - * Test get api key for visual recognition. - */ - @Test - public void testGetApiKeyForVisualRecognition() { - assertNull(CredentialUtils.getAPIKey(VISUAL_RECOGNITION, NOT_A_PASSWORD)); - } - - /** - * Test get user name and password without plan. - */ - @Test - public void testGetUserNameAndPasswordWithoutPlan() { - assertNull(CredentialUtils.getUserNameAndPassword(null)); - assertNull(CredentialUtils.getUserNameAndPassword(null, null)); - - ServiceCredentials credentials = CredentialUtils.getUserNameAndPassword(SERVICE_NAME); - Assert.assertTrue(credentials != null); - assertEquals(credentials.getUsername(), NOT_A_FREE_USERNAME); - assertEquals(credentials.getPassword(), NOT_A_FREE_PASSWORD); - - credentials = CredentialUtils.getUserNameAndPassword(SERVICE_NAME, null); - assertTrue(credentials != null); - assertEquals(credentials.getUsername(), NOT_A_FREE_USERNAME); - assertEquals(credentials.getPassword(), NOT_A_FREE_PASSWORD); - } - - /** - * Test get user credentials with plan. - */ - @Test - public void testGetUserCredentialsWithPlan() { - assertNull(CredentialUtils.getUserNameAndPassword(null)); - assertNull(CredentialUtils.getUserNameAndPassword(null, null)); - - ServiceCredentials credentials = CredentialUtils.getUserNameAndPassword(SERVICE_NAME, PLAN); - assertTrue(credentials != null); - assertEquals(credentials.getUsername(), NOT_A_USERNAME); - assertEquals(credentials.getPassword(), NOT_A_PASSWORD); - } - - /** - * Test getting IAM API key from VCAP_SERVICES. - */ - @Test - public void testGetIAMKey() { - String key = CredentialUtils.getIAMKey(IAM_SERVICE_NAME); - assertEquals(IAM_KEY_TEST_VALUE, key); - } - - /** - * Test getting the API URL using JDNI. We ignore this test in Travis because - * it always fails there. - */ - @Test - @Ignore - public void testGetAPIUrlFromJDNI() { - assertEquals(CredentialUtils.getAPIUrlTest(SERVICE_NAME), PERSONALITY_INSIGHTS_URL); - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/DateDeserializerTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/DateDeserializerTest.java deleted file mode 100644 index e2cd072b784..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/DateDeserializerTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.Test; - -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Test the Date deserializer. - */ -public class DateDeserializerTest { - - /** - * Test date deserializer. - */ - @Test - public void testDeserialize() { - DateDeserializer deserializer = new DateDeserializer(); - JsonParser parser = new JsonParser(); - - - // Date with MS and 3 digit and Z - try { - String dateString = "2017-04-23T19:09:46.712Z"; - JsonElement element = parser.parse("\"" + dateString + "\""); - assertNotNull(deserializer.deserialize(element, null, null)); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // Date with MS and 3 digit TZ - try { - String dateString = "2016-06-20T04:25:16.218+000"; - JsonElement element = parser.parse("\"" + dateString + "\""); - // I have no idea what the actual value should be, so just check not null - assertNotNull(deserializer.deserialize(element, null, null)); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // Date without MS or TZ - try { - String dateString = "2016-06-20T04:25:16"; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - Date dateVal = dateFormat.parse(dateString); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // ISO 8601 date / time with MS and 'Z' TZ - try { - String dateString = "2016-06-20T04:25:16.218Z"; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX"); - Date dateVal = dateFormat.parse(dateString); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // ISO 8601 date /time with 'Z' TZ but no MS - try { - String dateString = "2015-05-28T18:01:57Z"; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - Date dateVal = dateFormat.parse(dateString); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // Date with MS but no TZ (SpeechToText) - try { - String dateString = "2016-09-30T16:51:47.558"; - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); - Date dateVal = dateFormat.parse(dateString); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // Seconds since epoch - try { - String dateString = "1478097789"; - Date dateVal = new Date(Long.parseLong(dateString) * 1000); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - - // MS since epoch - try { - String dateString = "1478097789000"; - Date dateVal = new Date(Long.parseLong(dateString)); - JsonElement element = parser.parse("\"" + dateString + "\""); - assertEquals(deserializer.deserialize(element, null, null), dateVal); - } catch (Exception ex) { - fail(ex.getMessage()); - } - } -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/GsonSingletonTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/GsonSingletonTest.java deleted file mode 100644 index 482aa793288..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/GsonSingletonTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; - -import com.google.gson.reflect.TypeToken; - -/** - * Test the {@link GsonSingleton} class used to transform from and to JSON. - */ -public class GsonSingletonTest { - - /** The list type. */ - Type listType = new TypeToken>() { }.getType(); - - /** - * Test the date serializer and deserializer. - */ - @Test - public void testDateSerializer() { - String dateAsJson = "[\"2014-06-04T15:38:07Z\"," + "\"2015-08-24T18:42:25.324Z\"," + "\"2015-08-24T18:42:25.324Z\"," - + "\"2015-08-31T00:49:27.77Z\"," + "\"2015-09-01T16:05:30.058-0400\"," + "\"2015-09-01T16:05:30.058-0400\"," - + "\"2015-09-01T16:05:30.058-0400\"," + "\"2015-09-01T16:05:30.058-0400\"," + "\"2015-10-08T17:59:39.609Z\"," - + "\"2016-03-12 20:31:58\"]"; - - List dates = GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(dateAsJson, listType); - Assert.assertNotNull(dates); - - String datesAsString = GsonSingleton.getGsonWithoutPrettyPrinting().toJson(dates); - Assert.assertNotNull(datesAsString); - - Assert.assertNotEquals(GsonSingleton.getGson().toJson(dates), - GsonSingleton.getGsonWithoutPrettyPrinting().toJson(dates)); - } - -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/RequestUtilsTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/RequestUtilsTest.java deleted file mode 100644 index a04caadc0d9..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/RequestUtilsTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; - -import com.google.common.collect.Lists; - -/** - * The Class RequestUtilsTest. - * - */ -public class RequestUtilsTest { - - /** - * Creates the map. - * - * @return the map - */ - private Map createMap() { - final Map params = new HashMap(); - params.put("A", 1); - params.put("B", 2); - params.put("C", 3); - params.put("D", 4); - return params; - } - - /** - * Test omit. - */ - @Test - public void testOmit() { - final Map params = createMap(); - - - Map omitted = RequestUtils.omit(params, "A"); - - Assert.assertTrue(omitted.keySet().containsAll(Lists.newArrayList("B", "C", "D"))); - Assert.assertTrue(omitted.values().containsAll(Lists.newArrayList(2, 3, 4))); - - omitted = RequestUtils.omit(params, "F"); - Assert.assertTrue(omitted.keySet().containsAll(Lists.newArrayList("A", "B", "C", "D"))); - Assert.assertTrue(omitted.values().containsAll(Lists.newArrayList(1, 2, 3, 4))); - } - - /** - * Test omit with nulls. - */ - @Test - public void testOmitWithNulls() { - final Map params = createMap(); - - Assert.assertArrayEquals(params.keySet().toArray(), RequestUtils.omit(params).keySet().toArray()); - Assert.assertArrayEquals(params.values().toArray(), RequestUtils.omit(params).values().toArray()); - - Assert.assertNull(RequestUtils.omit(null)); - } - - /** - * Test pick. - */ - @Test - public void testPick() { - final Map params = createMap(); - - Map picked = RequestUtils.pick(params, "A"); - Assert.assertArrayEquals(picked.keySet().toArray(), new String[] { "A" }); - Assert.assertArrayEquals(picked.values().toArray(), new Integer[] { 1 }); - - picked = RequestUtils.pick(params, "F"); - Assert.assertArrayEquals(picked.keySet().toArray(), new String[] { }); - Assert.assertArrayEquals(picked.values().toArray(), new Integer[] { }); - } - - /** - * Test pick with nulls. - */ - @Test - public void testPickWithNulls() { - final Map params = createMap(); - - Assert.assertArrayEquals(params.keySet().toArray(), RequestUtils.pick(params).keySet().toArray()); - Assert.assertArrayEquals(params.values().toArray(), RequestUtils.pick(params).values().toArray()); - - Assert.assertNull(RequestUtils.pick(null)); - } - -} diff --git a/core/src/test/java/com/ibm/watson/developer_cloud/util/ValidatorTest.java b/core/src/test/java/com/ibm/watson/developer_cloud/util/ValidatorTest.java deleted file mode 100644 index f32021de62f..00000000000 --- a/core/src/test/java/com/ibm/watson/developer_cloud/util/ValidatorTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.util; - -import java.util.ArrayList; - -import org.junit.Test; - -/** - * The Class ValidatorTest. - */ -public class ValidatorTest { - - /** The error. */ - private final String error = "error message"; - - /** - * Test is true boolean string. - */ - @Test(expected = IllegalArgumentException.class) - public void testIsTrueBooleanString() { - Validator.isTrue(false, error); - } - - /** - * Test not empty collection string. - */ - @SuppressWarnings("rawtypes") - @Test(expected = IllegalArgumentException.class) - public void testNotEmptyCollectionString() { - Validator.notEmpty(new ArrayList(), error); - } - - /** - * Test not empty object array string. - */ - @Test(expected = IllegalArgumentException.class) - public void testNotEmptyObjectArrayString() { - Validator.notEmpty(new String[] { }, error); - } - - /** - * Test not empty string string. - */ - @Test(expected = IllegalArgumentException.class) - public void testNotEmptyStringString() { - Validator.notEmpty("", error); - } - - /** - * Test not null object string. - */ - @Test(expected = IllegalArgumentException.class) - public void testNotNullObjectString() { - Validator.notNull(null, error); - } -} diff --git a/core/src/test/resources/config.properties b/core/src/test/resources/config.properties deleted file mode 100644 index 087af50848b..00000000000 --- a/core/src/test/resources/config.properties +++ /dev/null @@ -1,62 +0,0 @@ -# SERVICE CREDENTIALS - -alchemy.alchemy=API_KEY - -conversation.username=SERVICE_USERNAME -conversation.password=SERVICE_PASSWORD -conversation.url=SERVICE_URL -conversation.workspace_id=PLACEHOLDER - -dialog.dialog_id=PLACEHOLDER -dialog.password=SERVICE_PASSWORD -dialog.url=SERVICE_URL -dialog.username=SERVICE_USERNAME - -discovery.password=SERVICE_PASSWORD -discovery.url=SERVICE_URL -discovery.username=SERVICE_USERNAME - -document_conversion.password=SERVICE_PASSWORD -document_conversion.url=SERVICE_URL -document_conversion.username=SERVICE_USERNAME - -language_translator.model_id=PLACEHOLDER -language_translator.password=SERVICE_PASSWORD -language_translator.url=SERVICE_URL -language_translator.username=SERVICE_USERNAME - -natural_language_classifier.classifier_id=PLACEHOLDER -natural_language_classifier.password=SERVICE_PASSWORD -natural_language_classifier.url=SERVICE_URL -natural_language_classifier.username=SERVICE_USERNAME - -personality_insights.password=SERVICE_PASSWORD -personality_insights.url=SERVICE_URL -personality_insights.username=SERVICE_USERNAME - -retrieve_and_rank.cluster_id=PLACEHOLDER -retrieve_and_rank.config_name=PLACEHOLDER -retrieve_and_rank.password=SERVICE_PASSWORD -retrieve_and_rank.ranker_id=PLACEHOLDER -retrieve_and_rank.url=SERVICE_URL -retrieve_and_rank.username=SERVICE_USERNAME - -speech_to_text.password=SERVICE_PASSWORD -speech_to_text.url=SERVICE_URL -speech_to_text.username=SERVICE_USERNAME - -text_to_speech.voice_name=PLACEHOLDER -text_to_speech.password=SERVICE_PASSWORD -text_to_speech.url=SERVICE_URL -text_to_speech.username=SERVICE_USERNAME - -tone_analyzer.v3.password=SERVICE_PASSWORD -tone_analyzer.v3.url=SERVICE_URL -tone_analyzer.v3.username=SERVICE_USERNAME - -tradeoff_analytics.password=SERVICE_PASSWORD -tradeoff_analytics.url=SERVICE_URL -tradeoff_analytics.username=SERVICE_USERNAME - -visual_recognition.v3.api_key=API_KEY -visual_recognition.v3.url=SERVICE_URL \ No newline at end of file diff --git a/core/src/test/resources/expired_iam_token.json b/core/src/test/resources/expired_iam_token.json deleted file mode 100644 index bce563ba19c..00000000000 --- a/core/src/test/resources/expired_iam_token.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "access_token": "wxyz-9876", - "refresh_token": "00000000", - "token_type": "Bearer", - "expires_in": 3600, - "expiration": 1522788645 -} \ No newline at end of file diff --git a/core/src/test/resources/jdni.properties b/core/src/test/resources/jdni.properties deleted file mode 100644 index 57b271affb7..00000000000 --- a/core/src/test/resources/jdni.properties +++ /dev/null @@ -1 +0,0 @@ -watson-developer-cloud/personality_insights/url=https://gateway.watsonplatform.net/personality-insights/api \ No newline at end of file diff --git a/core/src/test/resources/valid_iam_token.json b/core/src/test/resources/valid_iam_token.json deleted file mode 100644 index 7fed350545c..00000000000 --- a/core/src/test/resources/valid_iam_token.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "access_token": "aaaa-1111", - "refresh_token": "99999999", - "token_type": "Bearer", - "expires_in": 3600, - "expiration": 999999999999999999 -} \ No newline at end of file diff --git a/core/src/test/resources/vcap_services.json b/core/src/test/resources/vcap_services.json deleted file mode 100644 index b9e636b10a8..00000000000 --- a/core/src/test/resources/vcap_services.json +++ /dev/null @@ -1,217 +0,0 @@ -{ - "concept_insights": [ - { - "name": "concept_insights_docs", - "label": "concept_insights", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/concept-insights/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "conversation": [ - { - "name": "conversation", - "label": "conversation", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/conversation/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "dialog": [ - { - "name": "dialog_docs", - "label": "dialog", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/dialog/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "discovery": [ - { - "name": "discovery", - "label": "discovery", - "plan": "experimental", - "credentials": { - "url": "https://gateway.watsonplatform.net/discovery-experimental/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "document_conversion": [ - { - "name": "document_conversion_experimental_docs", - "label": "document_conversion", - "plan": "experimental", - "credentials": { - "url": "https://gateway.watsonplatform.net/document-conversion-experimental/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "language_translator": [ - { - "name": "language_translator_docs", - "label": "language_translator", - "plan": "standard", - "credentials": { - "apikey": "123456789", - "iam_apikey_description": "Auto generated apikey...", - "iam_apikey_name": "auto-generated-apikey-111-222-333", - "iam_role_crn": "crn:v1:bluemix:public:iam::::serviceRole:Manager", - "iam_serviceid_crn": "crn:v1:staging:public:iam-identity::a/::serviceid:ServiceID-1234", - "url": "https://gateway.watsonplatform.net/language-translator/api", - "iam_url": "https://iam.ng.bluemix.net/identity/token" - } - } - ], - "natural_language_classifier": [ - { - "name": "natural_language_classifier_docs", - "label": "natural_language_classifier", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/natural-language-classifier/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "personality_insights": [ - { - "name": "personality_insights_docs", - "label": "personality_insights", - "plan": "free", - "credentials": { - "url": "https://gateway.watsonplatform.net/personality-insights/api", - "username": "not-a-free-username", - "password": "not-a-free-password" - } - }, { - "name": "personality_insights_docs", - "label": "personality_insights", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/personality-insights/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "speech_to_text": [ - { - "name": "speech_to_text_docs", - "label": "speech_to_text", - "plan": "standard", - "credentials": { - "url": "https://stream.watsonplatform.net/speech-to-text/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "text_to_speech": [ - { - "name": "text_to_speech_docs", - "label": "text_to_speech", - "plan": "standard", - "credentials": { - "url": "https://stream.watsonplatform.net/text-to-speech/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "tone_analyzer": [ - { - "name": "tone_analyzer_experimental_docs", - "label": "tone_analyzer", - "plan": "experimental", - "credentials": { - "url": "https://gateway.watsonplatform.net/tone-analyzer-experimental/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "tradeoff_analytics": [ - { - "name": "tradeoff_analytics_docs", - "label": "tradeoff_analytics", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/tradeoff-analytics/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "alchemy_api": [ - { - "name": "alchemy_api_free_docs", - "label": "alchemy_api", - "plan": "Free", - "credentials": { - "url": "https://gateway-a.watsonplatform.net/calls", - "apikey": "not-a-apikey" - } - } - ], - "retrieve_and_rank": [ - { - "name": "retrieve_and_rank_docs", - "label": "retrieve_and_rank", - "plan": "standard", - "credentials": { - "url": "https://gateway.watsonplatform.net/retrieve-and-rank/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "watson_vision_combined": [ - { - "name": "visual_recognition_docs", - "label": "watson_vision_combined", - "plan": "free", - "credentials": { - "url": "https://gateway.watsonplatform.net/visual-recognition/api", - "api_key": "not-a-password" - } - } - ], - "relationship_extraction": [ - { - "name": "relationship-extraction-service", - "label": "relationship_extraction", - "plan": "relationship_extraction_free_plan", - "credentials": { - "url": "https://gateway.watsonplatform.net/relationship-extraction-beta/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ], - "question_and_answer": [ - { - "name": "question_and_answer_docs", - "label": "question_and_answer", - "plan": "question_and_answer_free_plan", - "credentials": { - "url": "https://gateway.watsonplatform.net/question-and-answer-beta/api", - "username": "not-a-username", - "password": "not-a-password" - } - } - ] -} diff --git a/discovery/README.md b/discovery/README.md index 15f317e15a3..2a27ed3605b 100644 --- a/discovery/README.md +++ b/discovery/README.md @@ -3,32 +3,38 @@ ## Installation ##### Maven + ```xml - com.ibm.watson.developer_cloud + com.ibm.watson discovery - 6.1.0 + 16.1.0 ``` ##### Gradle + ```gradle -'com.ibm.watson.developer_cloud:discovery:6.1.0' +'com.ibm.watson:discovery:16.1.0' ``` ## Usage -The [Discovery][discovery] wraps the environment, collection, configuration, document, and query operations of the Discovery service. + +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/apidocs/discovery-data). + +### Using Discovery v2 ```java -Discovery discovery = new Discovery("2017-11-07"); -discovery.setEndPoint("https://gateway.watsonplatform.net/discovery/api/"); -discovery.setUsernameAndPassword("", ""); - -//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(); -``` +// Make sure to use the Discovery v2 import! +Authenticator authenticator = new BearerTokenAuthenticator(""); +Discovery discovery = new Discovery("2019-11-22", authenticator); -[discovery]: https://console.bluemix.net/docs/services/discovery/getting-started.html +// Build an empty query on an existing project. +String projectId = ""; +QueryOptions queryOptions = new QueryOptions.Builder() + .projectId(projectId) + .build(); +QueryResponse queryResponse = discovery.query(queryOptions).execute().getResult(); +``` diff --git a/discovery/build.gradle b/discovery/build.gradle deleted file mode 100644 index 2e2f393edca..00000000000 --- a/discovery/build.gradle +++ /dev/null @@ -1,116 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'discovery' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Discovery Service' - url 'https://console.bluemix.net/docs/services/discovery/index.html' - - 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' - } - - 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' - } - } - } - } - } -} \ No newline at end of file diff --git a/discovery/ibm-credentials.env b/discovery/ibm-credentials.env new file mode 100644 index 00000000000..f7dfc54bc88 --- /dev/null +++ b/discovery/ibm-credentials.env @@ -0,0 +1,3 @@ +DISCOVERY_USERNAME=username +DISCOVERY_PASSWORD=password +DISCOVERY_AUTH_TYPE=basic \ 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/developer_cloud/discovery/v1/Discovery.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java deleted file mode 100644 index b12c18587c3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/Discovery.java +++ /dev/null @@ -1,1377 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Collection; -import com.ibm.watson.developer_cloud.discovery.v1.model.Configuration; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentStatus; -import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; -import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; -import com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingExamplesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryEntitiesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryEntitiesResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryRelationsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryRelationsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.TestConfigurationInEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.TestDocument; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExample; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExampleList; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingQuery; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -/** - * The IBM Watson™ Discovery Service 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 WatsonService { - - private static final String SERVICE_NAME = "discovery"; - private static final String URL = "https://gateway.watsonplatform.net/discovery/api"; - - private String versionDate; - - /** - * Instantiates a new `Discovery`. - * - * @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) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `Discovery` with username and password. - * - * @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 username the username - * @param password the password - */ - public Discovery(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `Discovery` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public Discovery(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * 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) { - Validator.notNull(createEnvironmentOptions, "createEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class)); - } - - /** - * Delete environment. - * - * @param deleteEnvironmentOptions the {@link DeleteEnvironmentOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteEnvironment(DeleteEnvironmentOptions deleteEnvironmentOptions) { - Validator.notNull(deleteEnvironmentOptions, "deleteEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { deleteEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getEnvironmentOptions, "getEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { getEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class)); - } - - /** - * 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(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listEnvironmentsOptions != null) { - if (listEnvironmentsOptions.name() != null) { - builder.query("name", listEnvironmentsOptions.name()); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListEnvironmentsResponse.class)); - } - - /** - * 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); - } - - /** - * 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) { - Validator.notNull(listFieldsOptions, "listFieldsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "fields" }; - String[] pathParameters = { listFieldsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class)); - } - - /** - * 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) { - Validator.notNull(updateEnvironmentOptions, "updateEnvironmentOptions cannot be null"); - String[] pathSegments = { "v1/environments" }; - String[] pathParameters = { updateEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateEnvironmentOptions.name() != null) { - contentJson.addProperty("name", updateEnvironmentOptions.name()); - } - if (updateEnvironmentOptions.description() != null) { - contentJson.addProperty("description", updateEnvironmentOptions.description()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Environment.class)); - } - - /** - * 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) { - Validator.notNull(createConfigurationOptions, "createConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { createConfigurationOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (createConfigurationOptions.name() != null) { - contentJson.addProperty("name", createConfigurationOptions.name()); - } - if (createConfigurationOptions.description() != null) { - contentJson.addProperty("description", createConfigurationOptions.description()); - } - if (createConfigurationOptions.conversions() != null) { - contentJson.add("conversions", GsonSingleton.getGson().toJsonTree(createConfigurationOptions.conversions())); - } - if (createConfigurationOptions.enrichments() != null) { - contentJson.add("enrichments", GsonSingleton.getGson().toJsonTree(createConfigurationOptions.enrichments())); - } - if (createConfigurationOptions.normalizations() != null) { - contentJson.add("normalizations", GsonSingleton.getGson().toJsonTree(createConfigurationOptions - .normalizations())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class)); - } - - /** - * 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 Void - */ - public ServiceCall deleteConfiguration(DeleteConfigurationOptions deleteConfigurationOptions) { - Validator.notNull(deleteConfigurationOptions, "deleteConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { deleteConfigurationOptions.environmentId(), deleteConfigurationOptions - .configurationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getConfigurationOptions, "getConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { getConfigurationOptions.environmentId(), getConfigurationOptions.configurationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class)); - } - - /** - * 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) { - Validator.notNull(listConfigurationsOptions, "listConfigurationsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { listConfigurationsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (listConfigurationsOptions.name() != null) { - builder.query("name", listConfigurationsOptions.name()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListConfigurationsResponse.class)); - } - - /** - * 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) { - Validator.notNull(updateConfigurationOptions, "updateConfigurationOptions cannot be null"); - String[] pathSegments = { "v1/environments", "configurations" }; - String[] pathParameters = { updateConfigurationOptions.environmentId(), updateConfigurationOptions - .configurationId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateConfigurationOptions.name() != null) { - contentJson.addProperty("name", updateConfigurationOptions.name()); - } - if (updateConfigurationOptions.description() != null) { - contentJson.addProperty("description", updateConfigurationOptions.description()); - } - if (updateConfigurationOptions.conversions() != null) { - contentJson.add("conversions", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.conversions())); - } - if (updateConfigurationOptions.enrichments() != null) { - contentJson.add("enrichments", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions.enrichments())); - } - if (updateConfigurationOptions.normalizations() != null) { - contentJson.add("normalizations", GsonSingleton.getGson().toJsonTree(updateConfigurationOptions - .normalizations())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Configuration.class)); - } - - /** - * Test configuration. - * - * Runs a sample document through the default or your configuration and returns diagnostic information designed to - * help you understand how the document was processed. The document is not added to the index. - * - * @param testConfigurationInEnvironmentOptions the {@link TestConfigurationInEnvironmentOptions} containing the - * options for the call - * @return a {@link ServiceCall} with a response type of {@link TestDocument} - */ - public ServiceCall testConfigurationInEnvironment( - TestConfigurationInEnvironmentOptions testConfigurationInEnvironmentOptions) { - Validator.notNull(testConfigurationInEnvironmentOptions, "testConfigurationInEnvironmentOptions cannot be null"); - Validator.isTrue((testConfigurationInEnvironmentOptions.configuration() != null) - || (testConfigurationInEnvironmentOptions.file() != null) || (testConfigurationInEnvironmentOptions - .metadata() != null), "At least one of configuration, file, or metadata must be supplied."); - String[] pathSegments = { "v1/environments", "preview" }; - String[] pathParameters = { testConfigurationInEnvironmentOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (testConfigurationInEnvironmentOptions.step() != null) { - builder.query("step", testConfigurationInEnvironmentOptions.step()); - } - if (testConfigurationInEnvironmentOptions.configurationId() != null) { - builder.query("configuration_id", testConfigurationInEnvironmentOptions.configurationId()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (testConfigurationInEnvironmentOptions.configuration() != null) { - multipartBuilder.addFormDataPart("configuration", testConfigurationInEnvironmentOptions.configuration()); - } - if (testConfigurationInEnvironmentOptions.file() != null) { - RequestBody fileBody = RequestUtils.inputStreamBody(testConfigurationInEnvironmentOptions.file(), - testConfigurationInEnvironmentOptions.fileContentType()); - multipartBuilder.addFormDataPart("file", testConfigurationInEnvironmentOptions.filename(), fileBody); - } - if (testConfigurationInEnvironmentOptions.metadata() != null) { - multipartBuilder.addFormDataPart("metadata", testConfigurationInEnvironmentOptions.metadata()); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TestDocument.class)); - } - - /** - * 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) { - Validator.notNull(createCollectionOptions, "createCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { createCollectionOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class)); - } - - /** - * Delete a collection. - * - * @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) { - Validator.notNull(deleteCollectionOptions, "deleteCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { deleteCollectionOptions.environmentId(), deleteCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getCollectionOptions, "getCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { getCollectionOptions.environmentId(), getCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionFieldsResponse.class)); - } - - /** - * 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) { - Validator.notNull(listCollectionsOptions, "listCollectionsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { listCollectionsOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (listCollectionsOptions.name() != null) { - builder.query("name", listCollectionsOptions.name()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListCollectionsResponse.class)); - } - - /** - * 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) { - Validator.notNull(updateCollectionOptions, "updateCollectionOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections" }; - String[] pathParameters = { updateCollectionOptions.environmentId(), updateCollectionOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (updateCollectionOptions.name() != null) { - 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Collection.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (createExpansionsOptions.expansions() != null) { - contentJson.add("expansions", GsonSingleton.getGson().toJsonTree(createExpansionsOptions.expansions())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Expansions.class)); - } - - /** - * 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 `,`. - * - * @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) { - Validator.notNull(addDocumentOptions, "addDocumentOptions cannot be null"); - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (addDocumentOptions.file() != null) { - 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()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentAccepted.class)); - } - - /** - * 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 Void - */ - public ServiceCall deleteDocument(DeleteDocumentOptions deleteDocumentOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentStatus.class)); - } - - /** - * Update a document. - * - * Replace an existing document. Starts ingesting a document with optional metadata. - * - * @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) { - Validator.notNull(updateDocumentOptions, "updateDocumentOptions cannot be null"); - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (updateDocumentOptions.file() != null) { - 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()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DocumentAccepted.class)); - } - - /** - * Query documents in multiple collections. - * - * See the [Discovery service documentation](https://console.bluemix.net/docs/services/discovery/using.html) for more - * details. - * - * @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) { - Validator.notNull(federatedQueryOptions, "federatedQueryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "query" }; - String[] pathParameters = { federatedQueryOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - builder.query("collection_ids", RequestUtils.join(federatedQueryOptions.collectionIds(), ",")); - if (federatedQueryOptions.filter() != null) { - builder.query("filter", federatedQueryOptions.filter()); - } - if (federatedQueryOptions.query() != null) { - builder.query("query", federatedQueryOptions.query()); - } - if (federatedQueryOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", federatedQueryOptions.naturalLanguageQuery()); - } - if (federatedQueryOptions.aggregation() != null) { - builder.query("aggregation", federatedQueryOptions.aggregation()); - } - if (federatedQueryOptions.count() != null) { - builder.query("count", String.valueOf(federatedQueryOptions.count())); - } - if (federatedQueryOptions.returnFields() != null) { - builder.query("return_fields", RequestUtils.join(federatedQueryOptions.returnFields(), ",")); - } - if (federatedQueryOptions.offset() != null) { - builder.query("offset", String.valueOf(federatedQueryOptions.offset())); - } - if (federatedQueryOptions.sort() != null) { - builder.query("sort", RequestUtils.join(federatedQueryOptions.sort(), ",")); - } - if (federatedQueryOptions.highlight() != null) { - builder.query("highlight", String.valueOf(federatedQueryOptions.highlight())); - } - if (federatedQueryOptions.deduplicate() != null) { - builder.query("deduplicate", String.valueOf(federatedQueryOptions.deduplicate())); - } - if (federatedQueryOptions.deduplicateField() != null) { - builder.query("deduplicate.field", federatedQueryOptions.deduplicateField()); - } - if (federatedQueryOptions.similar() != null) { - builder.query("similar", String.valueOf(federatedQueryOptions.similar())); - } - if (federatedQueryOptions.similarDocumentIds() != null) { - builder.query("similar.document_ids", RequestUtils.join(federatedQueryOptions.similarDocumentIds(), ",")); - } - if (federatedQueryOptions.similarFields() != null) { - builder.query("similar.fields", RequestUtils.join(federatedQueryOptions.similarFields(), ",")); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryResponse.class)); - } - - /** - * 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 service - * documentation](https://console.bluemix.net/docs/services/discovery/using.html) 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) { - Validator.notNull(federatedQueryNoticesOptions, "federatedQueryNoticesOptions cannot be null"); - String[] pathSegments = { "v1/environments", "notices" }; - String[] pathParameters = { federatedQueryNoticesOptions.environmentId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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.returnFields() != null) { - builder.query("return_fields", RequestUtils.join(federatedQueryNoticesOptions.returnFields(), ",")); - } - 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(), ",")); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryNoticesResponse.class)); - } - - /** - * Query your collection. - * - * After your content is uploaded and enriched by the Discovery service, you can build queries to search your content. - * For details, see the [Discovery service - * documentation](https://console.bluemix.net/docs/services/discovery/using.html). - * - * @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) { - Validator.notNull(queryOptions, "queryOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "query" }; - String[] pathParameters = { queryOptions.environmentId(), queryOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - if (queryOptions.filter() != null) { - builder.query("filter", queryOptions.filter()); - } - if (queryOptions.query() != null) { - builder.query("query", queryOptions.query()); - } - if (queryOptions.naturalLanguageQuery() != null) { - builder.query("natural_language_query", queryOptions.naturalLanguageQuery()); - } - if (queryOptions.passages() != null) { - builder.query("passages", String.valueOf(queryOptions.passages())); - } - if (queryOptions.aggregation() != null) { - builder.query("aggregation", queryOptions.aggregation()); - } - if (queryOptions.count() != null) { - builder.query("count", String.valueOf(queryOptions.count())); - } - if (queryOptions.returnFields() != null) { - builder.query("return", RequestUtils.join(queryOptions.returnFields(), ",")); - } - if (queryOptions.offset() != null) { - builder.query("offset", String.valueOf(queryOptions.offset())); - } - if (queryOptions.sort() != null) { - builder.query("sort", RequestUtils.join(queryOptions.sort(), ",")); - } - if (queryOptions.highlight() != null) { - builder.query("highlight", String.valueOf(queryOptions.highlight())); - } - if (queryOptions.passagesFields() != null) { - builder.query("passages.fields", RequestUtils.join(queryOptions.passagesFields(), ",")); - } - if (queryOptions.passagesCount() != null) { - builder.query("passages.count", String.valueOf(queryOptions.passagesCount())); - } - if (queryOptions.passagesCharacters() != null) { - builder.query("passages.characters", String.valueOf(queryOptions.passagesCharacters())); - } - if (queryOptions.deduplicate() != null) { - builder.query("deduplicate", String.valueOf(queryOptions.deduplicate())); - } - if (queryOptions.deduplicateField() != null) { - builder.query("deduplicate.field", queryOptions.deduplicateField()); - } - if (queryOptions.similar() != null) { - builder.query("similar", String.valueOf(queryOptions.similar())); - } - if (queryOptions.similarDocumentIds() != null) { - builder.query("similar.document_ids", RequestUtils.join(queryOptions.similarDocumentIds(), ",")); - } - if (queryOptions.similarFields() != null) { - builder.query("similar.fields", RequestUtils.join(queryOptions.similarFields(), ",")); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryResponse.class)); - } - - /** - * Knowledge Graph entity query. - * - * See the [Knowledge Graph documentation](https://console.bluemix.net/docs/services/discovery/building-kg.html) for - * more details. - * - * @param queryEntitiesOptions the {@link QueryEntitiesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryEntitiesResponse} - */ - public ServiceCall queryEntities(QueryEntitiesOptions queryEntitiesOptions) { - Validator.notNull(queryEntitiesOptions, "queryEntitiesOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "query_entities" }; - String[] pathParameters = { queryEntitiesOptions.environmentId(), queryEntitiesOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (queryEntitiesOptions.feature() != null) { - contentJson.addProperty("feature", queryEntitiesOptions.feature()); - } - if (queryEntitiesOptions.entity() != null) { - contentJson.add("entity", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.entity())); - } - if (queryEntitiesOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryEntitiesOptions.context())); - } - if (queryEntitiesOptions.count() != null) { - contentJson.addProperty("count", queryEntitiesOptions.count()); - } - if (queryEntitiesOptions.evidenceCount() != null) { - contentJson.addProperty("evidence_count", queryEntitiesOptions.evidenceCount()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryEntitiesResponse.class)); - } - - /** - * 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 service - * documentation](https://console.bluemix.net/docs/services/discovery/using.html) 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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.returnFields() != null) { - builder.query("return_fields", RequestUtils.join(queryNoticesOptions.returnFields(), ",")); - } - 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(), ",")); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryNoticesResponse.class)); - } - - /** - * Knowledge Graph relationship query. - * - * See the [Knowledge Graph documentation](https://console.bluemix.net/docs/services/discovery/building-kg.html) for - * more details. - * - * @param queryRelationsOptions the {@link QueryRelationsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link QueryRelationsResponse} - */ - public ServiceCall queryRelations(QueryRelationsOptions queryRelationsOptions) { - Validator.notNull(queryRelationsOptions, "queryRelationsOptions cannot be null"); - String[] pathSegments = { "v1/environments", "collections", "query_relations" }; - String[] pathParameters = { queryRelationsOptions.environmentId(), queryRelationsOptions.collectionId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (queryRelationsOptions.entities() != null) { - contentJson.add("entities", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.entities())); - } - if (queryRelationsOptions.context() != null) { - contentJson.add("context", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.context())); - } - if (queryRelationsOptions.sort() != null) { - contentJson.addProperty("sort", queryRelationsOptions.sort()); - } - if (queryRelationsOptions.filter() != null) { - contentJson.add("filter", GsonSingleton.getGson().toJsonTree(queryRelationsOptions.filter())); - } - if (queryRelationsOptions.count() != null) { - contentJson.addProperty("count", queryRelationsOptions.count()); - } - if (queryRelationsOptions.evidenceCount() != null) { - contentJson.addProperty("evidence_count", queryRelationsOptions.evidenceCount()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(QueryRelationsResponse.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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", GsonSingleton.getGson().toJsonTree(addTrainingDataOptions.examples())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingQuery.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingDataSet.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExampleList.class)); - } - - /** - * 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) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TrainingExample.class)); - } - - /** - * 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://console.bluemix.net/docs/services/discovery/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddDocumentOptions.java deleted file mode 100644 index 7ff54a34c6b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddDocumentOptions.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addDocument options. - */ -public class AddDocumentOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - private Builder(AddDocumentOptions addDocumentOptions) { - environmentId = addDocumentOptions.environmentId; - collectionId = addDocumentOptions.collectionId; - file = addDocumentOptions.file; - filename = addDocumentOptions.filename; - metadata = addDocumentOptions.metadata; - fileContentType = addDocumentOptions.fileContentType; - } - - /** - * 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 metadata. - * - * @param metadata the metadata - * @return the AddDocumentOptions builder - */ - public Builder metadata(String metadata) { - this.metadata = metadata; - 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 file. - * - * @param file the file - * @return the AddDocumentOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file(File file) throws FileNotFoundException { - this.file = new FileInputStream(file); - this.filename = file.getName(); - return this; - } - } - - private AddDocumentOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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; - metadata = builder.metadata; - fileContentType = builder.fileContentType; - } - - /** - * 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 is 50 megabytes. Files larger than 50 - * megabytes is 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 metadata. - * - * If you're using the Data Crawler to upload your documents, you can test a document against the type of metadata - * that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB - * are rejected. - * Example: ``` { - * "Creator": "Johnny Appleseed", - * "Subject": "Apples" - * } ```. - * - * @return the metadata - */ - public String metadata() { - return metadata; - } - - /** - * Gets the 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddTrainingDataOptions.java deleted file mode 100644 index faa3496c216..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AddTrainingDataOptions.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addTrainingData options. - */ -public class AddTrainingDataOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String naturalLanguageQuery; - private String filter; - private 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) { - environmentId = addTrainingDataOptions.environmentId; - collectionId = addTrainingDataOptions.collectionId; - naturalLanguageQuery = addTrainingDataOptions.naturalLanguageQuery; - filter = addTrainingDataOptions.filter; - 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) { - 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; - } - } - - private AddTrainingDataOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the filter. - * - * @return the filter - */ - public String filter() { - return filter; - } - - /** - * Gets the examples. - * - * @return the examples - */ - public List examples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AggregationResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AggregationResult.java deleted file mode 100644 index cc836beefff..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/AggregationResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AggregationResult. - */ -public class AggregationResult extends GenericModel { - - private String key; - @SerializedName("matching_results") - private Long matchingResults; - private 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/developer_cloud/discovery/v1/model/Calculation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Calculation.java deleted file mode 100644 index 39b4d4e4ef4..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Calculation.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Calculation. - */ -public class Calculation extends QueryAggregation { - - private String field; - private 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/developer_cloud/discovery/v1/model/Collection.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Collection.java deleted file mode 100644 index 3d0acc75330..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Collection.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private String collectionId; - private String name; - private String description; - private Date created; - private Date updated; - private String status; - @SerializedName("configuration_id") - private String configurationId; - private String language; - @SerializedName("document_counts") - private DocumentCounts documentCounts; - @SerializedName("disk_usage") - private CollectionDiskUsage diskUsage; - @SerializedName("training_status") - private TrainingStatus trainingStatus; - - /** - * 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. - * - * The object providing information about the documents in the collection. Present only when retrieving details of a - * collection. - * - * @return the documentCounts - */ - public DocumentCounts getDocumentCounts() { - return documentCounts; - } - - /** - * Gets the diskUsage. - * - * The object providing information about the disk usage of the collection. Present only when retrieving details of a - * collection. - * - * @return the diskUsage - */ - public CollectionDiskUsage getDiskUsage() { - return diskUsage; - } - - /** - * Gets the trainingStatus. - * - * Provides information about the status of relevance training for collection. - * - * @return the trainingStatus - */ - public TrainingStatus getTrainingStatus() { - return trainingStatus; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CollectionDiskUsage.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CollectionDiskUsage.java deleted file mode 100644 index 6af43280cb6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CollectionDiskUsage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Summary of the disk usage statistics for this collection. - */ -public class CollectionDiskUsage extends GenericModel { - - @SerializedName("used_bytes") - private 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/developer_cloud/discovery/v1/model/CollectionUsage.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CollectionUsage.java deleted file mode 100644 index 055cb77aaf6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CollectionUsage.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Summary of the collection usage in the environment. - */ -public class CollectionUsage extends GenericModel { - - private Long available; - @SerializedName("maximum_allowed") - private 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/developer_cloud/discovery/v1/model/Configuration.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Configuration.java deleted file mode 100644 index 2f8a69ffef1..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Configuration.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A custom configuration for the environment. - */ -public class Configuration extends GenericModel { - - @SerializedName("configuration_id") - private String configurationId; - private String name; - private Date created; - private Date updated; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - - /** - * Gets the configurationId. - * - * The unique identifier of the configuration. - * - * @return the configurationId - */ - public String getConfigurationId() { - return configurationId; - } - - /** - * Gets the name. - * - * The name of the configuration. - * - * @return the name - */ - public String getName() { - 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 getCreated() { - 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 getUpdated() { - return updated; - } - - /** - * Gets the description. - * - * The description of the configuration, if available. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the conversions. - * - * The document conversion settings for the configuration. - * - * @return the conversions - */ - public Conversions getConversions() { - return conversions; - } - - /** - * Gets the enrichments. - * - * An array of document enrichment settings for the configuration. - * - * @return the enrichments - */ - public List getEnrichments() { - 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 getNormalizations() { - return normalizations; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(final String name) { - this.name = name; - } - - /** - * Sets the description. - * - * @param description the new description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * Sets the conversions. - * - * @param conversions the new conversions - */ - public void setConversions(final Conversions conversions) { - this.conversions = conversions; - } - - /** - * Sets the enrichments. - * - * @param enrichments the new enrichments - */ - public void setEnrichments(final List enrichments) { - this.enrichments = enrichments; - } - - /** - * Sets the normalizations. - * - * @param normalizations the new normalizations - */ - public void setNormalizations(final List normalizations) { - this.normalizations = normalizations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Conversions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Conversions.java deleted file mode 100644 index e5fac92c8b2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Conversions.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Document conversion settings. - */ -public class Conversions extends GenericModel { - - private PdfSettings pdf; - private WordSettings word; - private HtmlSettings html; - private SegmentSettings segment; - @SerializedName("json_normalizations") - private List jsonNormalizations; - - /** - * Gets the pdf. - * - * A list of PDF conversion settings. - * - * @return the pdf - */ - public PdfSettings getPdf() { - return pdf; - } - - /** - * Gets the word. - * - * A list of Word conversion settings. - * - * @return the word - */ - public WordSettings getWord() { - return word; - } - - /** - * Gets the html. - * - * A list of HTML conversion settings. - * - * @return the html - */ - public HtmlSettings getHtml() { - return html; - } - - /** - * Gets the segment. - * - * A list of Document Segmentation settings. - * - * @return the segment - */ - public SegmentSettings getSegment() { - 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 getJsonNormalizations() { - return jsonNormalizations; - } - - /** - * Sets the pdf. - * - * @param pdf the new pdf - */ - public void setPdf(final PdfSettings pdf) { - this.pdf = pdf; - } - - /** - * Sets the word. - * - * @param word the new word - */ - public void setWord(final WordSettings word) { - this.word = word; - } - - /** - * Sets the html. - * - * @param html the new html - */ - public void setHtml(final HtmlSettings html) { - this.html = html; - } - - /** - * Sets the segment. - * - * @param segment the new segment - */ - public void setSegment(final SegmentSettings segment) { - this.segment = segment; - } - - /** - * Sets the jsonNormalizations. - * - * @param jsonNormalizations the new jsonNormalizations - */ - public void setJsonNormalizations(final List jsonNormalizations) { - this.jsonNormalizations = jsonNormalizations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateCollectionOptions.java deleted file mode 100644 index 75647f1e128..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateCollectionOptions.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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"; - } - - private String environmentId; - private String name; - private String description; - private String configurationId; - private 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) { - environmentId = createCollectionOptions.environmentId; - name = createCollectionOptions.name; - description = createCollectionOptions.description; - configurationId = createCollectionOptions.configurationId; - 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; - } - } - - private CreateCollectionOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/CreateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateConfigurationOptions.java deleted file mode 100644 index c3611cc1a44..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateConfigurationOptions.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createConfiguration options. - */ -public class CreateConfigurationOptions extends GenericModel { - - private String environmentId; - private String name; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - - private Builder(CreateConfigurationOptions createConfigurationOptions) { - environmentId = createConfigurationOptions.environmentId; - name = createConfigurationOptions.name; - description = createConfigurationOptions.description; - conversions = createConfigurationOptions.conversions; - enrichments = createConfigurationOptions.enrichments; - normalizations = createConfigurationOptions.normalizations; - } - - /** - * 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 CreateConfigurationOptions. - * - * @return the createConfigurationOptions - */ - public CreateConfigurationOptions build() { - return new CreateConfigurationOptions(this); - } - - /** - * Adds an enrichments to enrichments. - * - * @param enrichments the new enrichments - * @return the CreateConfigurationOptions builder - */ - public Builder addEnrichments(Enrichment enrichments) { - Validator.notNull(enrichments, "enrichments cannot be null"); - if (this.enrichments == null) { - this.enrichments = new ArrayList(); - } - this.enrichments.add(enrichments); - return this; - } - - /** - * Adds an normalizations to normalizations. - * - * @param normalizations the new normalizations - * @return the CreateConfigurationOptions builder - */ - public Builder addNormalizations(NormalizationOperation normalizations) { - Validator.notNull(normalizations, "normalizations cannot be null"); - if (this.normalizations == null) { - this.normalizations = new ArrayList(); - } - this.normalizations.add(normalizations); - 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 configuration. - * - * @param configuration the configuration - * @return the CreateConfigurationOptions builder - */ - public Builder configuration(Configuration configuration) { - this.name = configuration.getName(); - this.description = configuration.getDescription(); - this.conversions = configuration.getConversions(); - this.enrichments = configuration.getEnrichments(); - this.normalizations = configuration.getNormalizations(); - return this; - } - } - - private CreateConfigurationOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - description = builder.description; - conversions = builder.conversions; - enrichments = builder.enrichments; - normalizations = builder.normalizations; - } - - /** - * 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. - * - * The document conversion settings for the configuration. - * - * @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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java deleted file mode 100644 index 451699dee03..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateEnvironmentOptions.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createEnvironment options. - */ -public class CreateEnvironmentOptions extends GenericModel { - - private String name; - private String description; - private Long size; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String description; - private Long size; - - private Builder(CreateEnvironmentOptions createEnvironmentOptions) { - name = createEnvironmentOptions.name; - description = createEnvironmentOptions.description; - 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(long size) { - this.size = size; - return this; - } - } - - private CreateEnvironmentOptions(Builder builder) { - 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. - * - * **Deprecated**: Size of the environment. - * - * @return the size - */ - public Long size() { - return size; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateExpansionsOptions.java deleted file mode 100644 index 1b262859fde..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateExpansionsOptions.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createExpansions options. - */ -public class CreateExpansionsOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private List expansions; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private List expansions; - - private Builder(CreateExpansionsOptions createExpansionsOptions) { - environmentId = createExpansionsOptions.environmentId; - collectionId = createExpansionsOptions.collectionId; - expansions = createExpansionsOptions.expansions; - } - - /** - * 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 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) { - 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.getExpansions(); - return this; - } - } - - private CreateExpansionsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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 so that all terms are expanded to all other terms in the object - - * bi-directional, or a set list of terms can be expanded into a second list of terms - uni-directional. - * - * 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/developer_cloud/discovery/v1/model/CreateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateTrainingExampleOptions.java deleted file mode 100644 index ed4788af233..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/CreateTrainingExampleOptions.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createTrainingExample options. - */ -public class CreateTrainingExampleOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - private String documentId; - private String crossReference; - private 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) { - environmentId = createTrainingExampleOptions.environmentId; - collectionId = createTrainingExampleOptions.collectionId; - queryId = createTrainingExampleOptions.queryId; - documentId = createTrainingExampleOptions.documentId; - crossReference = createTrainingExampleOptions.crossReference; - 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.getDocumentId(); - this.crossReference = trainingExample.getCrossReference(); - this.relevance = trainingExample.getRelevance(); - return this; - } - } - - private CreateTrainingExampleOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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. - * - * @return the documentId - */ - public String documentId() { - return documentId; - } - - /** - * Gets the crossReference. - * - * @return the crossReference - */ - public String crossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * @return the relevance - */ - public Long relevance() { - return relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteAllTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteAllTrainingDataOptions.java deleted file mode 100644 index 6e3ea9f3d24..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteAllTrainingDataOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteAllTrainingData options. - */ -public class DeleteAllTrainingDataOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteAllTrainingDataOptions deleteAllTrainingDataOptions) { - environmentId = deleteAllTrainingDataOptions.environmentId; - 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; - } - } - - private DeleteAllTrainingDataOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteCollectionOptions.java deleted file mode 100644 index 1679a369475..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteCollectionOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteCollection options. - */ -public class DeleteCollectionOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteCollectionOptions deleteCollectionOptions) { - environmentId = deleteCollectionOptions.environmentId; - 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; - } - } - - private DeleteCollectionOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteConfigurationOptions.java deleted file mode 100644 index e97b3627cd9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteConfigurationOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteConfiguration options. - */ -public class DeleteConfigurationOptions extends GenericModel { - - private String environmentId; - private String configurationId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configurationId; - - private Builder(DeleteConfigurationOptions deleteConfigurationOptions) { - environmentId = deleteConfigurationOptions.environmentId; - 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; - } - } - - private DeleteConfigurationOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteDocumentOptions.java deleted file mode 100644 index 300b28183dc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteDocumentOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteDocument options. - */ -public class DeleteDocumentOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String documentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - - private Builder(DeleteDocumentOptions deleteDocumentOptions) { - environmentId = deleteDocumentOptions.environmentId; - collectionId = deleteDocumentOptions.collectionId; - 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; - } - } - - private DeleteDocumentOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteEnvironmentOptions.java deleted file mode 100644 index 055e2924666..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteEnvironmentOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteEnvironment options. - */ -public class DeleteEnvironmentOptions extends GenericModel { - - private String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(DeleteEnvironmentOptions deleteEnvironmentOptions) { - 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; - } - } - - private DeleteEnvironmentOptions(Builder builder) { - 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/developer_cloud/discovery/v1/model/DeleteExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteExpansionsOptions.java deleted file mode 100644 index 6e105cf6f57..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteExpansionsOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteExpansions options. - */ -public class DeleteExpansionsOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(DeleteExpansionsOptions deleteExpansionsOptions) { - environmentId = deleteExpansionsOptions.environmentId; - 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; - } - } - - private DeleteExpansionsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteTrainingDataOptions.java deleted file mode 100644 index 9c3cfe6d730..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteTrainingDataOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteTrainingData options. - */ -public class DeleteTrainingDataOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(DeleteTrainingDataOptions deleteTrainingDataOptions) { - environmentId = deleteTrainingDataOptions.environmentId; - collectionId = deleteTrainingDataOptions.collectionId; - 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; - } - } - - private DeleteTrainingDataOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteTrainingExampleOptions.java deleted file mode 100644 index 34e458396ae..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteTrainingExampleOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteTrainingExample options. - */ -public class DeleteTrainingExampleOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - private Builder(DeleteTrainingExampleOptions deleteTrainingExampleOptions) { - environmentId = deleteTrainingExampleOptions.environmentId; - collectionId = deleteTrainingExampleOptions.collectionId; - queryId = deleteTrainingExampleOptions.queryId; - 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; - } - } - - private DeleteTrainingExampleOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - Validator.notEmpty(builder.queryId, "queryId cannot be empty"); - 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/developer_cloud/discovery/v1/model/DeleteUserDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index 12cba7785c8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/developer_cloud/discovery/v1/model/DiskUsage.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DiskUsage.java deleted file mode 100644 index 4ae2332ab31..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DiskUsage.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Summary of the disk usage statistics for the environment. - */ -public class DiskUsage extends GenericModel { - - @SerializedName("used_bytes") - private Long usedBytes; - @SerializedName("maximum_allowed_bytes") - private Long maximumAllowedBytes; - @SerializedName("total_bytes") - private Long totalBytes; - private String used; - private String total; - @SerializedName("percent_used") - private Double percentUsed; - - /** - * Gets the usedBytes. - * - * Number of bytes used on the environment's disk capacity. - * - * @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; - } - - /** - * Gets the totalBytes. - * - * **Deprecated**: Total number of bytes available in the environment's disk capacity. - * - * @return the totalBytes - */ - public Long getTotalBytes() { - return totalBytes; - } - - /** - * Gets the used. - * - * **Deprecated**: Amount of disk capacity used, in KB or GB format. - * - * @return the used - */ - public String getUsed() { - return used; - } - - /** - * Gets the total. - * - * **Deprecated**: Total amount of the environment's disk capacity, in KB or GB format. - * - * @return the total - */ - public String getTotal() { - return total; - } - - /** - * Gets the percentUsed. - * - * **Deprecated**: Percentage of the environment's disk capacity that is being used. - * - * @return the percentUsed - */ - public Double getPercentUsed() { - return percentUsed; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentAccepted.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentAccepted.java deleted file mode 100644 index 7f5e3a83563..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentAccepted.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DocumentAccepted. - */ -public class DocumentAccepted extends GenericModel { - - /** - * Status of the document in the ingestion process. - */ - public interface Status { - /** processing. */ - String PROCESSING = "processing"; - } - - @SerializedName("document_id") - private String documentId; - private String status; - private 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. - * - * @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/developer_cloud/discovery/v1/model/DocumentCounts.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentCounts.java deleted file mode 100644 index cc7d91bd5a8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentCounts.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DocumentCounts. - */ -public class DocumentCounts extends GenericModel { - - private Long available; - private Long processing; - private Long failed; - - /** - * 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentSnapshot.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentSnapshot.java deleted file mode 100644 index b6eecd59b99..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentSnapshot.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Map; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DocumentSnapshot. - */ -public class DocumentSnapshot extends GenericModel { - - public interface Step { - /** html_input. */ - String HTML_INPUT = "html_input"; - /** html_output. */ - String HTML_OUTPUT = "html_output"; - /** json_output. */ - String JSON_OUTPUT = "json_output"; - /** json_normalizations_output. */ - String JSON_NORMALIZATIONS_OUTPUT = "json_normalizations_output"; - /** enrichments_output. */ - String ENRICHMENTS_OUTPUT = "enrichments_output"; - /** normalizations_output. */ - String NORMALIZATIONS_OUTPUT = "normalizations_output"; - } - - private String step; - private Map snapshot; - - /** - * Gets the step. - * - * @return the step - */ - public String getStep() { - return step; - } - - /** - * Gets the snapshot. - * - * @return the snapshot - */ - public Map getSnapshot() { - return snapshot; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentStatus.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentStatus.java deleted file mode 100644 index c330533bb2a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/DocumentStatus.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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"; - } - - /** - * 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("configuration_id") - private String configurationId; - private Date created; - private Date updated; - private String status; - @SerializedName("status_description") - private String statusDescription; - private String filename; - @SerializedName("file_type") - private String fileType; - private String sha1; - private 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 created. - * - * The creation date of the document 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 the most recent document update, in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. - * - * @return the updated - */ - public Date getUpdated() { - return updated; - } - - /** - * 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/developer_cloud/discovery/v1/model/Enrichment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java deleted file mode 100644 index ccfb08e832e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Enrichment.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Enrichment. - */ -public class Enrichment extends GenericModel { - - private String description; - @SerializedName("destination_field") - private String destinationField; - @SerializedName("source_field") - private String sourceField; - private Boolean overwrite; - @SerializedName("enrichment") - private String enrichmentName; - @SerializedName("ignore_downstream_errors") - private Boolean ignoreDownstreamErrors; - private EnrichmentOptions options; - - /** - * Gets the description. - * - * Describes what the enrichment step does. - * - * @return the description - */ - public String getDescription() { - 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 getDestinationField() { - return destinationField; - } - - /** - * Gets the sourceField. - * - * Field to be enriched. - * - * @return the sourceField - */ - public String getSourceField() { - return sourceField; - } - - /** - * Gets the overwrite. - * - * Indicates that the enrichments will overwrite the destination_field field if it already exists. - * - * @return the overwrite - */ - public Boolean isOverwrite() { - return overwrite; - } - - /** - * Gets the enrichmentName. - * - * 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://console.bluemix.net/docs/services/discovery/element-classification.html) - * - * - * - * Previous API versions also supported `alchemy_language`. - * - * @return the enrichmentName - */ - public String getEnrichmentName() { - return enrichmentName; - } - - /** - * 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 isIgnoreDownstreamErrors() { - return ignoreDownstreamErrors; - } - - /** - * Gets the options. - * - * A list of options specific to the enrichment. - * - * @return the options - */ - public EnrichmentOptions getOptions() { - return options; - } - - /** - * Sets the description. - * - * @param description the new description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * Sets the destinationField. - * - * @param destinationField the new destinationField - */ - public void setDestinationField(final String destinationField) { - this.destinationField = destinationField; - } - - /** - * Sets the sourceField. - * - * @param sourceField the new sourceField - */ - public void setSourceField(final String sourceField) { - this.sourceField = sourceField; - } - - /** - * Sets the overwrite. - * - * @param overwrite the new overwrite - */ - public void setOverwrite(final Boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * Sets the enrichmentName. - * - * @param enrichmentName the new enrichmentName - */ - public void setEnrichmentName(final String enrichmentName) { - this.enrichmentName = enrichmentName; - } - - /** - * Sets the ignoreDownstreamErrors. - * - * @param ignoreDownstreamErrors the new ignoreDownstreamErrors - */ - public void setIgnoreDownstreamErrors(final Boolean ignoreDownstreamErrors) { - this.ignoreDownstreamErrors = ignoreDownstreamErrors; - } - - /** - * Sets the options. - * - * @param options the new options - */ - public void setOptions(final EnrichmentOptions options) { - this.options = options; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java deleted file mode 100644 index be8431e68c2..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnrichmentOptions.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Options which are specific to a particular enrichment. - */ -public class EnrichmentOptions extends GenericModel { - - private NluEnrichmentFeatures features; - private String model; - - /** - * Builder. - */ - public static class Builder { - private NluEnrichmentFeatures features; - private String model; - - private Builder(EnrichmentOptions enrichmentOptions) { - features = enrichmentOptions.features; - 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 model. - * - * @param model the model - * @return the EnrichmentOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - private EnrichmentOptions(Builder builder) { - features = builder.features; - model = builder.model; - } - - /** - * New builder. - * - * @return a EnrichmentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the features. - * - * An object representing the enrichment features that will be applied to the specified field. - * - * @return the features - */ - public NluEnrichmentFeatures features() { - return features; - } - - /** - * 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/developer_cloud/discovery/v1/model/Environment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java deleted file mode 100644 index fcd83704b53..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Environment.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Details about an environment. - */ -public class Environment extends GenericModel { - - /** - * Status of the environment. - */ - public interface Status { - /** active. */ - String ACTIVE = "active"; - /** pending. */ - String PENDING = "pending"; - /** maintenance. */ - String MAINTENANCE = "maintenance"; - } - - @SerializedName("environment_id") - private String environmentId; - private String name; - private String description; - private Date created; - private Date updated; - private String status; - @SerializedName("read_only") - private Boolean readOnly; - private Long size; - @SerializedName("index_capacity") - private IndexCapacity indexCapacity; - - /** - * 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. - * - * Status of the environment. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the readOnly. - * - * If true, then the environment contains read-only collections which are maintained by IBM. - * - * @return the readOnly - */ - public Boolean isReadOnly() { - return readOnly; - } - - /** - * Gets the size. - * - * **Deprecated**: Size of the environment. - * - * @return the size - */ - public Long getSize() { - return size; - } - - /** - * Gets the indexCapacity. - * - * Details about the resource usage and capacity of the environment. - * - * @return the indexCapacity - */ - public IndexCapacity getIndexCapacity() { - return indexCapacity; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnvironmentDocuments.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnvironmentDocuments.java deleted file mode 100644 index 7cc17e8b962..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/EnvironmentDocuments.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Summary of the document usage statistics for the environment. - */ -public class EnvironmentDocuments extends GenericModel { - - private Long indexed; - @SerializedName("maximum_allowed") - private Long maximumAllowed; - - /** - * Gets the indexed. - * - * Number of documents indexed for the environment. - * - * @return the indexed - */ - public Long getIndexed() { - return indexed; - } - - /** - * 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/developer_cloud/discovery/v1/model/Expansion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Expansion.java deleted file mode 100644 index 19b5eb64228..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Expansion.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private List inputTerms; - @SerializedName("expanded_terms") - private List expandedTerms; - - /** - * 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 getInputTerms() { - 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 getExpandedTerms() { - return expandedTerms; - } - - /** - * Sets the inputTerms. - * - * @param inputTerms the new inputTerms - */ - public void setInputTerms(final List inputTerms) { - this.inputTerms = inputTerms; - } - - /** - * Sets the expandedTerms. - * - * @param expandedTerms the new expandedTerms - */ - public void setExpandedTerms(final List expandedTerms) { - this.expandedTerms = expandedTerms; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Expansions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Expansions.java deleted file mode 100644 index 35bc786af14..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Expansions.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The query expansion definitions for the specified collection. - */ -public class Expansions extends GenericModel { - - private List expansions; - - /** - * 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 so that all terms are expanded to all other terms in the object - - * bi-directional, or a set list of terms can be expanded into a second list of terms - uni-directional. - * - * 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 getExpansions() { - return expansions; - } - - /** - * Sets the expansions. - * - * @param expansions the new expansions - */ - public void setExpansions(final List expansions) { - this.expansions = expansions; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java deleted file mode 100644 index 220db5fb7ca..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryNoticesOptions.java +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The federatedQueryNotices options. - */ -public class FederatedQueryNoticesOptions extends GenericModel { - - private String environmentId; - private List collectionIds; - private String filter; - private String query; - private String naturalLanguageQuery; - private String aggregation; - private Long count; - private List returnFields; - private Long offset; - private List sort; - private Boolean highlight; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private 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 returnFields; - 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) { - environmentId = federatedQueryNoticesOptions.environmentId; - collectionIds = federatedQueryNoticesOptions.collectionIds; - filter = federatedQueryNoticesOptions.filter; - query = federatedQueryNoticesOptions.query; - naturalLanguageQuery = federatedQueryNoticesOptions.naturalLanguageQuery; - aggregation = federatedQueryNoticesOptions.aggregation; - count = federatedQueryNoticesOptions.count; - returnFields = federatedQueryNoticesOptions.returnFields; - offset = federatedQueryNoticesOptions.offset; - sort = federatedQueryNoticesOptions.sort; - highlight = federatedQueryNoticesOptions.highlight; - deduplicateField = federatedQueryNoticesOptions.deduplicateField; - similar = federatedQueryNoticesOptions.similar; - similarDocumentIds = federatedQueryNoticesOptions.similarDocumentIds; - 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) { - 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 returnFields. - * - * @param returnField the new returnField - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addReturnField(String returnField) { - Validator.notNull(returnField, "returnField cannot be null"); - if (this.returnFields == null) { - this.returnFields = new ArrayList(); - } - this.returnFields.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the FederatedQueryNoticesOptions builder - */ - public Builder addSort(String sort) { - 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) { - 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) { - 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 returnFields. - * Existing returnFields will be replaced. - * - * @param returnFields the returnFields - * @return the FederatedQueryNoticesOptions builder - */ - public Builder returnFields(List returnFields) { - this.returnFields = returnFields; - 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; - } - } - - private FederatedQueryNoticesOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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; - returnFields = builder.returnFields; - 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 limits the documents returned to exclude any documents that don't mention the query content. - * Filter searches are better for metadata type searches and when you are trying to get a sense of 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. You - * cannot use `natural_language_query` and `query` at the same time. - * - * @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. You cannot use `natural_language_query` and `query` at the same time. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the aggregation. - * - * An aggregation search uses combinations of filters and query search to return an exact answer. Aggregations are - * useful for building applications, because you can use them to build lists, tables, and time series. For a full list - * of possible aggregrations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of documents to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the returnFields. - * - * A comma separated list of the portion of the document hierarchy to return. - * - * @return the returnFields - */ - public List returnFields() { - return returnFields; - } - - /** - * 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. - * - * @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 that match the query with - * `` tags around the matching query terms. Defaults to false. - * - * @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. The default is `false`. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs that will be used to find similar documents. - * - * **Note:** If the `natural_language_query` parameter is also specified, it will be used to expand the scope of the - * document similarity search to include the natural language query. Other query parameters, such as `filter` and - * `query` are subsequently applied and reduce the query scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that will be 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/developer_cloud/discovery/v1/model/FederatedQueryOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java deleted file mode 100644 index 41d1576ad6b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FederatedQueryOptions.java +++ /dev/null @@ -1,592 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The federatedQuery options. - */ -public class FederatedQueryOptions extends GenericModel { - - private String environmentId; - private List collectionIds; - private String filter; - private String query; - private String naturalLanguageQuery; - private String aggregation; - private Long count; - private List returnFields; - private Long offset; - private List sort; - private Boolean highlight; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private 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 returnFields; - private Long offset; - private List sort; - private Boolean highlight; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private List similarFields; - - private Builder(FederatedQueryOptions federatedQueryOptions) { - environmentId = federatedQueryOptions.environmentId; - collectionIds = federatedQueryOptions.collectionIds; - filter = federatedQueryOptions.filter; - query = federatedQueryOptions.query; - naturalLanguageQuery = federatedQueryOptions.naturalLanguageQuery; - aggregation = federatedQueryOptions.aggregation; - count = federatedQueryOptions.count; - returnFields = federatedQueryOptions.returnFields; - offset = federatedQueryOptions.offset; - sort = federatedQueryOptions.sort; - highlight = federatedQueryOptions.highlight; - deduplicate = federatedQueryOptions.deduplicate; - deduplicateField = federatedQueryOptions.deduplicateField; - similar = federatedQueryOptions.similar; - similarDocumentIds = federatedQueryOptions.similarDocumentIds; - similarFields = federatedQueryOptions.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 FederatedQueryOptions. - * - * @return the federatedQueryOptions - */ - public FederatedQueryOptions build() { - return new FederatedQueryOptions(this); - } - - /** - * Adds an collectionIds to collectionIds. - * - * @param collectionIds the new collectionIds - * @return the FederatedQueryOptions builder - */ - public Builder addCollectionIds(String collectionIds) { - 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 returnFields. - * - * @param returnField the new returnField - * @return the FederatedQueryOptions builder - */ - public Builder addReturnField(String returnField) { - Validator.notNull(returnField, "returnField cannot be null"); - if (this.returnFields == null) { - this.returnFields = new ArrayList(); - } - this.returnFields.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the FederatedQueryOptions builder - */ - public Builder addSort(String sort) { - 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 FederatedQueryOptions builder - */ - public Builder addSimilarDocumentIds(String similarDocumentIds) { - 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 FederatedQueryOptions builder - */ - public Builder addSimilarFields(String similarFields) { - 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 FederatedQueryOptions 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 FederatedQueryOptions builder - */ - public Builder collectionIds(List 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 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 returnFields. - * Existing returnFields will be replaced. - * - * @param returnFields the returnFields - * @return the FederatedQueryOptions builder - */ - public Builder returnFields(List returnFields) { - this.returnFields = returnFields; - 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. - * Existing sort will be replaced. - * - * @param sort the sort - * @return the FederatedQueryOptions builder - */ - public Builder sort(List 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 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. - * Existing similarDocumentIds will be replaced. - * - * @param similarDocumentIds the similarDocumentIds - * @return the FederatedQueryOptions 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 FederatedQueryOptions builder - */ - public Builder similarFields(List similarFields) { - this.similarFields = similarFields; - return this; - } - } - - private FederatedQueryOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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; - returnFields = builder.returnFields; - offset = builder.offset; - sort = builder.sort; - highlight = builder.highlight; - deduplicate = builder.deduplicate; - deduplicateField = builder.deduplicateField; - similar = builder.similar; - similarDocumentIds = builder.similarDocumentIds; - similarFields = builder.similarFields; - } - - /** - * 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 List collectionIds() { - return collectionIds; - } - - /** - * Gets the filter. - * - * A cacheable query that limits the documents returned to exclude any documents that don't mention the query content. - * Filter searches are better for metadata type searches and when you are trying to get a sense of 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. You - * cannot use `natural_language_query` and `query` at the same time. - * - * @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. You cannot use `natural_language_query` and `query` at the same time. - * - * @return the naturalLanguageQuery - */ - public String naturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the aggregation. - * - * An aggregation search uses combinations of filters and query search to return an exact answer. Aggregations are - * useful for building applications, because you can use them to build lists, tables, and time series. For a full list - * of possible aggregrations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of documents to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the returnFields. - * - * A comma separated list of the portion of the document hierarchy to return. - * - * @return the returnFields - */ - public List returnFields() { - return returnFields; - } - - /** - * 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. - * - * @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 that match the query with - * `` tags around the matching query terms. Defaults to false. - * - * @return the highlight - */ - public Boolean highlight() { - return highlight; - } - - /** - * 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. - * Defaults to `false`. 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. The default is `false`. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs that will be used to find similar documents. - * - * **Note:** If the `natural_language_query` parameter is also specified, it will be used to expand the scope of the - * document similarity search to include the natural language query. Other query parameters, such as `filter` and - * `query` are subsequently applied and reduce the query scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that will be 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/developer_cloud/discovery/v1/model/Field.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Field.java deleted file mode 100644 index ac719ff8d92..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Field.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Field. - */ -public class Field extends GenericModel { - - /** - * The type of the field. - */ - public interface FieldType { - /** nested. */ - String NESTED = "nested"; - /** string. */ - String STRING = "string"; - /** date. */ - String DATE = "date"; - /** long. */ - String LONG = "long"; - /** integer. */ - String INTEGER = "integer"; - /** short. */ - String SHORT = "short"; - /** byte. */ - String BYTE = "byte"; - /** double. */ - String DOUBLE = "double"; - /** float. */ - String FLOAT = "float"; - /** boolean. */ - String BOOLEAN = "boolean"; - /** binary. */ - String BINARY = "binary"; - } - - @SerializedName("field") - private String fieldName; - @SerializedName("type") - private String fieldType; - - /** - * Gets the fieldName. - * - * The name of the field. - * - * @return the fieldName - */ - public String getFieldName() { - return fieldName; - } - - /** - * Gets the fieldType. - * - * The type of the field. - * - * @return the fieldType - */ - public String getFieldType() { - return fieldType; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Filter.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Filter.java deleted file mode 100644 index 911b9da175f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Filter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Filter. - */ -public class Filter extends QueryAggregation { - - private 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/developer_cloud/discovery/v1/model/FontSetting.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FontSetting.java deleted file mode 100644 index d706244c7db..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/FontSetting.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * FontSetting. - */ -public class FontSetting extends GenericModel { - - private Long level; - @SerializedName("min_size") - private Long minSize; - @SerializedName("max_size") - private Long maxSize; - private Boolean bold; - private Boolean italic; - private String name; - - /** - * Gets the level. - * - * @return the level - */ - public Long getLevel() { - return level; - } - - /** - * Gets the minSize. - * - * @return the minSize - */ - public Long getMinSize() { - return minSize; - } - - /** - * Gets the maxSize. - * - * @return the maxSize - */ - public Long getMaxSize() { - return maxSize; - } - - /** - * Gets the bold. - * - * @return the bold - */ - public Boolean isBold() { - return bold; - } - - /** - * Gets the italic. - * - * @return the italic - */ - public Boolean isItalic() { - return italic; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets the level. - * - * @param level the new level - */ - public void setLevel(final long level) { - this.level = level; - } - - /** - * Sets the minSize. - * - * @param minSize the new minSize - */ - public void setMinSize(final long minSize) { - this.minSize = minSize; - } - - /** - * Sets the maxSize. - * - * @param maxSize the new maxSize - */ - public void setMaxSize(final long maxSize) { - this.maxSize = maxSize; - } - - /** - * Sets the bold. - * - * @param bold the new bold - */ - public void setBold(final Boolean bold) { - this.bold = bold; - } - - /** - * Sets the italic. - * - * @param italic the new italic - */ - public void setItalic(final Boolean italic) { - this.italic = italic; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(final String name) { - this.name = name; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetCollectionOptions.java deleted file mode 100644 index 0ff88543c0b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetCollectionOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getCollection options. - */ -public class GetCollectionOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(GetCollectionOptions getCollectionOptions) { - environmentId = getCollectionOptions.environmentId; - 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; - } - } - - private GetCollectionOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/GetConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetConfigurationOptions.java deleted file mode 100644 index cee65aec041..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetConfigurationOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getConfiguration options. - */ -public class GetConfigurationOptions extends GenericModel { - - private String environmentId; - private String configurationId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configurationId; - - private Builder(GetConfigurationOptions getConfigurationOptions) { - environmentId = getConfigurationOptions.environmentId; - 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; - } - } - - private GetConfigurationOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/GetDocumentStatusOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetDocumentStatusOptions.java deleted file mode 100644 index 6e7a2970b6c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetDocumentStatusOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getDocumentStatus options. - */ -public class GetDocumentStatusOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String documentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - - private Builder(GetDocumentStatusOptions getDocumentStatusOptions) { - environmentId = getDocumentStatusOptions.environmentId; - collectionId = getDocumentStatusOptions.collectionId; - 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; - } - } - - private GetDocumentStatusOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/GetEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetEnvironmentOptions.java deleted file mode 100644 index 0c649ccb25d..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetEnvironmentOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getEnvironment options. - */ -public class GetEnvironmentOptions extends GenericModel { - - private String environmentId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - - private Builder(GetEnvironmentOptions getEnvironmentOptions) { - 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; - } - } - - private GetEnvironmentOptions(Builder builder) { - 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/developer_cloud/discovery/v1/model/GetTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetTrainingDataOptions.java deleted file mode 100644 index 0288621aac0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetTrainingDataOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getTrainingData options. - */ -public class GetTrainingDataOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(GetTrainingDataOptions getTrainingDataOptions) { - environmentId = getTrainingDataOptions.environmentId; - collectionId = getTrainingDataOptions.collectionId; - 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; - } - } - - private GetTrainingDataOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/GetTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetTrainingExampleOptions.java deleted file mode 100644 index 1a2bfbde24b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/GetTrainingExampleOptions.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getTrainingExample options. - */ -public class GetTrainingExampleOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - - private Builder(GetTrainingExampleOptions getTrainingExampleOptions) { - environmentId = getTrainingExampleOptions.environmentId; - collectionId = getTrainingExampleOptions.collectionId; - queryId = getTrainingExampleOptions.queryId; - 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; - } - } - - private GetTrainingExampleOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - Validator.notEmpty(builder.queryId, "queryId cannot be empty"); - 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/developer_cloud/discovery/v1/model/Histogram.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Histogram.java deleted file mode 100644 index fccec945cb9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Histogram.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Histogram. - */ -public class Histogram extends QueryAggregation { - - private String field; - private 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/developer_cloud/discovery/v1/model/HtmlSettings.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/HtmlSettings.java deleted file mode 100644 index 9cfdad79c6f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/HtmlSettings.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A list of HTML conversion settings. - */ -public class HtmlSettings extends GenericModel { - - @SerializedName("exclude_tags_completely") - private List excludeTagsCompletely; - @SerializedName("exclude_tags_keep_content") - private List excludeTagsKeepContent; - @SerializedName("keep_content") - private XPathPatterns keepContent; - @SerializedName("exclude_content") - private XPathPatterns excludeContent; - @SerializedName("keep_tag_attributes") - private List keepTagAttributes; - @SerializedName("exclude_tag_attributes") - private List excludeTagAttributes; - - /** - * Gets the excludeTagsCompletely. - * - * @return the excludeTagsCompletely - */ - public List getExcludeTagsCompletely() { - return excludeTagsCompletely; - } - - /** - * Gets the excludeTagsKeepContent. - * - * @return the excludeTagsKeepContent - */ - public List getExcludeTagsKeepContent() { - return excludeTagsKeepContent; - } - - /** - * Gets the keepContent. - * - * @return the keepContent - */ - public XPathPatterns getKeepContent() { - return keepContent; - } - - /** - * Gets the excludeContent. - * - * @return the excludeContent - */ - public XPathPatterns getExcludeContent() { - return excludeContent; - } - - /** - * Gets the keepTagAttributes. - * - * @return the keepTagAttributes - */ - public List getKeepTagAttributes() { - return keepTagAttributes; - } - - /** - * Gets the excludeTagAttributes. - * - * @return the excludeTagAttributes - */ - public List getExcludeTagAttributes() { - return excludeTagAttributes; - } - - /** - * Sets the excludeTagsCompletely. - * - * @param excludeTagsCompletely the new excludeTagsCompletely - */ - public void setExcludeTagsCompletely(final List excludeTagsCompletely) { - this.excludeTagsCompletely = excludeTagsCompletely; - } - - /** - * Sets the excludeTagsKeepContent. - * - * @param excludeTagsKeepContent the new excludeTagsKeepContent - */ - public void setExcludeTagsKeepContent(final List excludeTagsKeepContent) { - this.excludeTagsKeepContent = excludeTagsKeepContent; - } - - /** - * Sets the keepContent. - * - * @param keepContent the new keepContent - */ - public void setKeepContent(final XPathPatterns keepContent) { - this.keepContent = keepContent; - } - - /** - * Sets the excludeContent. - * - * @param excludeContent the new excludeContent - */ - public void setExcludeContent(final XPathPatterns excludeContent) { - this.excludeContent = excludeContent; - } - - /** - * Sets the keepTagAttributes. - * - * @param keepTagAttributes the new keepTagAttributes - */ - public void setKeepTagAttributes(final List keepTagAttributes) { - this.keepTagAttributes = keepTagAttributes; - } - - /** - * Sets the excludeTagAttributes. - * - * @param excludeTagAttributes the new excludeTagAttributes - */ - public void setExcludeTagAttributes(final List excludeTagAttributes) { - this.excludeTagAttributes = excludeTagAttributes; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/IndexCapacity.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/IndexCapacity.java deleted file mode 100644 index c04569d562b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/IndexCapacity.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Details about the resource usage and capacity of the environment. - */ -public class IndexCapacity extends GenericModel { - - private EnvironmentDocuments documents; - @SerializedName("disk_usage") - private DiskUsage diskUsage; - private CollectionUsage collections; - @SerializedName("memory_usage") - private MemoryUsage memoryUsage; - - /** - * 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 of 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; - } - - /** - * Gets the memoryUsage. - * - * **Deprecated**: Summary of the memory usage of the environment. - * - * @return the memoryUsage - */ - public MemoryUsage getMemoryUsage() { - return memoryUsage; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionFieldsOptions.java deleted file mode 100644 index e52d1e167c7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionFieldsOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listCollectionFields options. - */ -public class ListCollectionFieldsOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListCollectionFieldsOptions listCollectionFieldsOptions) { - environmentId = listCollectionFieldsOptions.environmentId; - 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; - } - } - - private ListCollectionFieldsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/ListCollectionFieldsResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionFieldsResponse.java deleted file mode 100644 index 3b7ae5404c5..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionFieldsResponse.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.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 { - - private 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/developer_cloud/discovery/v1/model/ListCollectionsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionsOptions.java deleted file mode 100644 index ac6851a4ad0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionsOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listCollections options. - */ -public class ListCollectionsOptions extends GenericModel { - - private String environmentId; - private String name; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - - private Builder(ListCollectionsOptions listCollectionsOptions) { - environmentId = listCollectionsOptions.environmentId; - 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; - } - } - - private ListCollectionsOptions(Builder builder) { - 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/developer_cloud/discovery/v1/model/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionsResponse.java deleted file mode 100644 index 8bfa57552a6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListCollectionsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ListCollectionsResponse. - */ -public class ListCollectionsResponse extends GenericModel { - - private 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/developer_cloud/discovery/v1/model/ListConfigurationsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListConfigurationsOptions.java deleted file mode 100644 index ba43ae0a916..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListConfigurationsOptions.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listConfigurations options. - */ -public class ListConfigurationsOptions extends GenericModel { - - private String environmentId; - private String name; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - - private Builder(ListConfigurationsOptions listConfigurationsOptions) { - environmentId = listConfigurationsOptions.environmentId; - 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; - } - } - - private ListConfigurationsOptions(Builder builder) { - 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/developer_cloud/discovery/v1/model/ListConfigurationsResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListConfigurationsResponse.java deleted file mode 100644 index 293fe34db10..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListConfigurationsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ListConfigurationsResponse. - */ -public class ListConfigurationsResponse extends GenericModel { - - private 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/developer_cloud/discovery/v1/model/ListEnvironmentsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListEnvironmentsOptions.java deleted file mode 100644 index 19e43275f5d..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListEnvironmentsOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listEnvironments options. - */ -public class ListEnvironmentsOptions extends GenericModel { - - private String name; - - /** - * Builder. - */ - public static class Builder { - private String name; - - private Builder(ListEnvironmentsOptions listEnvironmentsOptions) { - 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; - } - } - - private 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/developer_cloud/discovery/v1/model/ListEnvironmentsResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListEnvironmentsResponse.java deleted file mode 100644 index 619ca543f3c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListEnvironmentsResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ListEnvironmentsResponse. - */ -public class ListEnvironmentsResponse extends GenericModel { - - private 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/developer_cloud/discovery/v1/model/ListExpansionsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListExpansionsOptions.java deleted file mode 100644 index 53679ccdf20..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListExpansionsOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listExpansions options. - */ -public class ListExpansionsOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListExpansionsOptions listExpansionsOptions) { - environmentId = listExpansionsOptions.environmentId; - 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; - } - } - - private ListExpansionsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/ListFieldsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListFieldsOptions.java deleted file mode 100644 index 6d96b878a49..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListFieldsOptions.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listFields options. - */ -public class ListFieldsOptions extends GenericModel { - - private String environmentId; - private List collectionIds; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private List collectionIds; - - private Builder(ListFieldsOptions listFieldsOptions) { - environmentId = listFieldsOptions.environmentId; - 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) { - 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; - } - } - - private ListFieldsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/ListTrainingDataOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListTrainingDataOptions.java deleted file mode 100644 index ceb4aaf10b7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListTrainingDataOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listTrainingData options. - */ -public class ListTrainingDataOptions extends GenericModel { - - private String environmentId; - private String collectionId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - - private Builder(ListTrainingDataOptions listTrainingDataOptions) { - environmentId = listTrainingDataOptions.environmentId; - 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; - } - } - - private ListTrainingDataOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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/developer_cloud/discovery/v1/model/ListTrainingExamplesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListTrainingExamplesOptions.java deleted file mode 100644 index c4b2269cd83..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/ListTrainingExamplesOptions.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listTrainingExamples options. - */ -public class ListTrainingExamplesOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String queryId; - - private Builder(ListTrainingExamplesOptions listTrainingExamplesOptions) { - environmentId = listTrainingExamplesOptions.environmentId; - collectionId = listTrainingExamplesOptions.collectionId; - 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; - } - } - - private ListTrainingExamplesOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/MemoryUsage.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MemoryUsage.java deleted file mode 100644 index d6838cfe5a8..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/MemoryUsage.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * **Deprecated**: Summary of the memory usage statistics for this environment. - */ -public class MemoryUsage extends GenericModel { - - @SerializedName("used_bytes") - private Long usedBytes; - @SerializedName("total_bytes") - private Long totalBytes; - private String used; - private String total; - @SerializedName("percent_used") - private Double percentUsed; - - /** - * Gets the usedBytes. - * - * **Deprecated**: Number of bytes used in the environment's memory capacity. - * - * @return the usedBytes - */ - public Long getUsedBytes() { - return usedBytes; - } - - /** - * Gets the totalBytes. - * - * **Deprecated**: Total number of bytes available in the environment's memory capacity. - * - * @return the totalBytes - */ - public Long getTotalBytes() { - return totalBytes; - } - - /** - * Gets the used. - * - * **Deprecated**: Amount of memory capacity used, in KB or GB format. - * - * @return the used - */ - public String getUsed() { - return used; - } - - /** - * Gets the total. - * - * **Deprecated**: Total amount of the environment's memory capacity, in KB or GB format. - * - * @return the total - */ - public String getTotal() { - return total; - } - - /** - * Gets the percentUsed. - * - * **Deprecated**: Percentage of the environment's memory capacity that is being used. - * - * @return the percentUsed - */ - public Double getPercentUsed() { - return percentUsed; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Nested.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Nested.java deleted file mode 100644 index aa554ee78e6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Nested.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Nested. - */ -public class Nested extends QueryAggregation { - - private 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/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java deleted file mode 100644 index 6ead113acc9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentCategories.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.DynamicModel; - -/** - * An object that indicates the Categories enrichment will be applied to the specified field. - */ -public class NluEnrichmentCategories extends DynamicModel { - -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java deleted file mode 100644 index 674b1d6ed70..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEmotion.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * An object specifying the emotion detection enrichment and related parameters. - */ -public class NluEnrichmentEmotion extends GenericModel { - - private Boolean document; - private List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(NluEnrichmentEmotion nluEnrichmentEmotion) { - document = nluEnrichmentEmotion.document; - 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) { - 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; - } - } - - private 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/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java deleted file mode 100644 index a931cd467cd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentEntities.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object speficying the Entities enrichment and related parameters. - */ -public class NluEnrichmentEntities extends GenericModel { - - private Boolean sentiment; - private Boolean emotion; - private Long limit; - private Boolean mentions; - @SerializedName("mention_types") - private Boolean mentionTypes; - @SerializedName("sentence_location") - private Boolean sentenceLocation; - private String model; - - /** - * Builder. - */ - public static class Builder { - private Boolean sentiment; - private Boolean emotion; - private Long limit; - private Boolean mentions; - private Boolean mentionTypes; - private Boolean sentenceLocation; - private String model; - - private Builder(NluEnrichmentEntities nluEnrichmentEntities) { - sentiment = nluEnrichmentEntities.sentiment; - emotion = nluEnrichmentEntities.emotion; - limit = nluEnrichmentEntities.limit; - mentions = nluEnrichmentEntities.mentions; - mentionTypes = nluEnrichmentEntities.mentionTypes; - sentenceLocation = nluEnrichmentEntities.sentenceLocation; - 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 sentenceLocation. - * - * @param sentenceLocation the sentenceLocation - * @return the NluEnrichmentEntities builder - */ - public Builder sentenceLocation(Boolean sentenceLocation) { - this.sentenceLocation = sentenceLocation; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the NluEnrichmentEntities builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - private NluEnrichmentEntities(Builder builder) { - sentiment = builder.sentiment; - emotion = builder.emotion; - limit = builder.limit; - mentions = builder.mentions; - mentionTypes = builder.mentionTypes; - sentenceLocation = builder.sentenceLocation; - 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 sentenceLocation. - * - * When `true`, a list of sentence locations for each instance of each identified entity is recorded. The default is - * `false`. - * - * @return the sentenceLocation - */ - public Boolean sentenceLocation() { - return sentenceLocation; - } - - /** - * Gets the model. - * - * The enrichement model to use with entity extraction. May be a custom model provided by Watson Knowledge Studio, the - * public model for use with Knowledge Graph `en-news`, or the default public model `alchemy`. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java deleted file mode 100644 index 0bf91291fac..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentFeatures.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * NluEnrichmentFeatures. - */ -public class NluEnrichmentFeatures extends GenericModel { - - private NluEnrichmentKeywords keywords; - private NluEnrichmentEntities entities; - private NluEnrichmentSentiment sentiment; - private NluEnrichmentEmotion emotion; - private NluEnrichmentCategories categories; - @SerializedName("semantic_roles") - private NluEnrichmentSemanticRoles semanticRoles; - private NluEnrichmentRelations relations; - - /** - * 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 Builder(NluEnrichmentFeatures nluEnrichmentFeatures) { - keywords = nluEnrichmentFeatures.keywords; - entities = nluEnrichmentFeatures.entities; - sentiment = nluEnrichmentFeatures.sentiment; - emotion = nluEnrichmentFeatures.emotion; - categories = nluEnrichmentFeatures.categories; - semanticRoles = nluEnrichmentFeatures.semanticRoles; - relations = nluEnrichmentFeatures.relations; - } - - /** - * 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; - } - } - - private NluEnrichmentFeatures(Builder builder) { - keywords = builder.keywords; - entities = builder.entities; - sentiment = builder.sentiment; - emotion = builder.emotion; - categories = builder.categories; - semanticRoles = builder.semanticRoles; - relations = builder.relations; - } - - /** - * 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 specifying the categories enrichment and related parameters. - * - * @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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java deleted file mode 100644 index d7aa1066ce0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentKeywords.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object specifying the Keyword enrichment and related parameters. - */ -public class NluEnrichmentKeywords extends GenericModel { - - private Boolean sentiment; - private Boolean emotion; - private Long limit; - - /** - * Builder. - */ - public static class Builder { - private Boolean sentiment; - private Boolean emotion; - private Long limit; - - private Builder(NluEnrichmentKeywords nluEnrichmentKeywords) { - sentiment = nluEnrichmentKeywords.sentiment; - emotion = nluEnrichmentKeywords.emotion; - 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; - } - } - - private 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/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java deleted file mode 100644 index 2588e7ff3bd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentRelations.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object specifying the relations enrichment and related parameters. - */ -public class NluEnrichmentRelations extends GenericModel { - - private String model; - - /** - * 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 public model for use with Knowledge - * Graph `en-news`, the default is`en-news`. - * - * @return the model - */ - public String getModel() { - return model; - } - - /** - * Sets the model. - * - * @param model the new model - */ - public void setModel(final String model) { - this.model = model; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java deleted file mode 100644 index e04051831c6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSemanticRoles.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object specifiying the semantic roles enrichment and related parameters. - */ -public class NluEnrichmentSemanticRoles extends GenericModel { - - private Boolean entities; - private Boolean keywords; - private Long limit; - - /** - * Builder. - */ - public static class Builder { - private Boolean entities; - private Boolean keywords; - private Long limit; - - private Builder(NluEnrichmentSemanticRoles nluEnrichmentSemanticRoles) { - entities = nluEnrichmentSemanticRoles.entities; - keywords = nluEnrichmentSemanticRoles.keywords; - 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; - } - } - - private 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/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java deleted file mode 100644 index f46213d5af3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NluEnrichmentSentiment.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * An object specifying the sentiment extraction enrichment and related parameters. - */ -public class NluEnrichmentSentiment extends GenericModel { - - private Boolean document; - private List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(NluEnrichmentSentiment nluEnrichmentSentiment) { - document = nluEnrichmentSentiment.document; - 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) { - 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; - } - } - - private 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/developer_cloud/discovery/v1/model/NormalizationOperation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NormalizationOperation.java deleted file mode 100644 index c06c075909f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/NormalizationOperation.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * NormalizationOperation. - */ -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 is 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) leif values from the JSON tree. `source_field` and - * `destination_field` are ignored by this operation because _remove_nulls_ operates on the entire JSON tree. - * Typically, `remove_nulls` is invoked as the last normalization operation (if it is inoked 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"; - } - - private String operation; - @SerializedName("source_field") - private String sourceField; - @SerializedName("destination_field") - private String destinationField; - - /** - * 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 is 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) leif values from the JSON tree. `source_field` and - * `destination_field` are ignored by this operation because _remove_nulls_ operates on the entire JSON tree. - * Typically, `remove_nulls` is invoked as the last normalization operation (if it is inoked at all, it can be - * time-expensive). - * - * @return the operation - */ - public String getOperation() { - return operation; - } - - /** - * Gets the sourceField. - * - * The source field for the operation. - * - * @return the sourceField - */ - public String getSourceField() { - return sourceField; - } - - /** - * Gets the destinationField. - * - * The destination field for the operation. - * - * @return the destinationField - */ - public String getDestinationField() { - return destinationField; - } - - /** - * Sets the operation. - * - * @param operation the new operation - */ - public void setOperation(final String operation) { - this.operation = operation; - } - - /** - * Sets the sourceField. - * - * @param sourceField the new sourceField - */ - public void setSourceField(final String sourceField) { - this.sourceField = sourceField; - } - - /** - * Sets the destinationField. - * - * @param destinationField the new destinationField - */ - public void setDestinationField(final String destinationField) { - this.destinationField = destinationField; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Notice.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Notice.java deleted file mode 100644 index 139179ce12e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Notice.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private String noticeId; - private Date created; - @SerializedName("document_id") - private String documentId; - @SerializedName("query_id") - private String queryId; - private String severity; - private String step; - private 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. - * - * @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. - * - * @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/developer_cloud/discovery/v1/model/PdfHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/PdfHeadingDetection.java deleted file mode 100644 index 1ccd288e05c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/PdfHeadingDetection.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * PdfHeadingDetection. - */ -public class PdfHeadingDetection extends GenericModel { - - private List fonts; - - /** - * Gets the fonts. - * - * @return the fonts - */ - public List getFonts() { - return fonts; - } - - /** - * Sets the fonts. - * - * @param fonts the new fonts - */ - public void setFonts(final List fonts) { - this.fonts = fonts; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/PdfSettings.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/PdfSettings.java deleted file mode 100644 index 1fe42213419..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/PdfSettings.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A list of PDF conversion settings. - */ -public class PdfSettings extends GenericModel { - - private PdfHeadingDetection heading; - - /** - * Gets the heading. - * - * @return the heading - */ - public PdfHeadingDetection getHeading() { - return heading; - } - - /** - * Sets the heading. - * - * @param heading the new heading - */ - public void setHeading(final PdfHeadingDetection heading) { - this.heading = heading; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java deleted file mode 100644 index 4f5dd81d1ba..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryAggregation.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.JsonAdapter; -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationDeserializer; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -import java.util.List; - -/** - * An aggregation produced by the Discovery service to analyze the input provided. - */ -@JsonAdapter(AggregationDeserializer.class) -public class QueryAggregation extends GenericModel { - - private String type; - private List results; - @SerializedName("matching_results") - private Long matchingResults; - private 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. - * - * @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 the Discovery service. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } - - /** - * Sets the type. - * - * @param type the new type - */ - public void setType(final String type) { - this.type = type; - } - - /** - * Sets the results. - * - * @param results the new results - */ - public void setResults(final List results) { - this.results = results; - } - - /** - * Sets the matchingResults. - * - * @param matchingResults the new matchingResults - */ - public void setMatchingResults(final long matchingResults) { - this.matchingResults = matchingResults; - } - - /** - * Sets the aggregations. - * - * @param aggregations the new aggregations - */ - public void setAggregations(final List aggregations) { - this.aggregations = aggregations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesContext.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesContext.java deleted file mode 100644 index ce5b975af77..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesContext.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Entity text to provide context for the queried entity and rank based on that association. For example, if you wanted - * to query the city of London in England your query would look for `London` with the context of `England`. - */ -public class QueryEntitiesContext extends GenericModel { - - private String text; - - /** - * Gets the text. - * - * Entity text to provide context for the queried entity and rank based on that association. For example, if you - * wanted to query the city of London in England your query would look for `London` with the context of `England`. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final String text) { - this.text = text; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesEntity.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesEntity.java deleted file mode 100644 index 785e608f5cd..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesEntity.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A text string that appears within the entity text field. - */ -public class QueryEntitiesEntity extends GenericModel { - - private String text; - private String type; - - /** - * Gets the text. - * - * Entity text content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the type. - * - * The type of the specified entity. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final String text) { - this.text = text; - } - - /** - * Sets the type. - * - * @param type the new type - */ - public void setType(final String type) { - this.type = type; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesOptions.java deleted file mode 100644 index 1c06bae0781..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesOptions.java +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The queryEntities options. - */ -public class QueryEntitiesOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String feature; - private QueryEntitiesEntity entity; - private QueryEntitiesContext context; - private Long count; - private Long evidenceCount; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String feature; - private QueryEntitiesEntity entity; - private QueryEntitiesContext context; - private Long count; - private Long evidenceCount; - - private Builder(QueryEntitiesOptions queryEntitiesOptions) { - environmentId = queryEntitiesOptions.environmentId; - collectionId = queryEntitiesOptions.collectionId; - feature = queryEntitiesOptions.feature; - entity = queryEntitiesOptions.entity; - context = queryEntitiesOptions.context; - count = queryEntitiesOptions.count; - evidenceCount = queryEntitiesOptions.evidenceCount; - } - - /** - * 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 QueryEntitiesOptions. - * - * @return the queryEntitiesOptions - */ - public QueryEntitiesOptions build() { - return new QueryEntitiesOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the QueryEntitiesOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the QueryEntitiesOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the feature. - * - * @param feature the feature - * @return the QueryEntitiesOptions builder - */ - public Builder feature(String feature) { - this.feature = feature; - return this; - } - - /** - * Set the entity. - * - * @param entity the entity - * @return the QueryEntitiesOptions builder - */ - public Builder entity(QueryEntitiesEntity entity) { - this.entity = entity; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the QueryEntitiesOptions builder - */ - public Builder context(QueryEntitiesContext context) { - this.context = context; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the QueryEntitiesOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the evidenceCount. - * - * @param evidenceCount the evidenceCount - * @return the QueryEntitiesOptions builder - */ - public Builder evidenceCount(long evidenceCount) { - this.evidenceCount = evidenceCount; - return this; - } - } - - private QueryEntitiesOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - feature = builder.feature; - entity = builder.entity; - context = builder.context; - count = builder.count; - evidenceCount = builder.evidenceCount; - } - - /** - * New builder. - * - * @return a QueryEntitiesOptions 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 feature. - * - * The entity query feature to perform. Supported features are `disambiguate` and `similar_entities`. - * - * @return the feature - */ - public String feature() { - return feature; - } - - /** - * Gets the entity. - * - * A text string that appears within the entity text field. - * - * @return the entity - */ - public QueryEntitiesEntity entity() { - return entity; - } - - /** - * Gets the context. - * - * Entity text to provide context for the queried entity and rank based on that association. For example, if you - * wanted to query the city of London in England your query would look for `London` with the context of `England`. - * - * @return the context - */ - public QueryEntitiesContext context() { - return context; - } - - /** - * Gets the count. - * - * The number of results to return. The default is `10`. The maximum is `1000`. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the evidenceCount. - * - * The number of evidence items to return for each result. The default is `0`. The maximum number of evidence items - * per query is 10,000. - * - * @return the evidenceCount - */ - public Long evidenceCount() { - return evidenceCount; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponse.java deleted file mode 100644 index 631733ddec9..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An array of entities resulting from the query. - */ -public class QueryEntitiesResponse extends GenericModel { - - private List entities; - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponseItem.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponseItem.java deleted file mode 100644 index 44a237fe74c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEntitiesResponseItem.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Object containing Entity query response information. - */ -public class QueryEntitiesResponseItem extends GenericModel { - - private String text; - private String type; - private List evidence; - - /** - * Gets the text. - * - * Entity text content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the type. - * - * The type of the result entity. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the evidence. - * - * List of different evidentiary items to support the result. - * - * @return the evidence - */ - public List getEvidence() { - return evidence; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidence.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidence.java deleted file mode 100644 index 4e9af98210b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidence.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Description of evidence location supporting Knoweldge Graph query result. - */ -public class QueryEvidence extends GenericModel { - - @SerializedName("document_id") - private String documentId; - private String field; - @SerializedName("start_offset") - private Long startOffset; - @SerializedName("end_offset") - private Long endOffset; - private List entities; - - /** - * Gets the documentId. - * - * The docuemnt ID (as indexed in Discovery) of the evidence location. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the field. - * - * The field of the document where the supporting evidence was identified. - * - * @return the field - */ - public String getField() { - return field; - } - - /** - * Gets the startOffset. - * - * The start location of the evidence in the identified field. This value is inclusive. - * - * @return the startOffset - */ - public Long getStartOffset() { - return startOffset; - } - - /** - * Gets the endOffset. - * - * The end location of the evidence in the identified field. This value is inclusive. - * - * @return the endOffset - */ - public Long getEndOffset() { - return endOffset; - } - - /** - * Gets the entities. - * - * An array of entity objects that show evidence of the result. - * - * @return the entities - */ - public List getEntities() { - return entities; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidenceEntity.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidenceEntity.java deleted file mode 100644 index 1b3eb444dc0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryEvidenceEntity.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Entity description and location within evidence field. - */ -public class QueryEvidenceEntity extends GenericModel { - - private String type; - private String text; - @SerializedName("start_offset") - private Long startOffset; - @SerializedName("end_offset") - private Long endOffset; - - /** - * Gets the type. - * - * The entity type for this entity. Possible types vary based on model used. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the text. - * - * The original text of this entity as found in the evidence field. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the startOffset. - * - * The start location of the entity text in the identified field. This value is inclusive. - * - * @return the startOffset - */ - public Long getStartOffset() { - return startOffset; - } - - /** - * Gets the endOffset. - * - * The end location of the entity text in the identified field. This value is exclusive. - * - * @return the endOffset - */ - public Long getEndOffset() { - return endOffset; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryFilterType.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryFilterType.java deleted file mode 100644 index 83baf2bdffe..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryFilterType.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryFilterType. - */ -public class QueryFilterType extends GenericModel { - - private List exclude; - private List include; - - /** - * Gets the exclude. - * - * A comma-separated list of types to exclude. - * - * @return the exclude - */ - public List getExclude() { - return exclude; - } - - /** - * Gets the include. - * - * A comma-separated list of types to include. All other types are excluded. - * - * @return the include - */ - public List getInclude() { - return include; - } - - /** - * Sets the exclude. - * - * @param exclude the new exclude - */ - public void setExclude(final List exclude) { - this.exclude = exclude; - } - - /** - * Sets the include. - * - * @param include the new include - */ - public void setInclude(final List include) { - this.include = include; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java deleted file mode 100644 index 9a8a0503af5..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesOptions.java +++ /dev/null @@ -1,671 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The queryNotices options. - */ -public class QueryNoticesOptions extends GenericModel { - - 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 returnFields; - 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; - - /** - * 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 returnFields; - 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) { - environmentId = queryNoticesOptions.environmentId; - collectionId = queryNoticesOptions.collectionId; - filter = queryNoticesOptions.filter; - query = queryNoticesOptions.query; - naturalLanguageQuery = queryNoticesOptions.naturalLanguageQuery; - passages = queryNoticesOptions.passages; - aggregation = queryNoticesOptions.aggregation; - count = queryNoticesOptions.count; - returnFields = queryNoticesOptions.returnFields; - offset = queryNoticesOptions.offset; - sort = queryNoticesOptions.sort; - highlight = queryNoticesOptions.highlight; - passagesFields = queryNoticesOptions.passagesFields; - passagesCount = queryNoticesOptions.passagesCount; - passagesCharacters = queryNoticesOptions.passagesCharacters; - deduplicateField = queryNoticesOptions.deduplicateField; - similar = queryNoticesOptions.similar; - similarDocumentIds = queryNoticesOptions.similarDocumentIds; - 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 returnFields. - * - * @param returnField the new returnField - * @return the QueryNoticesOptions builder - */ - public Builder addReturnField(String returnField) { - Validator.notNull(returnField, "returnField cannot be null"); - if (this.returnFields == null) { - this.returnFields = new ArrayList(); - } - this.returnFields.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the QueryNoticesOptions builder - */ - public Builder addSort(String sort) { - 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) { - 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) { - 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) { - 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 returnFields. - * Existing returnFields will be replaced. - * - * @param returnFields the returnFields - * @return the QueryNoticesOptions builder - */ - public Builder returnFields(List returnFields) { - this.returnFields = returnFields; - 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; - } - } - - private QueryNoticesOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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; - returnFields = builder.returnFields; - 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 limits the documents returned to exclude any documents that don't mention the query content. - * Filter searches are better for metadata type searches and when you are trying to get a sense of 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. You - * cannot use `natural_language_query` and `query` at the same time. - * - * @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. You cannot use `natural_language_query` and `query` at the same time. - * - * @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 uses combinations of filters and query search to return an exact answer. Aggregations are - * useful for building applications, because you can use them to build lists, tables, and time series. For a full list - * of possible aggregrations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of documents to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the returnFields. - * - * A comma separated list of the portion of the document hierarchy to return. - * - * @return the returnFields - */ - public List returnFields() { - return returnFields; - } - - /** - * 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. - * - * @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 that match the query with - * `` tags around the matching query terms. Defaults to false. - * - * @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. - * 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. The default is `400`. The minimum is `50`. The - * maximum is `2000`. - * - * @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. The default is `false`. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs that will be used to find similar documents. - * - * **Note:** If the `natural_language_query` parameter is also specified, it will be used to expand the scope of the - * document similarity search to include the natural language query. Other query parameters, such as `filter` and - * `query` are subsequently applied and reduce the query scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that will be 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/developer_cloud/discovery/v1/model/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesResponse.java deleted file mode 100644 index 6991c00295b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryNoticesResponse. - */ -public class QueryNoticesResponse extends GenericModel { - - @SerializedName("matching_results") - private Long matchingResults; - private List results; - private List aggregations; - private List passages; - @SerializedName("duplicates_removed") - private Long duplicatesRemoved; - - /** - * Gets the matchingResults. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the results. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } - - /** - * Gets the passages. - * - * @return the passages - */ - public List getPassages() { - return passages; - } - - /** - * Gets the duplicatesRemoved. - * - * @return the duplicatesRemoved - */ - public Long getDuplicatesRemoved() { - return duplicatesRemoved; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesResult.java deleted file mode 100644 index 7565c5e3502..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryNoticesResult.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.lang.reflect.Type; -import java.util.List; -import java.util.Map; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * QueryNoticesResult. - */ -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"; - } - - private Type idType = new TypeToken() { - }.getType(); - private Type scoreType = new TypeToken() { - }.getType(); - private Type metadataType = new TypeToken() { - }.getType(); - private Type collectionIdType = new TypeToken() { - }.getType(); - private Type resultMetadataType = new TypeToken() { - }.getType(); - private Type codeType = new TypeToken() { - }.getType(); - private Type filenameType = new TypeToken() { - }.getType(); - private Type fileTypeType = new TypeToken() { - }.getType(); - private Type sha1Type = new TypeToken() { - }.getType(); - private Type noticesType = new TypeToken>() { - }.getType(); - - /** - * Gets the id. - * - * @return the id - */ - public String getId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("id"), idType); - } - - /** - * Gets the score. - * - * @return the score - */ - public Double getScore() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("score"), scoreType); - } - - /** - * Gets the metadata. - * - * @return the metadata - */ - public Map getMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("metadata"), metadataType); - } - - /** - * Gets the collectionId. - * - * @return the collectionId - */ - public String getCollectionId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("collection_id"), collectionIdType); - } - - /** - * Gets the resultMetadata. - * - * @return the resultMetadata - */ - public QueryResultResultMetadata getResultMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("result_metadata"), resultMetadataType); - } - - /** - * Gets the code. - * - * @return the code - */ - public Long getCode() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("code"), codeType); - } - - /** - * Gets the filename. - * - * @return the filename - */ - public String getFilename() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("filename"), filenameType); - } - - /** - * Gets the fileType. - * - * @return the fileType - */ - public String getFileType() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("file_type"), fileTypeType); - } - - /** - * Gets the sha1. - * - * @return the sha1 - */ - public String getSha1() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("sha1"), sha1Type); - } - - /** - * Gets the notices. - * - * @return the notices - */ - public List getNotices() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("notices"), noticesType); - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java deleted file mode 100644 index 5b3e368b604..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryOptions.java +++ /dev/null @@ -1,699 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The query options. - */ -public class QueryOptions extends GenericModel { - - 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 returnFields; - private Long offset; - private List sort; - private Boolean highlight; - private List passagesFields; - private Long passagesCount; - private Long passagesCharacters; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private 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 returnFields; - private Long offset; - private List sort; - private Boolean highlight; - private List passagesFields; - private Long passagesCount; - private Long passagesCharacters; - private Boolean deduplicate; - private String deduplicateField; - private Boolean similar; - private List similarDocumentIds; - private List similarFields; - - private Builder(QueryOptions queryOptions) { - environmentId = queryOptions.environmentId; - collectionId = queryOptions.collectionId; - filter = queryOptions.filter; - query = queryOptions.query; - naturalLanguageQuery = queryOptions.naturalLanguageQuery; - passages = queryOptions.passages; - aggregation = queryOptions.aggregation; - count = queryOptions.count; - returnFields = queryOptions.returnFields; - offset = queryOptions.offset; - sort = queryOptions.sort; - highlight = queryOptions.highlight; - passagesFields = queryOptions.passagesFields; - passagesCount = queryOptions.passagesCount; - passagesCharacters = queryOptions.passagesCharacters; - deduplicate = queryOptions.deduplicate; - deduplicateField = queryOptions.deduplicateField; - similar = queryOptions.similar; - similarDocumentIds = queryOptions.similarDocumentIds; - similarFields = queryOptions.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 QueryOptions. - * - * @return the queryOptions - */ - public QueryOptions build() { - return new QueryOptions(this); - } - - /** - * Adds an returnField to returnFields. - * - * @param returnField the new returnField - * @return the QueryOptions builder - */ - public Builder addReturnField(String returnField) { - Validator.notNull(returnField, "returnField cannot be null"); - if (this.returnFields == null) { - this.returnFields = new ArrayList(); - } - this.returnFields.add(returnField); - return this; - } - - /** - * Adds an sort to sort. - * - * @param sort the new sort - * @return the QueryOptions builder - */ - public Builder addSort(String sort) { - 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 QueryOptions builder - */ - public Builder addPassagesFields(String passagesFields) { - 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 QueryOptions builder - */ - public Builder addSimilarDocumentIds(String similarDocumentIds) { - 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 QueryOptions builder - */ - public Builder addSimilarFields(String similarFields) { - 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 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 returnFields. - * Existing returnFields will be replaced. - * - * @param returnFields the returnFields - * @return the QueryOptions builder - */ - public Builder returnFields(List returnFields) { - this.returnFields = returnFields; - 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. - * Existing sort will be replaced. - * - * @param sort the sort - * @return the QueryOptions builder - */ - public Builder sort(List 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. - * Existing passagesFields will be replaced. - * - * @param passagesFields the passagesFields - * @return the QueryOptions builder - */ - public Builder passagesFields(List 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. - * Existing similarDocumentIds will be replaced. - * - * @param similarDocumentIds the similarDocumentIds - * @return the QueryOptions 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 QueryOptions builder - */ - public Builder similarFields(List similarFields) { - this.similarFields = similarFields; - return this; - } - } - - private QueryOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - 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; - returnFields = builder.returnFields; - 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; - } - - /** - * 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 limits the documents returned to exclude any documents that don't mention the query content. - * Filter searches are better for metadata type searches and when you are trying to get a sense of 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. You - * cannot use `natural_language_query` and `query` at the same time. - * - * @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. You cannot use `natural_language_query` and `query` at the same time. - * - * @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 uses combinations of filters and query search to return an exact answer. Aggregations are - * useful for building applications, because you can use them to build lists, tables, and time series. For a full list - * of possible aggregrations, see the Query reference. - * - * @return the aggregation - */ - public String aggregation() { - return aggregation; - } - - /** - * Gets the count. - * - * Number of documents to return. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the returnFields. - * - * A comma separated list of the portion of the document hierarchy to return. - * - * @return the returnFields - */ - public List returnFields() { - return returnFields; - } - - /** - * 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. - * - * @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 that match the query with - * `` tags around the matching query terms. Defaults to false. - * - * @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. - * 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. The default is `400`. The minimum is `50`. The - * maximum is `2000`. - * - * @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. - * Defaults to `false`. 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. The default is `false`. - * - * @return the similar - */ - public Boolean similar() { - return similar; - } - - /** - * Gets the similarDocumentIds. - * - * A comma-separated list of document IDs that will be used to find similar documents. - * - * **Note:** If the `natural_language_query` parameter is also specified, it will be used to expand the scope of the - * document similarity search to include the natural language query. Other query parameters, such as `filter` and - * `query` are subsequently applied and reduce the query scope. - * - * @return the similarDocumentIds - */ - public List similarDocumentIds() { - return similarDocumentIds; - } - - /** - * Gets the similarFields. - * - * A comma-separated list of field names that will be 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/developer_cloud/discovery/v1/model/QueryPassages.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryPassages.java deleted file mode 100644 index e19f0d69afc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryPassages.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryPassages. - */ -public class QueryPassages extends GenericModel { - - @SerializedName("document_id") - private String documentId; - @SerializedName("passage_score") - private Double passageScore; - @SerializedName("passage_text") - private String passageText; - @SerializedName("start_offset") - private Long startOffset; - @SerializedName("end_offset") - private Long endOffset; - private 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/developer_cloud/discovery/v1/model/QueryRelationsArgument.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsArgument.java deleted file mode 100644 index 3e43a6da679..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsArgument.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryRelationsArgument. - */ -public class QueryRelationsArgument extends GenericModel { - - private List entities; - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsEntity.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsEntity.java deleted file mode 100644 index 8ed04fec410..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsEntity.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryRelationsEntity. - */ -public class QueryRelationsEntity extends GenericModel { - - private String text; - private String type; - private Boolean exact; - - /** - * Gets the text. - * - * Entity text content. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the type. - * - * The type of the specified entity. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the exact. - * - * If false, implicit querying is performed. The default is `false`. - * - * @return the exact - */ - public Boolean isExact() { - return exact; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final String text) { - this.text = text; - } - - /** - * Sets the type. - * - * @param type the new type - */ - public void setType(final String type) { - this.type = type; - } - - /** - * Sets the exact. - * - * @param exact the new exact - */ - public void setExact(final Boolean exact) { - this.exact = exact; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsFilter.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsFilter.java deleted file mode 100644 index 7d80d11587e..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsFilter.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryRelationsFilter. - */ -public class QueryRelationsFilter extends GenericModel { - - @SerializedName("relation_types") - private QueryFilterType relationTypes; - @SerializedName("entity_types") - private QueryFilterType entityTypes; - @SerializedName("document_ids") - private List documentIds; - - /** - * Gets the relationTypes. - * - * A list of relation types to include or exclude from the query. - * - * @return the relationTypes - */ - public QueryFilterType getRelationTypes() { - return relationTypes; - } - - /** - * Gets the entityTypes. - * - * A list of entity types to include or exclude from the query. - * - * @return the entityTypes - */ - public QueryFilterType getEntityTypes() { - return entityTypes; - } - - /** - * Gets the documentIds. - * - * A comma-separated list of document IDs to include in the query. - * - * @return the documentIds - */ - public List getDocumentIds() { - return documentIds; - } - - /** - * Sets the relationTypes. - * - * @param relationTypes the new relationTypes - */ - public void setRelationTypes(final QueryFilterType relationTypes) { - this.relationTypes = relationTypes; - } - - /** - * Sets the entityTypes. - * - * @param entityTypes the new entityTypes - */ - public void setEntityTypes(final QueryFilterType entityTypes) { - this.entityTypes = entityTypes; - } - - /** - * Sets the documentIds. - * - * @param documentIds the new documentIds - */ - public void setDocumentIds(final List documentIds) { - this.documentIds = documentIds; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsOptions.java deleted file mode 100644 index 3ace6ff4cfc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsOptions.java +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The queryRelations options. - */ -public class QueryRelationsOptions extends GenericModel { - - /** - * The sorting method for the relationships, can be `score` or `frequency`. `frequency` is the number of unique times - * each entity is identified. The default is `score`. - */ - public interface Sort { - /** score. */ - String SCORE = "score"; - /** frequency. */ - String FREQUENCY = "frequency"; - } - - private String environmentId; - private String collectionId; - private List entities; - private QueryEntitiesContext context; - private String sort; - private QueryRelationsFilter filter; - private Long count; - private Long evidenceCount; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private List entities; - private QueryEntitiesContext context; - private String sort; - private QueryRelationsFilter filter; - private Long count; - private Long evidenceCount; - - private Builder(QueryRelationsOptions queryRelationsOptions) { - environmentId = queryRelationsOptions.environmentId; - collectionId = queryRelationsOptions.collectionId; - entities = queryRelationsOptions.entities; - context = queryRelationsOptions.context; - sort = queryRelationsOptions.sort; - filter = queryRelationsOptions.filter; - count = queryRelationsOptions.count; - evidenceCount = queryRelationsOptions.evidenceCount; - } - - /** - * 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 QueryRelationsOptions. - * - * @return the queryRelationsOptions - */ - public QueryRelationsOptions build() { - return new QueryRelationsOptions(this); - } - - /** - * Adds an entities to entities. - * - * @param entities the new entities - * @return the QueryRelationsOptions builder - */ - public Builder addEntities(QueryRelationsEntity entities) { - Validator.notNull(entities, "entities cannot be null"); - if (this.entities == null) { - this.entities = new ArrayList(); - } - this.entities.add(entities); - return this; - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the QueryRelationsOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the collectionId. - * - * @param collectionId the collectionId - * @return the QueryRelationsOptions builder - */ - public Builder collectionId(String collectionId) { - this.collectionId = collectionId; - return this; - } - - /** - * Set the entities. - * Existing entities will be replaced. - * - * @param entities the entities - * @return the QueryRelationsOptions builder - */ - public Builder entities(List entities) { - this.entities = entities; - return this; - } - - /** - * Set the context. - * - * @param context the context - * @return the QueryRelationsOptions builder - */ - public Builder context(QueryEntitiesContext context) { - this.context = context; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the QueryRelationsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - - /** - * Set the filter. - * - * @param filter the filter - * @return the QueryRelationsOptions builder - */ - public Builder filter(QueryRelationsFilter filter) { - this.filter = filter; - return this; - } - - /** - * Set the count. - * - * @param count the count - * @return the QueryRelationsOptions builder - */ - public Builder count(long count) { - this.count = count; - return this; - } - - /** - * Set the evidenceCount. - * - * @param evidenceCount the evidenceCount - * @return the QueryRelationsOptions builder - */ - public Builder evidenceCount(long evidenceCount) { - this.evidenceCount = evidenceCount; - return this; - } - } - - private QueryRelationsOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - environmentId = builder.environmentId; - collectionId = builder.collectionId; - entities = builder.entities; - context = builder.context; - sort = builder.sort; - filter = builder.filter; - count = builder.count; - evidenceCount = builder.evidenceCount; - } - - /** - * New builder. - * - * @return a QueryRelationsOptions 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 entities. - * - * An array of entities to find relationships for. - * - * @return the entities - */ - public List entities() { - return entities; - } - - /** - * Gets the context. - * - * Entity text to provide context for the queried entity and rank based on that association. For example, if you - * wanted to query the city of London in England your query would look for `London` with the context of `England`. - * - * @return the context - */ - public QueryEntitiesContext context() { - return context; - } - - /** - * Gets the sort. - * - * The sorting method for the relationships, can be `score` or `frequency`. `frequency` is the number of unique times - * each entity is identified. The default is `score`. - * - * @return the sort - */ - public String sort() { - return sort; - } - - /** - * Gets the filter. - * - * Filters to apply to the relationship query. - * - * @return the filter - */ - public QueryRelationsFilter filter() { - return filter; - } - - /** - * Gets the count. - * - * The number of results to return. The default is `10`. The maximum is `1000`. - * - * @return the count - */ - public Long count() { - return count; - } - - /** - * Gets the evidenceCount. - * - * The number of evidence items to return for each result. The default is `0`. The maximum number of evidence items - * per query is 10,000. - * - * @return the evidenceCount - */ - public Long evidenceCount() { - return evidenceCount; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsRelationship.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsRelationship.java deleted file mode 100644 index bdb674f0587..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsRelationship.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryRelationsRelationship. - */ -public class QueryRelationsRelationship extends GenericModel { - - private String type; - private Long frequency; - private List arguments; - private List evidence; - - /** - * Gets the type. - * - * The identified relationship type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the frequency. - * - * The number of times the relationship is mentioned. - * - * @return the frequency - */ - public Long getFrequency() { - return frequency; - } - - /** - * Gets the arguments. - * - * Information about the relationship. - * - * @return the arguments - */ - public List getArguments() { - return arguments; - } - - /** - * Gets the evidence. - * - * List of different evidentiary items to support the result. - * - * @return the evidence - */ - public List getEvidence() { - return evidence; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsResponse.java deleted file mode 100644 index c9d1468599f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryRelationsResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * QueryRelationsResponse. - */ -public class QueryRelationsResponse extends GenericModel { - - private List relations; - - /** - * Gets the relations. - * - * @return the relations - */ - public List getRelations() { - return relations; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResponse.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResponse.java deleted file mode 100644 index 98a36790c8c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A response containing the documents and aggregations for the query. - */ -public class QueryResponse extends GenericModel { - - @SerializedName("matching_results") - private Long matchingResults; - private List results; - private List aggregations; - private List passages; - @SerializedName("duplicates_removed") - private Long duplicatesRemoved; - - /** - * Gets the matchingResults. - * - * @return the matchingResults - */ - public Long getMatchingResults() { - return matchingResults; - } - - /** - * Gets the results. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * Gets the aggregations. - * - * @return the aggregations - */ - public List getAggregations() { - return aggregations; - } - - /** - * Gets the passages. - * - * @return the passages - */ - public List getPassages() { - return passages; - } - - /** - * Gets the duplicatesRemoved. - * - * @return the duplicatesRemoved - */ - public Long getDuplicatesRemoved() { - return duplicatesRemoved; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResult.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResult.java deleted file mode 100644 index 227d06a97d6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResult.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.lang.reflect.Type; -import java.util.Map; - -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.service.model.DynamicModel; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; - -/** - * QueryResult. - */ -public class QueryResult extends DynamicModel { - private Type idType = new TypeToken() { - }.getType(); - private Type scoreType = new TypeToken() { - }.getType(); - private Type metadataType = new TypeToken() { - }.getType(); - private Type collectionIdType = new TypeToken() { - }.getType(); - private Type resultMetadataType = new TypeToken() { - }.getType(); - - /** - * Gets the id. - * - * @return the id - */ - public String getId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("id"), idType); - } - - /** - * Gets the score. - * - * @return the score - */ - public Double getScore() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("score"), scoreType); - } - - /** - * Gets the metadata. - * - * @return the metadata - */ - public Map getMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("metadata"), metadataType); - } - - /** - * Gets the collectionId. - * - * @return the collectionId - */ - public String getCollectionId() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("collection_id"), collectionIdType); - } - - /** - * Gets the resultMetadata. - * - * @return the resultMetadata - */ - public QueryResultResultMetadata getResultMetadata() { - return GsonSerializationHelper.serializeDynamicModelProperty(this.get("result_metadata"), resultMetadataType); - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResultResultMetadata.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResultResultMetadata.java deleted file mode 100644 index d5b602ed07a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/QueryResultResultMetadata.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Metadata of a query result. - */ -public class QueryResultResultMetadata extends GenericModel { - - private Double score; - - /** - * Gets the score. - * - * The confidence score of the result's analysis. A higher score indicating greater confidence. - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/SegmentSettings.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/SegmentSettings.java deleted file mode 100644 index 9e4c791b18a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/SegmentSettings.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A list of Document Segmentation settings. - */ -public class SegmentSettings extends GenericModel { - - private Boolean enabled; - @SerializedName("selector_tags") - private List selectorTags; - - /** - * Gets the enabled. - * - * Enables/disables the Document Segmentation feature. - * - * @return the enabled - */ - public Boolean isEnabled() { - return enabled; - } - - /** - * Gets the selectorTags. - * - * Defines the heading level that splits into document segments. Valid values are h1, h2, h3, h4, h5, h6. - * - * @return the selectorTags - */ - public List getSelectorTags() { - return selectorTags; - } - - /** - * Sets the enabled. - * - * @param enabled the new enabled - */ - public void setEnabled(final Boolean enabled) { - this.enabled = enabled; - } - - /** - * Sets the selectorTags. - * - * @param selectorTags the new selectorTags - */ - public void setSelectorTags(final List selectorTags) { - this.selectorTags = selectorTags; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Term.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Term.java deleted file mode 100644 index c9109a4581f..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Term.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Term. - */ -public class Term extends QueryAggregation { - - private String field; - private 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. - * - * @return the count - */ - public Long getCount() { - return count; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestConfigurationInEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestConfigurationInEnvironmentOptions.java deleted file mode 100644 index ae0368d4e4c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestConfigurationInEnvironmentOptions.java +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The testConfigurationInEnvironment options. - */ -public class TestConfigurationInEnvironmentOptions extends GenericModel { - - /** - * Specify to only run the input document through the given step instead of running the input document through the - * entire ingestion workflow. Valid values are `convert`, `enrich`, and `normalize`. - */ - public interface Step { - /** html_input. */ - String HTML_INPUT = "html_input"; - /** html_output. */ - String HTML_OUTPUT = "html_output"; - /** json_output. */ - String JSON_OUTPUT = "json_output"; - /** json_normalizations_output. */ - String JSON_NORMALIZATIONS_OUTPUT = "json_normalizations_output"; - /** enrichments_output. */ - String ENRICHMENTS_OUTPUT = "enrichments_output"; - /** normalizations_output. */ - String NORMALIZATIONS_OUTPUT = "normalizations_output"; - } - - private String environmentId; - private String configuration; - private String step; - private String configurationId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String configuration; - private String step; - private String configurationId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - private Builder(TestConfigurationInEnvironmentOptions testConfigurationInEnvironmentOptions) { - environmentId = testConfigurationInEnvironmentOptions.environmentId; - configuration = testConfigurationInEnvironmentOptions.configuration; - step = testConfigurationInEnvironmentOptions.step; - configurationId = testConfigurationInEnvironmentOptions.configurationId; - file = testConfigurationInEnvironmentOptions.file; - filename = testConfigurationInEnvironmentOptions.filename; - metadata = testConfigurationInEnvironmentOptions.metadata; - fileContentType = testConfigurationInEnvironmentOptions.fileContentType; - } - - /** - * 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 TestConfigurationInEnvironmentOptions. - * - * @return the testConfigurationInEnvironmentOptions - */ - public TestConfigurationInEnvironmentOptions build() { - return new TestConfigurationInEnvironmentOptions(this); - } - - /** - * Set the environmentId. - * - * @param environmentId the environmentId - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder environmentId(String environmentId) { - this.environmentId = environmentId; - return this; - } - - /** - * Set the configuration. - * - * @param configuration the configuration - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder configuration(String configuration) { - this.configuration = configuration; - return this; - } - - /** - * Set the step. - * - * @param step the step - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder step(String step) { - this.step = step; - return this; - } - - /** - * Set the configurationId. - * - * @param configurationId the configurationId - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder configurationId(String configurationId) { - this.configurationId = configurationId; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder file(InputStream file) { - this.file = file; - return this; - } - - /** - * Set the filename. - * - * @param filename the filename - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder filename(String filename) { - this.filename = filename; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder metadata(String metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the fileContentType. - * - * @param fileContentType the fileContentType - * @return the TestConfigurationInEnvironmentOptions builder - */ - public Builder fileContentType(String fileContentType) { - this.fileContentType = fileContentType; - return this; - } - - /** - * Set the file. - * - * @param file the file - * @return the TestConfigurationInEnvironmentOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder file(File file) throws FileNotFoundException { - this.file = new FileInputStream(file); - this.filename = file.getName(); - return this; - } - } - - private TestConfigurationInEnvironmentOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.isTrue((builder.file == null) || (builder.filename != null), - "filename cannot be null if file is not null."); - environmentId = builder.environmentId; - configuration = builder.configuration; - step = builder.step; - configurationId = builder.configurationId; - file = builder.file; - filename = builder.filename; - metadata = builder.metadata; - fileContentType = builder.fileContentType; - } - - /** - * New builder. - * - * @return a TestConfigurationInEnvironmentOptions 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 configuration. - * - * The configuration to use to process the document. If this part is provided, then the provided configuration is used - * to process the document. If the `configuration_id` is also provided (both are present at the same time), then - * request is rejected. The maximum supported configuration size is 1 MB. Configuration parts larger than 1 MB are - * rejected. - * See the `GET /configurations/{configuration_id}` operation for an example configuration. - * - * @return the configuration - */ - public String configuration() { - return configuration; - } - - /** - * Gets the step. - * - * Specify to only run the input document through the given step instead of running the input document through the - * entire ingestion workflow. Valid values are `convert`, `enrich`, and `normalize`. - * - * @return the step - */ - public String step() { - return step; - } - - /** - * Gets the configurationId. - * - * The ID of the configuration to use to process the document. If the `configuration` form part is also provided (both - * are present at the same time), then request will be rejected. - * - * @return the configurationId - */ - public String configurationId() { - return configurationId; - } - - /** - * Gets the file. - * - * The content of the document to ingest. The maximum supported file size is 50 megabytes. Files larger than 50 - * megabytes is 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 metadata. - * - * If you're using the Data Crawler to upload your documents, you can test a document against the type of metadata - * that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB - * are rejected. - * Example: ``` { - * "Creator": "Johnny Appleseed", - * "Subject": "Apples" - * } ```. - * - * @return the metadata - */ - public String metadata() { - return metadata; - } - - /** - * Gets the 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestDocument.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestDocument.java deleted file mode 100644 index 8506e170b05..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TestDocument.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TestDocument. - */ -public class TestDocument extends GenericModel { - - @SerializedName("configuration_id") - private String configurationId; - private String status; - @SerializedName("enriched_field_units") - private Long enrichedFieldUnits; - @SerializedName("original_media_type") - private String originalMediaType; - private List snapshots; - private 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 preview operation. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the enrichedFieldUnits. - * - * The number of 10-kB chunks of field data that were enriched. This can be used to estimate the cost of running a - * real ingestion. - * - * @return the enrichedFieldUnits - */ - public Long getEnrichedFieldUnits() { - return enrichedFieldUnits; - } - - /** - * Gets the originalMediaType. - * - * Format of the test document. - * - * @return the originalMediaType - */ - public String getOriginalMediaType() { - return originalMediaType; - } - - /** - * Gets the snapshots. - * - * An array of objects that describe each step in the preview process. - * - * @return the snapshots - */ - public List getSnapshots() { - return snapshots; - } - - /** - * Gets the notices. - * - * An array of notice messages about the preview operation. - * - * @return the notices - */ - public List getNotices() { - return notices; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Timeslice.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Timeslice.java deleted file mode 100644 index 939d50e4425..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/Timeslice.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * Timeslice. - */ -public class Timeslice extends QueryAggregation { - - private String field; - private String interval; - private 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 inducate 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/developer_cloud/discovery/v1/model/TopHits.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TopHits.java deleted file mode 100644 index 8ae487143d3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TopHits.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -/** - * TopHits. - */ -public class TopHits extends QueryAggregation { - - private Long size; - private 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/developer_cloud/discovery/v1/model/TopHitsResults.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TopHitsResults.java deleted file mode 100644 index ee7688eecc6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TopHitsResults.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TopHitsResults. - */ -public class TopHitsResults extends GenericModel { - - @SerializedName("matching_results") - private Long matchingResults; - private 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/developer_cloud/discovery/v1/model/TrainingDataSet.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingDataSet.java deleted file mode 100644 index 1e77256717b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingDataSet.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TrainingDataSet. - */ -public class TrainingDataSet extends GenericModel { - - @SerializedName("environment_id") - private String environmentId; - @SerializedName("collection_id") - private String collectionId; - private List queries; - - /** - * Gets the environmentId. - * - * @return the environmentId - */ - public String getEnvironmentId() { - return environmentId; - } - - /** - * Gets the collectionId. - * - * @return the collectionId - */ - public String getCollectionId() { - return collectionId; - } - - /** - * Gets the queries. - * - * @return the queries - */ - public List getQueries() { - return queries; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExample.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExample.java deleted file mode 100644 index d8cc9670676..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExample.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TrainingExample. - */ -public class TrainingExample extends GenericModel { - - @SerializedName("document_id") - private String documentId; - @SerializedName("cross_reference") - private String crossReference; - private Long relevance; - - /** - * Gets the documentId. - * - * @return the documentId - */ - public String getDocumentId() { - return documentId; - } - - /** - * Gets the crossReference. - * - * @return the crossReference - */ - public String getCrossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * @return the relevance - */ - public Long getRelevance() { - return relevance; - } - - /** - * Sets the documentId. - * - * @param documentId the new documentId - */ - public void setDocumentId(final String documentId) { - this.documentId = documentId; - } - - /** - * Sets the crossReference. - * - * @param crossReference the new crossReference - */ - public void setCrossReference(final String crossReference) { - this.crossReference = crossReference; - } - - /** - * Sets the relevance. - * - * @param relevance the new relevance - */ - public void setRelevance(final long relevance) { - this.relevance = relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExampleList.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExampleList.java deleted file mode 100644 index cc86620028c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingExampleList.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TrainingExampleList. - */ -public class TrainingExampleList extends GenericModel { - - private List examples; - - /** - * Gets the examples. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingQuery.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingQuery.java deleted file mode 100644 index 48e3db86bbc..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingQuery.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TrainingQuery. - */ -public class TrainingQuery extends GenericModel { - - @SerializedName("query_id") - private String queryId; - @SerializedName("natural_language_query") - private String naturalLanguageQuery; - private String filter; - private List examples; - - /** - * Gets the queryId. - * - * @return the queryId - */ - public String getQueryId() { - return queryId; - } - - /** - * Gets the naturalLanguageQuery. - * - * @return the naturalLanguageQuery - */ - public String getNaturalLanguageQuery() { - return naturalLanguageQuery; - } - - /** - * Gets the filter. - * - * @return the filter - */ - public String getFilter() { - return filter; - } - - /** - * Gets the examples. - * - * @return the examples - */ - public List getExamples() { - return examples; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingStatus.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingStatus.java deleted file mode 100644 index c8038818add..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/TrainingStatus.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TrainingStatus. - */ -public class TrainingStatus extends GenericModel { - - @SerializedName("total_examples") - private Long totalExamples; - private Boolean available; - private Boolean processing; - @SerializedName("minimum_queries_added") - private Boolean minimumQueriesAdded; - @SerializedName("minimum_examples_added") - private Boolean minimumExamplesAdded; - @SerializedName("sufficient_label_diversity") - private Boolean sufficientLabelDiversity; - private Long notices; - @SerializedName("successfully_trained") - private Date successfullyTrained; - @SerializedName("data_updated") - private Date dataUpdated; - - /** - * Gets the totalExamples. - * - * @return the totalExamples - */ - public Long getTotalExamples() { - return totalExamples; - } - - /** - * Gets the available. - * - * @return the available - */ - public Boolean isAvailable() { - return available; - } - - /** - * Gets the processing. - * - * @return the processing - */ - public Boolean isProcessing() { - return processing; - } - - /** - * Gets the minimumQueriesAdded. - * - * @return the minimumQueriesAdded - */ - public Boolean isMinimumQueriesAdded() { - return minimumQueriesAdded; - } - - /** - * Gets the minimumExamplesAdded. - * - * @return the minimumExamplesAdded - */ - public Boolean isMinimumExamplesAdded() { - return minimumExamplesAdded; - } - - /** - * Gets the sufficientLabelDiversity. - * - * @return the sufficientLabelDiversity - */ - public Boolean isSufficientLabelDiversity() { - return sufficientLabelDiversity; - } - - /** - * Gets the notices. - * - * @return the notices - */ - public Long getNotices() { - return notices; - } - - /** - * Gets the successfullyTrained. - * - * @return the successfullyTrained - */ - public Date getSuccessfullyTrained() { - return successfullyTrained; - } - - /** - * Gets the dataUpdated. - * - * @return the dataUpdated - */ - public Date getDataUpdated() { - return dataUpdated; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateCollectionOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateCollectionOptions.java deleted file mode 100644 index f40803cd6f7..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateCollectionOptions.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateCollection options. - */ -public class UpdateCollectionOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String name; - private String description; - private 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) { - environmentId = updateCollectionOptions.environmentId; - collectionId = updateCollectionOptions.collectionId; - name = updateCollectionOptions.name; - description = updateCollectionOptions.description; - configurationId = updateCollectionOptions.configurationId; - } - - /** - * 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 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; - } - } - - private UpdateCollectionOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - 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/developer_cloud/discovery/v1/model/UpdateConfigurationOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateConfigurationOptions.java deleted file mode 100644 index 26fedc161e3..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateConfigurationOptions.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateConfiguration options. - */ -public class UpdateConfigurationOptions extends GenericModel { - - private String environmentId; - private String configurationId; - private String name; - private String description; - private Conversions conversions; - private List enrichments; - private List normalizations; - - /** - * 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 Builder(UpdateConfigurationOptions updateConfigurationOptions) { - environmentId = updateConfigurationOptions.environmentId; - configurationId = updateConfigurationOptions.configurationId; - name = updateConfigurationOptions.name; - description = updateConfigurationOptions.description; - conversions = updateConfigurationOptions.conversions; - enrichments = updateConfigurationOptions.enrichments; - normalizations = updateConfigurationOptions.normalizations; - } - - /** - * 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 UpdateConfigurationOptions. - * - * @return the updateConfigurationOptions - */ - public UpdateConfigurationOptions build() { - return new UpdateConfigurationOptions(this); - } - - /** - * Adds an enrichments to enrichments. - * - * @param enrichments the new enrichments - * @return the UpdateConfigurationOptions builder - */ - public Builder addEnrichments(Enrichment enrichments) { - Validator.notNull(enrichments, "enrichments cannot be null"); - if (this.enrichments == null) { - this.enrichments = new ArrayList(); - } - this.enrichments.add(enrichments); - return this; - } - - /** - * Adds an normalizations to normalizations. - * - * @param normalizations the new normalizations - * @return the UpdateConfigurationOptions builder - */ - public Builder addNormalizations(NormalizationOperation normalizations) { - Validator.notNull(normalizations, "normalizations cannot be null"); - if (this.normalizations == null) { - this.normalizations = new ArrayList(); - } - this.normalizations.add(normalizations); - 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 configuration. - * - * @param configuration the configuration - * @return the UpdateConfigurationOptions builder - */ - public Builder configuration(Configuration configuration) { - this.name = configuration.getName(); - this.description = configuration.getDescription(); - this.conversions = configuration.getConversions(); - this.enrichments = configuration.getEnrichments(); - this.normalizations = configuration.getNormalizations(); - return this; - } - } - - private UpdateConfigurationOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.configurationId, "configurationId cannot be empty"); - environmentId = builder.environmentId; - configurationId = builder.configurationId; - name = builder.name; - description = builder.description; - conversions = builder.conversions; - enrichments = builder.enrichments; - normalizations = builder.normalizations; - } - - /** - * 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. - * - * The document conversion settings for the configuration. - * - * @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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateDocumentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateDocumentOptions.java deleted file mode 100644 index e9d4cfdbe2b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateDocumentOptions.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateDocument options. - */ -public class UpdateDocumentOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String documentId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String collectionId; - private String documentId; - private InputStream file; - private String filename; - private String metadata; - private String fileContentType; - - private Builder(UpdateDocumentOptions updateDocumentOptions) { - environmentId = updateDocumentOptions.environmentId; - collectionId = updateDocumentOptions.collectionId; - documentId = updateDocumentOptions.documentId; - file = updateDocumentOptions.file; - filename = updateDocumentOptions.filename; - metadata = updateDocumentOptions.metadata; - fileContentType = updateDocumentOptions.fileContentType; - } - - /** - * 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 metadata. - * - * @param metadata the metadata - * @return the UpdateDocumentOptions builder - */ - public Builder metadata(String metadata) { - this.metadata = metadata; - 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 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; - } - } - - private UpdateDocumentOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - Validator.notEmpty(builder.documentId, "documentId cannot be empty"); - 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; - metadata = builder.metadata; - fileContentType = builder.fileContentType; - } - - /** - * 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 is 50 megabytes. Files larger than 50 - * megabytes is 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 metadata. - * - * If you're using the Data Crawler to upload your documents, you can test a document against the type of metadata - * that the Data Crawler might send. The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 MB - * are rejected. - * Example: ``` { - * "Creator": "Johnny Appleseed", - * "Subject": "Apples" - * } ```. - * - * @return the metadata - */ - public String metadata() { - return metadata; - } - - /** - * Gets the 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateEnvironmentOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateEnvironmentOptions.java deleted file mode 100644 index ecc95f7d6a6..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateEnvironmentOptions.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateEnvironment options. - */ -public class UpdateEnvironmentOptions extends GenericModel { - - private String environmentId; - private String name; - private String description; - - /** - * Builder. - */ - public static class Builder { - private String environmentId; - private String name; - private String description; - - private Builder(UpdateEnvironmentOptions updateEnvironmentOptions) { - environmentId = updateEnvironmentOptions.environmentId; - name = updateEnvironmentOptions.name; - description = updateEnvironmentOptions.description; - } - - /** - * 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; - } - } - - private UpdateEnvironmentOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - environmentId = builder.environmentId; - name = builder.name; - description = builder.description; - } - - /** - * 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; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateTrainingExampleOptions.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateTrainingExampleOptions.java deleted file mode 100644 index 11a6449b92b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/UpdateTrainingExampleOptions.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateTrainingExample options. - */ -public class UpdateTrainingExampleOptions extends GenericModel { - - private String environmentId; - private String collectionId; - private String queryId; - private String exampleId; - private String crossReference; - private 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) { - environmentId = updateTrainingExampleOptions.environmentId; - collectionId = updateTrainingExampleOptions.collectionId; - queryId = updateTrainingExampleOptions.queryId; - exampleId = updateTrainingExampleOptions.exampleId; - crossReference = updateTrainingExampleOptions.crossReference; - 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; - } - } - - private UpdateTrainingExampleOptions(Builder builder) { - Validator.notEmpty(builder.environmentId, "environmentId cannot be empty"); - Validator.notEmpty(builder.collectionId, "collectionId cannot be empty"); - Validator.notEmpty(builder.queryId, "queryId cannot be empty"); - 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. - * - * @return the crossReference - */ - public String crossReference() { - return crossReference; - } - - /** - * Gets the relevance. - * - * @return the relevance - */ - public Long relevance() { - return relevance; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordHeadingDetection.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordHeadingDetection.java deleted file mode 100644 index 0244be3ca2c..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordHeadingDetection.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WordHeadingDetection. - */ -public class WordHeadingDetection extends GenericModel { - - private List fonts; - private List styles; - - /** - * Gets the fonts. - * - * @return the fonts - */ - public List getFonts() { - return fonts; - } - - /** - * Gets the styles. - * - * @return the styles - */ - public List getStyles() { - return styles; - } - - /** - * Sets the fonts. - * - * @param fonts the new fonts - */ - public void setFonts(final List fonts) { - this.fonts = fonts; - } - - /** - * Sets the styles. - * - * @param styles the new styles - */ - public void setStyles(final List styles) { - this.styles = styles; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordSettings.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordSettings.java deleted file mode 100644 index 4b351a6e20a..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordSettings.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A list of Word conversion settings. - */ -public class WordSettings extends GenericModel { - - private WordHeadingDetection heading; - - /** - * Gets the heading. - * - * @return the heading - */ - public WordHeadingDetection getHeading() { - return heading; - } - - /** - * Sets the heading. - * - * @param heading the new heading - */ - public void setHeading(final WordHeadingDetection heading) { - this.heading = heading; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordStyle.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordStyle.java deleted file mode 100644 index 8ddf1fb8ea0..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/WordStyle.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WordStyle. - */ -public class WordStyle extends GenericModel { - - private Long level; - private List names; - - /** - * Gets the level. - * - * @return the level - */ - public Long getLevel() { - return level; - } - - /** - * Gets the names. - * - * @return the names - */ - public List getNames() { - return names; - } - - /** - * Sets the level. - * - * @param level the new level - */ - public void setLevel(final long level) { - this.level = level; - } - - /** - * Sets the names. - * - * @param names the new names - */ - public void setNames(final List names) { - this.names = names; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/XPathPatterns.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/XPathPatterns.java deleted file mode 100644 index 194ab57cdfa..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/model/XPathPatterns.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * XPathPatterns. - */ -public class XPathPatterns extends GenericModel { - - private List xpaths; - - /** - * Gets the xpaths. - * - * @return the xpaths - */ - public List getXpaths() { - return xpaths; - } - - /** - * Sets the xpaths. - * - * @param xpaths the new xpaths - */ - public void setXpaths(final List xpaths) { - this.xpaths = xpaths; - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/package-info.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/package-info.java deleted file mode 100644 index fb67d3822ae..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.discovery.v1; diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationDeserializer.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationDeserializer.java deleted file mode 100644 index 139e11d046b..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationDeserializer.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.discovery.v1.query; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonParseException; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.ibm.watson.developer_cloud.discovery.v1.model.Calculation; -import com.ibm.watson.developer_cloud.discovery.v1.model.Filter; -import com.ibm.watson.developer_cloud.discovery.v1.model.Histogram; -import com.ibm.watson.developer_cloud.discovery.v1.model.Nested; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryAggregation; -import com.ibm.watson.developer_cloud.discovery.v1.model.Term; -import com.ibm.watson.developer_cloud.discovery.v1.model.Timeslice; -import com.ibm.watson.developer_cloud.discovery.v1.model.TopHits; -import com.ibm.watson.developer_cloud.util.GsonSerializationHelper; -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -/** - * Deserializer to transform JSON into a {@link QueryAggregation}. - */ -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 { - JsonReader in = new JsonReader(new StringReader(GsonSingleton.getGson().toJson(json))); - HashMap aggregationMap = null; - - try { - aggregationMap = getAggregationMap(in); - } catch (IOException e) { - e.printStackTrace(); - } - - QueryAggregation aggregation; - String aggregationType = (String) aggregationMap.get(TYPE); - - if (aggregationType.equals(AggregationType.HISTOGRAM.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, 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 = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Calculation.class); - } else if (aggregationType.equals(AggregationType.TERM.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Term.class); - } else if (aggregationType.equals(AggregationType.FILTER.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Filter.class); - } else if (aggregationType.equals(AggregationType.NESTED.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Nested.class); - } else if (aggregationType.equals(AggregationType.TIMESLICE.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, Timeslice.class); - } else if (aggregationType.equals(AggregationType.TOP_HITS.getName())) { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, TopHits.class); - } else { - aggregation = GsonSerializationHelper.serializeDynamicModelProperty(aggregationMap, QueryAggregation.class); - } - - return aggregation; - } - - /** - * Converts JSON into a Map representing a {@link QueryAggregation} object. - * - * @param in {@link JsonReader} object used for parsing - * @return Map representing the {@link QueryAggregation} object - * @throws IOException signals that there has been an IO exception - */ - private HashMap getAggregationMap(JsonReader in) throws IOException { - HashMap objMap = new HashMap<>(); - while (in.peek() != JsonToken.END_DOCUMENT) { - parseNext(in, objMap); - } - return objMap; - } - - /** - * Checks the next {@link JsonToken} to decide the next appropriate parsing method. - * - * @param in {@link JsonReader} object used for parsing - * @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object - * @throws IOException signals that there has been an IO exception - */ - private void parseNext(JsonReader in, HashMap objMap) throws IOException { - JsonToken token = in.peek(); - - String lastName = ""; - if (token == JsonToken.NAME) { - lastName = in.nextName(); - token = in.peek(); - } - - switch (token) { - case BEGIN_ARRAY: - parseArray(in, objMap, lastName); - break; - case BEGIN_OBJECT: - parseObject(in, objMap, lastName); - break; - case STRING: - objMap.put(lastName, in.nextString()); - break; - case NUMBER: - objMap.put(lastName, in.nextDouble()); - break; - case BOOLEAN: - objMap.put(lastName, in.nextBoolean()); - break; - default: - throw new IOException("Unexpected JSON token encountered"); - } - - collapseMap(objMap); - } - - /** - * Parses a JSON array and adds it to the main object map. - * - * @param in {@link JsonReader} object used for parsing - * @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object - * @param name key value to go with the resulting value of this method pass - * @throws IOException signals that there has been an IO exception - */ - private void parseArray(JsonReader in, HashMap objMap, String name) throws IOException { - List> array = new ArrayList<>(); - in.beginArray(); - - while (in.peek() != JsonToken.END_ARRAY) { - HashMap arrayItem = new HashMap<>(); - parseNext(in, arrayItem); - array.add(arrayItem); - } - - in.endArray(); - objMap.put(name, array); - } - - /** - * Parses a JSON object and adds it to the main object map. - * - * @param in {@link JsonReader} object used for parsing - * @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object - * @param name key value to go with the resulting value of this method pass - * @throws IOException signals that there has been an IO exception - */ - private void parseObject(JsonReader in, HashMap objMap, String name) throws IOException { - HashMap innerObject = new HashMap<>(); - in.beginObject(); - - while (in.peek() != JsonToken.END_OBJECT) { - parseNext(in, innerObject); - } - - in.endObject(); - objMap.put(name, innerObject); - } - - /** - * Condenses the main object map to eliminate unnecessary nesting and allow for proper type conversion when the map - * is complete. - * - * @param objMap Map used to build the structure for the resulting {@link QueryAggregation} object - */ - private void collapseMap(HashMap objMap) { - while (objMap.keySet().size() == 1 && objMap.keySet().contains("")) { - HashMap innerMap = (HashMap) objMap.get(""); - objMap.clear(); - objMap.putAll(innerMap); - } - } -} diff --git a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationType.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationType.java deleted file mode 100644 index 5ee9fb622be..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/AggregationType.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.discovery.v1.query; - -/** - * 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"); - - 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/developer_cloud/discovery/v1/query/Operator.java b/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/Operator.java deleted file mode 100644 index 6928f720223..00000000000 --- a/discovery/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/query/Operator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.discovery.v1.query; - -/** - * 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("\""); - - 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/query/AggregationType.java b/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java new file mode 100644 index 00000000000..2a239269e0e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/query/AggregationType.java @@ -0,0 +1,96 @@ +/* + * (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.query; + +/** Aggregation types. */ +public enum AggregationType { + + /** 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)) { + return aggregationType; + } + } + 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 new file mode 100644 index 00000000000..df973a97fea --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/query/Operator.java @@ -0,0 +1,128 @@ +/* + * (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.query; + +/** Query Language Operator Syntax. */ +public enum Operator { + + /** 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/v2/Discovery.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java new file mode 100644 index 00000000000..9d270fc962d --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/Discovery.java @@ -0,0 +1,2461 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT 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; +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.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&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. + * + *

API Version: 2.0 See: https://cloud.ibm.com/docs/discovery-data + */ +public class Discovery extends BaseService { + + /** Default service name used when configuring the `Discovery` client. */ + public static final String DEFAULT_SERVICE_NAME = "discovery"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.discovery.watson.cloud.ibm.com"; + + private String version; + + /** + * Constructs an instance of the `Discovery` client. The default service name is used to configure + * the client instance. + * + * @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 version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + } + + /** + * Constructs an instance of the `Discovery` client. The default service name and specified + * authenticator are used to configure the client instance. + * + * @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 version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `Discovery` client. The specified service name is used to + * configure the client instance. + * + * @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 version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `Discovery` client. The specified service name and authenticator + * are used to configure the client instance. + * + * @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 version, String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + setVersion(version); + this.configureService(serviceName); + } + + /** + * Gets the 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`. + * + * @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; + } + + /** + * 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"); + builder.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List projects. + * + *

Lists existing projects for this instance. + * + * @return a {@link ServiceCall} with a result of type {@link ListProjectsResponse} + */ + 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(); + 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())); + } + 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()); + } + 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()); + } + 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()); + } + 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()); + } + 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()); + } + builder.header("Accept", "application/json"); + builder.query("version", String.valueOf(this.version)); + if (listFieldsOptions.collectionIds() != null) { + builder.query("collection_ids", RequestUtils.join(listFieldsOptions.collectionIds(), ",")); + } + 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()); + } + 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()); + } + 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 (createCollectionOptions.language() != null) { + contentJson.addProperty("language", createCollectionOptions.language()); + } + if (createCollectionOptions.ocrEnabled() != null) { + contentJson.addProperty("ocr_enabled", createCollectionOptions.ocrEnabled()); + } + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get collection details. + * + *

Get details about the specified collection. + * + * @param getCollectionOptions the {@link GetCollectionOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link CollectionDetails} + */ + 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("version", String.valueOf(this.version)); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Update a collection. + * + *

Updates the specified collection's name, description, enrichments, and configuration. + * + *

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 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"); + builder.query("version", String.valueOf(this.version)); + final JsonObject contentJson = new JsonObject(); + if (updateCollectionOptions.name() != null) { + contentJson.addProperty("name", updateCollectionOptions.name()); + } + if (updateCollectionOptions.description() != null) { + contentJson.addProperty("description", updateCollectionOptions.description()); + } + if (updateCollectionOptions.ocrEnabled() != null) { + contentJson.addProperty("ocr_enabled", updateCollectionOptions.ocrEnabled()); + } + if (updateCollectionOptions.enrichments() != null) { + contentJson.add( + "enrichments", + com.ibm.cloud.sdk.core.util.GsonSingleton.getGson() + .toJsonTree(updateCollectionOptions.enrichments())); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = + ResponseConverterUtils.getValue( + new com.google.gson.reflect.TypeToken() {}.getType()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a collection. + * + *

Deletes the specified collection from the project. All documents stored in the specified + * collection and not shared is also deleted. + * + * @param deleteCollectionOptions the {@link DeleteCollectionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result + */ + 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.query("version", String.valueOf(this.version)); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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. + * + *

**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 listDocumentsOptions the {@link ListDocumentsOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link ListDocumentsResponse} + */ + 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"); + 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. + * + *

Use this method to upload a file to the collection. You cannot use this method to crawl an + * external data source. + * + *

* For a list of supported file types, see the [product + * documentation](/docs/discovery-data?topic=discovery-data-collections#supportedfiletypes). + * + *

* You must provide document content, metadata, or both. If the request is missing both + * document content and metadata, it is rejected. + * + *

* 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 shares its data with another collection, + * the **X-Watson-Discovery-Force** header must be set to `true`. + * + *

* 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. + * + *

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 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."); + 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()); + } + builder.header("Accept", "application/json"); + 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()); + 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. + * + *

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. + * + *

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`. + * + *

**Notes:** + * + *

* Uploading a new document with this method automatically replaces any existing document + * stored with the same document ID. + * + *

* 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 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."); + 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()); + } + builder.header("Accept", "application/json"); + 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()); + 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. + * + *

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:** 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. + * + *

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"); + 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()); + } + builder.header("Accept", "application/json"); + if (deleteDocumentOptions.xWatsonDiscoveryForce() != null) { + builder.header("X-Watson-Discovery-Force", deleteDocumentOptions.xWatsonDiscoveryForce()); + } + 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. + * + *

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. + * + *

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 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"); + 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); + } + + /** + * Get Autocomplete Suggestions. + * + *

Returns completion query suggestions for the specified prefix. + * + *

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 getAutocompletionOptions the {@link GetAutocompletionOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link Completions} + */ + 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()); + } + 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); + } + + /** + * Query collection notices. + * + *

Finds collection-level notices (errors and warnings) that are generated when documents are + * ingested. + * + * @param queryCollectionNoticesOptions the {@link QueryCollectionNoticesOptions} containing the + * options for the call + * @return a {@link ServiceCall} with a result of type {@link QueryNoticesResponse} + */ + 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"); + builder.query("version", String.valueOf(this.version)); + if (queryCollectionNoticesOptions.filter() != null) { + builder.query("filter", String.valueOf(queryCollectionNoticesOptions.filter())); + } + 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. + * + * @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"); + 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"); + 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 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 result of type {@link TrainingQuery} + */ + 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())); + if (updateTrainingQueryOptions.filter() != null) { + contentJson.addProperty("filter", updateTrainingQueryOptions.filter()); + } + builder.bodyJson(contentJson); + 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 new file mode 100644 index 00000000000..82086ad0529 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/AddDocumentOptions.java @@ -0,0 +1,292 @@ +/* + * (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.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 addDocument options. */ +public class AddDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected InputStream file; + protected String filename; + protected String fileContentType; + protected String metadata; + protected Boolean xWatsonDiscoveryForce; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private InputStream file; + private String filename; + private String fileContentType; + private String metadata; + private Boolean xWatsonDiscoveryForce; + + /** + * 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; + this.file = addDocumentOptions.file; + this.filename = addDocumentOptions.filename; + this.fileContentType = addDocumentOptions.fileContentType; + this.metadata = addDocumentOptions.metadata; + this.xWatsonDiscoveryForce = addDocumentOptions.xWatsonDiscoveryForce; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param collectionId the collectionId + */ + public Builder(String projectId, String collectionId) { + this.projectId = projectId; + this.collectionId = collectionId; + } + + /** + * Builds a AddDocumentOptions. + * + * @return the new AddDocumentOptions instance + */ + public AddDocumentOptions build() { + return new AddDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the AddDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionId. + * + * @param collectionId the collectionId + * @return the AddDocumentOptions builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AddDocumentOptions builder + */ + public Builder file(InputStream file) { + this.file = file; + return this; + } + + /** + * Set the filename. + * + * @param filename the filename + * @return the AddDocumentOptions builder + */ + public Builder filename(String filename) { + this.filename = filename; + return this; + } + + /** + * Set the fileContentType. + * + * @param fileContentType the fileContentType + * @return the AddDocumentOptions builder + */ + public Builder fileContentType(String fileContentType) { + this.fileContentType = fileContentType; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the AddDocumentOptions builder + */ + public Builder metadata(String metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the xWatsonDiscoveryForce. + * + * @param xWatsonDiscoveryForce the xWatsonDiscoveryForce + * @return the AddDocumentOptions builder + */ + public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { + this.xWatsonDiscoveryForce = xWatsonDiscoveryForce; + return this; + } + + /** + * Set the file. + * + * @param file the file + * @return the AddDocumentOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder file(File file) throws FileNotFoundException { + this.file = new FileInputStream(file); + this.filename = file.getName(); + return this; + } + } + + 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), + "filename cannot be null if file is not null."); + projectId = builder.projectId; + collectionId = builder.collectionId; + file = builder.file; + filename = builder.filename; + fileContentType = builder.fileContentType; + metadata = builder.metadata; + xWatsonDiscoveryForce = builder.xWatsonDiscoveryForce; + } + + /** + * New builder. + * + * @return a AddDocumentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the projectId. + * + *

The 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; + } + + /** + * Gets the xWatsonDiscoveryForce. + * + *

When `true`, the uploaded document is added to the collection even if the data for that + * collection is shared with other collections. + * + * @return the xWatsonDiscoveryForce + */ + public Boolean xWatsonDiscoveryForce() { + return xWatsonDiscoveryForce; + } +} 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 new file mode 100644 index 00000000000..e437c863f71 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Collection.java @@ -0,0 +1,50 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** A collection for storing documents. */ +public class Collection extends GenericModel { + + @SerializedName("collection_id") + protected String collectionId; + + protected String name; + + protected Collection() {} + + /** + * Gets the collectionId. + * + *

The Universally Unique Identifier (UUID) 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; + } +} 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 new file mode 100644 index 00000000000..0e1594f5989 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Completions.java @@ -0,0 +1,36 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** An object that contains an array of autocompletion suggestions. */ +public class Completions extends GenericModel { + + protected List completions; + + protected Completions() {} + + /** + * Gets the completions. + * + *

Array of autocomplete 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/v2/model/ComponentSettingsAggregation.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java new file mode 100644 index 00000000000..02b08751108 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsAggregation.java @@ -0,0 +1,88 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Display settings for aggregations. */ +public class ComponentSettingsAggregation extends GenericModel { + + /** Type of visualization to use when rendering the aggregation. */ + public interface VisualizationType { + /** auto. */ + String AUTO = "auto"; + /** facet_table. */ + String FACET_TABLE = "facet_table"; + /** word_cloud. */ + String WORD_CLOUD = "word_cloud"; + /** map. */ + String MAP = "map"; + } + + 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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the label. + * + *

User-friendly alias for the aggregation. + * + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * Gets the multipleSelectionsAllowed. + * + *

Whether users is allowed to select more than one of the aggregation terms. + * + * @return the multipleSelectionsAllowed + */ + public Boolean isMultipleSelectionsAllowed() { + return multipleSelectionsAllowed; + } + + /** + * Gets the visualizationType. + * + *

Type of visualization to use when rendering the aggregation. + * + * @return the visualizationType + */ + public String getVisualizationType() { + return 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 new file mode 100644 index 00000000000..ffda748e931 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShown.java @@ -0,0 +1,47 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the body + */ + public ComponentSettingsFieldsShownBody getBody() { + return body; + } + + /** + * Gets the title. + * + *

Title label. + * + * @return the title + */ + public ComponentSettingsFieldsShownTitle getTitle() { + return 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 new file mode 100644 index 00000000000..b9378decc55 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownBody.java @@ -0,0 +1,50 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the usePassage + */ + public Boolean isUsePassage() { + return usePassage; + } + + /** + * Gets the field. + * + *

Use a specific field as the title. + * + * @return the field + */ + public String getField() { + return 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 new file mode 100644 index 00000000000..5a682eaca6d --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsFieldsShownTitle.java @@ -0,0 +1,35 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Title label. */ +public class ComponentSettingsFieldsShownTitle extends GenericModel { + + protected String field; + + protected ComponentSettingsFieldsShownTitle() {} + + /** + * Gets the field. + * + *

Use a specific field as the title. + * + * @return the field + */ + public String getField() { + return 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 new file mode 100644 index 00000000000..420e7c446a2 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ComponentSettingsResponse.java @@ -0,0 +1,92 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the fieldsShown + */ + public ComponentSettingsFieldsShown getFieldsShown() { + return fieldsShown; + } + + /** + * Gets the autocomplete. + * + *

Whether or not autocomplete is enabled. + * + * @return the autocomplete + */ + public Boolean isAutocomplete() { + return autocomplete; + } + + /** + * Gets the structuredSearch. + * + *

Whether or not structured search is enabled. + * + * @return the structuredSearch + */ + public Boolean isStructuredSearch() { + return structuredSearch; + } + + /** + * Gets the resultsPerPage. + * + *

Number or results shown per page. + * + * @return the resultsPerPage + */ + public Long getResultsPerPage() { + return resultsPerPage; + } + + /** + * Gets the aggregations. + * + *

a list of component setting aggregations. + * + * @return the aggregations + */ + public List getAggregations() { + return 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 new file mode 100644 index 00000000000..92ee165a1a5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/CreateTrainingQueryOptions.java @@ -0,0 +1,214 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The createTrainingQuery options. */ +public class CreateTrainingQueryOptions extends GenericModel { + + protected String projectId; + protected String naturalLanguageQuery; + protected List examples; + protected String filter; + + /** 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; + this.examples = createTrainingQueryOptions.examples; + this.filter = createTrainingQueryOptions.filter; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param naturalLanguageQuery the naturalLanguageQuery + * @param examples the examples + */ + public Builder(String projectId, String naturalLanguageQuery, List examples) { + this.projectId = projectId; + this.naturalLanguageQuery = naturalLanguageQuery; + this.examples = examples; + } + + /** + * Builds a CreateTrainingQueryOptions. + * + * @return the new CreateTrainingQueryOptions instance + */ + public CreateTrainingQueryOptions build() { + return new CreateTrainingQueryOptions(this); + } + + /** + * Adds a new element to examples. + * + * @param examples the new element to be added + * @return the CreateTrainingQueryOptions 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 projectId. + * + * @param projectId the projectId + * @return the CreateTrainingQueryOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the naturalLanguageQuery. + * + * @param naturalLanguageQuery the naturalLanguageQuery + * @return the CreateTrainingQueryOptions builder + */ + public Builder naturalLanguageQuery(String naturalLanguageQuery) { + this.naturalLanguageQuery = naturalLanguageQuery; + return this; + } + + /** + * Set the examples. Existing examples will be replaced. + * + * @param examples the examples + * @return the CreateTrainingQueryOptions builder + */ + public Builder examples(List examples) { + this.examples = examples; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the CreateTrainingQueryOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the trainingQuery. + * + * @param trainingQuery the trainingQuery + * @return the CreateTrainingQueryOptions builder + */ + public Builder trainingQuery(TrainingQuery trainingQuery) { + this.naturalLanguageQuery = trainingQuery.naturalLanguageQuery(); + this.examples = trainingQuery.examples(); + this.filter = trainingQuery.filter(); + return this; + } + } + + 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"); + projectId = builder.projectId; + naturalLanguageQuery = builder.naturalLanguageQuery; + examples = builder.examples; + filter = builder.filter; + } + + /** + * New builder. + * + * @return a CreateTrainingQueryOptions 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 naturalLanguageQuery. + * + *

The natural text query that is used as the training query. + * + * @return the naturalLanguageQuery + */ + public String naturalLanguageQuery() { + return naturalLanguageQuery; + } + + /** + * Gets the examples. + * + *

Array of training examples. + * + * @return the examples + */ + public List examples() { + return examples; + } + + /** + * Gets the filter. + * + *

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 + */ + public String filter() { + return 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 new file mode 100644 index 00000000000..c4b6dc0380a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentOptions.java @@ -0,0 +1,183 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteDocument options. */ +public class DeleteDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String documentId; + protected Boolean xWatsonDiscoveryForce; + + /** 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; + this.documentId = deleteDocumentOptions.documentId; + this.xWatsonDiscoveryForce = deleteDocumentOptions.xWatsonDiscoveryForce; + } + + /** 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 DeleteDocumentOptions. + * + * @return the new DeleteDocumentOptions instance + */ + public DeleteDocumentOptions build() { + return new DeleteDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + 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; + } + + /** + * Set the xWatsonDiscoveryForce. + * + * @param xWatsonDiscoveryForce the xWatsonDiscoveryForce + * @return the DeleteDocumentOptions builder + */ + public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { + this.xWatsonDiscoveryForce = xWatsonDiscoveryForce; + return this; + } + } + + 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"); + projectId = builder.projectId; + collectionId = builder.collectionId; + documentId = builder.documentId; + xWatsonDiscoveryForce = builder.xWatsonDiscoveryForce; + } + + /** + * New builder. + * + * @return a DeleteDocumentOptions 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; + } + + /** + * Gets the xWatsonDiscoveryForce. + * + *

When `true`, the uploaded document is added to the collection even if the data for that + * collection is shared with other collections. + * + * @return the xWatsonDiscoveryForce + */ + public Boolean xWatsonDiscoveryForce() { + return xWatsonDiscoveryForce; + } +} 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 new file mode 100644 index 00000000000..dc658ceb97e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteDocumentResponse.java @@ -0,0 +1,56 @@ +/* + * (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.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; + + protected DeleteDocumentResponse() {} + + /** + * 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/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 new file mode 100644 index 00000000000..a7c9d4098e0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DeleteTrainingQueriesOptions.java @@ -0,0 +1,96 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteTrainingQueries options. */ +public class DeleteTrainingQueriesOptions extends GenericModel { + + protected String projectId; + + /** 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a DeleteTrainingQueriesOptions. + * + * @return the new DeleteTrainingQueriesOptions instance + */ + public DeleteTrainingQueriesOptions build() { + return new DeleteTrainingQueriesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the DeleteTrainingQueriesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected DeleteTrainingQueriesOptions() {} + + protected DeleteTrainingQueriesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a DeleteTrainingQueriesOptions 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/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 new file mode 100644 index 00000000000..6561cc79058 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAccepted.java @@ -0,0 +1,64 @@ +/* + * (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.model; + +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 DocumentAccepted() {} + + /** + * 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; + } +} 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 new file mode 100644 index 00000000000..5e0ce17672a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/DocumentAttribute.java @@ -0,0 +1,60 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @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 TableElementLocation getLocation() { + return 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 new file mode 100644 index 00000000000..7b774eebf85 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Field.java @@ -0,0 +1,88 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Object that contains 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; + + @SerializedName("collection_id") + protected String collectionId; + + protected Field() {} + + /** + * 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; + } + + /** + * Gets the collectionId. + * + *

The collection Id of the collection where the field was found. + * + * @return the collectionId + */ + public String getCollectionId() { + return 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 new file mode 100644 index 00000000000..72528d59733 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetAutocompletionOptions.java @@ -0,0 +1,222 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The getAutocompletion options. */ +public class GetAutocompletionOptions extends GenericModel { + + protected String projectId; + protected String prefix; + protected List collectionIds; + protected String field; + protected Long count; + + /** Builder. */ + public static class Builder { + private String projectId; + private String prefix; + private List collectionIds; + 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; + this.collectionIds = getAutocompletionOptions.collectionIds; + this.field = getAutocompletionOptions.field; + this.count = getAutocompletionOptions.count; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param prefix the prefix + */ + public Builder(String projectId, String prefix) { + this.projectId = projectId; + this.prefix = prefix; + } + + /** + * Builds a GetAutocompletionOptions. + * + * @return the new GetAutocompletionOptions instance + */ + public GetAutocompletionOptions build() { + return new GetAutocompletionOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.collectionIds == null) { + this.collectionIds = new ArrayList(); + } + this.collectionIds.add(collectionIds); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetAutocompletionOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + 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 collectionIds. Existing collectionIds will be replaced. + * + * @param collectionIds the collectionIds + * @return the GetAutocompletionOptions builder + */ + public Builder collectionIds(List collectionIds) { + this.collectionIds = collectionIds; + 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() {} + + 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"); + projectId = builder.projectId; + prefix = builder.prefix; + collectionIds = builder.collectionIds; + field = builder.field; + count = builder.count; + } + + /** + * New builder. + * + * @return a GetAutocompletionOptions 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 prefix. + * + *

The prefix to use for autocompletion. For example, the prefix `Ho` could autocomplete to + * `hot`, `housing`, or `how`. + * + * @return the prefix + */ + public String prefix() { + return prefix; + } + + /** + * Gets the collectionIds. + * + *

Comma separated list of the collection IDs. If this parameter is not specified, all + * collections in the project are used. + * + * @return the collectionIds + */ + public List collectionIds() { + return collectionIds; + } + + /** + * 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/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 new file mode 100644 index 00000000000..2be55eef734 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetComponentSettingsOptions.java @@ -0,0 +1,96 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getComponentSettings options. */ +public class GetComponentSettingsOptions extends GenericModel { + + protected String projectId; + + /** 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a GetComponentSettingsOptions. + * + * @return the new GetComponentSettingsOptions instance + */ + public GetComponentSettingsOptions build() { + return new GetComponentSettingsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetComponentSettingsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected GetComponentSettingsOptions() {} + + protected GetComponentSettingsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a GetComponentSettingsOptions 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/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 new file mode 100644 index 00000000000..7b3395b73d5 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/GetTrainingQueryOptions.java @@ -0,0 +1,125 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getTrainingQuery options. */ +public class GetTrainingQueryOptions 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 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 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 GetTrainingQueryOptions. + * + * @return the new GetTrainingQueryOptions instance + */ + public GetTrainingQueryOptions build() { + return new GetTrainingQueryOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the GetTrainingQueryOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the queryId. + * + * @param queryId the queryId + * @return the GetTrainingQueryOptions builder + */ + public Builder queryId(String queryId) { + this.queryId = queryId; + return this; + } + } + + 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"); + projectId = builder.projectId; + queryId = builder.queryId; + } + + /** + * New builder. + * + * @return a GetTrainingQueryOptions 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/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 new file mode 100644 index 00000000000..d1d4277b574 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsOptions.java @@ -0,0 +1,96 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listCollections options. */ +public class ListCollectionsOptions extends GenericModel { + + protected String projectId; + + /** 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a ListCollectionsOptions. + * + * @return the new ListCollectionsOptions instance + */ + public ListCollectionsOptions build() { + return new ListCollectionsOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListCollectionsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected ListCollectionsOptions() {} + + protected ListCollectionsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a ListCollectionsOptions 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/ListCollectionsResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java new file mode 100644 index 00000000000..ce6cd252084 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListCollectionsResponse.java @@ -0,0 +1,36 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Response object that contains an array of collection details. */ +public class ListCollectionsResponse extends GenericModel { + + protected List collections; + + protected ListCollectionsResponse() {} + + /** + * Gets the collections. + * + *

An array that contains information about each collection in the project. + * + * @return the collections + */ + public List getCollections() { + return 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 new file mode 100644 index 00000000000..6de91251c10 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsOptions.java @@ -0,0 +1,140 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The listFields options. */ +public class ListFieldsOptions extends GenericModel { + + protected String projectId; + protected List collectionIds; + + /** 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a ListFieldsOptions. + * + * @return the new ListFieldsOptions instance + */ + public ListFieldsOptions build() { + return new ListFieldsOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.collectionIds == null) { + this.collectionIds = new ArrayList(); + } + this.collectionIds.add(collectionIds); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListFieldsOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + 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() {} + + protected ListFieldsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + collectionIds = builder.collectionIds; + } + + /** + * New builder. + * + * @return a ListFieldsOptions 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 collectionIds. + * + *

Comma separated list of the collection IDs. If this parameter is not specified, all + * collections in the project are used. + * + * @return the collectionIds + */ + public List collectionIds() { + return 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 new file mode 100644 index 00000000000..f2ab4f5eb5c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListFieldsResponse.java @@ -0,0 +1,47 @@ +/* + * (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.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. + * + *

* 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`). + */ +public class ListFieldsResponse extends GenericModel { + + protected List fields; + + protected ListFieldsResponse() {} + + /** + * Gets the fields. + * + *

An array that contains 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/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 new file mode 100644 index 00000000000..2fab873f4d2 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/ListTrainingQueriesOptions.java @@ -0,0 +1,96 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listTrainingQueries options. */ +public class ListTrainingQueriesOptions extends GenericModel { + + protected String projectId; + + /** 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a ListTrainingQueriesOptions. + * + * @return the new ListTrainingQueriesOptions instance + */ + public ListTrainingQueriesOptions build() { + return new ListTrainingQueriesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the ListTrainingQueriesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + protected ListTrainingQueriesOptions() {} + + protected ListTrainingQueriesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + } + + /** + * New builder. + * + * @return a ListTrainingQueriesOptions 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/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 new file mode 100644 index 00000000000..743f2aed93a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/Notice.java @@ -0,0 +1,150 @@ +/* + * (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.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. */ +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("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`, + * `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 collectionId. + * + *

Unique identifier of the collection. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * 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. + * + * @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/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 new file mode 100644 index 00000000000..7cabf8636dd --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryAggregation.java @@ -0,0 +1,277 @@ +/* + * (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.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 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", 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. + * + *

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/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/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/QueryHistogramAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java new file mode 100644 index 00000000000..e7e9327eafc --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryHistogramAggregationResult.java @@ -0,0 +1,66 @@ +/* + * (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.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. */ +public class QueryHistogramAggregationResult extends GenericModel { + + protected Long key; + + @SerializedName("matching_results") + protected Long matchingResults; + + protected List> aggregations; + + protected QueryHistogramAggregationResult() {} + + /** + * Gets the key. + * + *

The value of the upper bound for the numeric segment. + * + * @return the key + */ + public Long getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + *

Number of documents with the specified key as the upper bound. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * 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/QueryLargePassages.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java new file mode 100644 index 00000000000..804e9c86a5a --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargePassages.java @@ -0,0 +1,319 @@ +/* + * (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.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. */ +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; + + @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; + private Long maxPerDocument; + 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; + this.maxPerDocument = queryLargePassages.maxPerDocument; + 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() {} + + /** + * Builds a QueryLargePassages. + * + * @return the new QueryLargePassages instance + */ + public QueryLargePassages build() { + return new QueryLargePassages(this); + } + + /** + * Adds a new element to 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"); + if (this.fields == null) { + this.fields = new ArrayList(); + } + this.fields.add(fields); + return this; + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the QueryLargePassages builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the perDocument. + * + * @param perDocument the perDocument + * @return the QueryLargePassages builder + */ + public Builder perDocument(Boolean perDocument) { + this.perDocument = perDocument; + return this; + } + + /** + * Set the maxPerDocument. + * + * @param maxPerDocument the maxPerDocument + * @return the QueryLargePassages builder + */ + public Builder maxPerDocument(long maxPerDocument) { + this.maxPerDocument = maxPerDocument; + return this; + } + + /** + * Set the fields. Existing fields will be replaced. + * + * @param fields the fields + * @return the QueryLargePassages builder + */ + public Builder fields(List fields) { + this.fields = fields; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the QueryLargePassages builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the characters. + * + * @param characters the characters + * @return the QueryLargePassages builder + */ + 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; + maxPerDocument = builder.maxPerDocument; + fields = builder.fields; + count = builder.count; + characters = builder.characters; + findAnswers = builder.findAnswers; + maxAnswersPerPassage = builder.maxAnswersPerPassage; + } + + /** + * New builder. + * + * @return a QueryLargePassages builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

A passages query that returns the most relevant passages from the results. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the perDocument. + * + *

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 + */ + public Boolean perDocument() { + return perDocument; + } + + /** + * Gets the maxPerDocument. + * + *

Maximum number of passages to return per document in the result. Ignored if + * **passages.per_document** is `false`. + * + * @return the maxPerDocument + */ + public Long maxPerDocument() { + return maxPerDocument; + } + + /** + * Gets the fields. + * + *

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 + */ + public List fields() { + return fields; + } + + /** + * Gets the count. + * + *

The maximum number of passages to return. Ignored if **passages.per_document** is `true`. + * + * @return the count + */ + public Long count() { + return count; + } + + /** + * Gets the characters. + * + *

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 new file mode 100644 index 00000000000..03fd2e0a0bc --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeSuggestedRefinements.java @@ -0,0 +1,116 @@ +/* + * (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.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. */ + 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() {} + + /** + * Builds a QueryLargeSuggestedRefinements. + * + * @return the new QueryLargeSuggestedRefinements instance + */ + public QueryLargeSuggestedRefinements build() { + return new QueryLargeSuggestedRefinements(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the QueryLargeSuggestedRefinements builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the QueryLargeSuggestedRefinements builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + } + + protected QueryLargeSuggestedRefinements() {} + + protected QueryLargeSuggestedRefinements(Builder builder) { + enabled = builder.enabled; + count = builder.count; + } + + /** + * New builder. + * + * @return a QueryLargeSuggestedRefinements builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

Whether to perform suggested refinements. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the count. + * + *

Maximum number of suggested refinements texts to be returned. The maximum is `100`. + * + * @return the count + */ + public Long count() { + return 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 new file mode 100644 index 00000000000..4510f6ac52b --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryLargeTableResults.java @@ -0,0 +1,111 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Configuration for table retrieval. */ +public class QueryLargeTableResults 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 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() {} + + /** + * Builds a QueryLargeTableResults. + * + * @return the new QueryLargeTableResults instance + */ + public QueryLargeTableResults build() { + return new QueryLargeTableResults(this); + } + + /** + * Set the enabled. + * + * @param enabled the enabled + * @return the QueryLargeTableResults builder + */ + public Builder enabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Set the count. + * + * @param count the count + * @return the QueryLargeTableResults builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + } + + protected QueryLargeTableResults() {} + + protected QueryLargeTableResults(Builder builder) { + enabled = builder.enabled; + count = builder.count; + } + + /** + * New builder. + * + * @return a QueryLargeTableResults builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the enabled. + * + *

Whether to enable table retrieval. + * + * @return the enabled + */ + public Boolean enabled() { + return enabled; + } + + /** + * Gets the count. + * + *

Maximum number of tables to return. + * + * @return the count + */ + public Long count() { + return count; + } +} 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 new file mode 100644 index 00000000000..e4072f6688e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesOptions.java @@ -0,0 +1,239 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The queryNotices options. */ +public class QueryNoticesOptions extends GenericModel { + + protected String projectId; + 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 filter; + private String query; + private String naturalLanguageQuery; + 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; + this.query = queryNoticesOptions.query; + this.naturalLanguageQuery = queryNoticesOptions.naturalLanguageQuery; + this.count = queryNoticesOptions.count; + this.offset = queryNoticesOptions.offset; + } + + /** 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 QueryNoticesOptions. + * + * @return the new QueryNoticesOptions instance + */ + public QueryNoticesOptions build() { + return new QueryNoticesOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the QueryNoticesOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + 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 count. + * + * @param count the count + * @return the QueryNoticesOptions builder + */ + public Builder count(long count) { + this.count = count; + return this; + } + + /** + * Set the offset. + * + * @param offset the offset + * @return the QueryNoticesOptions builder + */ + public Builder offset(long offset) { + this.offset = offset; + return this; + } + } + + protected QueryNoticesOptions() {} + + protected QueryNoticesOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.projectId, "projectId cannot be empty"); + projectId = builder.projectId; + filter = builder.filter; + query = builder.query; + naturalLanguageQuery = builder.naturalLanguageQuery; + count = builder.count; + offset = builder.offset; + } + + /** + * New builder. + * + * @return a QueryNoticesOptions 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 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/QueryNoticesResponse.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java new file mode 100644 index 00000000000..874b6aabc87 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryNoticesResponse.java @@ -0,0 +1,51 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the notices. + * + *

Array of document results that match the query. + * + * @return the notices + */ + public List getNotices() { + return 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 new file mode 100644 index 00000000000..03c409deb13 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryOptions.java @@ -0,0 +1,554 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The query options. */ +public class QueryOptions extends GenericModel { + + protected String projectId; + 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 String sort; + protected Boolean highlight; + protected Boolean spellingSuggestions; + protected QueryLargeTableResults tableResults; + protected QueryLargeSuggestedRefinements suggestedRefinements; + protected QueryLargePassages passages; + protected QueryLargeSimilar similar; + + /** Builder. */ + public static class Builder { + private String projectId; + 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 String sort; + private Boolean highlight; + private Boolean spellingSuggestions; + 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; + this.filter = queryOptions.filter; + this.query = queryOptions.query; + this.naturalLanguageQuery = queryOptions.naturalLanguageQuery; + 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.spellingSuggestions = queryOptions.spellingSuggestions; + 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 with required properties. + * + * @param projectId the projectId + */ + public Builder(String projectId) { + this.projectId = projectId; + } + + /** + * Builds a QueryOptions. + * + * @return the new QueryOptions instance + */ + public QueryOptions build() { + return new QueryOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.collectionIds == null) { + this.collectionIds = new ArrayList(); + } + this.collectionIds.add(collectionIds); + return this; + } + + /** + * Adds a new element to xReturn. + * + * @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"); + if (this.xReturn == null) { + this.xReturn = new ArrayList(); + } + this.xReturn.add(returnField); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the QueryOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the collectionIds. Existing collectionIds will be replaced. + * + * @param collectionIds the collectionIds + * @return the QueryOptions builder + */ + public Builder collectionIds(List collectionIds) { + this.collectionIds = collectionIds; + 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 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. Existing xReturn will be replaced. + * + * @param xReturn the xReturn + * @return the QueryOptions builder + */ + public Builder xReturn(List 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 spellingSuggestions. + * + * @param spellingSuggestions the spellingSuggestions + * @return the QueryOptions builder + */ + public Builder spellingSuggestions(Boolean spellingSuggestions) { + this.spellingSuggestions = spellingSuggestions; + return this; + } + + /** + * Set the tableResults. + * + * @param tableResults the tableResults + * @return the QueryOptions builder + */ + public Builder tableResults(QueryLargeTableResults tableResults) { + this.tableResults = tableResults; + return this; + } + + /** + * Set the suggestedRefinements. + * + * @param suggestedRefinements the suggestedRefinements + * @return the QueryOptions builder + */ + public Builder suggestedRefinements(QueryLargeSuggestedRefinements suggestedRefinements) { + this.suggestedRefinements = suggestedRefinements; + return this; + } + + /** + * Set the passages. + * + * @param passages the passages + * @return the QueryOptions builder + */ + 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"); + projectId = builder.projectId; + 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; + spellingSuggestions = builder.spellingSuggestions; + tableResults = builder.tableResults; + suggestedRefinements = builder.suggestedRefinements; + passages = builder.passages; + similar = builder.similar; + } + + /** + * New builder. + * + * @return a QueryOptions 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 collectionIds. + * + *

A comma-separated list of collection IDs to be queried against. + * + * @return the collectionIds + */ + public List collectionIds() { + return collectionIds; + } + + /** + * 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. 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 + */ + public String query() { + return query; + } + + /** + * Gets the naturalLanguageQuery. + * + *

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 + */ + 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 more information about the + * supported types of aggregations, see the [Discovery + * documentation](/docs/discovery-data?topic=discovery-data-query-aggregations). + * + * @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 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 + */ + public List xReturn() { + return xReturn; + } + + /** + * Gets the offset. + * + *

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 + */ + 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 String sort() { + return sort; + } + + /** + * Gets the highlight. + * + *

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 + */ + public Boolean highlight() { + return 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). + * + * @return the spellingSuggestions + */ + public Boolean spellingSuggestions() { + return spellingSuggestions; + } + + /** + * Gets the tableResults. + * + *

Configuration for table retrieval. + * + * @return the tableResults + */ + public QueryLargeTableResults tableResults() { + return tableResults; + } + + /** + * Gets the suggestedRefinements. + * + *

Configuration for suggested refinements. + * + *

**Note**: The **suggested_refinements** parameter that identified dynamic facets from the + * data is deprecated. + * + * @return the suggestedRefinements + */ + public QueryLargeSuggestedRefinements suggestedRefinements() { + return suggestedRefinements; + } + + /** + * Gets the passages. + * + *

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 new file mode 100644 index 00000000000..d3840a7058c --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResponse.java @@ -0,0 +1,137 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. Results that match due to a curation only are + * not counted in the total. + * + * @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 aggregations for the query. + * + * @return the aggregations + */ + public List getAggregations() { + return aggregations; + } + + /** + * Gets the retrievalDetails. + * + *

An object contain retrieval type information. + * + * @return the retrievalDetails + */ + public RetrievalDetails getRetrievalDetails() { + return retrievalDetails; + } + + /** + * Gets the suggestedQuery. + * + *

Suggested correction to the submitted **natural_language_query** value. + * + * @return the suggestedQuery + */ + public String getSuggestedQuery() { + return suggestedQuery; + } + + /** + * Gets the suggestedRefinements. + * + *

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; + } + + /** + * Gets the tableResults. + * + *

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 new file mode 100644 index 00000000000..a126a24114f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResult.java @@ -0,0 +1,89 @@ +/* + * (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.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() {}); + } + + /** + * 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 from the document that best matches the query. Returned if + * **passages.per_document** is `true`. + * + * @return the documentPassages + */ + public List getDocumentPassages() { + return this.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 new file mode 100644 index 00000000000..b8225b35dd7 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultMetadata.java @@ -0,0 +1,76 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Metadata of a query result. */ +public class QueryResultMetadata extends GenericModel { + + /** The document retrieval source that produced this search result. */ + public interface DocumentRetrievalSource { + /** search. */ + String SEARCH = "search"; + /** curation. */ + String CURATION = "curation"; + } + + @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. + * + * @return the documentRetrievalSource + */ + public String getDocumentRetrievalSource() { + return documentRetrievalSource; + } + + /** + * Gets the collectionId. + * + *

The collection id associated with this training data set. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the confidence. + * + *

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 + */ + public Double getConfidence() { + return 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 new file mode 100644 index 00000000000..9c9e82588b1 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryResultPassage.java @@ -0,0 +1,92 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @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 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 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 new file mode 100644 index 00000000000..78813097492 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QuerySuggestedRefinement.java @@ -0,0 +1,38 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * 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. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..6f79b5367cd --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTableResult.java @@ -0,0 +1,106 @@ +/* + * (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.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. */ +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. + * + * @return the tableId + */ + public String getTableId() { + return tableId; + } + + /** + * Gets the sourceDocumentId. + * + *

The identifier of the document the table was retrieved from. + * + * @return the sourceDocumentId + */ + public String getSourceDocumentId() { + return sourceDocumentId; + } + + /** + * Gets the collectionId. + * + *

The identifier of the collection the table was retrieved from. + * + * @return the collectionId + */ + public String getCollectionId() { + return collectionId; + } + + /** + * Gets the tableHtml. + * + *

HTML snippet of the table info. + * + * @return the tableHtml + */ + public String getTableHtml() { + return tableHtml; + } + + /** + * Gets the tableHtmlOffset. + * + *

The offset of the table html snippet in the original document html. + * + * @return the tableHtmlOffset + */ + public Long getTableHtmlOffset() { + return tableHtmlOffset; + } + + /** + * Gets the table. + * + *

Full table object retrieved from Table Understanding Enrichment. + * + * @return the table + */ + public TableResultTable getTable() { + return table; + } +} 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 new file mode 100644 index 00000000000..3dc53751d36 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTermAggregationResult.java @@ -0,0 +1,110 @@ +/* + * (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.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. */ +public class QueryTermAggregationResult 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 QueryTermAggregationResult() {} + + /** + * Gets the key. + * + *

Value of the field with a nonzero frequency in the document set. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + *

Number of documents that contain the 'key'. + * + * @return the matchingResults + */ + 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 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() { + return aggregations; + } +} 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 new file mode 100644 index 00000000000..a35b541d1f1 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTimesliceAggregationResult.java @@ -0,0 +1,81 @@ +/* + * (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.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. */ +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 QueryTimesliceAggregationResult() {} + + /** + * Gets the keyAsString. + * + *

String date value of the upper bound for the timeslice interval in ISO-8601 format. + * + * @return the keyAsString + */ + public String getKeyAsString() { + return keyAsString; + } + + /** + * Gets the key. + * + *

Numeric date value of the upper bound for the timeslice interval in UNIX milliseconds since + * epoch. + * + * @return the key + */ + public Long getKey() { + return key; + } + + /** + * Gets the matchingResults. + * + *

Number of documents with the specified key as the upper bound. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * 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/QueryTopHitsAggregationResult.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java new file mode 100644 index 00000000000..3b0a65566d1 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/QueryTopHitsAggregationResult.java @@ -0,0 +1,52 @@ +/* + * (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.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 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. + * + * @return the matchingResults + */ + public Long getMatchingResults() { + return matchingResults; + } + + /** + * Gets the hits. + * + *

An array of the document results in an ordered list. + * + * @return the hits + */ + public List> getHits() { + return 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 new file mode 100644 index 00000000000..cbb2dbf140d --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/RetrievalDetails.java @@ -0,0 +1,55 @@ +/* + * (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.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 { + + /** + * 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** is listed as `untrained`. + */ + public interface DocumentRetrievalStrategy { + /** untrained. */ + String UNTRAINED = "untrained"; + /** relevancy_training. */ + String RELEVANCY_TRAINING = "relevancy_training"; + } + + @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. + * + *

**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 + */ + public String getDocumentRetrievalStrategy() { + return 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 new file mode 100644 index 00000000000..2274a56e4df --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableBodyCells.java @@ -0,0 +1,219 @@ +/* + * (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.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. */ +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; + + @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; + + protected TableBodyCells() {} + + /** + * 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 TableElementLocation 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. + * + *

A list of ID values that represent the table row headers that are associated with this body + * cell. + * + * @return the rowHeaderIds + */ + public List getRowHeaderIds() { + return rowHeaderIds; + } + + /** + * Gets the rowHeaderTexts. + * + *

A list of row header values that are associated with this body cell. + * + * @return the rowHeaderTexts + */ + public List getRowHeaderTexts() { + return rowHeaderTexts; + } + + /** + * Gets the rowHeaderTextsNormalized. + * + *

A list of normalized row header values that are associated with this body cell. + * + * @return the rowHeaderTextsNormalized + */ + public List getRowHeaderTextsNormalized() { + return rowHeaderTextsNormalized; + } + + /** + * Gets the columnHeaderIds. + * + *

A list of ID values that represent the column headers that are associated with this body + * cell. + * + * @return the columnHeaderIds + */ + public List getColumnHeaderIds() { + return columnHeaderIds; + } + + /** + * Gets the columnHeaderTexts. + * + *

A list of column header values that are associated with this body cell. + * + * @return the columnHeaderTexts + */ + public List getColumnHeaderTexts() { + return columnHeaderTexts; + } + + /** + * Gets the columnHeaderTextsNormalized. + * + *

A list of normalized column header values that are associated with this body cell. + * + * @return the columnHeaderTextsNormalized + */ + public List getColumnHeaderTextsNormalized() { + return columnHeaderTextsNormalized; + } + + /** + * Gets the attributes. + * + *

A list of document attributes. + * + * @return the attributes + */ + public List getAttributes() { + return 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 new file mode 100644 index 00000000000..999e4244d5f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellKey.java @@ -0,0 +1,63 @@ +/* + * (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.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 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. + * + * @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 TableElementLocation 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/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 new file mode 100644 index 00000000000..7dabdd25825 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableCellValues.java @@ -0,0 +1,63 @@ +/* + * (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.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 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. + * + * @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 TableElementLocation 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/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 new file mode 100644 index 00000000000..d8fa9c7c826 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderIds.java @@ -0,0 +1,37 @@ +/* + * (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.model; + +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. + */ +public class TableColumnHeaderIds extends GenericModel { + + protected String id; + + protected TableColumnHeaderIds() {} + + /** + * Gets the id. + * + *

The `id` value of a column header. + * + * @return the id + */ + public String getId() { + return 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 new file mode 100644 index 00000000000..883d86955ba --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTexts.java @@ -0,0 +1,37 @@ +/* + * (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.model; + +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. + */ +public class TableColumnHeaderTexts extends GenericModel { + + protected String text; + + protected TableColumnHeaderTexts() {} + + /** + * Gets the text. + * + *

The `text` value of a column header. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..0bcbfbb66fe --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaderTextsNormalized.java @@ -0,0 +1,39 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +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`. + */ +public class TableColumnHeaderTextsNormalized extends GenericModel { + + @SerializedName("text_normalized") + protected String textNormalized; + + protected TableColumnHeaderTextsNormalized() {} + + /** + * Gets the textNormalized. + * + *

The normalized version of a column header text. + * + * @return the textNormalized + */ + public String getTextNormalized() { + return 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 new file mode 100644 index 00000000000..2c48b7d3408 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableColumnHeaders.java @@ -0,0 +1,136 @@ +/* + * (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.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 TableColumnHeaders 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 TableColumnHeaders() {} + + /** + * 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 TableElementLocation 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. + * + *

Normalized column header 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/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 new file mode 100644 index 00000000000..64dd5f2c678 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableElementLocation.java @@ -0,0 +1,50 @@ +/* + * (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.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 TableElementLocation extends GenericModel { + + protected Long begin; + protected Long end; + + protected TableElementLocation() {} + + /** + * Gets the begin. + * + *

The element's `begin` index. + * + * @return the begin + */ + public Long getBegin() { + return begin; + } + + /** + * Gets the end. + * + *

The element's `end` index. + * + * @return the end + */ + public Long getEnd() { + return 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 new file mode 100644 index 00000000000..41f62d2fbab --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableHeaders.java @@ -0,0 +1,119 @@ +/* + * (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.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 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. + * + * @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 TableElementLocation 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/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 new file mode 100644 index 00000000000..1b93fd28d43 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableKeyValuePairs.java @@ -0,0 +1,48 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the key + */ + public TableCellKey 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/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 new file mode 100644 index 00000000000..718d00f56ed --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableResultTable.java @@ -0,0 +1,166 @@ +/* + * (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.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. */ +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`. + * + * @return the location + */ + public TableElementLocation 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. + * + *

Text and associated location within a table. + * + * @return the sectionTitle + */ + public TableTextLocation getSectionTitle() { + return sectionTitle; + } + + /** + * Gets the title. + * + *

Text and associated location within a table. + * + * @return the title + */ + public TableTextLocation 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 keyValuePairs. + * + *

An array of key-value pairs identified in the current table. + * + * @return the keyValuePairs + */ + public List getKeyValuePairs() { + return keyValuePairs; + } + + /** + * 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 lists of textual entries across the document related to the current table being + * parsed. + * + * @return the contexts + */ + public List getContexts() { + return 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 new file mode 100644 index 00000000000..53718523ace --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderIds.java @@ -0,0 +1,37 @@ +/* + * (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.model; + +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. + */ +public class TableRowHeaderIds extends GenericModel { + + protected String id; + + protected TableRowHeaderIds() {} + + /** + * Gets the id. + * + *

The `id` values of a row header. + * + * @return the id + */ + public String getId() { + return 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 new file mode 100644 index 00000000000..5b832a5d8a0 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTexts.java @@ -0,0 +1,37 @@ +/* + * (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.model; + +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. + */ +public class TableRowHeaderTexts extends GenericModel { + + protected String text; + + protected TableRowHeaderTexts() {} + + /** + * Gets the text. + * + *

The `text` value of a row header. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..23caa5b5889 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaderTextsNormalized.java @@ -0,0 +1,39 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +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`. + */ +public class TableRowHeaderTextsNormalized extends GenericModel { + + @SerializedName("text_normalized") + protected String textNormalized; + + protected TableRowHeaderTextsNormalized() {} + + /** + * Gets the textNormalized. + * + *

The normalized version of a row header text. + * + * @return the textNormalized + */ + public String getTextNormalized() { + return 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 new file mode 100644 index 00000000000..23f990bd81f --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableRowHeaders.java @@ -0,0 +1,136 @@ +/* + * (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.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 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. + * + * @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 TableElementLocation 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. + * + *

Normalized row header 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/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 new file mode 100644 index 00000000000..b1308b4e16e --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TableTextLocation.java @@ -0,0 +1,48 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @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 TableElementLocation getLocation() { + return 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 new file mode 100644 index 00000000000..c2d02cf1c29 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingExample.java @@ -0,0 +1,185 @@ +/* + * (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.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.Date; + +/** 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. */ + public static class Builder { + private String documentId; + private String collectionId; + private Long relevance; + + /** + * 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; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param documentId the documentId + * @param collectionId the collectionId + * @param relevance the relevance + */ + public Builder(String documentId, String collectionId, Long relevance) { + this.documentId = documentId; + this.collectionId = collectionId; + this.relevance = relevance; + } + + /** + * Builds a TrainingExample. + * + * @return the new TrainingExample instance + */ + 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 collectionId. + * + * @param collectionId the collectionId + * @return the TrainingExample builder + */ + public Builder collectionId(String collectionId) { + this.collectionId = collectionId; + 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() {} + + 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"); + documentId = builder.documentId; + collectionId = builder.collectionId; + 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 collectionId. + * + *

The collection ID associated with this training example. + * + * @return the collectionId + */ + public String collectionId() { + return collectionId; + } + + /** + * Gets the relevance. + * + *

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 + */ + public Long relevance() { + return relevance; + } + + /** + * Gets the created. + * + *

The date and time the example was created. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the updated. + * + *

The date and time the example was updated. + * + * @return the updated + */ + public Date updated() { + return 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 new file mode 100644 index 00000000000..8a2d95bfd31 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuery.java @@ -0,0 +1,213 @@ +/* + * (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.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; + +/** 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. */ + public static class Builder { + private String naturalLanguageQuery; + private String filter; + 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.naturalLanguageQuery = trainingQuery.naturalLanguageQuery; + this.filter = trainingQuery.filter; + this.examples = trainingQuery.examples; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param naturalLanguageQuery the naturalLanguageQuery + * @param examples the examples + */ + public Builder(String naturalLanguageQuery, List examples) { + this.naturalLanguageQuery = naturalLanguageQuery; + this.examples = examples; + } + + /** + * Builds a TrainingQuery. + * + * @return the new TrainingQuery instance + */ + public TrainingQuery build() { + return new TrainingQuery(this); + } + + /** + * Adds a new element to 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"); + if (this.examples == null) { + this.examples = new ArrayList(); + } + this.examples.add(examples); + return this; + } + + /** + * Set the naturalLanguageQuery. + * + * @param naturalLanguageQuery the naturalLanguageQuery + * @return the TrainingQuery builder + */ + public Builder naturalLanguageQuery(String naturalLanguageQuery) { + this.naturalLanguageQuery = naturalLanguageQuery; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the TrainingQuery 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 TrainingQuery builder + */ + public Builder examples(List examples) { + this.examples = examples; + return this; + } + } + + 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"); + naturalLanguageQuery = builder.naturalLanguageQuery; + filter = builder.filter; + examples = builder.examples; + } + + /** + * New builder. + * + * @return a TrainingQuery builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the queryId. + * + *

The query ID associated with the training query. + * + * @return the queryId + */ + public String queryId() { + return queryId; + } + + /** + * Gets the naturalLanguageQuery. + * + *

The natural text query that is used as the 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. 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 + */ + public String filter() { + return filter; + } + + /** + * Gets the created. + * + *

The date and time the query was created. + * + * @return the created + */ + public Date created() { + return created; + } + + /** + * Gets the updated. + * + *

The date and time the query was updated. + * + * @return the updated + */ + public Date updated() { + return updated; + } + + /** + * 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/v2/model/TrainingQuerySet.java b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java new file mode 100644 index 00000000000..77f2e94e23d --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/TrainingQuerySet.java @@ -0,0 +1,37 @@ +/* + * (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.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. */ +public class TrainingQuerySet extends GenericModel { + + protected List queries; + + protected TrainingQuerySet() {} + + /** + * Gets the 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 + */ + public List getQueries() { + return 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 new file mode 100644 index 00000000000..fc7282a1624 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateDocumentOptions.java @@ -0,0 +1,322 @@ +/* + * (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.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 updateDocument options. */ +public class UpdateDocumentOptions extends GenericModel { + + protected String projectId; + protected String collectionId; + protected String documentId; + protected InputStream file; + protected String filename; + protected String fileContentType; + protected String metadata; + protected Boolean xWatsonDiscoveryForce; + + /** Builder. */ + public static class Builder { + private String projectId; + private String collectionId; + private String documentId; + private InputStream file; + private String filename; + private String fileContentType; + 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; + this.documentId = updateDocumentOptions.documentId; + this.file = updateDocumentOptions.file; + this.filename = updateDocumentOptions.filename; + this.fileContentType = updateDocumentOptions.fileContentType; + this.metadata = updateDocumentOptions.metadata; + this.xWatsonDiscoveryForce = updateDocumentOptions.xWatsonDiscoveryForce; + } + + /** 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 UpdateDocumentOptions. + * + * @return the new UpdateDocumentOptions instance + */ + public UpdateDocumentOptions build() { + return new UpdateDocumentOptions(this); + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateDocumentOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + 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 xWatsonDiscoveryForce. + * + * @param xWatsonDiscoveryForce the xWatsonDiscoveryForce + * @return the UpdateDocumentOptions builder + */ + public Builder xWatsonDiscoveryForce(Boolean xWatsonDiscoveryForce) { + this.xWatsonDiscoveryForce = xWatsonDiscoveryForce; + 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() {} + + 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), + "filename cannot be null if file is not null."); + projectId = builder.projectId; + collectionId = builder.collectionId; + documentId = builder.documentId; + file = builder.file; + filename = builder.filename; + fileContentType = builder.fileContentType; + metadata = builder.metadata; + xWatsonDiscoveryForce = builder.xWatsonDiscoveryForce; + } + + /** + * New builder. + * + * @return a UpdateDocumentOptions 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; + } + + /** + * 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; + } + + /** + * Gets the xWatsonDiscoveryForce. + * + *

When `true`, the uploaded document is added to the collection even if the data for that + * collection is shared with other collections. + * + * @return the xWatsonDiscoveryForce + */ + public Boolean xWatsonDiscoveryForce() { + return xWatsonDiscoveryForce; + } +} 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 new file mode 100644 index 00000000000..70c52b8a757 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/model/UpdateTrainingQueryOptions.java @@ -0,0 +1,247 @@ +/* + * (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.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The updateTrainingQuery options. */ +public class UpdateTrainingQueryOptions extends GenericModel { + + protected String projectId; + protected String queryId; + protected String naturalLanguageQuery; + protected List examples; + protected String filter; + + /** Builder. */ + public static class Builder { + private String projectId; + private String queryId; + private String naturalLanguageQuery; + 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; + this.naturalLanguageQuery = updateTrainingQueryOptions.naturalLanguageQuery; + this.examples = updateTrainingQueryOptions.examples; + this.filter = updateTrainingQueryOptions.filter; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param projectId the projectId + * @param queryId the queryId + * @param naturalLanguageQuery the naturalLanguageQuery + * @param examples the examples + */ + public Builder( + String projectId, + String queryId, + String naturalLanguageQuery, + List examples) { + this.projectId = projectId; + this.queryId = queryId; + this.naturalLanguageQuery = naturalLanguageQuery; + this.examples = examples; + } + + /** + * Builds a UpdateTrainingQueryOptions. + * + * @return the new UpdateTrainingQueryOptions instance + */ + public UpdateTrainingQueryOptions build() { + return new UpdateTrainingQueryOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.examples == null) { + this.examples = new ArrayList(); + } + this.examples.add(examples); + return this; + } + + /** + * Set the projectId. + * + * @param projectId the projectId + * @return the UpdateTrainingQueryOptions builder + */ + public Builder projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set the queryId. + * + * @param queryId the queryId + * @return the UpdateTrainingQueryOptions builder + */ + public Builder queryId(String queryId) { + this.queryId = queryId; + return this; + } + + /** + * Set the naturalLanguageQuery. + * + * @param naturalLanguageQuery the naturalLanguageQuery + * @return the UpdateTrainingQueryOptions builder + */ + public Builder naturalLanguageQuery(String naturalLanguageQuery) { + this.naturalLanguageQuery = naturalLanguageQuery; + return this; + } + + /** + * Set the examples. Existing examples will be replaced. + * + * @param examples the examples + * @return the UpdateTrainingQueryOptions builder + */ + public Builder examples(List examples) { + this.examples = examples; + return this; + } + + /** + * Set the filter. + * + * @param filter the filter + * @return the UpdateTrainingQueryOptions builder + */ + public Builder filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set the trainingQuery. + * + * @param trainingQuery the trainingQuery + * @return the UpdateTrainingQueryOptions builder + */ + public Builder trainingQuery(TrainingQuery trainingQuery) { + this.naturalLanguageQuery = trainingQuery.naturalLanguageQuery(); + this.examples = trainingQuery.examples(); + this.filter = trainingQuery.filter(); + return this; + } + } + + 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"); + projectId = builder.projectId; + queryId = builder.queryId; + naturalLanguageQuery = builder.naturalLanguageQuery; + examples = builder.examples; + filter = builder.filter; + } + + /** + * New builder. + * + * @return a UpdateTrainingQueryOptions 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; + } + + /** + * Gets the naturalLanguageQuery. + * + *

The natural text query that is used as the training query. + * + * @return the naturalLanguageQuery + */ + public String naturalLanguageQuery() { + return naturalLanguageQuery; + } + + /** + * Gets the examples. + * + *

Array of training examples. + * + * @return the examples + */ + public List examples() { + return examples; + } + + /** + * Gets the filter. + * + *

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 + */ + public String filter() { + return 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 new file mode 100644 index 00000000000..a93b9daa2e6 --- /dev/null +++ b/discovery/src/main/java/com/ibm/watson/discovery/v2/package-info.java @@ -0,0 +1,15 @@ +/* + * (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. + */ + +/** Discovery v2 v2. */ +package com.ibm.watson.discovery.v2; diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java deleted file mode 100644 index 3087b01fd4e..00000000000 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceIT.java +++ /dev/null @@ -1,1931 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.discovery.v1; - -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Calculation; -import com.ibm.watson.developer_cloud.discovery.v1.model.Collection; -import com.ibm.watson.developer_cloud.discovery.v1.model.Configuration; -import com.ibm.watson.developer_cloud.discovery.v1.model.Conversions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentStatus; -import com.ibm.watson.developer_cloud.discovery.v1.model.Enrichment; -import com.ibm.watson.developer_cloud.discovery.v1.model.EnrichmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; -import com.ibm.watson.developer_cloud.discovery.v1.model.Expansion; -import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Filter; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Histogram; -import com.ibm.watson.developer_cloud.discovery.v1.model.HtmlSettings; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Nested; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEmotion; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentEntities; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentFeatures; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentKeywords; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSemanticRoles; -import com.ibm.watson.developer_cloud.discovery.v1.model.NluEnrichmentSentiment; -import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation; -import com.ibm.watson.developer_cloud.discovery.v1.model.NormalizationOperation.Operation; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryAggregation; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryPassages; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.Term; -import com.ibm.watson.developer_cloud.discovery.v1.model.TestConfigurationInEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.TestDocument; -import com.ibm.watson.developer_cloud.discovery.v1.model.Timeslice; -import com.ibm.watson.developer_cloud.discovery.v1.model.TopHits; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExample; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingQuery; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationType; -import com.ibm.watson.developer_cloud.discovery.v1.query.Operator; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.service.exception.ForbiddenException; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import com.ibm.watson.developer_cloud.util.WaitFor; -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.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 { - - // Constants for enum fields - private static final Long FREE = 0L; - - private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; - private static final String DISCOVERY1_TEST_CONFIG_FILE = "src/test/resources/discovery/issue517.json"; - private static final String DISCOVERY2_TEST_CONFIG_FILE = "src/test/resources/discovery/issue518.json"; - private static final String PASSAGES_TEST_FILE_1 = "src/test/resources/discovery/passages_test_doc_1.json"; - private static final String PASSAGES_TEST_FILE_2 = "src/test/resources/discovery/passages_test_doc_2.json"; - 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 username = dummyTest.getProperty("discovery.username"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - dummyTest.setup(); - - ListEnvironmentsOptions listOptions = new ListEnvironmentsOptions.Builder().build(); - ListEnvironmentsResponse listResponse = dummyTest.discovery.listEnvironments(listOptions).execute(); - 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).size(FREE).build(); - Environment createResponse = dummyTest.discovery.createEnvironment(createOptions).execute(); - 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 username = getProperty("discovery.username"); - String password = getProperty("discovery.password"); - String url = getProperty("discovery.url"); - discovery = new Discovery("2017-11-07"); - discovery.setEndPoint(url); - discovery.setUsernameAndPassword(username, password); - - 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(); - return true; - } - - private static final String DEFAULT_CONFIG_NAME = "Default Configuration"; - - @Test - public void exampleIsSuccessful() { - // Discovery discovery = new Discovery("2016-12-15"); - // discovery.setEndPoint("https://gateway.watsonplatform.net/discovery/api"); - // discovery.setUsernameAndPassword("", " normalizations = Arrays.asList(operation); - Enrichment enrichment = new Enrichment(); - enrichment.setSourceField("foo"); - enrichment.setDestinationField("bar"); - enrichment.setEnrichmentName("baz"); - enrichment.setDescription("Erich foo to bar with baz"); - enrichment.setIgnoreDownstreamErrors(true); - enrichment.setOverwrite(false); - - 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.setOptions(options); - List enrichments = Arrays.asList(enrichment); - - CreateConfigurationOptions createOptions = new CreateConfigurationOptions.Builder() - .environmentId(environmentId) - .name(uniqueConfigName) - .description(description) - .conversions(conversions) - .normalizations(normalizations) - .enrichments(enrichments) - .build(); - Configuration createResponse = createConfiguration(createOptions); - - assertEquals(uniqueConfigName, createResponse.getName()); - assertEquals(description, createResponse.getDescription()); - assertEquals(conversions, createResponse.getConversions()); - assertEquals(normalizations, createResponse.getNormalizations()); - assertEquals(enrichments, createResponse.getEnrichments()); - - Date now = new Date(); - assertTrue(fuzzyBefore(createResponse.getCreated(), now)); - assertTrue(fuzzyAfter(createResponse.getCreated(), start)); - assertTrue(fuzzyBefore(createResponse.getUpdated(), now)); - assertTrue(fuzzyAfter(createResponse.getUpdated(), start)); - - } - - @Test - public void deleteConfigurationIsSuccessful() { - Configuration createResponse = createTestConfig(); - - DeleteConfigurationOptions deleteOptions = new DeleteConfigurationOptions.Builder(environmentId, createResponse - .getConfigurationId()).build(); - deleteConfiguration(deleteOptions); - } - - @Test - public void getConfigurationIsSuccessful() { - Configuration createResponse = createTestConfig(); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .getConfigurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute(); - - assertEquals(createResponse.getName(), getResponse.getName()); - } - - @Test - public void getConfigurationsByNameIsSuccessful() { - Configuration createResponse = createTestConfig(); - - ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId); - getBuilder.name(createResponse.getName()); - ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute(); - - assertEquals(1, getResponse.getConfigurations().size()); - assertEquals(createResponse.getName(), getResponse.getConfigurations().get(0).getName()); - } - - @Test - public void getConfigurationsWithFunkyNameIsSuccessful() { - String uniqueConfigName = uniqueName + " with \"funky\" ?x=y&foo=bar ,[x](y) ~!@#$%^&*()-+ {} | ;:<>\\/ chars"; - - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId); - Configuration configuration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE); - createBuilder.configuration(configuration); - createBuilder.name(uniqueConfigName); - Configuration createResponse = createConfiguration(createBuilder.build()); - - ListConfigurationsOptions.Builder getBuilder = new ListConfigurationsOptions.Builder(environmentId); - getBuilder.name(uniqueConfigName); - ListConfigurationsResponse getResponse = discovery.listConfigurations(getBuilder.build()).execute(); - - assertEquals(1, getResponse.getConfigurations().size()); - assertEquals(uniqueConfigName, getResponse.getConfigurations().get(0).getName()); - } - - @Test - public void updateConfigurationIsSuccessful() { - - Configuration testConfig = createTestConfig(); - - Date start = new Date(); - - String updatedName = testConfig.getName() + UUID.randomUUID().toString(); - String updatedDescription = "Description of " + updatedName; - Conversions updatedConversions = new Conversions(); - HtmlSettings newHtmlSettings = new HtmlSettings(); - newHtmlSettings.setExcludeTagsCompletely(Arrays.asList("table", "h6", "header")); - updatedConversions.setHtml(newHtmlSettings); - NormalizationOperation operation = new NormalizationOperation(); - operation.setOperation("foo"); - operation.setSourceField("bar"); - operation.setDestinationField("baz"); - List updatedNormalizations = Arrays.asList(operation); - Enrichment enrichment = new Enrichment(); - enrichment.setSourceField("foo"); - enrichment.setDestinationField("bar"); - enrichment.setEnrichmentName("baz"); - enrichment.setDescription("Erich foo to bar with baz"); - enrichment.setIgnoreDownstreamErrors(true); - enrichment.setOverwrite(false); - - 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.setOptions(options); - List updatedEnrichments = Arrays.asList(enrichment); - - UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(environmentId, testConfig - .getConfigurationId()); - updateBuilder.name(updatedName); - updateBuilder.description(updatedDescription); - updateBuilder.conversions(updatedConversions); - updateBuilder.normalizations(updatedNormalizations); - updateBuilder.enrichments(updatedEnrichments); - Configuration updatedConfiguration = discovery.updateConfiguration(updateBuilder.build()).execute(); - - assertEquals(updatedName, updatedConfiguration.getName()); - assertEquals(updatedDescription, updatedConfiguration.getDescription()); - assertEquals(updatedConversions, updatedConfiguration.getConversions()); - assertEquals(updatedNormalizations, updatedConfiguration.getNormalizations()); - assertEquals(updatedEnrichments, updatedConfiguration.getEnrichments()); - - Date now = new Date(); - assertTrue(fuzzyBefore(updatedConfiguration.getCreated(), start)); - assertTrue(fuzzyBefore(updatedConfiguration.getUpdated(), now)); - assertTrue(fuzzyAfter(updatedConfiguration.getUpdated(), start)); - } - - // Collections - - @Test - public void listCollectionsIsSuccessful() { - createTestCollection(); - ListCollectionsOptions listOptions = new ListCollectionsOptions.Builder(environmentId).build(); - ListCollectionsResponse listResponse = discovery.listCollections(listOptions).execute(); - - 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.getConfigurationId()) - .description(uniqueCollectionDescription); - Collection createResponse = createCollection(createCollectionBuilder.build()); - - assertEquals(createConfigResponse.getConfigurationId(), 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; - UpdateCollectionOptions.Builder updateBuilder = new UpdateCollectionOptions.Builder(environmentId, collection - .getCollectionId()); - updateBuilder.name(updatedCollectionName); - updateBuilder.description(updatedCollectionDescription); - updateBuilder.configurationId(testConfig.getConfigurationId()); - Collection updatedCollection = discovery.updateCollection(updateBuilder.build()).execute(); - - assertEquals(updatedCollectionName, updatedCollection.getName()); - assertEquals(updatedCollectionDescription, updatedCollection.getDescription()); - assertEquals(testConfig.getConfigurationId(), updatedCollection.getConfigurationId()); - } - - @Test - public void deleteCollectionIsSuccessful() { - Configuration createConfigResponse = createTestConfig(); - - String uniqueCollectionName = uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.getConfigurationId()); - 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.getConfigurationId()); - 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(); - - 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.getConfigurationId()); - createCollection(createCollectionBuilder.build()); - - ListCollectionsOptions.Builder getBuilder = new ListCollectionsOptions.Builder(environmentId); - getBuilder.name(uniqueCollectionName); - ListCollectionsResponse getResponse = discovery.listCollections(getBuilder.build()).execute(); - - assertEquals(1, getResponse.getCollections().size()); - assertEquals(uniqueCollectionName, getResponse.getCollections().get(0).getName()); - } - - @SuppressWarnings("deprecation") - @Test - public void addDocumentIsSuccessful() { - Collection collection = createTestCollection(); - - String myDocumentJson = "{\"field\":\"value\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - - AddDocumentOptions.Builder builder = new AddDocumentOptions.Builder(); - builder.environmentId(environmentId); - builder.collectionId(collection.getCollectionId()); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); - - assertFalse(createResponse.getDocumentId().isEmpty()); - assertNull(createResponse.getNotices()); - } - - @Test - public void addDocumentWithConfigurationIsSuccessful() { - Collection collection = createTestCollection(); - 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(collection.getCollectionId()); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); - - assertFalse(createResponse.getDocumentId().isEmpty()); - assertNull(createResponse.getNotices()); - } - - @Ignore - @SuppressWarnings("deprecation") - @Test - public void addDocumentWithMetadataIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - - 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("test_file"); - builder.metadata(myMetadata.toString()); - - DocumentAccepted createResponse = discovery.addDocument(builder.build()).execute(); - - 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(); - - assertTrue(queryResponse.getResults().get(0).getMetadata() != null); - } - - @Test - public void deleteDocumentIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId); - - DeleteDocumentOptions deleteOptions = new DeleteDocumentOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()).build(); - discovery.deleteDocument(deleteOptions).execute(); - } - - @Ignore - @Test - public void getDocumentIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - documentAccepted.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute(); - - assertEquals(DocumentStatus.Status.AVAILABLE, getResponse.getStatus()); - } - - @Test - public void updateDocumentIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted documentAccepted = createTestDocument("test_document", collectionId); - - uniqueName = UUID.randomUUID().toString(); - Configuration testConfig = createTestConfig(); - 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("test_file"); - //updateBuilder.configurationId(testConfig.getConfigurationId()); - DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute(); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - updateResponse.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute(); - - assertTrue(getResponse.getStatus().equals(DocumentStatus.Status.AVAILABLE) - || getResponse.getStatus().equals(DocumentStatus.Status.PROCESSING)); - } - - @Test - public void updateAnotherDocumentIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - - 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(); - - 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("test_file"); - DocumentAccepted updateResponse = discovery.updateDocument(updateBuilder.build()).execute(); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder(environmentId, collectionId, - updateResponse.getDocumentId()).build(); - DocumentStatus getResponse = discovery.getDocumentStatus(getOptions).execute(); - - assertTrue(getResponse.getStatus().equals(DocumentStatus.Status.AVAILABLE) - || getResponse.getStatus().equals(DocumentStatus.Status.PROCESSING)); - } - - @Test - @Ignore("Pending implementation of 'processing' after document update") - public void updateDocumentWithMetadataIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted documentAccepted = createTestDocument("test_document", 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(); - - 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(); - - assertTrue(queryResponse.getResults().get(0).getMetadata() != null); - } - - @Ignore - @Test - public void getCollectionFieldsIsSuccessful() { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - createTestDocument("test_document", collectionId); - - ListCollectionFieldsOptions getOptions = new ListCollectionFieldsOptions.Builder(environmentId, collectionId) - .build(); - ListCollectionFieldsResponse getResponse = discovery.listCollectionFields(getOptions).execute(); - - assertFalse(getResponse.getFields().isEmpty()); - } - - // query tests - - @Test - public void queryWithCountIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.count(5L); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - assertEquals(new Long(10), queryResponse.getMatchingResults()); - assertEquals(5, queryResponse.getResults().size()); - } - - @Test - public void queryWithOffsetIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.offset(5L); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - assertEquals(new Long(10), queryResponse.getMatchingResults()); - assertEquals(5, queryResponse.getResults().size()); - } - - @Test - public void queryWithReturnFieldsIsSuccessful() { - String collectionId = setupTestDocuments(); - createTestDocument("{\"field_2\":\"value_2\"}", collectionId); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - List fieldNames = new ArrayList<>(); - fieldNames.add("field"); - queryBuilder.returnFields(fieldNames); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - String[] expected = new String[] { "id", "result_metadata", "field" }; - assertTrue(queryResponse.getResults().get(0).keySet().containsAll(Arrays.asList(expected))); - } - - @Ignore - @Test - public void queryWithQueryIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.query("field" + Operator.CONTAINS + 1); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - assertEquals(new Long(1), queryResponse.getMatchingResults()); - assertEquals(1, queryResponse.getResults().size()); - assertTrue(queryResponse.getResults().get(0).getScore() > 1.0); - } - - @Test - public void queryWithFilterIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.filter("field" + Operator.CONTAINS + 1); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - assertEquals(new Long(1), queryResponse.getMatchingResults()); - assertEquals(1, queryResponse.getResults().size()); - } - - @Test - public void queryWithSortIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - ArrayList sortList = new ArrayList<>(); - sortList.add("field"); - queryBuilder.sort(sortList); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - assertTrue(queryResponse.getResults().size() > 1); - Double v0 = (Double) (queryResponse.getResults().get(0)).get("field"); - Double v1 = (Double) (queryResponse.getResults().get(1)).get("field"); - assertTrue(v0 <= v1); - } - - @Test - public void queryWithAggregationTermIsSuccessful() { - String collectionId = setupTestDocuments(); - - 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(); - Term term = (Term) queryResponse.getAggregations().get(0); - assertEquals(1, queryResponse.getAggregations().size()); - assertEquals(new Long(10), term.getCount()); - } - - @Test - public void queryWithAggregationHistogramIsSuccessful() throws InterruptedException { - String collectionId = setupTestDocuments(); - - 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(); - 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 { - String collectionId = setupTestDocuments(); - - 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(); - 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 { - String collectionId = setupTestDocuments(); - - 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(); - 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 { - String collectionId = setupTestDocuments(); - - 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(); - 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 { - String collectionId = setupTestDocuments(); - - 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(); - Calculation avg = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.AVERAGE.getName(), avg.getType()); - assertEquals(new Double(4.5), avg.getValue()); - } - - @Test - public void queryWithAggregationFilterIsSuccessful() { - String collectionId = setupTestDocuments(); - - 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(); - 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 { - Collection collection = createTestCollection(); - String collectionId = collection.getCollectionId(); - DocumentAccepted testDocument = createNestedTestDocument("test_document_1", collectionId); - String documentId = testDocument.getDocumentId(); - - 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); - - GetDocumentStatusOptions getOptions = new GetDocumentStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(documentId) - .build(); - DocumentStatus status = discovery.getDocumentStatus(getOptions).execute(); - while (status.getStatus().equals(DocumentAccepted.Status.PROCESSING)) { - Thread.sleep(3000); - status = discovery.getDocumentStatus(getOptions).execute(); - } - - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - 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, "timeslice_document_1", collectionId); - String documentId1 = testDocument1.getDocumentId(); - myDocumentJson = "{\"time\":\"1999-04-16T00:00:00.000-05:00\"}"; - DocumentAccepted testDocument2 = createTestDocument(myDocumentJson, "timeslice_document_2", 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(); - GetDocumentStatusOptions getOptions2 = new GetDocumentStatusOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .documentId(documentId2) - .build(); - DocumentStatus status2 = discovery.getDocumentStatus(getOptions2).execute(); - while (status1.getStatus().equals(DocumentAccepted.Status.PROCESSING) - || status2.getStatus().equals(DocumentAccepted.Status.PROCESSING)) { - Thread.sleep(3000); - status1 = discovery.getDocumentStatus(getOptions1).execute(); - status2 = discovery.getDocumentStatus(getOptions2).execute(); - } - - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - Timeslice timeslice = (Timeslice) queryResponse.getAggregations().get(0); - assertEquals(AggregationType.TIMESLICE.getName(), timeslice.getType()); - assertNotNull(timeslice.getResults()); - } - - @Test - public void queryWithAggregationTopHitsIsSuccessful() { - String collectionId = setupTestDocuments(); - - 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(); - 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() { - String collectionId = setupTestDocuments(); - - 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(); - Calculation uniqueCount = (Calculation) queryResponse.getAggregations().get(0); - assertEquals(new Double(10), uniqueCount.getValue()); - } - - @Test - public void queryWithPassagesIsSuccessful() throws InterruptedException, FileNotFoundException { - Collection testCollection = createTestCollection(); - String collectionId = testCollection.getCollectionId(); - createTestDocument(getStringFromInputStream(new FileInputStream(PASSAGES_TEST_FILE_1)), "test_document_1", - collectionId); - createTestDocument(getStringFromInputStream(new FileInputStream(PASSAGES_TEST_FILE_2)), - "test_document_2", collectionId); - - QueryOptions.Builder queryBuilder = new QueryOptions.Builder(environmentId, collectionId); - queryBuilder.passages(true); - queryBuilder.naturalLanguageQuery("Watson"); - QueryResponse queryResponse = discovery.query(queryBuilder.build()).execute(); - List passages = queryResponse.getPassages(); - assertTrue(passages.size() > 0); - for (QueryPassages passage : passages) { - assertTrue(passage.getPassageText().contains("Watson")); - } - } - - // queryNotices tests - - @Test - public void queryNoticesCountIsSuccessful() { - String collectionId = setupTestDocuments(); - - QueryNoticesOptions.Builder queryBuilder = new QueryNoticesOptions.Builder(environmentId, collectionId); - queryBuilder.count(5L); - QueryNoticesResponse queryResponse = discovery.queryNotices(queryBuilder.build()).execute(); - assertTrue(queryResponse.getResults().size() <= 5); - } - - // Tests for testConfigurationInEnvironment - - @Test - public void testConfigurationInEnvironmentIsSuccessful() { - Configuration testConfig = createTestConfig(); - String myDocumentJson = "{\"field\":\"value2\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - TestConfigurationInEnvironmentOptions options = new TestConfigurationInEnvironmentOptions.Builder(environmentId) - .configurationId(testConfig.getConfigurationId()) - .file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON) - .filename("test_file") - .build(); - TestDocument testResponse = discovery.testConfigurationInEnvironment(options).execute(); - assertNotNull(testResponse); - assertEquals(0, testResponse.getNotices().size()); - } - - @Test - public void testConfigurationInEnvironmentWithAllOptionsIsSuccessful() { - Configuration testConfig = createTestConfig(); - String myDocumentJson = "{\"field\":\"value2\"}"; - InputStream documentStream = new ByteArrayInputStream(myDocumentJson.getBytes()); - JsonObject myMetadata = new JsonObject(); - myMetadata.add("foo", new JsonPrimitive("bar")); - - TestConfigurationInEnvironmentOptions.Builder builder = new TestConfigurationInEnvironmentOptions.Builder(); - builder.environmentId(environmentId); - builder.configurationId(testConfig.getConfigurationId()); - builder.step(TestConfigurationInEnvironmentOptions.Step.HTML_OUTPUT); - builder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); - builder.filename("test_file"); - builder.metadata(myMetadata.toString()); - TestDocument testResponse = discovery.testConfigurationInEnvironment(builder.build()).execute(); - - assertNotNull(testResponse); - assertEquals(0, testResponse.getNotices().size()); - } - - // Tests for reported issues - - @Test - public void issueNumber517() { - String uniqueConfigName = uniqueName + "-config"; - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId); - Configuration configuration = getTestConfiguration(DISCOVERY1_TEST_CONFIG_FILE); - - configuration.setName(uniqueConfigName); - createBuilder.configuration(configuration); - Configuration createResponse = createConfiguration(createBuilder.build()); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .getConfigurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute(); - - // returned config should have some json data - assertEquals(1, getResponse.getConversions().getJsonNormalizations().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(environmentId); - Configuration configuration = getTestConfiguration(DISCOVERY2_TEST_CONFIG_FILE); - - configuration.setName(uniqueConfigName); - createBuilder.configuration(configuration); - Configuration createResponse = createConfiguration(createBuilder.build()); - - GetConfigurationOptions getOptions = new GetConfigurationOptions.Builder(environmentId, createResponse - .getConfigurationId()).build(); - Configuration getResponse = discovery.getConfiguration(getOptions).execute(); - - // verify getResponse deserializes the operations appropriately - for (NormalizationOperation normalization : getResponse.getNormalizations()) { - String operation = normalization.getOperation(); - 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(); - - 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"; - Configuration testConfiguration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE); - CreateConfigurationOptions configOptions = new CreateConfigurationOptions.Builder(environmentId) - .configuration(testConfiguration) - .name(uniqueConfigName) - .build(); - Configuration configuration = discovery.createConfiguration(configOptions).execute(); - configurationIds.add(configuration.getConfigurationId()); - - String uniqueCollectionName = UUID.randomUUID().toString() + "-collection"; - CreateCollectionOptions collectionOptions = new CreateCollectionOptions.Builder(environmentId, uniqueCollectionName) - .configurationId(configuration.getConfigurationId()) - .build(); - Collection collection = discovery.createCollection(collectionOptions).execute(); - collectionIds.add(collection.getCollectionId()); - - assertEquals(collection.getConfigurationId(), configuration.getConfigurationId()); - } - - @Test - public void addTrainingDataIsSuccessful() { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - String naturalLanguageQuery = "Example query" + UUID.randomUUID().toString(); - builder.naturalLanguageQuery(naturalLanguageQuery); - TrainingExample example = new TrainingExample(); - String documentId = createTestDocument("test_document", collectionId).getDocumentId(); - example.setDocumentId(documentId); - int relevance = 0; - example.setRelevance(relevance); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute(); - - 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.getDocumentId(), documentId); - assertTrue(returnedExample.getCrossReference().isEmpty()); - assertEquals(returnedExample.getRelevance(), 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(); - - GetTrainingDataOptions.Builder queryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery updatedQuery = discovery.getTrainingData(queryBuilder.build()).execute(); - - assertTrue(updatedQuery.getExamples().size() > startingExampleCount); - TrainingExample newExample = updatedQuery.getExamples().get(0); - assertEquals(newExample.getDocumentId(), documentId); - assertEquals(newExample.getCrossReference(), crossReference); - assertEquals(newExample.getRelevance(), 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(); - - 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(); - 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(); - 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(); - String exampleId = createdExample.getDocumentId(); - - GetTrainingDataOptions.Builder queryBuilder = new GetTrainingDataOptions.Builder(environmentId, collectionId, - queryId); - TrainingQuery queryWithAddedExample = discovery.getTrainingData(queryBuilder.build()).execute(); - 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(); - - 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(); - - 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); - TrainingExample example = new TrainingExample(); - String documentId = "Document" + UUID.randomUUID().toString(); - example.setDocumentId(documentId); - int relevance = 0; - example.setRelevance(relevance); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute(); - String queryId = response.getQueryId(); - - GetTrainingExampleOptions.Builder getExampleBuilder = new GetTrainingExampleOptions.Builder(environmentId, - collectionId, queryId, documentId); - TrainingExample returnedExample = discovery.getTrainingExample(getExampleBuilder.build()).execute(); - - assertEquals(returnedExample.getDocumentId(), documentId); - } - - @Test - public void updateTrainingExampleIsSuccessful() { - AddTrainingDataOptions.Builder builder = new AddTrainingDataOptions.Builder(environmentId, collectionId); - String naturalLanguageQuery = "Query" + UUID.randomUUID().toString(); - builder.naturalLanguageQuery(naturalLanguageQuery); - TrainingExample example = new TrainingExample(); - String documentId = "Document" + UUID.randomUUID().toString(); - example.setDocumentId(documentId); - int relevance = 0; - example.setRelevance(relevance); - builder.addExamples(example); - TrainingQuery response = discovery.addTrainingData(builder.build()).execute(); - 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(); - - assertEquals(updatedExample.getCrossReference(), newCrossReference); - assertEquals(updatedExample.getRelevance(), 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(); - expansion1.setInputTerms(expansion1InputTerms); - expansion1.setExpandedTerms(expansion1ExpandedTerms); - Expansion expansion2 = new Expansion(); - expansion2.setInputTerms(expansion2InputTerms); - expansion2.setExpandedTerms(expansion2ExpandedTerms); - Expansions expansions = new Expansions(); - expansions.setExpansions(Arrays.asList(expansion1, expansion2)); - CreateExpansionsOptions createOptions = new CreateExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .expansions(expansions) - .build(); - Expansions createResults = discovery.createExpansions(createOptions).execute(); - - assertEquals(createResults.getExpansions().size(), 2); - assertEquals(createResults.getExpansions().get(0).getInputTerms(), expansion1InputTerms); - assertEquals(createResults.getExpansions().get(0).getExpandedTerms(), expansion1ExpandedTerms); - assertEquals(createResults.getExpansions().get(1).getInputTerms(), expansion2InputTerms); - assertEquals(createResults.getExpansions().get(1).getExpandedTerms(), expansion2ExpandedTerms); - - ListExpansionsOptions listOptions = new ListExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - Expansions listResults = discovery.listExpansions(listOptions).execute(); - - assertEquals(listResults.getExpansions().size(), 2); - - DeleteExpansionsOptions deleteOptions = new DeleteExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - discovery.deleteExpansions(deleteOptions).execute(); - - Expansions emptyListResults = discovery.listExpansions(listOptions).execute(); - - assertTrue(emptyListResults.getExpansions().get(0).getInputTerms() == null - || emptyListResults.getExpansions().get(0).getInputTerms().isEmpty()); - assertTrue(emptyListResults.getExpansions().get(0).getExpandedTerms() == null - || emptyListResults.getExpansions().get(0).getExpandedTerms().get(0).isEmpty()); - } - - @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()); - } - } - - private Environment createEnvironment(CreateEnvironmentOptions createOptions) { - Environment createResponse = discovery.createEnvironment(createOptions).execute(); - return createResponse; - } - - private void deleteEnvironment(DeleteEnvironmentOptions deleteOptions) { - discovery.deleteEnvironment(deleteOptions).execute(); - } - - private Configuration createConfiguration(CreateConfigurationOptions createOptions) { - Configuration createResponse = discovery.createConfiguration(createOptions).execute(); - configurationIds.add(createResponse.getConfigurationId()); - 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); - Configuration configuration = getTestConfiguration(DISCOVERY_TEST_CONFIG_FILE); - configuration.setName(uniqueConfigName); - createBuilder.configuration(configuration); - return createConfiguration(createBuilder.build()); - } - - private Collection createCollection(CreateCollectionOptions createOptions) { - Collection createResponse = discovery.createCollection(createOptions).execute(); - 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 = uniqueName + "-collection"; - CreateCollectionOptions.Builder createCollectionBuilder = new CreateCollectionOptions.Builder(environmentId, - uniqueCollectionName) - .configurationId(createConfigResponse.getConfigurationId()); - Collection createResponse = createCollection(createCollectionBuilder.build()); - return createResponse; - } - - private DocumentAccepted createNestedTestDocument(String filename, String collectionId) { - String myDocumentJson = "{\"nested_fields\":{\"field\":\"value\"}}"; - return createTestDocument(myDocumentJson, filename, 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(); - 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); - TrainingQuery addResponse = discovery.addTrainingData(builder.build()).execute(); - return addResponse; - } - - 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().getQueries().size() > 0) { - return collectionId; - } - List queriesAccepted = 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().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().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().getStatus(); - return status.equals(Collection.Status.ACTIVE); - } - - private final String environmentId; - private final String collectionId; - - } - -} diff --git a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java b/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java deleted file mode 100644 index b3af0c178c7..00000000000 --- a/discovery/src/test/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryServiceTest.java +++ /dev/null @@ -1,950 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.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.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.AddTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.Collection; -import com.ibm.watson.developer_cloud.discovery.v1.model.Configuration; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.CreateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteAllTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentAccepted; -import com.ibm.watson.developer_cloud.discovery.v1.model.DocumentStatus; -import com.ibm.watson.developer_cloud.discovery.v1.model.Environment; -import com.ibm.watson.developer_cloud.discovery.v1.model.Expansion; -import com.ibm.watson.developer_cloud.discovery.v1.model.Expansions; -import com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryNoticesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.FederatedQueryOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetCollectionOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetDocumentStatusOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.GetTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionFieldsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListCollectionsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListConfigurationsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListEnvironmentsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListExpansionsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListFieldsOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingDataOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.ListTrainingExamplesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryNoticesResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.QueryResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingDataSet; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExample; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingExampleList; -import com.ibm.watson.developer_cloud.discovery.v1.model.TrainingQuery; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateConfigurationOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateDocumentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateEnvironmentOptions; -import com.ibm.watson.developer_cloud.discovery.v1.model.UpdateTrainingExampleOptions; -import com.ibm.watson.developer_cloud.discovery.v1.query.AggregationType; -import com.ibm.watson.developer_cloud.discovery.v1.query.Operator; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -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.FileNotFoundException; -import java.io.FileReader; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -/** - * Unit tests for {@link Discovery}. - */ -public class DiscoveryServiceTest extends WatsonServiceUnitTest { - private Discovery discoveryService; - - private static final Long THREE = 3L; - private static final String VERSION = "2017-11-07"; - - private static final String DISCOVERY_TEST_CONFIG_FILE = "src/test/resources/discovery/test-config.json"; - private static final String RESOURCE = "src/test/resources/discovery/"; - 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 - + "&filter=field:1" - + "&query=field:1&count=5&return=field&offset=5"; - private static final String Q2_PATH = "/v1/environments/mock_envid/collections/mock_collid/query?version=" - + VERSION - + "&aggregation=term(field)"; - private static final String Q3_PATH = "/v1/environments/mock_envid/query?version=" - + VERSION + "&collection_ids=mock_collid"; - private static final String Q4_PATH = "/v1/environments/mock_envid/notices?version=" - + VERSION + "&collection_ids=mock_collid"; - private static final String Q5_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 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 Environment envResp; - private ListEnvironmentsResponse envsResp; - private Environment createEnvResp; - private Map deleteEnvResp; - private Environment updateEnvResp; - private Configuration createConfResp; - private ListConfigurationsResponse getConfsResp; - private Configuration getConfResp; - private Map deleteConfResp; - private Configuration updateConfResp; - private Collection createCollResp; - private ListCollectionsResponse getCollsResp; - private Collection getCollResp; - private Map deleteCollResp; - private ListCollectionFieldsResponse listfieldsCollResp; - private DocumentAccepted createDocResp; - private DocumentAccepted updateDocResp; - private DocumentStatus getDocResp; - private Map 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; - - @BeforeClass - public static void setupClass() { - } - - @Before - public void setup() throws Exception { - super.setUp(); - discoveryService = new Discovery("2017-11-07"); - discoveryService.setUsernameAndPassword("", ""); - discoveryService.setEndPoint(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"; - - 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", Map.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", Map.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", Map.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", Map.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); - } - - @After - public void cleanup() { - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new Discovery(null); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new Discovery(""); - } - - // 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(); - 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(); - } - - @Test(expected = IllegalArgumentException.class) - public void getEnvironmentFails2() { - @SuppressWarnings("unused") - Environment response = discoveryService.getEnvironment(null).execute(); - } - - @Test - public void listEnvironmentsIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(envsResp)); - ListEnvironmentsResponse response = discoveryService.listEnvironments(null).execute(); - 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(THREE); - createRequestBuilder.description(environmentDesc); - Environment response = discoveryService.createEnvironment(createRequestBuilder.build()).execute(); - 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(); - discoveryService.deleteEnvironment(deleteRequest).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(ENV1_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test(expected = IllegalArgumentException.class) - public void deleteEnvironmentFails() { - discoveryService.deleteEnvironment(null).execute(); - } - - @Test - public void updateEnvironmentIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateEnvResp)); - UpdateEnvironmentOptions.Builder updateBuilder = new UpdateEnvironmentOptions.Builder(environmentId).name( - environmentName); - updateBuilder.description(environmentDesc); - Environment response = discoveryService.updateEnvironment(updateBuilder.build()).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(ENV1_PATH, request.getPath()); - assertEquals(PUT, request.getMethod()); - assertEquals(updateEnvResp, response); - } - - // Configuration tests - @Test - public void createConfigurationIsSuccessful() throws JsonSyntaxException, JsonIOException, - FileNotFoundException, InterruptedException { - server.enqueue(jsonResponse(createConfResp)); - CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId); - Configuration configuration = GsonSingleton.getGson().fromJson(new FileReader(DISCOVERY_TEST_CONFIG_FILE), - Configuration.class); - createBuilder.configuration(configuration); - createBuilder.name(uniqueConfigName); - Configuration response = discoveryService.createConfiguration(createBuilder.build()).execute(); - 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(); - 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(); - 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(); - discoveryService.deleteConfiguration(deleteRequest).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(CONF2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - @Test - public void updateConfigurationIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(updateConfResp)); - UpdateConfigurationOptions.Builder updateBuilder = new UpdateConfigurationOptions.Builder(environmentId, - configurationId); - - Configuration newConf = new Configuration(); - newConf.setName("newName"); - updateBuilder.configuration(newConf); - - Configuration response = discoveryService.updateConfiguration(updateBuilder.build()).execute(); - 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(); - 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(); - 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(); - 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(); - 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(); - discoveryService.deleteCollection(deleteRequest).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(COLL2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - // 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(); - 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(); - 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(); - 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(); - DocumentAccepted response = discoveryService.addDocument(options).execute(); - } - - @Test - public void addDocumentFromInputStreamWithFileNameAndMediaTypeIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(createDocResp)); - String fileName = "MyFileName"; - 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(); - 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(); - 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(); - DocumentAccepted response = discoveryService.updateDocument(options).execute(); - } - - @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(); - 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(); - discoveryService.deleteDocument(deleteRequest).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DOCS2_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } - - // 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); - List fieldNames = new ArrayList<>(); - fieldNames.add("field"); - queryBuilder.returnFields(fieldNames); - queryBuilder.query("field" + Operator.CONTAINS + 1); - queryBuilder.filter("field" + Operator.CONTAINS + 1); - queryBuilder.similar(true); - queryBuilder.similarDocumentIds(Arrays.asList("doc1", "doc2")); - queryBuilder.similarFields(Arrays.asList("field1", "field2")); - QueryResponse response = discoveryService.query(queryBuilder.build()).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q1_PATH + "&similar=true&similar.document_ids=doc1,doc2&similar.fields=field1,field2", - request.getPath()); - assertEquals(GET, 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(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q2_PATH, request.getPath()); - assertEquals(GET, 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(); - example.setDocumentId(documentId); - example.setRelevance(0); - builder.addExamples(example); - TrainingQuery response = discoveryService.addTrainingData(builder.build()).execute(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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); - QueryNoticesResponse response = discoveryService.queryNotices(builder.build()).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q5_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - } - - @Test - public void federatedQueryIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryResp)); - FederatedQueryOptions.Builder builder = new FederatedQueryOptions.Builder(environmentId, new ArrayList<>(Arrays - .asList(collectionId))); - QueryResponse response = discoveryService.federatedQuery(builder.build()).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q3_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - } - - @Test - public void federatedQueryNoticesIsSuccessful() throws InterruptedException { - server.enqueue(jsonResponse(queryNoticesResp)); - FederatedQueryNoticesOptions.Builder builder = new FederatedQueryNoticesOptions.Builder(environmentId, - new ArrayList<>(Arrays.asList(collectionId))); - QueryNoticesResponse response = discoveryService.federatedQueryNotices(builder.build()).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(Q4_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(); - expansion1.setInputTerms(expansion1InputTerms); - expansion1.setExpandedTerms(expansion1ExpandedTerms); - Expansion expansion2 = new Expansion(); - expansion2.setInputTerms(expansion2InputTerms); - expansion2.setExpandedTerms(expansion2ExpandedTerms); - Expansions expansions = new Expansions(); - expansions.setExpansions(Arrays.asList(expansion1, expansion2)); - - CreateExpansionsOptions createOptions = new CreateExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .expansions(expansions) - .build(); - Expansions createResults = discoveryService.createExpansions(createOptions).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXPANSIONS_PATH, request.getPath()); - assertEquals(POST, request.getMethod()); - assertEquals(expansion1, createResults.getExpansions().get(0)); - assertEquals(expansion2, createResults.getExpansions().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(); - expansion1.setInputTerms(expansion1InputTerms); - expansion1.setExpandedTerms(expansion1ExpandedTerms); - Expansion expansion2 = new Expansion(); - expansion2.setInputTerms(expansion2InputTerms); - expansion2.setExpandedTerms(expansion2ExpandedTerms); - - ListExpansionsOptions listOptions = new ListExpansionsOptions.Builder() - .environmentId(environmentId) - .collectionId(collectionId) - .build(); - Expansions listResults = discoveryService.listExpansions(listOptions).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(EXPANSIONS_PATH, request.getPath()); - assertEquals(GET, request.getMethod()); - assertEquals(expansion1, listResults.getExpansions().get(0)); - assertEquals(expansion2, listResults.getExpansions().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(); - 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(); - RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE_USER_DATA_PATH, request.getPath()); - assertEquals(DELETE, request.getMethod()); - } -} 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 new file mode 100644 index 00000000000..a45cc4f08c0 --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryIT.java @@ -0,0 +1,1542 @@ +/* + * (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.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.*; +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; + +/** The Class DiscoveryIT. */ +@RunWith(RetryRunner.class) +public class DiscoveryIT extends WatsonServiceTest { + private static final String VERSION = "2022-07-29"; + private static final String RESOURCE = "src/test/resources/discovery/v2/"; + 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.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + + 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(serviceUrl); + // premiumService = new Discovery(VERSION, premiumAuthenticator); + // premiumService.setDefaultHeaders(getDefaultHeaders()); + // premiumService.setServiceUrl(premiumUrl); + + 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(); + ListCollectionsResponse response = service.listCollections(options).execute().getResult(); + + assertNotNull(response); + boolean foundTestCollection = false; + for (Collection collection : response.getCollections()) { + if (collection.getCollectionId().equals(COLLECTION_ID)) { + foundTestCollection = true; + break; + } + } + 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() { + 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(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + } + + /** Test query with calculation aggregation. */ + @Test + public void testQueryWithCalculationAggregation() { + 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(); + 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); + QueryAggregationQueryCalculationAggregation histogramAggregation = + (QueryAggregationQueryCalculationAggregation) response.getAggregations().get(0); + assertNotNull(histogramAggregation); + + assertNotNull(response); + } + + /** Test query with filter aggregation. */ + @Test + public void testQueryWithFilterAggregation() { + 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(); + 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); + QueryAggregationQueryFilterAggregation filterAggregation = + (QueryAggregationQueryFilterAggregation) response.getAggregations().get(0); + assertNotNull(filterAggregation); + + assertNotNull(response); + } + + /** Test query with histogram aggregation. */ + @Test + public void testQueryWithHistogramAggregation() { + 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(); + 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); + QueryAggregationQueryHistogramAggregation histogramAggregation = + (QueryAggregationQueryHistogramAggregation) response.getAggregations().get(0); + assertNotNull(histogramAggregation); + + assertNotNull(response); + } + + /** Test query with nested aggregation. */ + @Test + public void testQueryWithNestedAggregation() { + StringBuilder sb = new StringBuilder(); + sb.append(AggregationType.NESTED); + sb.append(Operator.OPENING_GROUPING); + sb.append("enriched_text"); + sb.append(Operator.NEST_AGGREGATION); + sb.append("entities"); + 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(); + 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); + QueryAggregationQueryNestedAggregation nestedAggregation = + (QueryAggregationQueryNestedAggregation) response.getAggregations().get(0); + assertNotNull(nestedAggregation); + + assertNotNull(response); + } + + /** Test query with term aggregation. */ + @Test + public void testQueryWithTermAggregation() { + 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(); + 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); + QueryAggregationQueryTermAggregation termAggregation = + (QueryAggregationQueryTermAggregation) response.getAggregations().get(0); + assertNotNull(termAggregation); + + assertNotNull(response); + } + + /** Test query with timeslice aggregation. */ + @Test + public void testQueryWithTimesliceAggregation() { + 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(); + 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); + 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(); + sb.append(AggregationType.TOP_HITS); + sb.append(Operator.OPENING_GROUPING); + sb.append("3"); + sb.append(Operator.CLOSING_GROUPING); + String aggregation = sb.toString(); + 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); + 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(); + 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(); + QueryResponse responseNoOffset = service.query(optionsNoOffset).execute().getResult(); + + assertNotNull(responseNoOffset); + + QueryOptions optionsWithOffset = + new QueryOptions.Builder().projectId(PROJECT_ID).offset(2L).build(); + QueryResponse responseWithOffset = service.query(optionsWithOffset).execute().getResult(); + + assertNotNull(responseWithOffset); + if (responseNoOffset.getResults().size() > 2) { + assertNotEquals(responseNoOffset.getResults().get(0), responseWithOffset.getResults().get(0)); + } + } + + /** Test query with sort. */ + @Test + public void testQueryWithSort() { + QueryOptions options = + new QueryOptions.Builder().projectId(PROJECT_ID).sort("document_id").build(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + if (response.getResults().size() >= 2) { + String firstDocumentId = response.getResults().get(0).getDocumentId(); + String secondDocumentId = response.getResults().get(1).getDocumentId(); + assertTrue(firstDocumentId.compareTo(secondDocumentId) < 0); + } + } + + /** Test query with highlight. */ + @Test + public void testQueryWithHighlight() { + QueryOptions options = + new QueryOptions.Builder() + .projectId(PROJECT_ID) + .naturalLanguageQuery("president") + .highlight(true) + .build(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + if (response.getResults().size() > 0) { + boolean foundHighlight = false; + for (QueryResult result : response.getResults()) { + for (QueryResultPassage passage : result.getDocumentPassages()) { + if (passage.getPassageText().contains("")) { + foundHighlight = true; + break; + } + } + } + assertTrue(foundHighlight); + } + } + + /** Test query with spelling suggestions. */ + @Test + public void testQueryWithSpellingSuggestions() { + 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(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.getTableResults()); + 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(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + assertNotNull(response.getSuggestedRefinements()); + 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(); + QueryResponse response = service.query(options).execute().getResult(); + + assertNotNull(response); + boolean foundPassages = false; + for (QueryResult result : response.getResults()) { + if (result.getDocumentPassages() != null) { + assertTrue(result.getDocumentPassages().size() <= 5); + foundPassages = true; + break; + } + } + assertTrue(foundPassages); + } + + /** Test get autocompletion. */ + @Test + public void testGetAutocompletion() { + GetAutocompletionOptions options = + new GetAutocompletionOptions.Builder() + .projectId(PROJECT_ID) + .prefix("pre") + .count(5L) + .build(); + Completions response = service.getAutocompletion(options).execute().getResult(); + + assertNotNull(response); + assertTrue(response.getCompletions().size() <= 5); + 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(); + 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(); + 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(); + 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(); + + assertNotNull(responseNoOffset); + + 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) { + assertNotEquals(responseNoOffset.getNotices().get(0), responseWithOffset.getNotices().get(0)); + } + } + + /** Test list fields. */ + @Test + public void testListFields() { + 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(); + + 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(); + DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); + + assertNotNull(addResponse); + String documentId = addResponse.getDocumentId(); + + 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(); + + 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(); + + assertNotNull(deleteResponse); + assertEquals(documentId, deleteResponse.getDocumentId()); + + testFile.close(); + } + } + + /** + * 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(); + + 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(); + 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(); + + assertNotNull(createResponse); + assertEquals(trainingExample.collectionId(), createResponse.examples().get(0).collectionId()); + assertEquals(trainingExample.documentId(), createResponse.examples().get(0).documentId()); + assertEquals(trainingExample.relevance(), createResponse.examples().get(0).relevance()); + String queryId = createResponse.queryId(); + + try { + 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(); + + 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(); + + assertNotNull(updateResponse); + assertEquals(updatedQuery, updateResponse.naturalLanguageQuery()); + } finally { + DeleteTrainingQueriesOptions deleteTrainingQueriesOptions = + new DeleteTrainingQueriesOptions.Builder().projectId(PROJECT_ID).build(); + service.deleteTrainingQueries(deleteTrainingQueriesOptions).execute(); + + 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(); + 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 new file mode 100644 index 00000000000..f244f670ade --- /dev/null +++ b/discovery/src/test/java/com/ibm/watson/discovery/v2/DiscoveryTest.java @@ -0,0 +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.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.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); + } + + // 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 testCreateEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateEnrichmentWOptions(); + + discoveryService.disableRetries(); + testCreateEnrichmentWOptions(); + } + + // 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 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(); + } + + // 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 testUpdateEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testUpdateEnrichmentWOptions(); + + 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(); + } + + // 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 testDeleteEnrichmentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteEnrichmentWOptions(); + + discoveryService.disableRetries(); + testDeleteEnrichmentWOptions(); + } + + // 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 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(); + } + + // 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 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(); + } + + // 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 testPushBatchesWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testPushBatchesWOptions(); + + discoveryService.disableRetries(); + testPushBatchesWOptions(); + } + + // 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(); + } + + // 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 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(); + } + + // 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 testCreateDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateDocumentClassifierWOptions(); + + discoveryService.disableRetries(); + testCreateDocumentClassifierWOptions(); + } + + // 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(); + } + + // 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 testGetDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testGetDocumentClassifierWOptions(); + + discoveryService.disableRetries(); + testGetDocumentClassifierWOptions(); + } + + // 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 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(); + } + + // 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(); + } + + // 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 testDeleteDocumentClassifierWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteDocumentClassifierWOptions(); + + discoveryService.disableRetries(); + testDeleteDocumentClassifierWOptions(); + } + + // 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(); + } + + // 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 testListDocumentClassifierModelsWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testListDocumentClassifierModelsWOptions(); + + discoveryService.disableRetries(); + testListDocumentClassifierModelsWOptions(); + } + + // 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(); + } + + // 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 testCreateDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testCreateDocumentClassifierModelWOptions(); + + discoveryService.disableRetries(); + testCreateDocumentClassifierModelWOptions(); + } + + // 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(); + } + + // 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 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(); + } + + // 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(); + } + + // 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 testDeleteDocumentClassifierModelWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testDeleteDocumentClassifierModelWOptions(); + + discoveryService.disableRetries(); + testDeleteDocumentClassifierModelWOptions(); + } + + // 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 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"); + } + + // Test the analyzeDocument operation with and without retries enabled + @Test + public void testAnalyzeDocumentWRetries() throws Throwable { + discoveryService.enableRetries(4, 30); + testAnalyzeDocumentWOptions(); + + 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 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; + } + + // 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(); + 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/add_training_example_resp.json b/discovery/src/test/resources/discovery/add_training_example_resp.json deleted file mode 100644 index bc3d3cd680f..00000000000 --- a/discovery/src/test/resources/discovery/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/add_training_query_resp.json b/discovery/src/test/resources/discovery/add_training_query_resp.json deleted file mode 100644 index cf268ea13c8..00000000000 --- a/discovery/src/test/resources/discovery/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/create_coll_resp.json b/discovery/src/test/resources/discovery/create_coll_resp.json deleted file mode 100644 index 6d811a6ea50..00000000000 --- a/discovery/src/test/resources/discovery/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/create_conf_resp.json b/discovery/src/test/resources/discovery/create_conf_resp.json deleted file mode 100644 index e5067c71761..00000000000 --- a/discovery/src/test/resources/discovery/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/create_doc_resp.json b/discovery/src/test/resources/discovery/create_doc_resp.json deleted file mode 100644 index f89b8a20406..00000000000 --- a/discovery/src/test/resources/discovery/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/create_env_resp.json b/discovery/src/test/resources/discovery/create_env_resp.json deleted file mode 100644 index 5b0109a68d9..00000000000 --- a/discovery/src/test/resources/discovery/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/delete_coll_resp.json b/discovery/src/test/resources/discovery/delete_coll_resp.json deleted file mode 100644 index 5a5203844be..00000000000 --- a/discovery/src/test/resources/discovery/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/delete_conf_resp.json b/discovery/src/test/resources/discovery/delete_conf_resp.json deleted file mode 100644 index 81d69519c50..00000000000 --- a/discovery/src/test/resources/discovery/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/delete_doc_resp.json b/discovery/src/test/resources/discovery/delete_doc_resp.json deleted file mode 100644 index 6aeba34b3a0..00000000000 --- a/discovery/src/test/resources/discovery/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/delete_env_resp.json b/discovery/src/test/resources/discovery/delete_env_resp.json deleted file mode 100644 index 53df6cea614..00000000000 --- a/discovery/src/test/resources/discovery/delete_env_resp.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "environment_id": "{environment_id}", - "status": "deleted" -} diff --git a/discovery/src/test/resources/discovery/expansions_resp.json b/discovery/src/test/resources/discovery/expansions_resp.json deleted file mode 100644 index 3456f883d6f..00000000000 --- a/discovery/src/test/resources/discovery/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/get_coll1_resp.json b/discovery/src/test/resources/discovery/get_coll1_resp.json deleted file mode 100644 index aa9b74f432c..00000000000 --- a/discovery/src/test/resources/discovery/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/get_coll_resp.json b/discovery/src/test/resources/discovery/get_coll_resp.json deleted file mode 100644 index 3428eddeba7..00000000000 --- a/discovery/src/test/resources/discovery/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/get_conf_resp.json b/discovery/src/test/resources/discovery/get_conf_resp.json deleted file mode 100644 index 1c38c4bca7a..00000000000 --- a/discovery/src/test/resources/discovery/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/get_confs_resp.json b/discovery/src/test/resources/discovery/get_confs_resp.json deleted file mode 100644 index 50083f93f81..00000000000 --- a/discovery/src/test/resources/discovery/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/get_doc_resp.json b/discovery/src/test/resources/discovery/get_doc_resp.json deleted file mode 100644 index 36626fafa3b..00000000000 --- a/discovery/src/test/resources/discovery/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/get_env_resp.json b/discovery/src/test/resources/discovery/get_env_resp.json deleted file mode 100644 index 4ef2514162e..00000000000 --- a/discovery/src/test/resources/discovery/get_env_resp.json +++ /dev/null @@ -1,24 +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": "available", - "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 - } - } -} diff --git a/discovery/src/test/resources/discovery/get_envs_resp.json b/discovery/src/test/resources/discovery/get_envs_resp.json deleted file mode 100644 index bd3076b111c..00000000000 --- a/discovery/src/test/resources/discovery/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/get_training_data_resp.json b/discovery/src/test/resources/discovery/get_training_data_resp.json deleted file mode 100644 index cf268ea13c8..00000000000 --- a/discovery/src/test/resources/discovery/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/get_training_example_resp.json b/discovery/src/test/resources/discovery/get_training_example_resp.json deleted file mode 100644 index bc3d3cd680f..00000000000 --- a/discovery/src/test/resources/discovery/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/issue517.json b/discovery/src/test/resources/discovery/issue517.json deleted file mode 100644 index 5c4ee81a99b..00000000000 --- a/discovery/src/test/resources/discovery/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/issue518.json b/discovery/src/test/resources/discovery/issue518.json deleted file mode 100644 index 2e32c2ac4f7..00000000000 --- a/discovery/src/test/resources/discovery/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/list_fields_resp.json b/discovery/src/test/resources/discovery/list_fields_resp.json deleted file mode 100644 index 2a34d013a75..00000000000 --- a/discovery/src/test/resources/discovery/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/list_training_data_resp.json b/discovery/src/test/resources/discovery/list_training_data_resp.json deleted file mode 100644 index 503353e69bd..00000000000 --- a/discovery/src/test/resources/discovery/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/list_training_examples_resp.json b/discovery/src/test/resources/discovery/list_training_examples_resp.json deleted file mode 100644 index cdfd587bf69..00000000000 --- a/discovery/src/test/resources/discovery/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/listfields_coll_resp.json b/discovery/src/test/resources/discovery/listfields_coll_resp.json deleted file mode 100644 index dc45c39a1b2..00000000000 --- a/discovery/src/test/resources/discovery/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/passages_test_doc_1.json b/discovery/src/test/resources/discovery/passages_test_doc_1.json deleted file mode 100644 index c065af80ae5..00000000000 --- a/discovery/src/test/resources/discovery/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/passages_test_doc_2.json b/discovery/src/test/resources/discovery/passages_test_doc_2.json deleted file mode 100644 index 3dde183fe61..00000000000 --- a/discovery/src/test/resources/discovery/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/query1_resp.json b/discovery/src/test/resources/discovery/query1_resp.json deleted file mode 100644 index 594c49ab746..00000000000 --- a/discovery/src/test/resources/discovery/query1_resp.json +++ /dev/null @@ -1,533 +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" - } - ] - } - } - ] -} diff --git a/discovery/src/test/resources/discovery/test-config.json b/discovery/src/test/resources/discovery/test-config.json deleted file mode 100644 index 120e8b6da26..00000000000 --- a/discovery/src/test/resources/discovery/test-config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "watson_developer_cloud_config" -} diff --git a/discovery/src/test/resources/discovery/update_conf_resp.json b/discovery/src/test/resources/discovery/update_conf_resp.json deleted file mode 100644 index 97ea6fdfb57..00000000000 --- a/discovery/src/test/resources/discovery/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/update_doc_resp.json b/discovery/src/test/resources/discovery/update_doc_resp.json deleted file mode 100644 index bd8a195c28c..00000000000 --- a/discovery/src/test/resources/discovery/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/update_env_resp.json b/discovery/src/test/resources/discovery/update_env_resp.json deleted file mode 100644 index ebaed798103..00000000000 --- a/discovery/src/test/resources/discovery/update_env_resp.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "environment_id": "9e21069a-8bc1-475e-a1d3-2121c49ef060", - "name": "Andrea_environment", - "description": "Dev environment for Andrea", - "created": "2016-12-13T17:42:23.067Z", - "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/update_training_example_resp.json b/discovery/src/test/resources/discovery/update_training_example_resp.json deleted file mode 100644 index 68a65bd2934..00000000000 --- a/discovery/src/test/resources/discovery/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/completions.json b/discovery/src/test/resources/discovery/v2/completions.json new file mode 100644 index 00000000000..2a4c39356c8 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/completions.json @@ -0,0 +1,5 @@ +{ + "completions": [ + "completion" + ] +} diff --git a/discovery/src/test/resources/discovery/v2/component-settings-response.json b/discovery/src/test/resources/discovery/v2/component-settings-response.json new file mode 100644 index 00000000000..ab189ef9e85 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/component-settings-response.json @@ -0,0 +1,22 @@ +{ + "fields_shown": { + "body": { + "use_passage": true, + "field": "field" + }, + "title": { + "field": "field" + } + }, + "autocomplete": true, + "structured_search": true, + "results_per_page": 17, + "aggregations": [ + { + "name": "name", + "label": "label", + "multiple_selections_allowed": true, + "visualization_type": "visualization_type" + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/delete-document-response.json b/discovery/src/test/resources/discovery/v2/delete-document-response.json new file mode 100644 index 00000000000..235ffe50471 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/delete-document-response.json @@ -0,0 +1,4 @@ +{ + "document_id": "document_id", + "status": "status" +} diff --git a/discovery/src/test/resources/discovery/v2/document-accepted.json b/discovery/src/test/resources/discovery/v2/document-accepted.json new file mode 100644 index 00000000000..235ffe50471 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/document-accepted.json @@ -0,0 +1,4 @@ +{ + "document_id": "document_id", + "status": "status" +} diff --git a/discovery/src/test/resources/discovery/v2/list-collections-response.json b/discovery/src/test/resources/discovery/v2/list-collections-response.json new file mode 100644 index 00000000000..3c627d7f6f1 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/list-collections-response.json @@ -0,0 +1,8 @@ +{ + "collections": [ + { + "collection_id": "collection_id", + "name": "name" + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/list-fields-response.json b/discovery/src/test/resources/discovery/v2/list-fields-response.json new file mode 100644 index 00000000000..db88f7b2242 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/list-fields-response.json @@ -0,0 +1,9 @@ +{ + "fields": [ + { + "field": "field", + "type": "type", + "collection_id": "collection_id" + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/query-notices-response.json b/discovery/src/test/resources/discovery/v2/query-notices-response.json new file mode 100644 index 00000000000..34433a005b7 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/query-notices-response.json @@ -0,0 +1,15 @@ +{ + "matching_results": 6, + "notices": [ + { + "notice_id": "notice_id", + "created": "1995-06-12T01:11:11.111Z", + "document_id": "document_id", + "collection_id": "collection_id", + "query_id": "query_id", + "severity": "severity", + "step": "step", + "description": "description" + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/query-response.json b/discovery/src/test/resources/discovery/v2/query-response.json new file mode 100644 index 00000000000..53666ef4111 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/query-response.json @@ -0,0 +1,184 @@ +{ + "matching_results": 6, + "results": [ + { + "document_id": "document_id", + "metadata": {}, + "result_metadata": { + "document_retrieval_source": "document_retrieval_source", + "collection_id": "collection_id", + "confidence": 0.0 + }, + "document_passages": [ + { + "passage_text": "passage_text", + "start_offset": 7, + "end_offset": 8, + "field": "field" + } + ] + } + ], + "retrieval_details": { + "document_retrieval_strategy": "document_retrieval_strategy" + }, + "suggested_query": "suggested_query", + "suggested_refinements": [ + { + "text": "text" + } + ], + "table_results": [ + { + "table_id": "table_id", + "source_document_id": "source_document_id", + "collection_id": "collection_id", + "table_html": "table_html", + "table_html_offset": 9, + "table": { + "location": { + "begin": 10, + "end": 11 + }, + "text": "text", + "section_title": { + "text": "text", + "location": { + "begin": 10, + "end": 11 + } + }, + "title": { + "text": "text", + "location": { + "begin": 10, + "end": 11 + } + }, + "table_headers": [ + { + "cell_id": "cell_id", + "location": {}, + "text": "text", + "row_index_begin": 12, + "row_index_end": 13, + "column_index_begin": 14, + "column_index_end": 15 + } + ], + "row_headers": [ + { + "cell_id": "cell_id", + "location": { + "begin": 10, + "end": 11 + }, + "text": "text", + "text_normalized": "text_normalized", + "row_index_begin": 12, + "row_index_end": 13, + "column_index_begin": 14, + "column_index_end": 15 + } + ], + "column_headers": [ + { + "cell_id": "cell_id", + "location": {}, + "text": "text", + "text_normalized": "text_normalized", + "row_index_begin": 12, + "row_index_end": 13, + "column_index_begin": 14, + "column_index_end": 15 + } + ], + "key_value_pairs": [ + { + "key": { + "cell_id": "cell_id", + "location": { + "begin": 10, + "end": 11 + }, + "text": "text" + }, + "value": [ + { + "cell_id": "cell_id", + "location": { + "begin": 10, + "end": 11 + }, + "text": "text" + } + ] + } + ], + "body_cells": [ + { + "cell_id": "cell_id", + "location": { + "begin": 10, + "end": 11 + }, + "text": "text", + "row_index_begin": 12, + "row_index_end": 13, + "column_index_begin": 14, + "column_index_end": 15, + "row_header_ids": [ + { + "id": "id" + } + ], + "row_header_texts": [ + { + "text": "text" + } + ], + "row_header_texts_normalized": [ + { + "text_normalized": "text_normalized" + } + ], + "column_header_ids": [ + { + "id": "id" + } + ], + "column_header_texts": [ + { + "text": "text" + } + ], + "column_header_texts_normalized": [ + { + "text_normalized": "text_normalized" + } + ], + "attributes": [ + { + "type": "type", + "text": "text", + "location": { + "begin": 10, + "end": 11 + } + } + ] + } + ], + "contexts": [ + { + "text": "text", + "location": { + "begin": 10, + "end": 11 + } + } + ] + } + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/test-pdf.pdf b/discovery/src/test/resources/discovery/v2/test-pdf.pdf new file mode 100644 index 00000000000..bf1241ab635 Binary files /dev/null and b/discovery/src/test/resources/discovery/v2/test-pdf.pdf differ 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/discovery/src/test/resources/discovery/v2/training-query-set.json b/discovery/src/test/resources/discovery/v2/training-query-set.json new file mode 100644 index 00000000000..544e85f464d --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/training-query-set.json @@ -0,0 +1,20 @@ +{ + "queries": [ + { + "query_id": "query_id", + "natural_language_query": "natural_language_query", + "filter": "filter", + "created": "1995-06-12T01:11:11.111Z", + "updated": "1995-06-12T01:11:11.111Z", + "examples": [ + { + "document_id": "document_id", + "collection_id": "collection_id", + "relevance": 1, + "created": "1995-06-12T01:11:11.111Z", + "updated": "1995-06-12T01:11:11.111Z" + } + ] + } + ] +} diff --git a/discovery/src/test/resources/discovery/v2/training-query.json b/discovery/src/test/resources/discovery/v2/training-query.json new file mode 100644 index 00000000000..76f1b8bea58 --- /dev/null +++ b/discovery/src/test/resources/discovery/v2/training-query.json @@ -0,0 +1,16 @@ +{ + "query_id": "query_id", + "natural_language_query": "natural_language_query", + "filter": "filter", + "created": "1995-06-12T01:11:11.111Z", + "updated": "1995-06-12T01:11:11.111Z", + "examples": [ + { + "document_id": "document_id", + "collection_id": "collection_id", + "relevance": 1, + "created": "1995-06-12T01:11:11.111Z", + "updated": "1995-06-12T01:11:11.111Z" + } + ] +} diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000000..0c142869323 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,13 @@ +# Import java base image (using maven to build project) +FROM maven:3.6.1-jdk-11-slim + +# Copy project files +COPY pom.xml /app/pom.xml +COPY src /app/src +WORKDIR /app + +# Build project +RUN mvn compiler:compile -f "/app/pom.xml" + +# Be sure to change the main class name if you use your own files! +RUN mvn -e exec:java -Dexec.mainClass="com.ibm.DockerTest" \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 00000000000..f48aaaa09a3 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,19 @@ +## Using this library in Docker +You can use the provided Dockerfile and POM to help test issues you have with the SDK. + +1. Install Docker + - Mac: + - Windows: +2. Add the dependencies and code you'd like to test + - If you're testing a simple project, you can edit the `DockerTest.java` file directly. Everything's set up to pull in the lastest version of the `ibm-watson` package and run that file when building the image. + - If you'd like to use your own files, feel free to add them. Just be sure to edit the execution line in the Dockerfile to run your main class: + + ``` + RUN mvn -e exec:java -Dexec.mainClass="com.ibm." + ``` + If you import a project with a different group ID, you'll need to change that in the provided `pom.xml` as well. + + - For more information on dockerfile construction please visit +3. Build the Docker image + - From the directory with the Dockerfile, run `docker build --tag= .` + - You should be able to verify that everything worked properly based on the output! \ No newline at end of file diff --git a/docker/pom.xml b/docker/pom.xml new file mode 100644 index 00000000000..c5bc7eb1071 --- /dev/null +++ b/docker/pom.xml @@ -0,0 +1,43 @@ + + 4.0.0 + com.ibm + java-sdk-docker-app + jar + 1.0-SNAPSHOT + java-sdk-docker-app + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + com.ibm.watson + ibm-watson + 16.1.0 + + + + 7 + 7 + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + + java + + + + + + + \ No newline at end of file diff --git a/docker/src/main/java/com/ibm/DockerTest.java b/docker/src/main/java/com/ibm/DockerTest.java new file mode 100644 index 00000000000..598fb1e3827 --- /dev/null +++ b/docker/src/main/java/com/ibm/DockerTest.java @@ -0,0 +1,7 @@ +package com.ibm; + +public class DockerTest { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} 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 a683a0af5b4..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 { - mavenCentral() -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -checkstyle { - configFile = rootProject.file('checkstyle.xml') -} - -dependencies { - compile group: 'com.ibm.watson.developer_cloud', name: 'java-sdk', version: '5.1.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 new file mode 100644 index 00000000000..bc80ca4330a --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/assistant/v1/AssistantExample.java @@ -0,0 +1,75 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.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.MessageInput; +import com.ibm.watson.assistant.v1.model.MessageOptions; +import com.ibm.watson.assistant.v1.model.MessageResponse; +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. + * + * @version v1-experimental + */ +public class AssistantExample { + + public static void main(String[] args) throws Exception { + Authenticator authenticator = new IamAuthenticator(""); + Assistant service = new Assistant("2019-02-28", authenticator); + + MessageInput input = new MessageInput(); + input.setText("Hi"); + 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()); + } + + @Override + public void onFailure(Exception e) {} + }); + + // RxJava + 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()); + } + }); + + Thread.sleep(5000); + } +} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantExample.java deleted file mode 100644 index f29e48a70e6..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/AssistantExample.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1; - -import java.util.Map; - -import com.ibm.watson.developer_cloud.assistant.v1.Assistant; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.assistant.v1.model.OutputData; -import com.ibm.watson.developer_cloud.http.ServiceCallback; - -import jersey.repackaged.jsr166e.CompletableFuture; - -/** - * Example of how to call the Assisant message method synchronously, - * asynchronously, and using react. - * - * @version v1-experimental - */ -public class AssistantExample { - - public static void main(String[] args) throws Exception { - Assistant service = new Assistant("2018-02-16"); - service.setUsernameAndPassword("", ""); - - InputData input = new InputData.Builder("Hi").build(); - MessageOptions options = new MessageOptions.Builder("") - .input(input) - .build(); - - // sync - MessageResponse response = service.message(options).execute(); - System.out.println(response); - - // async - service.message(options).enqueue(new ServiceCallback() { - @Override - public void onResponse(MessageResponse response) { - System.out.println(response); - } - - @Override - public void onFailure(Exception e) { } - }); - - // rx callback - service.message(options).rx() - .thenApply(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx async callback - service.message(options).rx() - .thenApplyAsync(new CompletableFuture.Fun() { - @Override - public OutputData apply(MessageResponse message) { - return message.getOutput(); - } - }).thenAccept(new CompletableFuture.Action() { - @Override - public void accept(OutputData output) { - System.out.println(output); - } - }); - - // rx sync - try { - MessageResponse rxMessageResponse = service.message(options).rx().get(); - System.out.println(rxMessageResponse); - } catch (Exception ex) { - // Handle exception - } - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java deleted file mode 100644 index 256c18702ee..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/AssistantToneAnalyzerIntegrationExample.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.assistant.v1.tone_analyzer_integration; - -import java.util.HashMap; -import java.util.Map; - -import com.ibm.watson.developer_cloud.assistant.v1.Assistant; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageOptions; -import com.ibm.watson.developer_cloud.assistant.v1.model.MessageResponse; -import com.ibm.watson.developer_cloud.http.ServiceCallback; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.ToneAnalyzer; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; - -/** - * 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 - Assistant assistantService = new Assistant("2018-02-16"); - assistantService.setUsernameAndPassword("", ""); - - // instantiate the tone analyzer service - ToneAnalyzer toneService = new ToneAnalyzer("2017-09-21"); - toneService.setUsernameAndPassword("", ""); - - // 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: input (String): an input string (the user's conversation turn) and context - * (Map: 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 input = "I am happy"; - Map context = new HashMap<>(); - - // 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(ToneAnalysis toneResponsePayload) { - - // update context with the tone data returned by the Tone Analyzer - ToneDetection.updateUserTone(context, toneResponsePayload, maintainHistory); - - // call Assistant Service with the input and tone-aware context - MessageOptions messageOptions = new MessageOptions.Builder(workspaceId) - .input(new InputData.Builder(input).build()) - .context(context) - .build(); - assistantService.message(messageOptions).enqueue(new ServiceCallback() { - @Override - public void onResponse(MessageResponse response) { - System.out.println(response); - } - - @Override - public void onFailure(Exception e) { } - }); - } - - @Override - public void onFailure(Exception e) { } - }); - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/ToneDetection.java b/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/ToneDetection.java deleted file mode 100644 index 021a7cecba0..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/assistant/v1/tone_analyzer_integration/ToneDetection.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneCategory; -import com.ibm.watson.developer_cloud.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://console.bluemix.net/docs/services/tone-analyzer/using-tone.html 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(Map 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")) { - 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/developer_cloud/discovery/v1/DiscoveryQueryExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryQueryExample.java deleted file mode 100644 index 9aed5812053..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/discovery/v1/DiscoveryQueryExample.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.ibm.watson.developer_cloud.discovery.v1; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.discovery.v1.model.collection.CreateCollectionRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.collection.CreateCollectionResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.collection.DeleteCollectionRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.collection.GetCollectionRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.collection.GetCollectionResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.common.Status; -import com.ibm.watson.developer_cloud.discovery.v1.model.configuration.Configuration; -import com.ibm.watson.developer_cloud.discovery.v1.model.configuration.GetConfigurationsRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.configuration.GetConfigurationsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.document.CreateDocumentRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.document.CreateDocumentResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.document.Document; -import com.ibm.watson.developer_cloud.discovery.v1.model.document.GetDocumentRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.document.GetDocumentResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.CreateEnvironmentRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.CreateEnvironmentResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.Environment; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.GetEnvironmentRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.GetEnvironmentResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.GetEnvironmentsRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.environment.GetEnvironmentsResponse; -import com.ibm.watson.developer_cloud.discovery.v1.model.query.QueryRequest; -import com.ibm.watson.developer_cloud.discovery.v1.model.query.QueryResponse; -import com.ibm.watson.developer_cloud.http.HttpMediaType; - -/** - * End-to-end example for querying Discovery. - */ -public class DiscoveryQueryExample { - private static final String DEFAULT_CONFIG_NAME = "Default Configuration"; - - public static void main(String[] args) { - Discovery discovery = new Discovery("2017-11-07"); - discovery.setEndPoint("https://gateway.watsonplatform.net/discovery/api"); - discovery.setUsernameAndPassword("", "", ""); - - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello") - .source(Language.ENGLISH) - .target(Language.SPANISH) - .build(); - TranslationResult translationResult = service.translate(translateOptions).execute(); - - System.out.println(translationResult); - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierExample.java deleted file mode 100644 index e6b433a0a4b..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierExample.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1; - -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classification; - -public class NaturalLanguageClassifierExample { - - public static void main(String[] args) { - NaturalLanguageClassifier service = new NaturalLanguageClassifier(); - service.setUsernameAndPassword("", ""); - - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId("") - .text("Is it sunny?") - .build(); - Classification classification = service.classify(classifyOptions).execute(); - - System.out.println(classification); - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsExample.java deleted file mode 100644 index 6dec3bd8a39..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsExample.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights_v3_example; - -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions; -import com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights; - -public class PersonalityInsightsExample { - - public static void main(String[] args) { - PersonalityInsights service = new PersonalityInsights("2016-10-19"); - service.setUsernameAndPassword("", ""); - - 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(); - - System.out.println(profile); - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/CustomizationExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/CustomizationExample.java deleted file mode 100755 index 15d36c81619..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/CustomizationExample.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import java.io.File; -import java.util.List; - -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpora; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words; - -/** - * 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"; - - /** - * The main method. - * - * @param args the arguments - * @throws InterruptedException the interrupted exception - */ - public static void main(String[] args) throws InterruptedException { - SpeechToText service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - - // Create language model - CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder() - .name("IEEE-permanent") - .baseModelName("en-US_BroadbandModel") - .description("My customization") - .build(); - LanguageModel myModel = service.createLanguageModel(createOptions).execute(); - 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)) - .corpusFileContentType(HttpMediaType.TEXT_PLAIN) - .allowOverwrite(false) - .build(); - service.addCorpus(addOptions).execute(); - - // Get corpus status - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .build(); - for (int x = 0; x < 30 && (service.getCorpus(getOptions).execute()).getStatus() != Status.ANALYZED; x++) { - Thread.sleep(5000); - } - - // Get all corpora - ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder() - .customizationId(id) - .build(); - Corpora corpora = service.listCorpora(listCorporaOptions).execute(); - System.out.println(corpora); - - // Get specific corpus - Corpus corpus = service.getCorpus(getOptions).execute(); - 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(); - - // 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(); - Words words = service.listWords(listWordsAlphabeticalOptions).execute(); - 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(); - words = service.listWords(listWordsCountOptions).execute(); - 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(); - service.trainLanguageModel(trainOptions).execute(); - - for (int x = 0; x < 30 && myModel.getStatus() != LanguageModel.Status.AVAILABLE; x++) { - GetLanguageModelOptions getOptions = new GetLanguageModelOptions.Builder() - .customizationId(id) - .build(); - myModel = service.getLanguageModel(getOptions).execute(); - Thread.sleep(10000); - } - - File audio = new File(AUDIO_FILE); - RecognizeOptions recognizeOptionsWithModel = new RecognizeOptions.Builder() - .model(RecognizeOptions.EN_US_BROADBANDMODEL) - .customizationId(id) - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); - RecognizeOptions recognizeOptionsWithoutModel = new RecognizeOptions.Builder() - .model(RecognizeOptions.EN_US_BROADBANDMODEL) - .audio(audio) - .contentType(HttpMediaType.AUDIO_WAV) - .build(); - - // First decode WITHOUT the custom model - SpeechRecognitionResults transcript = service.recognize(recognizeOptionsWithoutModel).execute(); - System.out.println(transcript); - - // Now decode with the custom model - transcript = service.recognize(recognizeOptionsWithModel).execute(); - System.out.println(transcript); - } finally { - DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteLanguageModel(deleteOptions).execute(); - } - - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java deleted file mode 100644 index 9984c852668..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/MicrophoneWithWebSocketsExample.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -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.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeCallback; - -/** - * Recognize microphone input speech continuously using WebSockets. - */ -public class MicrophoneWithWebSocketsExample { - - /** - * The main method. - * - * @param args the arguments - * @throws Exception the exception - */ - public static void main(final String[] args) throws Exception { - SpeechToText service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - - // Signed PCM AudioFormat with 16kHz, 16 bit sample size, mono - int sampleRate = 16000; - AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, false); - DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); - - if (!AudioSystem.isLineSupported(info)) { - System.out.println("Line not supported"); - System.exit(0); - } - - TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); - line.open(format); - line.start(); - - 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(); - - 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); - - // closing the WebSockets underlying InputStream will close the WebSocket itself. - line.stop(); - line.close(); - - System.out.println("Fin."); - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsExample.java deleted file mode 100644 index efb7357dfd9..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsExample.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeCallback; - -/** - * Recognize using WebSockets a sample wav file and print the transcript into the console output. - */ -public class RecognizeUsingWebSocketsExample { - private static CountDownLatch lock = new CountDownLatch(1); - - public static void main(String[] args) throws FileNotFoundException, InterruptedException { - SpeechToText service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - - 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(); - } - }); - - lock.await(1, TimeUnit.MINUTES); - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java deleted file mode 100644 index 25dc2b39ca3..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeakerLabel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechAlternative; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResult; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechTimestamp; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeCallback; -import com.ibm.watson.developer_cloud.util.GsonSingleton; - -public class RecognizeUsingWebSocketsWithSpeakerLabelsExample { - - public static class RecoToken { - private Double startTime; - private Double endTime; - private Long speaker; - private String word; - private Boolean spLabelIsFinal; - - /** - * Instantiates a new reco token. - * - * @param speechTimestamp the speech timestamp - */ - RecoToken(SpeechTimestamp speechTimestamp) { - startTime = speechTimestamp.getStartTime(); - endTime = speechTimestamp.getEndTime(); - word = speechTimestamp.getWord(); - } - - /** - * Instantiates a new reco token. - * - * @param speakerLabel the speaker label - */ - RecoToken(SpeakerLabelsResult speakerLabel) { - startTime = (Double) speakerLabel.getFrom(); - endTime = (Double) speakerLabel.getTo(); - speaker = speakerLabel.getSpeaker(); - } - - /** - * Update from. - * - * @param speechTimestamp the speech timestamp - */ - void updateFrom(SpeechTimestamp speechTimestamp) { - word = speechTimestamp.getWord(); - } - - /** - * Update from. - * - * @param speakerLabel the speaker label - */ - void updateFrom(SpeakerLabelsResult speakerLabel) { - speaker = speakerLabel.getSpeaker(); - } - } - - /** - * The Class Utterance. - */ - public static class Utterance { - private Integer speaker; - private String transcript = ""; - - /** - * Instantiates a new utterance. - * - * @param speaker the speaker - * @param transcript the transcript - */ - public Utterance(final Integer speaker, final String transcript) { - this.speaker = speaker; - this.transcript = transcript; - } - } - - /** - * The Class RecoTokens. - */ - public static class RecoTokens { - - private Map recoTokenMap; - - /** - * Instantiates a new reco tokens. - */ - public RecoTokens() { - recoTokenMap = new LinkedHashMap(); - } - - /** - * Adds the. - * - * @param speechResults the speech results - */ - 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()) { - SpeechRecognitionAlternative speechAlternative = transcript.getAlternatives().get(0); - - for (int ts = 0; ts < speechAlternative.getTimestamps().size(); ts++) { - SpeechTimestamp speechTimestamp = speechAlternative.getTimestamps().get(ts); - add(speechTimestamp); - } - } - } - if (speechResults.getSpeakerLabels() != null) - for (int i = 0; i < speechResults.getSpeakerLabels().size(); i++) { - add(speechResults.getSpeakerLabels().get(i)); - } - - } - - /** - * Adds the. - * - * @param speechTimestamp the speech timestamp - */ - public void add(SpeechTimestamp speechTimestamp) { - RecoToken recoToken = recoTokenMap.get(speechTimestamp.getStartTime()); - if (recoToken == null) { - recoToken = new RecoToken(speechTimestamp); - recoTokenMap.put(speechTimestamp.getStartTime(), recoToken); - } else { - recoToken.updateFrom(speechTimestamp); - } - } - - /** - * Adds the. - * - * @param speakerLabel the speaker label - */ - public void add(SpeakerLabelsResult speakerLabel) { - RecoToken recoToken = recoTokenMap.get(speakerLabel.getFrom()); - if (recoToken == null) { - recoToken = new RecoToken(speakerLabel); - recoTokenMap.put(speakerLabel.getFrom(), recoToken); - } else { - recoToken.updateFrom(speakerLabel); - } - - if (speakerLabel.isFinalResults()) { - markTokensBeforeAsFinal(speakerLabel.getFrom()); - report(); - cleanFinal(); - } - } - - private void markTokensBeforeAsFinal(Float from) { - Map recoTokenMap = new LinkedHashMap<>(); - - for (RecoToken rt : recoTokenMap.values()) { - if (rt.startTime <= from) - rt.spLabelIsFinal = true; - } - } - - /** - * Report. - */ - public void report() { - List uttterances = new ArrayList(); - Utterance currentUtterance = new Utterance(0, ""); - - for (RecoToken rt : recoTokenMap.values()) { - if (currentUtterance.speaker != rt.speaker) { - uttterances.add(currentUtterance); - currentUtterance = new Utterance(rt.speaker, ""); - } - currentUtterance.transcript = currentUtterance.transcript + rt.word + " "; - } - uttterances.add(currentUtterance); - - String result = GsonSingleton.getGson().toJson(uttterances); - System.out.println(result); - } - - private void cleanFinal() { - Set> set = recoTokenMap.entrySet(); - for (Map.Entry e : set) { - if (e.getValue().spLabelIsFinal) { - recoTokenMap.remove(e.getKey()); - } - } - } - - } - - - private static CountDownLatch lock = new CountDownLatch(1); - - /** - * The main method. - * - * @param args the arguments - * @throws FileNotFoundException the file not found exception - * @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"); - - SpeechToText service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .speakerLabels(true) - .model(RecognizeOptions.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); - } - - @Override - public void onDisconnected() { - lock.countDown(); - } - }); - - lock.await(1, TimeUnit.MINUTES); - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextExample.java deleted file mode 100644 index 926d48c4668..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextExample.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import java.io.File; - -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; - -/** - * 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 { - - public static void main(String[] args) { - SpeechToText service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - - 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(); - SpeechRecognitionResults transcript = service.recognize(options).execute(); - - System.out.println(transcript); - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationExample.java deleted file mode 100755 index aeff9ab8a76..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationExample.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import java.util.Arrays; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.List; - -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.developer_cloud.text_to_speech.v1.util.WaveUtils; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words; - -public class CustomizationExample { - - public static void main(String[] args) throws IOException { - TextToSpeech service = new TextToSpeech("", ""); - - // 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(); - 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); - System.out.println(customVoiceModels); - - // update custom voice model. - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .name(newName) - .description("the updated model for testing") - .build(); - service.updateVoiceModel(updateOptions).execute(); - - // list custom voice models regardless of language. - customVoiceModels = service.listVoiceModels().execute(); - System.out.println(customVoiceModels); - - // create multiple custom word translations - Word word1 = new Word(); - word1.setWord("hodor"); - word1.setTranslation("hold the door"); - Word word2 = new Word(); - word2.setWord("plz"); - word2.setTranslation("please"); - List words = Arrays.asList(word1, word2); - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .words(words) - .build(); - service.addWords(addOptions).execute(); - - // create a single custom word translation - AddWordOptions addOptions = new AddWordOptions.Builder() - .word("nat") - .translation("and that") - .customizationId(customVoiceModel.getCustomizationId()) - .build(); - service.addWord(addOptions).execute(); - - // get custom word translations - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .build(); - Words words = service.listWords(listOptions).execute(); - System.out.println(words); - - // get custom word translation - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .word("hodor") - .build(); - Translation translation = service.getWord(getOptions).execute(); - 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(); - InputStream in = service.synthesize(synthesizeOptions).execute(); - 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(); - service.deleteWord(deleteOptions1).execute(); - DeleteWordOptions deleteOptions2 = new DeleteWordOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .word(word2.getWord()) - .build(); - service.deleteWord(deleteOptions2).execute(); - - // delete custom voice model - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(customVoiceModel.getCustomizationId()) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); - - // list custom voice models regardless of language. - customVoiceModels = service.listVoiceModels().execute(); - System.out.println(customVoiceModels); - } - - private static void writeToFile(InputStream in, File file) { - try { - OutputStream out = new FileOutputStream(file); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - out.close(); - in.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechExample.java deleted file mode 100644 index ed72b9e81a2..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechExample.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voices; - -public class TextToSpeechExample { - - public static void main(String[] args) { - TextToSpeech service = new TextToSpeech(); - service.setUsernameAndPassword("", ""); - - Voices voices = service.listVoices().execute(); - System.out.println(voices); - } - -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java deleted file mode 100644 index 4c5792e6389..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TranslateAndSynthesizeExample.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import com.ibm.watson.developer_cloud.language_translation.v2.LanguageTranslation; -import com.ibm.watson.developer_cloud.language_translation.v2.model.Language; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translation.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AudioFormat; -import com.ibm.watson.developer_cloud.text_to_speech.v1.util.WaveUtils; - -/** - * Translate from English to Spanish and synthesize that as a WAV file. - */ -public class TranslateAndSynthesizeExample { - - public static void main(String[] args) throws IOException { - LanguageTranslator translator = new LanguageTranslator(); - translator.setUsernameAndPassword("username", "password"); - - TextToSpeech synthesizer = new TextToSpeech(); - synthesizer.setUsernameAndPassword("username", "password"); - - String text = "Greetings from Watson Developer Cloud"; - - // translate - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText(text) - .source(Language.ENGLISH) - .target(Language.SPANISH) - .build(); - TranslationResult translationResult = service.translate(translateOptions).execute(); - 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(); - InputStream in = service.synthesize(synthesizeOptions).execute(); - writeToFile(WaveUtils.reWriteWaveHeader(in), new File("output.wav")); - } - - /** - * Write the input stream to a file. - */ - private static void writeToFile(InputStream in, File file) { - try { - OutputStream out = new FileOutputStream(file); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) > 0) { - out.write(buf, 0, len); - } - out.close(); - in.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerChatExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerChatExample.java deleted file mode 100644 index 5c3cd9f0bc2..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerChatExample.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneChatRequest; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.Utterance; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.UtterancesTone; - -public class ToneAnalyzerExample { - - public static void main(String[] args) { - ToneAnalyzer service = new ToneAnalyzer("2017-09-21"); - service.setUsernameAndPassword("", ""); - - 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(); - System.out.println(utterancesTone); - } -} \ No newline at end of file diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerExample.java deleted file mode 100644 index d987e96953c..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerExample.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3; - -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions; - -public class ToneAnalyzerExample { - - - public static void main(String[] args) { - ToneAnalyzer service = new ToneAnalyzer("2017-09-21"); - service.setUsernameAndPassword("", ""); - - 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(); - System.out.println(tone); - - } -} diff --git a/examples/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionExample.java b/examples/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionExample.java deleted file mode 100644 index 7dc5e62812f..00000000000 --- a/examples/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionExample.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3; - -import java.io.File; - -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.UpdateClassifierOptions; - -public class VisualRecognitionExample { - - public static void main(String[] args) { - VisualRecognition service = new VisualRecognition("2016-05-20"); - service.setApiKey(""); - - 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(); - 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(); - 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(); - 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(); - System.out.println(updatedFoo); - } -} 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 new file mode 100644 index 00000000000..efb7746e98d --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/discovery/v1/DiscoveryQueryExample.java @@ -0,0 +1,195 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.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; +import com.ibm.watson.discovery.v1.model.CreateCollectionOptions; +import com.ibm.watson.discovery.v1.model.CreateEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.DeleteCollectionOptions; +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.GetCollectionOptions; +import com.ibm.watson.discovery.v1.model.GetDocumentStatusOptions; +import com.ibm.watson.discovery.v1.model.GetEnvironmentOptions; +import com.ibm.watson.discovery.v1.model.ListConfigurationsOptions; +import com.ibm.watson.discovery.v1.model.ListConfigurationsResponse; +import com.ibm.watson.discovery.v1.model.ListEnvironmentsOptions; +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 java.io.ByteArrayInputStream; +import java.io.InputStream; + +/** End-to-end example for querying Discovery. */ +public class DiscoveryQueryExample { + private static final String DEFAULT_CONFIG_NAME = "Default Configuration"; + + public static void main(String[] args) { + Authenticator authenticator = new IamAuthenticator(""); + Discovery discovery = new Discovery("2019-04-30", authenticator); + + String environmentId = null; + String configurationId = null; + String collectionId = null; + String documentId = null; + + // 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(); + for (Environment environment : listResponse.getEnvironments()) { + // look for an existing environment that isn't read only + if (!environment.isReadOnly()) { + environmentId = environment.getEnvironmentId(); + System.out.println("Found existing environment ID: " + environmentId); + break; + } + } + + 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) + String environmentName = "watson_developer_cloud_test_environment"; + 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 + 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(); + environmentReady = getEnvironmentResponse.getStatus().equals(Environment.Status.ACTIVE); + try { + if (!environmentReady) { + Thread.sleep(500); + } + } catch (InterruptedException e) { + throw new RuntimeException("Interrupted", e); + } + } + System.out.println("Environment Ready!"); + } + + // 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(); + for (Configuration configuration : listConfigsResponse.getConfigurations()) { + if (configuration.name().equals(DEFAULT_CONFIG_NAME)) { + configurationId = configuration.configurationId(); + System.out.println("Found default configuration ID: " + configurationId); + break; + } + } + + // 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(); + collectionId = collection.getCollectionId(); + System.out.println("Created a collection ID: " + collectionId); + + // 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(); + collectionReady = getCollectionResponse.getStatus().equals(Collection.Status.ACTIVE); + try { + if (!collectionReady) { + Thread.sleep(500); + } + } catch (InterruptedException e) { + throw new RuntimeException("Interrupted", e); + } + } + System.out.println("Collection Ready!"); + + // 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); + createDocumentBuilder.file(documentStream).fileContentType(HttpMediaType.APPLICATION_JSON); + 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 + 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(); + documentReady = !getDocumentResponse.getStatus().equals(DocumentStatus.Status.PROCESSING); + try { + if (!documentReady) { + Thread.sleep(500); + } + } catch (InterruptedException e) { + throw new RuntimeException("Interrupted"); + } + } + System.out.println("Document Ready!"); + + // 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 + System.out.println("Query Results:"); + System.out.println(queryResponse); + + // cleanup the collection created + System.out.println("Deleting the collection..."); + DeleteCollectionOptions deleteOptions = + new DeleteCollectionOptions.Builder(environmentId, collectionId).build(); + discovery.deleteCollection(deleteOptions).execute(); + System.out.println("Collection deleted!"); + + System.out.println("Discovery example finished"); + } +} 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 new file mode 100644 index 00000000000..2c0ec9d8eec --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/discovery/v2/DiscoveryV2Example.java @@ -0,0 +1,70 @@ +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.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; + +public class DiscoveryV2Example { + + public static void main(String[] args) throws IOException { + Authenticator authenticator = new BearerTokenAuthenticator("{bearer_token}"); + 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 + // 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(); + DocumentAccepted addResponse = service.addDocument(addDocumentOptions).execute().getResult(); + String documentId = addResponse.getDocumentId(); + + // Query your collection with the new document inside. + 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!"); + + // See if the added document got returned by the query. + for (QueryResult result : queryResponse.getResults()) { + if (result.getDocumentId().equals(documentId)) { + System.out.println("Our new document matched the query!"); + } + } + + // Delete our uploaded document from the collection. + 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 new file mode 100644 index 00000000000..8f6268688f2 --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/language_translator/v3/LanguageTranslatorExample.java @@ -0,0 +1,33 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.ibm.cloud.sdk.core.security.Authenticator; +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; + +/** 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(); + TranslationResult translationResult = service.translate(translateOptions).execute().getResult(); + + System.out.println(translationResult); + } +} 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 new file mode 100755 index 00000000000..c58afd5724c --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/CustomizationExample.java @@ -0,0 +1,190 @@ +/* + * (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.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; +import com.ibm.watson.speech_to_text.v1.model.Corpus; +import com.ibm.watson.speech_to_text.v1.model.CreateLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.DeleteLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.GetCorpusOptions; +import com.ibm.watson.speech_to_text.v1.model.GetLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.LanguageModel; +import com.ibm.watson.speech_to_text.v1.model.ListCorporaOptions; +import com.ibm.watson.speech_to_text.v1.model.ListWordsOptions; +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.model.TrainLanguageModelOptions; +import com.ibm.watson.speech_to_text.v1.model.Words; +import java.io.File; +import java.io.FileNotFoundException; + +/** 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"; + + /** + * The main method. + * + * @param args the arguments + * @throws InterruptedException the interrupted exception + */ + public static void main(String[] args) throws InterruptedException, FileNotFoundException { + Authenticator authenticator = new IamAuthenticator(""); + SpeechToText service = new SpeechToText(authenticator); + + // Create language model + 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(); + 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++) { + Thread.sleep(5000); + } + + // Get all corpora + ListCorporaOptions listCorporaOptions = + new ListCorporaOptions.Builder().customizationId(id).build(); + Corpora corpora = service.listCorpora(listCorporaOptions).execute().getResult(); + System.out.println(corpora); + + // Get specific corpus + Corpus corpus = service.getCorpus(getOptions).execute().getResult(); + 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(); + + // 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(); + 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(); + 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(); + 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(); + 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(); + + // First decode WITHOUT the custom model + 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(); + 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 new file mode 100644 index 00000000000..d0abae02a50 --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/MicrophoneWithWebSocketsExample.java @@ -0,0 +1,84 @@ +/* + * (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.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; + +/** Recognize microphone input speech continuously using WebSockets. */ +public class MicrophoneWithWebSocketsExample { + + /** + * The main method. + * + * @param args the arguments + * @throws Exception the exception + */ + public static void main(final String[] args) throws Exception { + Authenticator authenticator = new IamAuthenticator(""); + SpeechToText service = new SpeechToText(authenticator); + + // Signed PCM AudioFormat with 16kHz, 16 bit sample size, mono + int sampleRate = 16000; + AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, false); + DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); + + if (!AudioSystem.isLineSupported(info)) { + System.out.println("Line not supported"); + System.exit(0); + } + + TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); + line.open(format); + line.start(); + + AudioInputStream audio = new AudioInputStream(line); + + 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); + } + }); + + System.out.println("Listening to your voice for the next 30s..."); + Thread.sleep(30 * 1000); + + // closing the WebSockets underlying InputStream will close the WebSocket itself. + line.stop(); + line.close(); + + System.out.println("Fin."); + } +} 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 new file mode 100644 index 00000000000..1c1ad4301ed --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsExample.java @@ -0,0 +1,60 @@ +/* + * (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.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 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. + */ +public class RecognizeUsingWebSocketsExample { + private static CountDownLatch lock = new CountDownLatch(1); + + public static void main(String[] args) throws FileNotFoundException, InterruptedException { + Authenticator authenticator = new IamAuthenticator(""); + SpeechToText service = new SpeechToText(authenticator); + + FileInputStream audio = new FileInputStream("src/test/resources/speech_to_text/sample1.wav"); + + 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 new file mode 100644 index 00000000000..11065523135 --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/RecognizeUsingWebSocketsWithSpeakerLabelsExample.java @@ -0,0 +1,251 @@ +/* + * (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.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.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; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +public class RecognizeUsingWebSocketsWithSpeakerLabelsExample { + + public static class RecoToken { + private Double startTime; + private Double endTime; + private Long speaker; + private String word; + private Boolean spLabelIsFinal; + + /** + * Instantiates a new reco token. + * + * @param speechTimestamp the speech timestamp + */ + RecoToken(SpeechTimestamp speechTimestamp) { + startTime = speechTimestamp.getStartTime(); + endTime = speechTimestamp.getEndTime(); + word = speechTimestamp.getWord(); + } + + /** + * Instantiates a new reco token. + * + * @param speakerLabel the speaker label + */ + RecoToken(SpeakerLabelsResult speakerLabel) { + startTime = Double.valueOf(speakerLabel.getFrom()); + endTime = Double.valueOf(speakerLabel.getTo()); + speaker = speakerLabel.getSpeaker(); + } + + /** + * Update from. + * + * @param speechTimestamp the speech timestamp + */ + public void updateFrom(SpeechTimestamp speechTimestamp) { + word = speechTimestamp.getWord(); + } + + /** + * Update from. + * + * @param speakerLabel the speaker label + */ + public void updateFrom(SpeakerLabelsResult speakerLabel) { + speaker = speakerLabel.getSpeaker(); + } + } + + /** The Class Utterance. */ + public static class Utterance { + private Integer speaker; + private String transcript = ""; + + /** + * Instantiates a new utterance. + * + * @param speaker the speaker + * @param transcript the transcript + */ + public Utterance(final Integer speaker, final String transcript) { + this.speaker = speaker; + this.transcript = transcript; + } + } + + /** The Class RecoTokens. */ + public static class RecoTokens { + + private Map recoTokenMap; + + /** Instantiates a new reco tokens. */ + public RecoTokens() { + recoTokenMap = new LinkedHashMap(); + } + + /** + * Adds the. + * + * @param speechResults the speech results + */ + 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.isXFinal()) { + SpeechRecognitionAlternative speechAlternative = transcript.getAlternatives().get(0); + + for (int ts = 0; ts < speechAlternative.getTimestamps().size(); ts++) { + SpeechTimestamp speechTimestamp = speechAlternative.getTimestamps().get(ts); + add(speechTimestamp); + } + } + } + if (speechResults.getSpeakerLabels() != null) + for (int i = 0; i < speechResults.getSpeakerLabels().size(); i++) { + add(speechResults.getSpeakerLabels().get(i)); + } + } + + /** + * Adds the. + * + * @param speechTimestamp the speech timestamp + */ + public void add(SpeechTimestamp speechTimestamp) { + RecoToken recoToken = recoTokenMap.get(speechTimestamp.getStartTime()); + if (recoToken == null) { + recoToken = new RecoToken(speechTimestamp); + recoTokenMap.put(speechTimestamp.getStartTime(), recoToken); + } else { + recoToken.updateFrom(speechTimestamp); + } + } + + /** + * Adds the. + * + * @param speakerLabel the speaker label + */ + public void add(SpeakerLabelsResult speakerLabel) { + RecoToken recoToken = recoTokenMap.get(speakerLabel.getFrom()); + if (recoToken == null) { + recoToken = new RecoToken(speakerLabel); + recoTokenMap.put(Double.valueOf(speakerLabel.getFrom()), recoToken); + } else { + recoToken.updateFrom(speakerLabel); + } + + if (speakerLabel.isXFinal()) { + markTokensBeforeAsFinal(speakerLabel.getFrom()); + report(); + cleanFinal(); + } + } + + private void markTokensBeforeAsFinal(Float from) { + Map recoTokenMap = new LinkedHashMap<>(); + + for (RecoToken rt : recoTokenMap.values()) { + if (rt.startTime <= from) rt.spLabelIsFinal = true; + } + } + + /** Report. */ + public void report() { + List uttterances = new ArrayList(); + Utterance currentUtterance = new Utterance(0, ""); + + for (RecoToken rt : recoTokenMap.values()) { + if (currentUtterance.speaker != Math.toIntExact(rt.speaker)) { + uttterances.add(currentUtterance); + currentUtterance = new Utterance(Math.toIntExact(rt.speaker), ""); + } + currentUtterance.transcript = currentUtterance.transcript + rt.word + " "; + } + uttterances.add(currentUtterance); + + String result = GsonSingleton.getGson().toJson(uttterances); + System.out.println(result); + } + + private void cleanFinal() { + Set> set = recoTokenMap.entrySet(); + for (Map.Entry e : set) { + if (e.getValue().spLabelIsFinal) { + recoTokenMap.remove(e.getKey()); + } + } + } + } + + private static CountDownLatch lock = new CountDownLatch(1); + + /** + * The main method. + * + * @param args the arguments + * @throws FileNotFoundException the file not found exception + * @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"); + + Authenticator authenticator = new IamAuthenticator(""); + SpeechToText service = new SpeechToText(authenticator); + + 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); + } + + @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 new file mode 100644 index 00000000000..04d5f07b71c --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToTextExample.java @@ -0,0 +1,40 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.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. + */ +public class SpeechToTextExample { + + public static void main(String[] args) throws FileNotFoundException { + Authenticator authenticator = new IamAuthenticator(""); + 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(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 new file mode 100755 index 00000000000..51c15cb580a --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/CustomizationExample.java @@ -0,0 +1,167 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.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.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.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.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; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Arrays; +import java.util.List; + +public class CustomizationExample { + + public static void main(String[] args) throws IOException { + Authenticator authenticator = new IamAuthenticator(""); + TextToSpeech service = new TextToSpeech(authenticator); + + // create custom voice model. + 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. + 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"; + 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.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(); + List words = Arrays.asList(word1, word2); + 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(); + service.addWord(addWordOptions).execute(); + + // get custom word translations + 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(); + 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(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.word()) + .build(); + service.deleteWord(deleteOptions1).execute(); + DeleteWordOptions deleteOptions2 = + new DeleteWordOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .word(word2.word()) + .build(); + service.deleteWord(deleteOptions2).execute(); + + // delete custom voice model + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder() + .customizationId(customVoiceModel.getCustomizationId()) + .build(); + service.deleteCustomModel(deleteOptions).execute(); + + // list custom voice models regardless of language. + customVoiceModels = service.listCustomModels().execute().getResult(); + System.out.println(customVoiceModels); + } + + private static void writeToFile(InputStream in, File file) { + try { + OutputStream out = new FileOutputStream(file); + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + out.close(); + in.close(); + } catch (Exception e) { + 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 new file mode 100644 index 00000000000..97adc0d5a4e --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeechExample.java @@ -0,0 +1,28 @@ +/* + * (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.text_to_speech.v1; + +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.Voices; + +public class TextToSpeechExample { + + public static void main(String[] args) { + Authenticator authenticator = new IamAuthenticator(""); + TextToSpeech service = new TextToSpeech(authenticator); + + 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 new file mode 100644 index 00000000000..1a040ec319c --- /dev/null +++ b/examples/src/main/java/com/ibm/watson/text_to_speech/v1/TranslateAndSynthesizeExample.java @@ -0,0 +1,79 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.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.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. */ +public class TranslateAndSynthesizeExample { + + public static void main(String[] args) throws IOException { + Authenticator ltAuthenticator = new IamAuthenticator(""); + LanguageTranslator translator = new LanguageTranslator("2019-11-22", ltAuthenticator); + + Authenticator ttsAuthenticator = new IamAuthenticator(""); + TextToSpeech synthesizer = new TextToSpeech(ttsAuthenticator); + + 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(); + String translation = translationResult.getTranslations().get(0).getTranslation(); + + // synthesize + 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. */ + private static void writeToFile(InputStream in, File file) { + try { + OutputStream out = new FileOutputStream(file); + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + out.close(); + in.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index acb8e04c337..00000000000 --- a/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -version=6.1.1-SNAPSHOT -group = com.ibm.watson.developer_cloud 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 7f5b84e9e27..00000000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Sun Aug 27 17:15:44 EDT 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.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/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/java-sdk/build.gradle b/java-sdk/build.gradle deleted file mode 100644 index 1986d06853c..00000000000 --- a/java-sdk/build.gradle +++ /dev/null @@ -1,148 +0,0 @@ -plugins { - id 'ru.vyarus.animalsniffer' version '1.3.0' - id 'com.github.johnrengelman.shadow' version '1.2.4' -} - -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 - -shadowJar { - classifier = 'jar-with-dependencies' -} - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':conversation') - compile project(':core') - 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() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'Watson Developer Cloud Java SDK' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Services and AlchemyAPI' - url 'https://www.ibm.com/watson/developer' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/language-translator/README.md b/language-translator/README.md deleted file mode 100644 index f839ece8222..00000000000 --- a/language-translator/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Language Translator - -## Deprecation notice -Language Translator v3 is now available. The v2 Language Translator API will no longer be available after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the [Migrating to Language Translator v3](https://console.bluemix.net/docs/services/language-translator/migrating.html) page for more information. - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - language-translator - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:language-translator:6.1.0' -``` - -## 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 -LanguageTranslator service = new LanguageTranslator(); -IamOptions iamOptions = new IamOptions.Builder() - .apiKey("") - .build(); -service.setIamCredentials(iamOptions); - -TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello") - .source(Language.ENGLISH) - .target(Language.SPANISH) - .build(); -TranslationResult translationResult = service.translate(translateOptions).execute(); - -System.out.println(translationResult); -``` - -[language_translator]: https://console.bluemix.net/docs/services/language-translator/index.html diff --git a/language-translator/build.gradle b/language-translator/build.gradle deleted file mode 100644 index 25456435702..00000000000 --- a/language-translator/build.gradle +++ /dev/null @@ -1,112 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'language-translator' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Language Translator Service' - url 'https://console.bluemix.net/docs/services/language-translator/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java deleted file mode 100644 index d959a0dde63..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslator.java +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguages; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguages; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.ListIdentifiableLanguagesOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModels; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -/** - * IBM Watson™ Language Translator translates text from one language to another. The service offers multiple - * domain-specific 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 v2 - * @see Language Translator - * @deprecated Language Translator v3 is now available. The v2 Language Translator API will no longer be available - * after July 31, 2018. To take advantage of the latest service enhancements, migrate to the v3 API. View the - * following page for more information: https://console.bluemix.net/docs/services/language-translator/migrating.html). - */ -@Deprecated -public class LanguageTranslator extends WatsonService { - - private static final String SERVICE_NAME = "language_translator"; - private static final String URL = "https://gateway.watsonplatform.net/language-translator/api"; - - /** - * Instantiates a new `LanguageTranslator`. - * - */ - public LanguageTranslator() { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - } - - /** - * Instantiates a new `LanguageTranslator` with username and password. - * - * @param username the username - * @param password the password - */ - public LanguageTranslator(String username, String password) { - this(); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `LanguageTranslator` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @param iamOptions the options for authenticating through IAM - */ - public LanguageTranslator(IamOptions iamOptions) { - this(); - setIamCredentials(iamOptions); - } - - /** - * 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) { - Validator.notNull(translateOptions, "translateOptions cannot be null"); - String[] pathSegments = { "v2/translate" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - final JsonObject contentJson = new JsonObject(); - contentJson.add("text", 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationResult.class)); - } - - /** - * 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) { - Validator.notNull(identifyOptions, "identifyOptions cannot be null"); - String[] pathSegments = { "v2/identify" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.bodyContent(identifyOptions.text(), "text/plain"); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiedLanguages.class)); - } - - /** - * 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 = { "v2/identifiable_languages" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listIdentifiableLanguagesOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiableLanguages.class)); - } - - /** - * 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); - } - - /** - * Create model. - * - * Uploads a TMX glossary file on top of a domain to customize a translation model. - * - * Depending on the size of the file, training can range from minutes for a glossary to several hours for a large - * parallel corpus. Glossary files must be less than 10 MB. The cumulative file size of all uploaded glossary and - * corpus files is limited to 250 MB. - * - * @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) { - Validator.notNull(createModelOptions, "createModelOptions cannot be null"); - Validator.isTrue((createModelOptions.forcedGlossary() != null) || (createModelOptions.parallelCorpus() != null) - || (createModelOptions.monolingualCorpus() != null), - "At least one of forcedGlossary, parallelCorpus, or monolingualCorpus must be supplied."); - String[] pathSegments = { "v2/models" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - 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) { - RequestBody forcedGlossaryBody = RequestUtils.inputStreamBody(createModelOptions.forcedGlossary(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("forced_glossary", createModelOptions.forcedGlossaryFilename(), - forcedGlossaryBody); - } - if (createModelOptions.parallelCorpus() != null) { - RequestBody parallelCorpusBody = RequestUtils.inputStreamBody(createModelOptions.parallelCorpus(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("parallel_corpus", createModelOptions.parallelCorpusFilename(), - parallelCorpusBody); - } - if (createModelOptions.monolingualCorpus() != null) { - RequestBody monolingualCorpusBody = RequestUtils.inputStreamBody(createModelOptions.monolingualCorpus(), - "text/plain"); - multipartBuilder.addFormDataPart("monolingual_corpus", createModelOptions.monolingualCorpusFilename(), - monolingualCorpusBody); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * 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 Void - */ - public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { - Validator.notNull(deleteModelOptions, "deleteModelOptions cannot be null"); - String[] pathSegments = { "v2/models" }; - String[] pathParameters = { deleteModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * Get model details. - * - * Gets information about a translation model, including training status for custom models. - * - * @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) { - Validator.notNull(getModelOptions, "getModelOptions cannot be null"); - String[] pathSegments = { "v2/models" }; - String[] pathParameters = { getModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * 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 = { "v2/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listModelsOptions != null) { - if (listModelsOptions.source() != null) { - builder.query("source", listModelsOptions.source()); - } - if (listModelsOptions.target() != null) { - builder.query("target", listModelsOptions.target()); - } - if (listModelsOptions.defaultModels() != null) { - builder.query("default", String.valueOf(listModelsOptions.defaultModels())); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModels.class)); - } - - /** - * List models. - * - * Lists available translation models. - * - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} - */ - public ServiceCall listModels() { - return listModels(null); - } - -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java deleted file mode 100644 index 4851e2668f5..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/CreateModelOptions.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createModel options. - */ -public class CreateModelOptions extends GenericModel { - - private String baseModelId; - private String name; - private InputStream forcedGlossary; - private String forcedGlossaryFilename; - private InputStream parallelCorpus; - private String parallelCorpusFilename; - private InputStream monolingualCorpus; - private String monolingualCorpusFilename; - - /** - * Builder. - */ - public static class Builder { - private String baseModelId; - private String name; - private InputStream forcedGlossary; - private String forcedGlossaryFilename; - private InputStream parallelCorpus; - private String parallelCorpusFilename; - private InputStream monolingualCorpus; - private String monolingualCorpusFilename; - - private Builder(CreateModelOptions createModelOptions) { - baseModelId = createModelOptions.baseModelId; - name = createModelOptions.name; - forcedGlossary = createModelOptions.forcedGlossary; - forcedGlossaryFilename = createModelOptions.forcedGlossaryFilename; - parallelCorpus = createModelOptions.parallelCorpus; - parallelCorpusFilename = createModelOptions.parallelCorpusFilename; - monolingualCorpus = createModelOptions.monolingualCorpus; - monolingualCorpusFilename = createModelOptions.monolingualCorpusFilename; - } - - /** - * 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 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 - */ - public Builder forcedGlossary(InputStream forcedGlossary) { - this.forcedGlossary = forcedGlossary; - return this; - } - - /** - * Set the forcedGlossaryFilename. - * - * @param forcedGlossaryFilename the forcedGlossaryFilename - * @return the CreateModelOptions builder - */ - public Builder forcedGlossaryFilename(String forcedGlossaryFilename) { - this.forcedGlossaryFilename = forcedGlossaryFilename; - 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 parallelCorpusFilename. - * - * @param parallelCorpusFilename the parallelCorpusFilename - * @return the CreateModelOptions builder - */ - public Builder parallelCorpusFilename(String parallelCorpusFilename) { - this.parallelCorpusFilename = parallelCorpusFilename; - return this; - } - - /** - * Set the monolingualCorpus. - * - * @param monolingualCorpus the monolingualCorpus - * @return the CreateModelOptions builder - */ - public Builder monolingualCorpus(InputStream monolingualCorpus) { - this.monolingualCorpus = monolingualCorpus; - return this; - } - - /** - * Set the monolingualCorpusFilename. - * - * @param monolingualCorpusFilename the monolingualCorpusFilename - * @return the CreateModelOptions builder - */ - public Builder monolingualCorpusFilename(String monolingualCorpusFilename) { - this.monolingualCorpusFilename = monolingualCorpusFilename; - 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); - this.forcedGlossaryFilename = forcedGlossary.getName(); - 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); - this.parallelCorpusFilename = parallelCorpus.getName(); - return this; - } - - /** - * Set the monolingualCorpus. - * - * @param monolingualCorpus the monolingualCorpus - * @return the CreateModelOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder monolingualCorpus(File monolingualCorpus) throws FileNotFoundException { - this.monolingualCorpus = new FileInputStream(monolingualCorpus); - this.monolingualCorpusFilename = monolingualCorpus.getName(); - return this; - } - } - - private CreateModelOptions(Builder builder) { - Validator.notNull(builder.baseModelId, "baseModelId cannot be null"); - baseModelId = builder.baseModelId; - name = builder.name; - forcedGlossary = builder.forcedGlossary; - forcedGlossaryFilename = builder.forcedGlossaryFilename; - parallelCorpus = builder.parallelCorpus; - parallelCorpusFilename = builder.parallelCorpusFilename; - monolingualCorpus = builder.monolingualCorpus; - monolingualCorpusFilename = builder.monolingualCorpusFilename; - } - - /** - * 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. - * - * @return the baseModelId - */ - public String baseModelId() { - return baseModelId; - } - - /** - * 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; - } - - /** - * 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. - * - * @return the forcedGlossary - */ - public InputStream forcedGlossary() { - return forcedGlossary; - } - - /** - * Gets the forcedGlossaryFilename. - * - * The filename for forcedGlossary. - * - * @return the forcedGlossaryFilename - */ - public String forcedGlossaryFilename() { - return forcedGlossaryFilename; - } - - /** - * Gets the parallelCorpus. - * - * A TMX file that contains entries that are treated as a parallel corpus instead of a glossary. - * - * @return the parallelCorpus - */ - public InputStream parallelCorpus() { - return parallelCorpus; - } - - /** - * Gets the parallelCorpusFilename. - * - * The filename for parallelCorpus. - * - * @return the parallelCorpusFilename - */ - public String parallelCorpusFilename() { - return parallelCorpusFilename; - } - - /** - * Gets the monolingualCorpus. - * - * A UTF-8 encoded plain text file that is used to customize the target language model. - * - * @return the monolingualCorpus - */ - public InputStream monolingualCorpus() { - return monolingualCorpus; - } - - /** - * Gets the monolingualCorpusFilename. - * - * The filename for monolingualCorpus. - * - * @return the monolingualCorpusFilename - */ - public String monolingualCorpusFilename() { - return monolingualCorpusFilename; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/DeleteModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/DeleteModelOptions.java deleted file mode 100644 index f39d6913b06..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/DeleteModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteModel options. - */ -public class DeleteModelOptions extends GenericModel { - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(DeleteModelOptions deleteModelOptions) { - 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; - } - } - - private DeleteModelOptions(Builder builder) { - 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/developer_cloud/language_translator/v2/model/GetModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/GetModelOptions.java deleted file mode 100644 index 797e4dd58b7..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/GetModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getModel options. - */ -public class GetModelOptions extends GenericModel { - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(GetModelOptions getModelOptions) { - 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; - } - } - - private GetModelOptions(Builder builder) { - 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/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java deleted file mode 100644 index 1c6be4aaa16..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiableLanguage. - */ -public class IdentifiableLanguage extends GenericModel { - - private String language; - private 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/developer_cloud/language_translator/v2/model/IdentifiableLanguages.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguages.java deleted file mode 100644 index 0b94f33253c..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiableLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiableLanguages. - */ -public class IdentifiableLanguages extends GenericModel { - - private 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/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java deleted file mode 100644 index 3a1a7bd9f21..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiedLanguage. - */ -public class IdentifiedLanguage extends GenericModel { - - private String language; - private 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/developer_cloud/language_translator/v2/model/IdentifiedLanguages.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguages.java deleted file mode 100644 index 47042442725..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifiedLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiedLanguages. - */ -public class IdentifiedLanguages extends GenericModel { - - private 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/developer_cloud/language_translator/v2/model/IdentifyOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifyOptions.java deleted file mode 100644 index 1e9ad05c421..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/IdentifyOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The identify options. - */ -public class IdentifyOptions extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(IdentifyOptions identifyOptions) { - 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; - } - } - - private IdentifyOptions(Builder builder) { - 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/developer_cloud/language_translator/v2/model/ListIdentifiableLanguagesOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/ListIdentifiableLanguagesOptions.java deleted file mode 100644 index b747ec00fe3..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/ListIdentifiableLanguagesOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.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/developer_cloud/language_translator/v2/model/ListModelsOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/ListModelsOptions.java deleted file mode 100644 index 226c150401b..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/ListModelsOptions.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listModels options. - */ -public class ListModelsOptions extends GenericModel { - - private String source; - private String target; - private Boolean defaultModels; - - /** - * Builder. - */ - public static class Builder { - private String source; - private String target; - private Boolean defaultModels; - - private Builder(ListModelsOptions listModelsOptions) { - source = listModelsOptions.source; - target = listModelsOptions.target; - defaultModels = listModelsOptions.defaultModels; - } - - /** - * 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 defaultModels. - * - * @param defaultModels the defaultModels - * @return the ListModelsOptions builder - */ - public Builder defaultModels(Boolean defaultModels) { - this.defaultModels = defaultModels; - return this; - } - } - - private ListModelsOptions(Builder builder) { - source = builder.source; - target = builder.target; - defaultModels = builder.defaultModels; - } - - /** - * 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 defaultModels. - * - * 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`. - * - * @return the defaultModels - */ - public Boolean defaultModels() { - return defaultModels; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslateOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslateOptions.java deleted file mode 100644 index a28617c0f75..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslateOptions.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The translate options. - */ -public class TranslateOptions extends GenericModel { - - private List text; - private String modelId; - private String source; - private String target; - - /** - * Builder. - */ - public static class Builder { - private List text; - private String modelId; - private String source; - private String target; - - private Builder(TranslateOptions translateOptions) { - text = translateOptions.text; - modelId = translateOptions.modelId; - source = translateOptions.source; - 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) { - 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; - } - } - - private TranslateOptions(Builder builder) { - 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. - * - * Model ID of the translation model to use. If this is specified, the **source** and **target** parameters will be - * ignored. The method requires either a model ID or both the **source** and **target** parameters. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the source. - * - * Language code of the source text language. Use with `target` as an alternative way to select a translation model. - * When `source` and `target` are set, and a model ID is not set, the system chooses a default model for the language - * pair (usually the model based on the news domain). - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the target. - * - * Language code of the translation target language. Use with source as an alternative way to select a translation - * model. - * - * @return the target - */ - public String target() { - return target; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java deleted file mode 100644 index 4ca8ba1dafc..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/Translation.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Translation. - */ -public class Translation extends GenericModel { - - private 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/developer_cloud/language_translator/v2/model/TranslationModel.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java deleted file mode 100644 index 223d810c8e6..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModel.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private String modelId; - private String name; - private String source; - private String target; - @SerializedName("base_model_id") - private String baseModelId; - private String domain; - private Boolean customizable; - @SerializedName("default_model") - private Boolean defaultModel; - private String owner; - private 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/developer_cloud/language_translator/v2/model/TranslationModels.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java deleted file mode 100644 index 46eebbce1e1..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationModels.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The response type for listing existing translation models. - */ -public class TranslationModels extends GenericModel { - - private 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/developer_cloud/language_translator/v2/model/TranslationResult.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java deleted file mode 100644 index f3cb4e9c623..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/model/TranslationResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TranslationResult. - */ -public class TranslationResult extends GenericModel { - - @SerializedName("word_count") - private Long wordCount; - @SerializedName("character_count") - private Long characterCount; - private List translations; - - /** - * Gets the wordCount. - * - * 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/developer_cloud/language_translator/v2/package-info.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java deleted file mode 100644 index b32505d7bec..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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 v2. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/util/Language.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/util/Language.java deleted file mode 100644 index b188decd557..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v2/util/Language.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2.util; - -import com.ibm.watson.developer_cloud.language_translator.v2.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/main/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslator.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslator.java deleted file mode 100644 index 44f89d7fccb..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslator.java +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.language_translator.v3.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiableLanguages; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiedLanguages; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.ListIdentifiableLanguagesOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModels; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationResult; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -/** - * 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 WatsonService { - - private static final String SERVICE_NAME = "language_translator"; - private static final String URL = "https://gateway.watsonplatform.net/language-translator/api"; - - private String versionDate; - - /** - * Instantiates a new `LanguageTranslator`. - * - * @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) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `LanguageTranslator` with username and password. - * - * @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 username the username - * @param password the password - */ - public LanguageTranslator(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `LanguageTranslator` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public LanguageTranslator(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * 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) { - Validator.notNull(translateOptions, "translateOptions cannot be null"); - String[] pathSegments = { "v3/translate" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - contentJson.add("text", 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); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationResult.class)); - } - - /** - * 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) { - Validator.notNull(identifyOptions, "identifyOptions cannot be null"); - String[] pathSegments = { "v3/identify" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.bodyContent(identifyOptions.text(), "text/plain"); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiedLanguages.class)); - } - - /** - * 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(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listIdentifiableLanguagesOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(IdentifiableLanguages.class)); - } - - /** - * 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); - } - - /** - * 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 maxium 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) { - Validator.notNull(createModelOptions, "createModelOptions cannot be null"); - 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(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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) { - RequestBody forcedGlossaryBody = RequestUtils.inputStreamBody(createModelOptions.forcedGlossary(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("forced_glossary", createModelOptions.forcedGlossaryFilename(), - forcedGlossaryBody); - } - if (createModelOptions.parallelCorpus() != null) { - RequestBody parallelCorpusBody = RequestUtils.inputStreamBody(createModelOptions.parallelCorpus(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("parallel_corpus", createModelOptions.parallelCorpusFilename(), - parallelCorpusBody); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * 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 Void - */ - public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { - Validator.notNull(deleteModelOptions, "deleteModelOptions cannot be null"); - String[] pathSegments = { "v3/models" }; - String[] pathParameters = { deleteModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getModelOptions, "getModelOptions cannot be null"); - String[] pathSegments = { "v3/models" }; - String[] pathParameters = { getModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModel.class)); - } - - /** - * 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(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listModelsOptions != null) { - if (listModelsOptions.source() != null) { - builder.query("source", listModelsOptions.source()); - } - if (listModelsOptions.target() != null) { - builder.query("target", listModelsOptions.target()); - } - if (listModelsOptions.defaultModels() != null) { - builder.query("default", String.valueOf(listModelsOptions.defaultModels())); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(TranslationModels.class)); - } - - /** - * List models. - * - * Lists available translation models. - * - * @return a {@link ServiceCall} with a response type of {@link TranslationModels} - */ - public ServiceCall listModels() { - return listModels(null); - } - -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/CreateModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/CreateModelOptions.java deleted file mode 100644 index 76a17520bb3..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/CreateModelOptions.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createModel options. - */ -public class CreateModelOptions extends GenericModel { - - private String baseModelId; - private String name; - private InputStream forcedGlossary; - private String forcedGlossaryFilename; - private InputStream parallelCorpus; - private String parallelCorpusFilename; - - /** - * Builder. - */ - public static class Builder { - private String baseModelId; - private String name; - private InputStream forcedGlossary; - private String forcedGlossaryFilename; - private InputStream parallelCorpus; - private String parallelCorpusFilename; - - private Builder(CreateModelOptions createModelOptions) { - baseModelId = createModelOptions.baseModelId; - name = createModelOptions.name; - forcedGlossary = createModelOptions.forcedGlossary; - forcedGlossaryFilename = createModelOptions.forcedGlossaryFilename; - parallelCorpus = createModelOptions.parallelCorpus; - parallelCorpusFilename = createModelOptions.parallelCorpusFilename; - } - - /** - * 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 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 - */ - public Builder forcedGlossary(InputStream forcedGlossary) { - this.forcedGlossary = forcedGlossary; - return this; - } - - /** - * Set the forcedGlossaryFilename. - * - * @param forcedGlossaryFilename the forcedGlossaryFilename - * @return the CreateModelOptions builder - */ - public Builder forcedGlossaryFilename(String forcedGlossaryFilename) { - this.forcedGlossaryFilename = forcedGlossaryFilename; - 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 parallelCorpusFilename. - * - * @param parallelCorpusFilename the parallelCorpusFilename - * @return the CreateModelOptions builder - */ - public Builder parallelCorpusFilename(String parallelCorpusFilename) { - this.parallelCorpusFilename = parallelCorpusFilename; - 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); - this.forcedGlossaryFilename = forcedGlossary.getName(); - 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); - this.parallelCorpusFilename = parallelCorpus.getName(); - return this; - } - } - - private CreateModelOptions(Builder builder) { - Validator.notNull(builder.baseModelId, "baseModelId cannot be null"); - baseModelId = builder.baseModelId; - name = builder.name; - forcedGlossary = builder.forcedGlossary; - forcedGlossaryFilename = builder.forcedGlossaryFilename; - parallelCorpus = builder.parallelCorpus; - parallelCorpusFilename = builder.parallelCorpusFilename; - } - - /** - * 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 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; - } - - /** - * 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 forcedGlossaryFilename. - * - * The filename for forcedGlossary. - * - * @return the forcedGlossaryFilename - */ - public String forcedGlossaryFilename() { - return forcedGlossaryFilename; - } - - /** - * 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 parallelCorpusFilename. - * - * The filename for parallelCorpus. - * - * @return the parallelCorpusFilename - */ - public String parallelCorpusFilename() { - return parallelCorpusFilename; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/DeleteModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/DeleteModelOptions.java deleted file mode 100644 index 17f0b4fbe77..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/DeleteModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteModel options. - */ -public class DeleteModelOptions extends GenericModel { - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(DeleteModelOptions deleteModelOptions) { - 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; - } - } - - private DeleteModelOptions(Builder builder) { - 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/developer_cloud/language_translator/v3/model/GetModelOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/GetModelOptions.java deleted file mode 100644 index 0bb573bbc3b..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/GetModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getModel options. - */ -public class GetModelOptions extends GenericModel { - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(GetModelOptions getModelOptions) { - 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; - } - } - - private GetModelOptions(Builder builder) { - 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/developer_cloud/language_translator/v3/model/IdentifiableLanguage.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiableLanguage.java deleted file mode 100644 index fecf6676c05..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiableLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiableLanguage. - */ -public class IdentifiableLanguage extends GenericModel { - - private String language; - private 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/developer_cloud/language_translator/v3/model/IdentifiableLanguages.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiableLanguages.java deleted file mode 100644 index d1a8783fedf..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiableLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiableLanguages. - */ -public class IdentifiableLanguages extends GenericModel { - - private 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/developer_cloud/language_translator/v3/model/IdentifiedLanguage.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiedLanguage.java deleted file mode 100644 index 8d58a5de01c..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiedLanguage.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiedLanguage. - */ -public class IdentifiedLanguage extends GenericModel { - - private String language; - private 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/developer_cloud/language_translator/v3/model/IdentifiedLanguages.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiedLanguages.java deleted file mode 100644 index aa3d425933e..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifiedLanguages.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * IdentifiedLanguages. - */ -public class IdentifiedLanguages extends GenericModel { - - private 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/developer_cloud/language_translator/v3/model/IdentifyOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifyOptions.java deleted file mode 100644 index f6fb455abcd..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/IdentifyOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The identify options. - */ -public class IdentifyOptions extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(IdentifyOptions identifyOptions) { - 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; - } - } - - private IdentifyOptions(Builder builder) { - 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/developer_cloud/language_translator/v3/model/ListIdentifiableLanguagesOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/ListIdentifiableLanguagesOptions.java deleted file mode 100644 index 8ac51bfe1fe..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/ListIdentifiableLanguagesOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.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/developer_cloud/language_translator/v3/model/ListModelsOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/ListModelsOptions.java deleted file mode 100644 index 38d6a260913..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/ListModelsOptions.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listModels options. - */ -public class ListModelsOptions extends GenericModel { - - private String source; - private String target; - private Boolean defaultModels; - - /** - * Builder. - */ - public static class Builder { - private String source; - private String target; - private Boolean defaultModels; - - private Builder(ListModelsOptions listModelsOptions) { - source = listModelsOptions.source; - target = listModelsOptions.target; - defaultModels = listModelsOptions.defaultModels; - } - - /** - * 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 defaultModels. - * - * @param defaultModels the defaultModels - * @return the ListModelsOptions builder - */ - public Builder defaultModels(Boolean defaultModels) { - this.defaultModels = defaultModels; - return this; - } - } - - private ListModelsOptions(Builder builder) { - source = builder.source; - target = builder.target; - defaultModels = builder.defaultModels; - } - - /** - * 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 defaultModels. - * - * 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 defaultModels - */ - public Boolean defaultModels() { - return defaultModels; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslateOptions.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslateOptions.java deleted file mode 100644 index 2996e0b5c71..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslateOptions.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The translate options. - */ -public class TranslateOptions extends GenericModel { - - private List text; - private String modelId; - private String source; - private String target; - - /** - * Builder. - */ - public static class Builder { - private List text; - private String modelId; - private String source; - private String target; - - private Builder(TranslateOptions translateOptions) { - text = translateOptions.text; - modelId = translateOptions.modelId; - source = translateOptions.source; - 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) { - 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; - } - } - - private TranslateOptions(Builder builder) { - 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. - * - * Model ID of the translation model to use. If this is specified, the **source** and **target** parameters will be - * ignored. The method requires either a model ID or both the **source** and **target** parameters. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } - - /** - * Gets the source. - * - * Language code of the source text language. Use with `target` as an alternative way to select a translation model. - * When `source` and `target` are set, and a model ID is not set, the system chooses a default model for the language - * pair (usually the model based on the news domain). - * - * @return the source - */ - public String source() { - return source; - } - - /** - * Gets the target. - * - * Language code of the translation target language. Use with source as an alternative way to select a translation - * model. - * - * @return the target - */ - public String target() { - return target; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/Translation.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/Translation.java deleted file mode 100644 index 8db93e035bc..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/Translation.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Translation. - */ -public class Translation extends GenericModel { - - @SerializedName("translation") - private String translationOutput; - - /** - * Gets the translationOutput. - * - * Translation output in UTF-8. - * - * @return the translationOutput - */ - public String getTranslationOutput() { - return translationOutput; - } -} diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationModel.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationModel.java deleted file mode 100644 index 02a9136bee1..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationModel.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private String modelId; - private String name; - private String source; - private String target; - @SerializedName("base_model_id") - private String baseModelId; - private String domain; - private Boolean customizable; - @SerializedName("default_model") - private Boolean defaultModel; - private String owner; - private 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/developer_cloud/language_translator/v3/model/TranslationModels.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationModels.java deleted file mode 100644 index e9978a39a98..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationModels.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The response type for listing existing translation models. - */ -public class TranslationModels extends GenericModel { - - private 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/developer_cloud/language_translator/v3/model/TranslationResult.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationResult.java deleted file mode 100644 index 6f146e9698c..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/model/TranslationResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TranslationResult. - */ -public class TranslationResult extends GenericModel { - - @SerializedName("word_count") - private Long wordCount; - @SerializedName("character_count") - private Long characterCount; - private List translations; - - /** - * Gets the wordCount. - * - * 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/developer_cloud/language_translator/v3/package-info.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/package-info.java deleted file mode 100644 index c38f5d22238..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.language_translator.v3; diff --git a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/util/Language.java b/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/util/Language.java deleted file mode 100644 index 77619c2c002..00000000000 --- a/language-translator/src/main/java/com/ibm/watson/developer_cloud/language_translator/v3/util/Language.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3.util; - -import com.ibm.watson.developer_cloud.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/developer_cloud/language_translator/v2/LanguageTranslatorIT.java b/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java deleted file mode 100644 index edc0bbbb427..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorIT.java +++ /dev/null @@ -1,262 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.List; -import java.util.Map; - -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.language_translator.v2.util.Language; - -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.watson.developer_cloud.WatsonServiceTest; - -/** - * Language Translator integration test. - */ -public class LanguageTranslatorIT extends WatsonServiceTest { - - private static final String ENGLISH_TO_SPANISH = "en-es"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - - 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()); - - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("language_translator_v2.username"); - String password = getProperty("language_translator_v2.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new LanguageTranslator(); - service.setUsernameAndPassword(username, password); - service.setEndPoint(getProperty("language_translator.url_cf")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - // LanguageTranslator service = new LanguageTranslator(); - // service.setUsernameAndPassword("", ""); - - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello").source(Language.ENGLISH).target(Language.SPANISH).build(); - TranslationResult translationResult = service.translate(translateOptions).execute(); - - System.out.println(translationResult); - } - - /** - * Test create and delete model. - */ - @Test - public void testCreateAndDeleteModel() throws IOException { - - String modelName = "integration-test"; - String baseModelId = "en-es"; - - InputStream glossary = new FileInputStream(new File(RESOURCE + "glossary.tmx")); - CreateModelOptions options = new CreateModelOptions.Builder() - .name(modelName) - .baseModelId(baseModelId) - .forcedGlossary(glossary) - .forcedGlossaryFilename("test_glossary") - .build(); - - TranslationModel model = null; - try { - model = service.createModel(options).execute(); - Thread.sleep(3000); - assertNotNull(model); - assertTrue(model.getModelId() != null && model.getModelId().length() > 0); - assertEquals(model.getName(), modelName); - assertEquals(model.getBaseModelId(), baseModelId); - assertEquals(model.isCustomizable(), false); - assertEquals(model.isDefaultModel(), false); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - if (model != null) { - DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(model.getModelId()).build(); - service.deleteModel(deleteOptions).execute(); - } - } - } - - /** - * Test Get Identifiable languages. - */ - @Test - public void testGetIdentifiableLanguages() { - final List languages = service.listIdentifiableLanguages().execute().getLanguages(); - assertNotNull(languages); - assertTrue(!languages.isEmpty()); - } - - /** - * Test Get model by id. - */ - @Test - public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder(ENGLISH_TO_SPANISH).build(); - final TranslationModel model = service.getModel(getOptions).execute(); - assertNotNull(model); - } - - /** - * Test List Models. - */ - @Test - public void testListModels() { - final List models = service.listModels(null).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - } - - /** - * Test List Models with Options. - */ - @Test - public void testListModelsWithOptions() { - ListModelsOptions options = new ListModelsOptions.Builder() - .source("en") - .target("es") - .defaultModels(false) - .build(); - final List models = service.listModels(options).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - assertEquals(models.get(0).getSource(), options.source()); - assertEquals(models.get(0).getTarget(), options.target()); - } - - /** - * Test Identify. - */ - @Test - public void testIdentify() { - - IdentifyOptions options = new IdentifyOptions.Builder(texts.get(0)).build(); - final List identifiedLanguages = service.identify(options).execute().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()); - TranslateOptions options1 = new TranslateOptions.Builder() - .addText(text).source(Language.ENGLISH).target(Language.SPANISH).build(); - testTranslationResult(text, translations.get(text), service.translate(options1).execute()); - } - } - - /** - * Test translate multiple. - */ - @Test - public void testTranslateMultiple() { - TranslateOptions options = new TranslateOptions.Builder(texts) - .modelId(ENGLISH_TO_SPANISH).build(); - TranslationResult results = service.translate(options).execute(); - 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(); - 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().getModels(); - for (TranslationModel translationModel : models) { - DeleteModelOptions options = new DeleteModelOptions.Builder(translationModel.getModelId()).build(); - service.deleteModel(options).execute(); - } - } - - /** - * 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/developer_cloud/language_translator/v2/LanguageTranslatorTest.java b/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java deleted file mode 100644 index 1764e442ae4..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v2/LanguageTranslatorTest.java +++ /dev/null @@ -1,348 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v2; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.language_translator.v2.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifiedLanguages; -import com.ibm.watson.developer_cloud.language_translator.v2.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationModels; -import com.ibm.watson.developer_cloud.language_translator.v2.model.TranslationResult; -import com.ibm.watson.developer_cloud.language_translator.v2.util.Language; -import com.ibm.watson.developer_cloud.service.exception.BadRequestException; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -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 V2 Unit tests. - */ -public class LanguageTranslatorTest extends WatsonServiceUnitTest { - - private static final String GET_MODELS_PATH = "/v2/models"; - private static final String IDENTIFIABLE_LANGUAGES_PATH = "/v2/identifiable_languages"; - private static final String IDENTITY_PATH = "/v2/identify"; - private static final String LANGUAGE_TRANSLATION_PATH = "/v2/translate"; - 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; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new LanguageTranslator(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(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); - } - - /** - * 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)); - - final List languages = service.listIdentifiableLanguages().execute().getLanguages(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTIFIABLE_LANGUAGES_PATH, 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(); - final TranslationModel returnedModel = service.getModel(getOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH + "/" + model.getModelId(), 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(); - final List modelList = service.listModels(options).execute().getModels(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(GET_MODELS_PATH, 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(); - final List identifiedLanguages = service.identify(identifyOptions).execute().getLanguages(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(IDENTITY_PATH, 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH, 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(LANGUAGE_TRANSLATION_PATH, 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()); - String myMonolingualCorpus = "{\"field\":\"value\"}"; - InputStream monolingualCorpusStream = new ByteArrayInputStream(myMonolingualCorpus.getBytes()); - - CreateModelOptions options1 = new CreateModelOptions.Builder(modelId) - .parallelCorpus(parallelCorpusStream) - .monolingualCorpus(monolingualCorpusStream) - .build(); - CreateModelOptions.Builder builder = options1.newBuilder(); - CreateModelOptions options2 = builder.name("baz").build(); - assertEquals(options2.baseModelId(), modelId); - assertEquals(options2.parallelCorpus(), parallelCorpusStream); - assertEquals(options2.monolingualCorpus(), monolingualCorpusStream); - assertEquals(options2.name(), "baz"); - } -} diff --git a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITCF.java b/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITCF.java deleted file mode 100644 index 02a9416c1f3..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITCF.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.language_translator.v3.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationResult; -import com.ibm.watson.developer_cloud.language_translator.v3.util.Language; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.IOException; -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 LanguageTranslatorITCF extends WatsonServiceTest { - - private static final String ENGLISH_TO_SPANISH = "en-es"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - - 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 username = getProperty("language_translator_v3.username"); - String password = getProperty("language_translator_v3.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new LanguageTranslator("2018-05-01"); - service.setUsernameAndPassword(username, password); - service.setEndPoint(getProperty("language_translator.url_cf")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello").source(Language.ENGLISH).target(Language.SPANISH).build(); - TranslationResult translationResult = service.translate(translateOptions).execute(); - - System.out.println(translationResult); - } - - /** - * Test Get Identifiable languages. - */ - @Test - public void testGetIdentifiableLanguages() { - final List languages = service.listIdentifiableLanguages().execute().getLanguages(); - assertNotNull(languages); - assertTrue(!languages.isEmpty()); - } - - /** - * Test Get model by id. - */ - @Test - public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder(ENGLISH_TO_SPANISH).build(); - final TranslationModel model = service.getModel(getOptions).execute(); - assertNotNull(model); - } - - /** - * Test List Models. - */ - @Test - public void testListModels() { - final List models = service.listModels(null).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - } - - /** - * Test List Models with Options. - */ - @Test - public void testListModelsWithOptions() { - ListModelsOptions options = new ListModelsOptions.Builder() - .source("en") - .target("es") - .defaultModels(true) - .build(); - final List models = service.listModels(options).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - assertEquals(models.get(0).getSource(), options.source()); - assertEquals(models.get(0).getTarget(), options.target()); - } - - /** - * Test Identify. - */ - @Test - public void testIdentify() { - - IdentifyOptions options = new IdentifyOptions.Builder(texts.get(0)).build(); - final List identifiedLanguages = service.identify(options).execute().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()); - TranslateOptions options1 = new TranslateOptions.Builder() - .addText(text).source(Language.ENGLISH).target(Language.SPANISH).build(); - testTranslationResult(text, translations.get(text), service.translate(options1).execute()); - } - } - - /** - * Test translate multiple. - */ - @Test - public void testTranslateMultiple() { - TranslateOptions options = new TranslateOptions.Builder(texts) - .modelId(ENGLISH_TO_SPANISH).build(); - TranslationResult results = service.translate(options).execute(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslationOutput()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslationOutput()); - - 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(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslationOutput()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslationOutput()); - } - - /** - * Test delete all models. - */ - @Test - @Ignore - public void testDeleteAllModels() { - List models = service.listModels(null).execute().getModels(); - for (TranslationModel translationModel : models) { - DeleteModelOptions options = new DeleteModelOptions.Builder(translationModel.getModelId()).build(); - service.deleteModel(options).execute(); - } - } - - /** - * 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).getTranslationOutput()); - assertEquals(result, translationResult.getTranslations().get(0).getTranslationOutput()); - } - -} diff --git a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITRC.java b/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITRC.java deleted file mode 100644 index c5823262d32..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorITRC.java +++ /dev/null @@ -1,221 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.language_translator.v3.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationResult; -import com.ibm.watson.developer_cloud.language_translator.v3.util.Language; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; - -import java.io.IOException; -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 LanguageTranslatorITRC extends WatsonServiceTest { - - private static final String ENGLISH_TO_SPANISH = "en-es"; - private static final String RESOURCE = "src/test/resources/language_translation/"; - - 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_v3.iam_api_key"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", (iamApiKey == null)); - - service = new LanguageTranslator("2018-05-01"); - IamOptions iamOptions = new IamOptions.Builder() - .apiKey(iamApiKey) - .build(); - service.setIamCredentials(iamOptions); - service.setEndPoint(getProperty("language_translator.url_rc")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - TranslateOptions translateOptions = new TranslateOptions.Builder() - .addText("hello").source(Language.ENGLISH).target(Language.SPANISH).build(); - TranslationResult translationResult = service.translate(translateOptions).execute(); - - System.out.println(translationResult); - } - - /** - * Test Get Identifiable languages. - */ - @Test - public void testGetIdentifiableLanguages() { - final List languages = service.listIdentifiableLanguages().execute().getLanguages(); - assertNotNull(languages); - assertTrue(!languages.isEmpty()); - } - - /** - * Test Get model by id. - */ - @Test - public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder(ENGLISH_TO_SPANISH).build(); - final TranslationModel model = service.getModel(getOptions).execute(); - assertNotNull(model); - } - - /** - * Test List Models. - */ - @Test - public void testListModels() { - final List models = service.listModels(null).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - } - - /** - * Test List Models with Options. - */ - @Test - public void testListModelsWithOptions() { - ListModelsOptions options = new ListModelsOptions.Builder() - .source("en") - .target("es") - .defaultModels(true) - .build(); - final List models = service.listModels(options).execute().getModels(); - - assertNotNull(models); - assertFalse(models.isEmpty()); - assertEquals(models.get(0).getSource(), options.source()); - assertEquals(models.get(0).getTarget(), options.target()); - } - - /** - * Test Identify. - */ - @Test - public void testIdentify() { - - IdentifyOptions options = new IdentifyOptions.Builder(texts.get(0)).build(); - final List identifiedLanguages = service.identify(options).execute().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()); - TranslateOptions options1 = new TranslateOptions.Builder() - .addText(text).source(Language.ENGLISH).target(Language.SPANISH).build(); - testTranslationResult(text, translations.get(text), service.translate(options1).execute()); - } - } - - /** - * Test translate multiple. - */ - @Test - public void testTranslateMultiple() { - TranslateOptions options = new TranslateOptions.Builder(texts) - .modelId(ENGLISH_TO_SPANISH).build(); - TranslationResult results = service.translate(options).execute(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslationOutput()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslationOutput()); - - 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(); - assertEquals(2, results.getTranslations().size()); - assertEquals(translations.get(texts.get(0)), results.getTranslations().get(0).getTranslationOutput()); - assertEquals(translations.get(texts.get(1)), results.getTranslations().get(1).getTranslationOutput()); - } - - /** - * Test delete all models. - */ - @Test - @Ignore - public void testDeleteAllModels() { - List models = service.listModels(null).execute().getModels(); - for (TranslationModel translationModel : models) { - DeleteModelOptions options = new DeleteModelOptions.Builder(translationModel.getModelId()).build(); - service.deleteModel(options).execute(); - } - } - - /** - * 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).getTranslationOutput()); - assertEquals(result, translationResult.getTranslations().get(0).getTranslationOutput()); - } - -} diff --git a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorTest.java b/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorTest.java deleted file mode 100644 index 3efb1ccdff6..00000000000 --- a/language-translator/src/test/java/com/ibm/watson/developer_cloud/language_translator/v3/LanguageTranslatorTest.java +++ /dev/null @@ -1,345 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.language_translator.v3; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.language_translator.v3.model.CreateModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.GetModelOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiableLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiedLanguage; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifiedLanguages; -import com.ibm.watson.developer_cloud.language_translator.v3.model.IdentifyOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslateOptions; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModel; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationModels; -import com.ibm.watson.developer_cloud.language_translator.v3.model.TranslationResult; -import com.ibm.watson.developer_cloud.language_translator.v3.util.Language; -import com.ibm.watson.developer_cloud.service.exception.BadRequestException; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -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 V2 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; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developercloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new LanguageTranslator("2018-05-01"); - service.setUsernameAndPassword("", ""); - service.setEndPoint(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); - } - - /** - * 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)); - - final List languages = service.listIdentifiableLanguages().execute().getLanguages(); - final 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(); - final TranslationModel returnedModel = service.getModel(getOptions).execute(); - final 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(); - final List modelList = service.listModels(options).execute().getModels(); - final 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(); - final List identifiedLanguages = service.identify(identifyOptions).execute().getLanguages(); - final 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(); - final 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(); - final 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).getTranslationOutput()); - assertEquals(translations.get(texts.get(1)), translationResult.getTranslations().get(1).getTranslationOutput()); - } - - /** - * 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).getTranslationOutput()); - } - - /** - * 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"); - } -} 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/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/natural-language-classifier/README.md b/natural-language-classifier/README.md deleted file mode 100644 index 4cb14058fe7..00000000000 --- a/natural-language-classifier/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# Natural Language Classifier - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - natural-language-classifier - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:natural-language-classifier:6.1.0' -``` - -## Usage -Use [Natural Language Classifier](https://console.bluemix.net/docs/services/natural-language-classifier/getting-started.html) 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 -NaturalLanguageClassifier service = new NaturalLanguageClassifier(); -service.setUsernameAndPassword("", ""); - -ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId("") - .text("Is it sunny?") - .build(); - -Classification classification = service.classify(classifyOptions).execute(); -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 7bc68ea40bc..00000000000 --- a/natural-language-classifier/build.gradle +++ /dev/null @@ -1,117 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'natural-language-classifier' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Natural Language Classifer Service' - url 'https://console.bluemix.net/docs/services/natural-language-understanding/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java deleted file mode 100644 index 0de9aa6d9f5..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifier.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.HashMap; -import java.util.Map; - -/** - * 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 WatsonService { - - private static final String SERVICE_NAME = "natural_language_classifier"; - private static final String URL = "https://gateway.watsonplatform.net/natural-language-classifier/api"; - - /** - * Instantiates a new `NaturalLanguageClassifier`. - * - */ - public NaturalLanguageClassifier() { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - } - - /** - * Instantiates a new `NaturalLanguageClassifier` with username and password. - * - * @param username the username - * @param password the password - */ - public NaturalLanguageClassifier(String username, String password) { - this(); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `NaturalLanguageClassifier` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this one expires. Failing to do so will result in authentication errors after this token expires. - * - * @param iamOptions the options for authenticating through IAM - */ - public NaturalLanguageClassifier(IamOptions iamOptions) { - this(); - setIamCredentials(iamOptions); - } - - /** - * 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) { - Validator.notNull(classifyOptions, "classifyOptions cannot be null"); - String[] pathSegments = { "v1/classifiers", "classify" }; - String[] pathParameters = { classifyOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", classifyOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classification.class)); - } - - /** - * 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) { - Validator.notNull(classifyCollectionOptions, "classifyCollectionOptions cannot be null"); - String[] pathSegments = { "v1/classifiers", "classify_collection" }; - String[] pathParameters = { classifyCollectionOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - contentJson.add("collection", GsonSingleton.getGson().toJsonTree(classifyCollectionOptions.collection())); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassificationCollection.class)); - } - - /** - * 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) { - Validator.notNull(createClassifierOptions, "createClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - RequestBody trainingMetadataBody = RequestUtils.inputStreamBody(createClassifierOptions.metadata(), - "application/json"); - multipartBuilder.addFormDataPart("training_metadata", createClassifierOptions.metadataFilename(), - trainingMetadataBody); - RequestBody trainingDataBody = RequestUtils.inputStreamBody(createClassifierOptions.trainingData(), "text/csv"); - multipartBuilder.addFormDataPart("training_data", createClassifierOptions.trainingDataFilename(), trainingDataBody); - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class)); - } - - /** - * 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) { - Validator.notNull(deleteClassifierOptions, "deleteClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - String[] pathParameters = { deleteClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null"); - String[] pathSegments = { "v1/classifiers" }; - String[] pathParameters = { getClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class)); - } - - /** - * 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(getEndPoint(), pathSegments)); - if (listClassifiersOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifierList.class)); - } - - /** - * 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); - } - - /** - * Classify. - * - * This method is here for backwards-compatibility with the other version of classify. - * - * @param classifierId the classifier ID - * @param text the submitted phrase to classify - * @return the classification of a phrase with a given classifier - */ - public ServiceCall classify(String classifierId, String text) { - ClassifyOptions classifyOptions = new ClassifyOptions.Builder() - .classifierId(classifierId) - .text(text) - .build(); - return classify(classifyOptions); - } - - /** - * Create classifier. - * - * This method is here for backwards-compatibility with the old version of createClassifier. - * - * @param name the classifier name - * @param language IETF primary language for the classifier. for example: 'en' - * @param trainingData the set of questions and their "keys" used to adapt a system to a domain (the ground truth) - * @return the classifier - * @throws FileNotFoundException if the file could not be found - */ - public ServiceCall createClassifier(String name, String language, File trainingData) - throws FileNotFoundException { - Map metadataMap = new HashMap<>(); - metadataMap.put("name", name); - metadataMap.put("language", language); - String metadataString = GsonSingleton.getGson().toJson(metadataMap); - - CreateClassifierOptions createClassifierOptions = new CreateClassifierOptions.Builder() - .metadata(new ByteArrayInputStream(metadataString.getBytes())) - .trainingData(trainingData) - .build(); - - return createClassifier(createClassifierOptions); - } - - /** - * Delete classifier. - * - * This method is here for backwards-compatibility with the old version of deleteClassifier. - * - * @param classifierId the classifier ID - * @return the service call - */ - public ServiceCall deleteClassifier(String classifierId) { - DeleteClassifierOptions deleteClassifierOptions = new DeleteClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - - return deleteClassifier(deleteClassifierOptions); - } - - /** - * Get information about a classifier. - * - * This method is here for backwards-compatibility with the old version of getClassifier. - * - * @param classifierId the classifier ID - * @return the classifier - */ - public ServiceCall getClassifier(String classifierId) { - GetClassifierOptions getClassifierOptions = new GetClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - - return getClassifier(getClassifierOptions); - } - - /** - * List classifiers. - * - * This method is here for backwards-compatibility with the old version of getClassifiers, which has been renamed - * to listClassifiers. - * - * @return the classifier list - */ - public ServiceCall getClassifiers() { - return listClassifiers(); - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classification.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classification.java deleted file mode 100644 index 0b73ed0dc2b..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classification.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Response from the classifier for a phrase. - */ -public class Classification extends GenericModel { - - @SerializedName("classifier_id") - private String classifierId; - private String url; - private String text; - @SerializedName("top_class") - private String topClass; - private 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/developer_cloud/natural_language_classifier/v1/model/ClassificationCollection.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassificationCollection.java deleted file mode 100644 index c47ef4fe6e4..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassificationCollection.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Response from the classifier for multiple phrases. - */ -public class ClassificationCollection extends GenericModel { - - @SerializedName("classifier_id") - private String classifierId; - private String url; - private 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/developer_cloud/natural_language_classifier/v1/model/ClassifiedClass.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifiedClass.java deleted file mode 100644 index 3b4791ba659..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifiedClass.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Class and confidence. - */ -public class ClassifiedClass extends GenericModel { - - private Double confidence; - @SerializedName("class_name") - private 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/developer_cloud/natural_language_classifier/v1/model/Classifier.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java deleted file mode 100644 index b45b19ff2a9..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/Classifier.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.Date; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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"; - } - - private String name; - private String url; - private String status; - @SerializedName("classifier_id") - private String classifierId; - private Date created; - @SerializedName("status_description") - private String statusDescription; - private 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/developer_cloud/natural_language_classifier/v1/model/ClassifierList.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifierList.java deleted file mode 100644 index 7ec536016d4..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifierList.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * List of available classifiers. - */ -public class ClassifierList extends GenericModel { - - private 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/developer_cloud/natural_language_classifier/v1/model/ClassifyCollectionOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyCollectionOptions.java deleted file mode 100644 index ae4f5df6559..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyCollectionOptions.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The classifyCollection options. - */ -public class ClassifyCollectionOptions extends GenericModel { - - private String classifierId; - private List collection; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private List collection; - - private Builder(ClassifyCollectionOptions classifyCollectionOptions) { - classifierId = classifyCollectionOptions.classifierId; - 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) { - 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; - } - } - - private ClassifyCollectionOptions(Builder builder) { - Validator.notEmpty(builder.classifierId, "classifierId cannot be empty"); - 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/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java deleted file mode 100644 index 1730425994c..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyInput.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Request payload to classify. - */ -public class ClassifyInput extends GenericModel { - - private String text; - - /** - * Gets the text. - * - * The submitted phrase. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Sets the text. - * - * @param text the new text - */ - public void setText(final String text) { - this.text = text; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java deleted file mode 100644 index adecf9bc6ed..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ClassifyOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The classify options. - */ -public class ClassifyOptions extends GenericModel { - - private String classifierId; - private String text; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private String text; - - private Builder(ClassifyOptions classifyOptions) { - classifierId = classifyOptions.classifierId; - 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; - } - } - - private ClassifyOptions(Builder builder) { - Validator.notEmpty(builder.classifierId, "classifierId cannot be empty"); - 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. - * - * @return the text - */ - public String text() { - return text; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java deleted file mode 100644 index e8d1cd627e7..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CollectionItem.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Response from the classifier for a phrase in a collection. - */ -public class CollectionItem extends GenericModel { - - private String text; - @SerializedName("top_class") - private String topClass; - private List classes; - - /** - * 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/developer_cloud/natural_language_classifier/v1/model/CreateClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CreateClassifierOptions.java deleted file mode 100644 index b9ec5987356..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/CreateClassifierOptions.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createClassifier options. - */ -public class CreateClassifierOptions extends GenericModel { - - private InputStream metadata; - private String metadataFilename; - private InputStream trainingData; - private String trainingDataFilename; - - /** - * Builder. - */ - public static class Builder { - private InputStream metadata; - private String metadataFilename; - private InputStream trainingData; - private String trainingDataFilename; - - private Builder(CreateClassifierOptions createClassifierOptions) { - metadata = createClassifierOptions.metadata; - metadataFilename = createClassifierOptions.metadataFilename; - trainingData = createClassifierOptions.trainingData; - trainingDataFilename = createClassifierOptions.trainingDataFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param metadata the metadata - * @param trainingData the trainingData - */ - public Builder(InputStream metadata, InputStream trainingData) { - this.metadata = metadata; - this.trainingData = trainingData; - } - - /** - * Builds a CreateClassifierOptions. - * - * @return the createClassifierOptions - */ - public CreateClassifierOptions build() { - return new CreateClassifierOptions(this); - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateClassifierOptions builder - */ - public Builder metadata(InputStream metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the metadataFilename. - * - * @param metadataFilename the metadataFilename - * @return the CreateClassifierOptions builder - */ - public Builder metadataFilename(String metadataFilename) { - this.metadataFilename = metadataFilename; - 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 trainingDataFilename. - * - * @param trainingDataFilename the trainingDataFilename - * @return the CreateClassifierOptions builder - */ - public Builder trainingDataFilename(String trainingDataFilename) { - this.trainingDataFilename = trainingDataFilename; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the CreateClassifierOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder metadata(File metadata) throws FileNotFoundException { - this.metadata = new FileInputStream(metadata); - this.metadataFilename = metadata.getName(); - 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); - this.trainingDataFilename = trainingData.getName(); - return this; - } - } - - private CreateClassifierOptions(Builder builder) { - Validator.notNull(builder.metadata, "metadata cannot be null"); - Validator.notNull(builder.trainingData, "trainingData cannot be null"); - metadata = builder.metadata; - metadataFilename = builder.metadataFilename; - trainingData = builder.trainingData; - trainingDataFilename = builder.trainingDataFilename; - } - - /** - * New builder. - * - * @return a CreateClassifierOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the metadata. - * - * 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 metadata - */ - public InputStream metadata() { - return metadata; - } - - /** - * Gets the metadataFilename. - * - * The filename for trainingMetadata. - * - * @return the metadataFilename - */ - public String metadataFilename() { - return metadataFilename; - } - - /** - * Gets the trainingData. - * - * Training data in CSV format. Each text value must have at least one class. The data can include up to 20,000 - * records. For details, see [Data - * preparation](https://console.bluemix.net/docs/services/natural-language-classifier/using-your-data.html). - * - * @return the trainingData - */ - public InputStream trainingData() { - return trainingData; - } - - /** - * Gets the trainingDataFilename. - * - * The filename for trainingData. - * - * @return the trainingDataFilename - */ - public String trainingDataFilename() { - return trainingDataFilename; - } -} diff --git a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/DeleteClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/DeleteClassifierOptions.java deleted file mode 100644 index d55f0cedf9d..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/DeleteClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteClassifier options. - */ -public class DeleteClassifierOptions extends GenericModel { - - private String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(DeleteClassifierOptions deleteClassifierOptions) { - 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; - } - } - - private DeleteClassifierOptions(Builder builder) { - 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/developer_cloud/natural_language_classifier/v1/model/GetClassifierOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/GetClassifierOptions.java deleted file mode 100644 index 4d9cc490ac8..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/GetClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getClassifier options. - */ -public class GetClassifierOptions extends GenericModel { - - private String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetClassifierOptions getClassifierOptions) { - 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; - } - } - - private GetClassifierOptions(Builder builder) { - 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/developer_cloud/natural_language_classifier/v1/model/ListClassifiersOptions.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ListClassifiersOptions.java deleted file mode 100644 index a40e42d5ef2..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/model/ListClassifiersOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1.model; - -import com.ibm.watson.developer_cloud.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/developer_cloud/natural_language_classifier/v1/package-info.java b/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/package-info.java deleted file mode 100644 index c273408e9e6..00000000000 --- a/natural-language-classifier/src/main/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.natural_language_classifier.v1; diff --git a/natural-language-classifier/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java b/natural-language-classifier/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java deleted file mode 100644 index e39a1f460db..00000000000 --- a/natural-language-classifier/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierIT.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier.Status; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyInput; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ListClassifiersOptions; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -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 java.util.List; - -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 username = getProperty("natural_language_classifier.username"); - String password = getProperty("natural_language_classifier.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new NaturalLanguageClassifier(); - service.setDefaultHeaders(getDefaultHeaders()); - service.setUsernameAndPassword(username, password); - service.setEndPoint(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() - .metadata(metadata) - .trainingData(trainingData) - .trainingDataFilename("weather_data_train.csv") - .build(); - Classifier classifier = service.createClassifier(createOptions).execute(); - - try { - assertNotNull(classifier); - assertEquals(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(); - } 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(); - 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(); - } 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 { - List classifiers = service.listClassifiers().execute().getClassifiers(); - - for (Classifier classifier : classifiers) { - GetClassifierOptions getOptions = new GetClassifierOptions.Builder() - .classifierId(classifier.getClassifierId()) - .build(); - Classifier currentClassifier = service.getClassifier(getOptions).execute(); - if (currentClassifier.getClassifierId().equals(classifierId)) { - while (!currentClassifier.getStatus().equals(Status.AVAILABLE)) { - Thread.sleep(5000); - getOptions = new GetClassifierOptions.Builder() - .classifierId(classifierId) - .build(); - currentClassifier = service.getClassifier(getOptions).execute(); - } - - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder() - .classifierId(classifier.getClassifierId()) - .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(); - input1.setText("How hot will it be today?"); - ClassifyInput input2 = new ClassifyInput(); - input2.setText("Is it hot outside?"); - - try { - ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder() - .classifierId(preCreatedClassifierId) - .addClassifyInput(input1) - .addClassifyInput(input2) - .build(); - classificationCollection = service.classifyCollection(classifyOptions).execute(); - } 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/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierTest.java b/natural-language-classifier/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierTest.java deleted file mode 100644 index 17d44a34ab2..00000000000 --- a/natural-language-classifier/src/test/java/com/ibm/watson/developer_cloud/natural_language_classifier/v1/NaturalLanguageClassifierTest.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_classifier.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classification; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassificationCollection; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.Classifier; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifierList; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyCollectionOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyInput; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.natural_language_classifier.v1.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.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(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(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(); - 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(); - input1.setText("How hot will it be today?"); - ClassifyInput input2 = new ClassifyInput(); - input2.setText("Is it hot outside?"); - List inputCollection = Arrays.asList(input1, input2); - - ClassifyCollectionOptions classifyOptions = new ClassifyCollectionOptions.Builder() - .classifierId(classifierId) - .collection(inputCollection) - .build(); - final ClassificationCollection result = service.classifyCollection(classifyOptions).execute(); - 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(); - 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(); - 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() - .metadata(metadata) - .trainingData(trainingData) - .trainingDataFilename("weather_data_train.csv") - .build(); - final Classifier response = service.createClassifier(createOptions).execute(); - 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() - .metadata(metadata) - .trainingData(trainingData) - .trainingDataFilename("notfound.txt") - .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 2532d6bf554..079e51cd420 100644 --- a/natural-language-understanding/README.md +++ b/natural-language-understanding/README.md @@ -3,32 +3,35 @@ ## Installation ##### Maven + ```xml - com.ibm.watson.developer_cloud + com.ibm.watson natural-language-understanding - 6.1.0 + 16.1.0 ``` ##### Gradle + ```gradle -'com.ibm.watson.developer_cloud:natural-language-understanding:6.1.0' +'com.ibm.watson:natural-language-understanding:16.1.0' ``` ## Usage -Use [Natural Language Understanding](https://console.bluemix.net/docs/services/natural-language-understanding/index.html) + +Use [Natural Language Understanding](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-about) to 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. ```java -NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding("2017-02-27"); -service.setUsernameAndPassword("", ""); +Authenticator authenticator = new IamAuthenticator(""); +NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding("2019-07-12", authenticator); EntitiesOptions entities = new EntitiesOptions.Builder() .sentiment(true) - .limit(1) + .limit(1L) .build(); Features features = new Features.Builder() .entities(entities) @@ -38,9 +41,6 @@ AnalyzeOptions parameters = new AnalyzeOptions.Builder() .features(features) .build(); -AnalysisResults results = service.analyze(parameters).execute(); +AnalysisResults results = service.analyze(parameters).execute().getResult(); System.out.println(results); ``` - -We also offer a cognitive client which makes use of this API to provide enhanced features for applications using our natural language understanding services: -https://github.com/watson-developer-cloud/cognitive-client-java diff --git a/natural-language-understanding/build.gradle b/natural-language-understanding/build.gradle deleted file mode 100644 index 5f8d70544e9..00000000000 --- a/natural-language-understanding/build.gradle +++ /dev/null @@ -1,112 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'natural-language-understanding' - packaging 'jar' - // optionally artifactId can be defined here - description 'Natural language processing for advanced text analysis' - url 'https://console.bluemix.net/docs/services/natural-language-understanding/index.html' - - 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' - } - - 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' - } - } - } - } - } -} 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/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstanding.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstanding.java deleted file mode 100644 index 3f1421edc17..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstanding.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ListModelsResults; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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 - * models with Watson Knowledge Studio that can be used to detect custom entities and relations in Natural Language - * Understanding. - * - * @version v1 - * @see Natural Language - * Understanding - */ -public class NaturalLanguageUnderstanding extends WatsonService { - - private static final String SERVICE_NAME = "natural_language_understanding"; - private static final String URL = "https://gateway.watsonplatform.net/natural-language-understanding/api"; - - private String versionDate; - - /** - * Instantiates a new `NaturalLanguageUnderstanding`. - * - * @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 NaturalLanguageUnderstanding(String versionDate) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `NaturalLanguageUnderstanding` with username and password. - * - * @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 username the username - * @param password the password - */ - public NaturalLanguageUnderstanding(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `NaturalLanguageUnderstanding` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public NaturalLanguageUnderstanding(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * Analyze text, HTML, or a public webpage. - * - * Analyzes text, HTML, or a public webpage with one or more text analysis features. - * - * ### Concepts - * Identify general concepts that are referenced or alluded to in your content. Concepts that are detected typically - * have an associated link to a DBpedia resource. - * - * ### Emotion - * Detect anger, disgust, fear, joy, or sadness that is conveyed by your content. Emotion information can be returned - * for detected entities, keywords, or user-specified target phrases found in the text. - * - * ### Entities - * Detect important people, places, geopolitical entities and other types of entities in your content. Entity - * detection recognizes consecutive coreferences of each entity. For example, analysis of the following text would - * count \"Barack Obama\" and \"He\" as the same entity: - * - * \"Barack Obama was the 44th President of the United States. He took office in January 2009.\" - * - * ### Keywords - * Determine the most important keywords in your content. Keyword phrases are organized by relevance in the results. - * - * ### Metadata - * Get author information, publication date, and the title of your text/HTML content. - * - * ### Relations - * Recognize when two entities are related, and identify the type of relation. For example, you can identify an - * \"awardedTo\" relation between an award and its recipient. - * - * ### Semantic Roles - * Parse sentences into subject-action-object form, and identify entities and keywords that are subjects or objects of - * an action. - * - * ### Sentiment - * Determine whether your content conveys postive or negative sentiment. Sentiment information can be returned for - * detected entities, keywords, or user-specified target phrases found in the text. - * - * ### Categories - * Categorize your content into a hierarchical 5-level taxonomy. For example, \"Leonardo DiCaprio won an Oscar\" - * returns \"/art and entertainment/movies and tv/movies\" as the most confident classification. - * - * @param analyzeOptions the {@link AnalyzeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AnalysisResults} - */ - public ServiceCall analyze(AnalyzeOptions analyzeOptions) { - Validator.notNull(analyzeOptions, "analyzeOptions cannot be null"); - String[] pathSegments = { "v1/analyze" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - final JsonObject contentJson = new JsonObject(); - if (analyzeOptions.text() != null) { - contentJson.addProperty("text", analyzeOptions.text()); - } - if (analyzeOptions.html() != null) { - contentJson.addProperty("html", analyzeOptions.html()); - } - if (analyzeOptions.url() != null) { - contentJson.addProperty("url", analyzeOptions.url()); - } - contentJson.add("features", GsonSingleton.getGson().toJsonTree(analyzeOptions.features())); - if (analyzeOptions.clean() != null) { - contentJson.addProperty("clean", analyzeOptions.clean()); - } - if (analyzeOptions.xpath() != null) { - contentJson.addProperty("xpath", analyzeOptions.xpath()); - } - if (analyzeOptions.fallbackToRaw() != null) { - contentJson.addProperty("fallback_to_raw", analyzeOptions.fallbackToRaw()); - } - if (analyzeOptions.returnAnalyzedText() != null) { - contentJson.addProperty("return_analyzed_text", analyzeOptions.returnAnalyzedText()); - } - if (analyzeOptions.language() != null) { - contentJson.addProperty("language", analyzeOptions.language()); - } - if (analyzeOptions.limitTextCharacters() != null) { - contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AnalysisResults.class)); - } - - /** - * Delete 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 Void - */ - public ServiceCall deleteModel(DeleteModelOptions deleteModelOptions) { - Validator.notNull(deleteModelOptions, "deleteModelOptions cannot be null"); - String[] pathSegments = { "v1/models" }; - String[] pathParameters = { deleteModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * List models. - * - * Lists available models for Relations and Entities features, including Watson Knowledge Studio custom models that - * you have created and linked 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} - */ - public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = { "v1/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listModelsOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ListModelsResults.class)); - } - - /** - * List models. - * - * Lists available models for Relations and Entities features, including Watson Knowledge Studio custom models that - * you have created and linked to your Natural Language Understanding service. - * - * @return a {@link ServiceCall} with a response type of {@link ListModelsResults} - */ - public ServiceCall listModels() { - return listModels(null); - } - -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalysisResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalysisResults.java deleted file mode 100644 index ba8107da522..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalysisResults.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Results of the analysis, organized by feature. - */ -public class AnalysisResults extends GenericModel { - - private String language; - @SerializedName("analyzed_text") - private String analyzedText; - @SerializedName("retrieved_url") - private String retrievedUrl; - private Usage usage; - private List concepts; - private List entities; - private List keywords; - private List categories; - private EmotionResult emotion; - private MetadataResult metadata; - private List relations; - @SerializedName("semantic_roles") - private List semanticRoles; - private SentimentResult sentiment; - - /** - * Gets the language. - * - * Language used to analyze the text. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the analyzedText. - * - * Text that was used in the analysis. - * - * @return the analyzedText - */ - public String getAnalyzedText() { - return analyzedText; - } - - /** - * Gets the retrievedUrl. - * - * URL that was used to retrieve HTML content. - * - * @return the retrievedUrl - */ - public String getRetrievedUrl() { - return retrievedUrl; - } - - /** - * Gets the usage. - * - * API usage information for the request. - * - * @return the usage - */ - public Usage getUsage() { - return usage; - } - - /** - * Gets the concepts. - * - * The general concepts referenced or alluded to in the specified content. - * - * @return the concepts - */ - public List getConcepts() { - return concepts; - } - - /** - * Gets the entities. - * - * The important entities in the specified content. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the keywords. - * - * The important keywords in content organized by relevance. - * - * @return the keywords - */ - public List getKeywords() { - return keywords; - } - - /** - * Gets the categories. - * - * The hierarchical 5-level taxonomy the content is categorized into. - * - * @return the categories - */ - public List getCategories() { - return categories; - } - - /** - * Gets the emotion. - * - * The anger, disgust, fear, joy, or sadness conveyed by the content. - * - * @return the emotion - */ - public EmotionResult getEmotion() { - return emotion; - } - - /** - * Gets the metadata. - * - * The metadata holds author information, publication date and the title of the text/HTML content. - * - * @return the metadata - */ - public MetadataResult getMetadata() { - return metadata; - } - - /** - * Gets the relations. - * - * The relationships between entities in the content. - * - * @return the relations - */ - public List getRelations() { - return relations; - } - - /** - * Gets the semanticRoles. - * - * The subjects of actions and the objects the actions act upon. - * - * @return the semanticRoles - */ - public List getSemanticRoles() { - return semanticRoles; - } - - /** - * Gets the sentiment. - * - * The sentiment of the content. - * - * @return the sentiment - */ - public SentimentResult getSentiment() { - return sentiment; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalyzeOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalyzeOptions.java deleted file mode 100644 index 4dc0c34bac2..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/AnalyzeOptions.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The analyze options. - */ -public class AnalyzeOptions extends GenericModel { - - private String text; - private String html; - private String url; - private Features features; - private Boolean clean; - private String xpath; - private Boolean fallbackToRaw; - private Boolean returnAnalyzedText; - private String language; - private Long limitTextCharacters; - - /** - * Builder. - */ - public static class Builder { - private String text; - private String html; - private String url; - private Features features; - private Boolean clean; - private String xpath; - private Boolean fallbackToRaw; - private Boolean returnAnalyzedText; - private String language; - private Long limitTextCharacters; - - private Builder(AnalyzeOptions analyzeOptions) { - text = analyzeOptions.text; - html = analyzeOptions.html; - url = analyzeOptions.url; - features = analyzeOptions.features; - clean = analyzeOptions.clean; - xpath = analyzeOptions.xpath; - fallbackToRaw = analyzeOptions.fallbackToRaw; - returnAnalyzedText = analyzeOptions.returnAnalyzedText; - language = analyzeOptions.language; - limitTextCharacters = analyzeOptions.limitTextCharacters; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param features the features - */ - public Builder(Features features) { - this.features = features; - } - - /** - * Builds a AnalyzeOptions. - * - * @return the analyzeOptions - */ - public AnalyzeOptions build() { - return new AnalyzeOptions(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the AnalyzeOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the html. - * - * @param html the html - * @return the AnalyzeOptions builder - */ - public Builder html(String html) { - this.html = html; - return this; - } - - /** - * Set the url. - * - * @param url the url - * @return the AnalyzeOptions builder - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Set the features. - * - * @param features the features - * @return the AnalyzeOptions builder - */ - public Builder features(Features features) { - this.features = features; - return this; - } - - /** - * Set the clean. - * - * @param clean the clean - * @return the AnalyzeOptions builder - */ - public Builder clean(Boolean clean) { - this.clean = clean; - return this; - } - - /** - * Set the xpath. - * - * @param xpath the xpath - * @return the AnalyzeOptions builder - */ - public Builder xpath(String xpath) { - this.xpath = xpath; - return this; - } - - /** - * Set the fallbackToRaw. - * - * @param fallbackToRaw the fallbackToRaw - * @return the AnalyzeOptions builder - */ - public Builder fallbackToRaw(Boolean fallbackToRaw) { - this.fallbackToRaw = fallbackToRaw; - return this; - } - - /** - * Set the returnAnalyzedText. - * - * @param returnAnalyzedText the returnAnalyzedText - * @return the AnalyzeOptions builder - */ - public Builder returnAnalyzedText(Boolean returnAnalyzedText) { - this.returnAnalyzedText = returnAnalyzedText; - return this; - } - - /** - * Set the language. - * - * @param language the language - * @return the AnalyzeOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - - /** - * Set the limitTextCharacters. - * - * @param limitTextCharacters the limitTextCharacters - * @return the AnalyzeOptions builder - */ - public Builder limitTextCharacters(long limitTextCharacters) { - this.limitTextCharacters = limitTextCharacters; - return this; - } - } - - private AnalyzeOptions(Builder builder) { - Validator.notNull(builder.features, "features cannot be null"); - text = builder.text; - html = builder.html; - url = builder.url; - features = builder.features; - clean = builder.clean; - xpath = builder.xpath; - fallbackToRaw = builder.fallbackToRaw; - returnAnalyzedText = builder.returnAnalyzedText; - language = builder.language; - limitTextCharacters = builder.limitTextCharacters; - } - - /** - * New builder. - * - * @return a AnalyzeOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The plain text to analyze. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the html. - * - * The HTML file to analyze. - * - * @return the html - */ - public String html() { - return html; - } - - /** - * Gets the url. - * - * The web page to analyze. - * - * @return the url - */ - public String url() { - return url; - } - - /** - * Gets the features. - * - * Specific features to analyze the document for. - * - * @return the features - */ - public Features features() { - return features; - } - - /** - * Gets the clean. - * - * Remove website elements, such as links, ads, etc. - * - * @return the clean - */ - public Boolean clean() { - return clean; - } - - /** - * Gets the xpath. - * - * XPath query for targeting nodes in HTML. - * - * @return the xpath - */ - public String xpath() { - return xpath; - } - - /** - * Gets the fallbackToRaw. - * - * Whether to use raw HTML content if text cleaning fails. - * - * @return the fallbackToRaw - */ - public Boolean fallbackToRaw() { - return fallbackToRaw; - } - - /** - * Gets the returnAnalyzedText. - * - * Whether or not to return the analyzed text. - * - * @return the returnAnalyzedText - */ - public Boolean returnAnalyzedText() { - return returnAnalyzedText; - } - - /** - * Gets the language. - * - * ISO 639-1 code indicating the language to use in the analysis. - * - * @return the language - */ - public String language() { - return language; - } - - /** - * Gets the limitTextCharacters. - * - * Sets the maximum number of characters that are processed by the service. - * - * @return the limitTextCharacters - */ - public Long limitTextCharacters() { - return limitTextCharacters; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Author.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Author.java deleted file mode 100644 index dc369663222..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Author.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The author of the analyzed content. - */ -public class Author extends GenericModel { - - private String name; - - /** - * Gets the name. - * - * Name of the author. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesOptions.java deleted file mode 100644 index a4176bad7ba..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.DynamicModel; - -/** - * The hierarchical 5-level taxonomy the content is categorized into. - */ -public class CategoriesOptions extends DynamicModel { - -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesResult.java deleted file mode 100644 index a43b97d6eed..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/CategoriesResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The hierarchical 5-level taxonomy the content is categorized into. - */ -public class CategoriesResult extends GenericModel { - - private String label; - private Double score; - - /** - * Gets the label. - * - * The path to the category through the taxonomy hierarchy. - * - * @return the label - */ - public String getLabel() { - return label; - } - - /** - * Gets the score. - * - * Confidence score for the category classification. Higher values indicate greater confidence. - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsOptions.java deleted file mode 100644 index 2b00b964a74..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Whether or not to analyze content for general concepts that are referenced or alluded to. - */ -public class ConceptsOptions extends GenericModel { - - private Long limit; - - /** - * Builder. - */ - public static class Builder { - private Long limit; - - private Builder(ConceptsOptions conceptsOptions) { - limit = conceptsOptions.limit; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ConceptsOptions. - * - * @return the conceptsOptions - */ - public ConceptsOptions build() { - return new ConceptsOptions(this); - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the ConceptsOptions builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - } - - private ConceptsOptions(Builder builder) { - limit = builder.limit; - } - - /** - * New builder. - * - * @return a ConceptsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the limit. - * - * Maximum number of concepts to return. - * - * @return the limit - */ - public Long limit() { - return limit; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsResult.java deleted file mode 100644 index 431ca7d5911..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ConceptsResult.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The general concepts referenced or alluded to in the specified content. - */ -public class ConceptsResult extends GenericModel { - - private String text; - private Double relevance; - @SerializedName("dbpedia_resource") - private String dbpediaResource; - - /** - * Gets the text. - * - * Name of the concept. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the relevance. - * - * Relevance score between 0 and 1. Higher scores indicate greater relevance. - * - * @return the relevance - */ - public Double getRelevance() { - return relevance; - } - - /** - * Gets the dbpediaResource. - * - * Link to the corresponding DBpedia resource. - * - * @return the dbpediaResource - */ - public String getDbpediaResource() { - return dbpediaResource; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DeleteModelOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DeleteModelOptions.java deleted file mode 100644 index 45d2ffa1ef8..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DeleteModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteModel options. - */ -public class DeleteModelOptions extends GenericModel { - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(DeleteModelOptions deleteModelOptions) { - 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; - } - } - - private DeleteModelOptions(Builder builder) { - 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/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java deleted file mode 100644 index 6f46da17faf..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DisambiguationResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Disambiguation information for the entity. - */ -public class DisambiguationResult extends GenericModel { - - private String name; - @SerializedName("dbpedia_resource") - private String dbpediaResource; - private List subtype; - - /** - * Gets the name. - * - * Common entity name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the dbpediaResource. - * - * Link to the corresponding DBpedia resource. - * - * @return the dbpediaResource - */ - public String getDbpediaResource() { - return dbpediaResource; - } - - /** - * Gets the subtype. - * - * Entity subtype information. - * - * @return the subtype - */ - public List getSubtype() { - return subtype; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentEmotionResults.java deleted file mode 100644 index 8ef7fcbe43d..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentEmotionResults.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object containing the emotion results of a document. - */ -public class DocumentEmotionResults extends GenericModel { - - private EmotionScores emotion; - - /** - * Gets the emotion. - * - * An object containing the emotion results for the document. - * - * @return the emotion - */ - public EmotionScores getEmotion() { - return emotion; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentSentimentResults.java deleted file mode 100644 index 836d79b6745..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/DocumentSentimentResults.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DocumentSentimentResults. - */ -public class DocumentSentimentResults extends GenericModel { - - private String label; - private Double score; - - /** - * Gets the label. - * - * Indicates whether the sentiment is positive, neutral, or negative. - * - * @return the label - */ - public String getLabel() { - return label; - } - - /** - * Gets the score. - * - * Sentiment score from -1 (negative) to 1 (positive). - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionOptions.java deleted file mode 100644 index 4928d218a9b..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionOptions.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * Whether or not to return emotion analysis of the content. - */ -public class EmotionOptions extends GenericModel { - - private Boolean document; - private List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(EmotionOptions emotionOptions) { - document = emotionOptions.document; - targets = emotionOptions.targets; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a EmotionOptions. - * - * @return the emotionOptions - */ - public EmotionOptions build() { - return new EmotionOptions(this); - } - - /** - * Adds an targets to targets. - * - * @param targets the new targets - * @return the EmotionOptions builder - */ - public Builder addTargets(String targets) { - Validator.notNull(targets, "targets cannot be null"); - if (this.targets == null) { - this.targets = new ArrayList(); - } - this.targets.add(targets); - return this; - } - - /** - * Set the document. - * - * @param document the document - * @return the EmotionOptions 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 EmotionOptions builder - */ - public Builder targets(List targets) { - this.targets = targets; - return this; - } - } - - private EmotionOptions(Builder builder) { - document = builder.document; - targets = builder.targets; - } - - /** - * New builder. - * - * @return a EmotionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the document. - * - * Set this to false to hide document-level emotion results. - * - * @return the document - */ - public Boolean document() { - return document; - } - - /** - * Gets the targets. - * - * Emotion results will be returned for each target string that is found in the document. - * - * @return the targets - */ - public List targets() { - return targets; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionResult.java deleted file mode 100644 index a973e28328a..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionResult.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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 { - - private DocumentEmotionResults document; - private List targets; - - /** - * Gets the document. - * - * The returned emotion results across the document. - * - * @return the document - */ - public DocumentEmotionResults getDocument() { - return document; - } - - /** - * Gets the targets. - * - * The returned emotion results per specified target. - * - * @return the targets - */ - public List getTargets() { - return targets; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionScores.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionScores.java deleted file mode 100644 index 15bbf7c1d68..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EmotionScores.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * EmotionScores. - */ -public class EmotionScores extends GenericModel { - - private Double anger; - private Double disgust; - private Double fear; - private Double joy; - private Double sadness; - - /** - * Gets the anger. - * - * Anger score from 0 to 1. A higher score means that the text is more likely to convey anger. - * - * @return the anger - */ - public Double getAnger() { - return anger; - } - - /** - * Gets the disgust. - * - * Disgust score from 0 to 1. A higher score means that the text is more likely to convey disgust. - * - * @return the disgust - */ - public Double getDisgust() { - return disgust; - } - - /** - * Gets the fear. - * - * Fear score from 0 to 1. A higher score means that the text is more likely to convey fear. - * - * @return the fear - */ - public Double getFear() { - return fear; - } - - /** - * Gets the joy. - * - * Joy score from 0 to 1. A higher score means that the text is more likely to convey joy. - * - * @return the joy - */ - public Double getJoy() { - return joy; - } - - /** - * Gets the sadness. - * - * Sadness score from 0 to 1. A higher score means that the text is more likely to convey sadness. - * - * @return the sadness - */ - public Double getSadness() { - return sadness; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesOptions.java deleted file mode 100644 index b68ed6cd8e6..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesOptions.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Whether or not to return important people, places, geopolitical, and other entities detected in the analyzed content. - */ -public class EntitiesOptions extends GenericModel { - - private Long limit; - private Boolean mentions; - private String model; - private Boolean sentiment; - private Boolean emotion; - - /** - * Builder. - */ - public static class Builder { - private Long limit; - private Boolean mentions; - private String model; - private Boolean sentiment; - private Boolean emotion; - - private Builder(EntitiesOptions entitiesOptions) { - limit = entitiesOptions.limit; - mentions = entitiesOptions.mentions; - model = entitiesOptions.model; - sentiment = entitiesOptions.sentiment; - emotion = entitiesOptions.emotion; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a EntitiesOptions. - * - * @return the entitiesOptions - */ - public EntitiesOptions build() { - return new EntitiesOptions(this); - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the EntitiesOptions builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - - /** - * Set the mentions. - * - * @param mentions the mentions - * @return the EntitiesOptions builder - */ - public Builder mentions(Boolean mentions) { - this.mentions = mentions; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the EntitiesOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the EntitiesOptions builder - */ - public Builder sentiment(Boolean sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the EntitiesOptions builder - */ - public Builder emotion(Boolean emotion) { - this.emotion = emotion; - return this; - } - } - - private EntitiesOptions(Builder builder) { - limit = builder.limit; - mentions = builder.mentions; - model = builder.model; - sentiment = builder.sentiment; - emotion = builder.emotion; - } - - /** - * New builder. - * - * @return a EntitiesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the limit. - * - * Maximum number of entities to return. - * - * @return the limit - */ - public Long limit() { - return limit; - } - - /** - * Gets the mentions. - * - * Set this to true to return locations of entity mentions. - * - * @return the mentions - */ - public Boolean mentions() { - return mentions; - } - - /** - * Gets the model. - * - * Enter a custom model ID to override the standard entity detection model. - * - * @return the model - */ - public String model() { - return model; - } - - /** - * Gets the sentiment. - * - * Set this to true to return sentiment information for detected entities. - * - * @return the sentiment - */ - public Boolean sentiment() { - return sentiment; - } - - /** - * Gets the emotion. - * - * Set this to true to analyze emotion for detected keywords. - * - * @return the emotion - */ - public Boolean emotion() { - return emotion; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java deleted file mode 100644 index eacd933f5af..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntitiesResult.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The important people, places, geopolitical entities and other types of entities in your content. - */ -public class EntitiesResult extends GenericModel { - - private String type; - private String text; - private Double relevance; - private List mentions; - private Long count; - private EmotionScores emotion; - private FeatureSentimentResults sentiment; - private DisambiguationResult disambiguation; - - /** - * Gets the type. - * - * Entity type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the text. - * - * The name of the entity. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the relevance. - * - * Relevance score from 0 to 1. Higher values indicate greater relevance. - * - * @return the relevance - */ - public Double getRelevance() { - return relevance; - } - - /** - * Gets the mentions. - * - * Entity mentions and locations. - * - * @return the mentions - */ - public List getMentions() { - return mentions; - } - - /** - * Gets the count. - * - * How many times the entity was mentioned in the text. - * - * @return the count - */ - public Long getCount() { - return count; - } - - /** - * Gets the emotion. - * - * Emotion analysis results for the entity, enabled with the "emotion" option. - * - * @return the emotion - */ - public EmotionScores getEmotion() { - return emotion; - } - - /** - * Gets the sentiment. - * - * Sentiment analysis results for the entity, enabled with the "sentiment" option. - * - * @return the sentiment - */ - public FeatureSentimentResults getSentiment() { - return sentiment; - } - - /** - * Gets the disambiguation. - * - * Disambiguation information for the entity. - * - * @return the disambiguation - */ - public DisambiguationResult getDisambiguation() { - return disambiguation; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntityMention.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntityMention.java deleted file mode 100644 index 8b14ff34cbf..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/EntityMention.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * EntityMention. - */ -public class EntityMention extends GenericModel { - - private String text; - private List location; - - /** - * Gets the text. - * - * Entity mention text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the location. - * - * Character offsets indicating the beginning and end of the mention in the analyzed text. - * - * @return the location - */ - public List getLocation() { - return location; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/FeatureSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/FeatureSentimentResults.java deleted file mode 100644 index a7b42a00080..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/FeatureSentimentResults.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * FeatureSentimentResults. - */ -public class FeatureSentimentResults extends GenericModel { - - private Double score; - - /** - * Gets the score. - * - * Sentiment score from -1 (negative) to 1 (positive). - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Features.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Features.java deleted file mode 100644 index 4eec59903df..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Features.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Analysis features and options. - */ -public class Features extends GenericModel { - - private ConceptsOptions concepts; - private EmotionOptions emotion; - private EntitiesOptions entities; - private KeywordsOptions keywords; - private MetadataOptions metadata; - private RelationsOptions relations; - @SerializedName("semantic_roles") - private SemanticRolesOptions semanticRoles; - private SentimentOptions sentiment; - private CategoriesOptions categories; - - /** - * Builder. - */ - public static class Builder { - private ConceptsOptions concepts; - private EmotionOptions emotion; - private EntitiesOptions entities; - private KeywordsOptions keywords; - private MetadataOptions metadata; - private RelationsOptions relations; - private SemanticRolesOptions semanticRoles; - private SentimentOptions sentiment; - private CategoriesOptions categories; - - private Builder(Features features) { - concepts = features.concepts; - emotion = features.emotion; - entities = features.entities; - keywords = features.keywords; - metadata = features.metadata; - relations = features.relations; - semanticRoles = features.semanticRoles; - sentiment = features.sentiment; - categories = features.categories; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a Features. - * - * @return the features - */ - public Features build() { - return new Features(this); - } - - /** - * Set the concepts. - * - * @param concepts the concepts - * @return the Features builder - */ - public Builder concepts(ConceptsOptions concepts) { - this.concepts = concepts; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the Features builder - */ - public Builder emotion(EmotionOptions emotion) { - this.emotion = emotion; - return this; - } - - /** - * Set the entities. - * - * @param entities the entities - * @return the Features builder - */ - public Builder entities(EntitiesOptions entities) { - this.entities = entities; - return this; - } - - /** - * Set the keywords. - * - * @param keywords the keywords - * @return the Features builder - */ - public Builder keywords(KeywordsOptions keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the metadata. - * - * @param metadata the metadata - * @return the Features builder - */ - public Builder metadata(MetadataOptions metadata) { - this.metadata = metadata; - return this; - } - - /** - * Set the relations. - * - * @param relations the relations - * @return the Features builder - */ - public Builder relations(RelationsOptions relations) { - this.relations = relations; - return this; - } - - /** - * Set the semanticRoles. - * - * @param semanticRoles the semanticRoles - * @return the Features builder - */ - public Builder semanticRoles(SemanticRolesOptions semanticRoles) { - this.semanticRoles = semanticRoles; - return this; - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the Features builder - */ - public Builder sentiment(SentimentOptions sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the categories. - * - * @param categories the categories - * @return the Features builder - */ - public Builder categories(CategoriesOptions categories) { - this.categories = categories; - return this; - } - } - - private Features(Builder builder) { - concepts = builder.concepts; - emotion = builder.emotion; - entities = builder.entities; - keywords = builder.keywords; - metadata = builder.metadata; - relations = builder.relations; - semanticRoles = builder.semanticRoles; - sentiment = builder.sentiment; - categories = builder.categories; - } - - /** - * New builder. - * - * @return a Features builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the concepts. - * - * Whether or not to return the concepts that are mentioned in the analyzed text. - * - * @return the concepts - */ - public ConceptsOptions concepts() { - return concepts; - } - - /** - * Gets the emotion. - * - * Whether or not to extract the emotions implied in the analyzed text. - * - * @return the emotion - */ - public EmotionOptions emotion() { - return emotion; - } - - /** - * Gets the entities. - * - * Whether or not to extract detected entity objects from the analyzed text. - * - * @return the entities - */ - public EntitiesOptions entities() { - return entities; - } - - /** - * Gets the keywords. - * - * Whether or not to return the keywords in the analyzed text. - * - * @return the keywords - */ - public KeywordsOptions keywords() { - return keywords; - } - - /** - * Gets the metadata. - * - * Whether or not the author, publication date, and title of the analyzed text should be returned. This parameter is - * only available for URL and HTML input. - * - * @return the metadata - */ - public MetadataOptions metadata() { - return metadata; - } - - /** - * Gets the relations. - * - * Whether or not to return the relationships between detected entities in the analyzed text. - * - * @return the relations - */ - public RelationsOptions relations() { - return relations; - } - - /** - * Gets the semanticRoles. - * - * Whether or not to return the subject-action-object relations from the analyzed text. - * - * @return the semanticRoles - */ - public SemanticRolesOptions semanticRoles() { - return semanticRoles; - } - - /** - * Gets the sentiment. - * - * Whether or not to return the overall sentiment of the analyzed text. - * - * @return the sentiment - */ - public SentimentOptions sentiment() { - return sentiment; - } - - /** - * Gets the categories. - * - * Whether or not to return the high level category the content is categorized as (i.e. news, art). - * - * @return the categories - */ - public CategoriesOptions categories() { - return categories; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Feed.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Feed.java deleted file mode 100644 index b2523fc83c9..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Feed.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * RSS or ATOM feed found on the webpage. - */ -public class Feed extends GenericModel { - - private String link; - - /** - * Gets the link. - * - * URL of the RSS or ATOM feed. - * - * @return the link - */ - public String getLink() { - return link; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsOptions.java deleted file mode 100644 index 85a73256a7c..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsOptions.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An option indicating whether or not important keywords from the analyzed content should be returned. - */ -public class KeywordsOptions extends GenericModel { - - private Long limit; - private Boolean sentiment; - private Boolean emotion; - - /** - * Builder. - */ - public static class Builder { - private Long limit; - private Boolean sentiment; - private Boolean emotion; - - private Builder(KeywordsOptions keywordsOptions) { - limit = keywordsOptions.limit; - sentiment = keywordsOptions.sentiment; - emotion = keywordsOptions.emotion; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a KeywordsOptions. - * - * @return the keywordsOptions - */ - public KeywordsOptions build() { - return new KeywordsOptions(this); - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the KeywordsOptions builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - - /** - * Set the sentiment. - * - * @param sentiment the sentiment - * @return the KeywordsOptions builder - */ - public Builder sentiment(Boolean sentiment) { - this.sentiment = sentiment; - return this; - } - - /** - * Set the emotion. - * - * @param emotion the emotion - * @return the KeywordsOptions builder - */ - public Builder emotion(Boolean emotion) { - this.emotion = emotion; - return this; - } - } - - private KeywordsOptions(Builder builder) { - limit = builder.limit; - sentiment = builder.sentiment; - emotion = builder.emotion; - } - - /** - * New builder. - * - * @return a KeywordsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the limit. - * - * Maximum number of keywords to return. - * - * @return the limit - */ - public Long limit() { - return limit; - } - - /** - * Gets the sentiment. - * - * Set this to true to return sentiment information for detected keywords. - * - * @return the sentiment - */ - public Boolean sentiment() { - return sentiment; - } - - /** - * Gets the emotion. - * - * Set this to true to analyze emotion for detected keywords. - * - * @return the emotion - */ - public Boolean emotion() { - return emotion; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsResult.java deleted file mode 100644 index 53ab4154362..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/KeywordsResult.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The most important keywords in the content, organized by relevance. - */ -public class KeywordsResult extends GenericModel { - - private Double relevance; - private String text; - private EmotionScores emotion; - private FeatureSentimentResults sentiment; - - /** - * Gets the relevance. - * - * Relevance score from 0 to 1. Higher values indicate greater relevance. - * - * @return the relevance - */ - public Double getRelevance() { - return relevance; - } - - /** - * Gets the text. - * - * The keyword text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the emotion. - * - * Emotion analysis results for the keyword, enabled with the "emotion" option. - * - * @return the emotion - */ - public EmotionScores getEmotion() { - return emotion; - } - - /** - * Gets the sentiment. - * - * Sentiment analysis results for the keyword, enabled with the "sentiment" option. - * - * @return the sentiment - */ - public FeatureSentimentResults getSentiment() { - return sentiment; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsOptions.java deleted file mode 100644 index a37a91c29ec..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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); - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsResults.java deleted file mode 100644 index 6f3abca74de..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/ListModelsResults.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Models available for Relations and Entities features. - */ -public class ListModelsResults extends GenericModel { - - private List models; - - /** - * Gets the models. - * - * @return the models - */ - public List getModels() { - return models; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataOptions.java deleted file mode 100644 index b3ed1db062e..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataOptions.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.DynamicModel; - -/** - * The Authors, Publication Date, and Title of the document. Supports URL and HTML input types. - */ -public class MetadataOptions extends DynamicModel { - -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataResult.java deleted file mode 100644 index 07133a19c6e..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/MetadataResult.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The Authors, Publication Date, and Title of the document. Supports URL and HTML input types. - */ -public class MetadataResult extends GenericModel { - - private List authors; - @SerializedName("publication_date") - private String publicationDate; - private String title; - private String image; - private 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/developer_cloud/natural_language_understanding/v1/model/Model.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Model.java deleted file mode 100644 index 4742ed00a68..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Model.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Model. - */ -public class Model extends GenericModel { - - private String status; - @SerializedName("model_id") - private String modelId; - private String language; - private String description; - - /** - * Gets the status. - * - * Shows as available if the model is ready for 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 language. - * - * ISO 639-1 code indicating the language of the model. - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the description. - * - * Model description. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationArgument.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationArgument.java deleted file mode 100644 index e42e56163e3..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationArgument.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * RelationArgument. - */ -public class RelationArgument extends GenericModel { - - private List entities; - private List location; - private String text; - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the location. - * - * Character offsets indicating the beginning and end of the mention in the analyzed text. - * - * @return the location - */ - public List getLocation() { - return location; - } - - /** - * Gets the text. - * - * Text that corresponds to the argument. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationEntity.java deleted file mode 100644 index b3b8566b496..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An entity that corresponds with an argument in a relation. - */ -public class RelationEntity extends GenericModel { - - private String text; - private String type; - - /** - * Gets the text. - * - * Text that corresponds to the entity. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the type. - * - * Entity type. - * - * @return the type - */ - public String getType() { - return type; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsOptions.java deleted file mode 100644 index 7d184a4c213..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An option specifying if the relationships found between entities in the analyzed content should be returned. - */ -public class RelationsOptions extends GenericModel { - - private String model; - - /** - * Builder. - */ - public static class Builder { - private String model; - - private Builder(RelationsOptions relationsOptions) { - model = relationsOptions.model; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a RelationsOptions. - * - * @return the relationsOptions - */ - public RelationsOptions build() { - return new RelationsOptions(this); - } - - /** - * Set the model. - * - * @param model the model - * @return the RelationsOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - } - - private RelationsOptions(Builder builder) { - model = builder.model; - } - - /** - * New builder. - * - * @return a RelationsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the model. - * - * Enter a custom model ID to override the default model. - * - * @return the model - */ - public String model() { - return model; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsResult.java deleted file mode 100644 index 3b2ec679bb7..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/RelationsResult.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The relations between entities found in the content. - */ -public class RelationsResult extends GenericModel { - - private Double score; - private String sentence; - private String type; - private List arguments; - - /** - * Gets the score. - * - * Confidence score for the relation. Higher values indicate greater confidence. - * - * @return the score - */ - public Double getScore() { - return score; - } - - /** - * Gets the sentence. - * - * The sentence that contains the relation. - * - * @return the sentence - */ - public String getSentence() { - return sentence; - } - - /** - * Gets the type. - * - * The type of the relation. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the arguments. - * - * The extracted relation objects from the text. - * - * @return the arguments - */ - public List getArguments() { - return arguments; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesAction.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesAction.java deleted file mode 100644 index 152583a2290..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesAction. - */ -public class SemanticRolesAction extends GenericModel { - - private String text; - private String normalized; - private SemanticRolesVerb verb; - - /** - * Gets the text. - * - * Analyzed text that corresponds to the action. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the normalized. - * - * normalized version of the action. - * - * @return the normalized - */ - public String getNormalized() { - return normalized; - } - - /** - * Gets the verb. - * - * @return the verb - */ - public SemanticRolesVerb getVerb() { - return verb; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesEntity.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesEntity.java deleted file mode 100644 index df0812ed6e9..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesEntity.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesEntity. - */ -public class SemanticRolesEntity extends GenericModel { - - private String type; - private String text; - - /** - * Gets the type. - * - * Entity type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the text. - * - * The entity text. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesKeyword.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesKeyword.java deleted file mode 100644 index 8fd210625c8..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesKeyword.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesKeyword. - */ -public class SemanticRolesKeyword extends GenericModel { - - private String text; - - /** - * Gets the text. - * - * The keyword text. - * - * @return the text - */ - public String getText() { - return text; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesObject.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesObject.java deleted file mode 100644 index 0b7bfa1d8eb..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesObject.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesObject. - */ -public class SemanticRolesObject extends GenericModel { - - private String text; - private List keywords; - - /** - * Gets the text. - * - * Object text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the keywords. - * - * @return the keywords - */ - public List getKeywords() { - return keywords; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesOptions.java deleted file mode 100644 index bec9515b745..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesOptions.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An option specifying whether or not to identify the subjects, actions, and verbs in the analyzed content. - */ -public class SemanticRolesOptions extends GenericModel { - - private Long limit; - private Boolean keywords; - private Boolean entities; - - /** - * Builder. - */ - public static class Builder { - private Long limit; - private Boolean keywords; - private Boolean entities; - - private Builder(SemanticRolesOptions semanticRolesOptions) { - limit = semanticRolesOptions.limit; - keywords = semanticRolesOptions.keywords; - entities = semanticRolesOptions.entities; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a SemanticRolesOptions. - * - * @return the semanticRolesOptions - */ - public SemanticRolesOptions build() { - return new SemanticRolesOptions(this); - } - - /** - * Set the limit. - * - * @param limit the limit - * @return the SemanticRolesOptions builder - */ - public Builder limit(long limit) { - this.limit = limit; - return this; - } - - /** - * Set the keywords. - * - * @param keywords the keywords - * @return the SemanticRolesOptions builder - */ - public Builder keywords(Boolean keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the entities. - * - * @param entities the entities - * @return the SemanticRolesOptions builder - */ - public Builder entities(Boolean entities) { - this.entities = entities; - return this; - } - } - - private SemanticRolesOptions(Builder builder) { - limit = builder.limit; - keywords = builder.keywords; - entities = builder.entities; - } - - /** - * New builder. - * - * @return a SemanticRolesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the limit. - * - * Maximum number of semantic_roles results to return. - * - * @return the limit - */ - public Long limit() { - return limit; - } - - /** - * Gets the keywords. - * - * Set this to true to return keyword information for subjects and objects. - * - * @return the keywords - */ - public Boolean keywords() { - return keywords; - } - - /** - * Gets the entities. - * - * Set this to true to return entity information for subjects and objects. - * - * @return the entities - */ - public Boolean entities() { - return entities; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesResult.java deleted file mode 100644 index 9334fbdbbaf..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesResult.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The object containing the actions and the objects the actions act upon. - */ -public class SemanticRolesResult extends GenericModel { - - private String sentence; - private SemanticRolesSubject subject; - private SemanticRolesAction action; - private SemanticRolesObject object; - - /** - * Gets the sentence. - * - * Sentence from the source that contains the subject, action, and object. - * - * @return the sentence - */ - public String getSentence() { - return sentence; - } - - /** - * Gets the subject. - * - * The extracted subject from the sentence. - * - * @return the subject - */ - public SemanticRolesSubject getSubject() { - return subject; - } - - /** - * Gets the action. - * - * The extracted action from the sentence. - * - * @return the action - */ - public SemanticRolesAction getAction() { - return action; - } - - /** - * Gets the object. - * - * The extracted object from the sentence. - * - * @return the object - */ - public SemanticRolesObject getObject() { - return object; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesSubject.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesSubject.java deleted file mode 100644 index 6a254caf314..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesSubject.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesSubject. - */ -public class SemanticRolesSubject extends GenericModel { - - private String text; - private List entities; - private List keywords; - - /** - * Gets the text. - * - * Text that corresponds to the subject role. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the entities. - * - * @return the entities - */ - public List getEntities() { - return entities; - } - - /** - * Gets the keywords. - * - * @return the keywords - */ - public List getKeywords() { - return keywords; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesVerb.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesVerb.java deleted file mode 100644 index 53d82fa4ee9..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SemanticRolesVerb.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SemanticRolesVerb. - */ -public class SemanticRolesVerb extends GenericModel { - - private String text; - private String tense; - - /** - * Gets the text. - * - * The keyword text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the tense. - * - * Verb tense. - * - * @return the tense - */ - public String getTense() { - return tense; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentOptions.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentOptions.java deleted file mode 100644 index 1faa018a4e7..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentOptions.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * An option specifying if sentiment of detected entities, keywords, or phrases should be returned. - */ -public class SentimentOptions extends GenericModel { - - private Boolean document; - private List targets; - - /** - * Builder. - */ - public static class Builder { - private Boolean document; - private List targets; - - private Builder(SentimentOptions sentimentOptions) { - document = sentimentOptions.document; - targets = sentimentOptions.targets; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a SentimentOptions. - * - * @return the sentimentOptions - */ - public SentimentOptions build() { - return new SentimentOptions(this); - } - - /** - * Adds an targets to targets. - * - * @param targets the new targets - * @return the SentimentOptions builder - */ - public Builder addTargets(String targets) { - Validator.notNull(targets, "targets cannot be null"); - if (this.targets == null) { - this.targets = new ArrayList(); - } - this.targets.add(targets); - return this; - } - - /** - * Set the document. - * - * @param document the document - * @return the SentimentOptions 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 SentimentOptions builder - */ - public Builder targets(List targets) { - this.targets = targets; - return this; - } - } - - private SentimentOptions(Builder builder) { - document = builder.document; - targets = builder.targets; - } - - /** - * New builder. - * - * @return a SentimentOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the document. - * - * Set this to false to hide document-level sentiment results. - * - * @return the document - */ - public Boolean document() { - return document; - } - - /** - * Gets the targets. - * - * Sentiment results will be returned for each target string that is found in the document. - * - * @return the targets - */ - public List targets() { - return targets; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentResult.java deleted file mode 100644 index b7181d314df..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/SentimentResult.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The sentiment of the content. - */ -public class SentimentResult extends GenericModel { - - private DocumentSentimentResults document; - private List targets; - - /** - * Gets the document. - * - * The document level sentiment. - * - * @return the document - */ - public DocumentSentimentResults getDocument() { - return document; - } - - /** - * Gets the targets. - * - * The targeted sentiment to analyze. - * - * @return the targets - */ - public List getTargets() { - return targets; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedEmotionResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedEmotionResults.java deleted file mode 100644 index dff50bf73f3..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedEmotionResults.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * An object containing the emotion results for the target. - */ -public class TargetedEmotionResults extends GenericModel { - - private String text; - private EmotionScores emotion; - - /** - * Gets the text. - * - * Targeted text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the emotion. - * - * An object containing the emotion results for the target. - * - * @return the emotion - */ - public EmotionScores getEmotion() { - return emotion; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedSentimentResults.java deleted file mode 100644 index 2466abcfde0..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/TargetedSentimentResults.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * TargetedSentimentResults. - */ -public class TargetedSentimentResults extends GenericModel { - - private String text; - private Double score; - - /** - * Gets the text. - * - * Targeted text. - * - * @return the text - */ - public String getText() { - return text; - } - - /** - * Gets the score. - * - * Sentiment score from -1 (negative) to 1 (positive). - * - * @return the score - */ - public Double getScore() { - return score; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Usage.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Usage.java deleted file mode 100644 index 6fb2bfb7955..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/model/Usage.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Usage information. - */ -public class Usage extends GenericModel { - - private Long features; - @SerializedName("text_characters") - private Long textCharacters; - @SerializedName("text_units") - private Long textUnits; - - /** - * Gets the features. - * - * Number of features used in the API call. - * - * @return the features - */ - public Long getFeatures() { - return features; - } - - /** - * Gets the textCharacters. - * - * Number of text characters processed. - * - * @return the textCharacters - */ - public Long getTextCharacters() { - return textCharacters; - } - - /** - * Gets the textUnits. - * - * Number of 10,000-character units processed. - * - * @return the textUnits - */ - public Long getTextUnits() { - return textUnits; - } -} diff --git a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/package-info.java b/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/package-info.java deleted file mode 100644 index 2fa1e751efb..00000000000 --- a/natural-language-understanding/src/main/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1; 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 new file mode 100644 index 00000000000..7db48403f4d --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstanding.java @@ -0,0 +1,757 @@ +/* + * (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. + */ + +/* + * 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; +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_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. + * + *

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. + * + *

API Version: 1.0 See: https://cloud.ibm.com/docs/natural-language-understanding + */ +public class NaturalLanguageUnderstanding extends BaseService { + + /** Default service name used when configuring the `NaturalLanguageUnderstanding` client. */ + public static final String DEFAULT_SERVICE_NAME = "natural-language-understanding"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com"; + + private String version; + + /** + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * is used to configure the client instance. + * + * @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 version) { + this( + version, + DEFAULT_SERVICE_NAME, + ConfigBasedAuthenticatorFactory.getAuthenticator(DEFAULT_SERVICE_NAME)); + } + + /** + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The default service name + * and specified authenticator are used to configure the client instance. + * + * @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 version, Authenticator authenticator) { + this(version, DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * is used to configure the client instance. + * + * @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 version, String serviceName) { + this(version, serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `NaturalLanguageUnderstanding` client. The specified service name + * and authenticator are used to configure the client instance. + * + * @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 version, String serviceName, Authenticator authenticator) { + super(serviceName, authenticator); + setServiceUrl(DEFAULT_SERVICE_URL); + 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 - + * 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 result of type {@link AnalysisResults} + */ + public ServiceCall analyze(AnalyzeOptions analyzeOptions) { + 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())); + if (analyzeOptions.text() != null) { + contentJson.addProperty("text", analyzeOptions.text()); + } + if (analyzeOptions.html() != null) { + contentJson.addProperty("html", analyzeOptions.html()); + } + if (analyzeOptions.url() != null) { + contentJson.addProperty("url", analyzeOptions.url()); + } + if (analyzeOptions.clean() != null) { + contentJson.addProperty("clean", analyzeOptions.clean()); + } + if (analyzeOptions.xpath() != null) { + contentJson.addProperty("xpath", analyzeOptions.xpath()); + } + if (analyzeOptions.fallbackToRaw() != null) { + contentJson.addProperty("fallback_to_raw", analyzeOptions.fallbackToRaw()); + } + if (analyzeOptions.returnAnalyzedText() != null) { + contentJson.addProperty("return_analyzed_text", analyzeOptions.returnAnalyzedText()); + } + if (analyzeOptions.language() != null) { + contentJson.addProperty("language", analyzeOptions.language()); + } + if (analyzeOptions.limitTextCharacters() != null) { + contentJson.addProperty("limit_text_characters", analyzeOptions.limitTextCharacters()); + } + builder.bodyJson(contentJson); + 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 + * 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 result of type {@link ListModelsResults} + */ + public ServiceCall listModels(ListModelsOptions listModelsOptions) { + 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"); + 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 + * 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 result of type {@link ListModelsResults} + */ + public ServiceCall listModels() { + return listModels(null); + } + + /** + * Delete model. + * + *

Deletes a custom model. + * + * @param deleteModelOptions the {@link DeleteModelOptions} containing the options for the call + * @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"); + 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); + } + + /** + * 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 new file mode 100644 index 00000000000..5a2f96a124b --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResults.java @@ -0,0 +1,212 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** 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 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. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the analyzedText. + * + *

Text that was used in the analysis. + * + * @return the analyzedText + */ + public String getAnalyzedText() { + return analyzedText; + } + + /** + * Gets the retrievedUrl. + * + *

URL of the webpage that was analyzed. + * + * @return the retrievedUrl + */ + public String getRetrievedUrl() { + return retrievedUrl; + } + + /** + * Gets the usage. + * + *

API usage information for the request. + * + * @return the usage + */ + public AnalysisResultsUsage getUsage() { + return usage; + } + + /** + * Gets the concepts. + * + *

The general concepts referenced or alluded to in the analyzed text. + * + * @return the concepts + */ + public List getConcepts() { + return concepts; + } + + /** + * Gets the entities. + * + *

The entities detected in the analyzed text. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the keywords. + * + *

The keywords from the analyzed text. + * + * @return the keywords + */ + public List getKeywords() { + return keywords; + } + + /** + * Gets the categories. + * + *

The categories that the service assigned to the analyzed text. + * + * @return the categories + */ + 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. + * + * @return the emotion + */ + public EmotionResult getEmotion() { + return emotion; + } + + /** + * Gets the metadata. + * + *

Webpage metadata, such as the author and the title of the page. + * + * @return the metadata + */ + public FeaturesResultsMetadata getMetadata() { + return metadata; + } + + /** + * Gets the relations. + * + *

The relationships between entities in the content. + * + * @return the relations + */ + public List getRelations() { + return relations; + } + + /** + * Gets the semanticRoles. + * + *

Sentences parsed into `subject`, `action`, and `object` form. + * + * @return the semanticRoles + */ + public List getSemanticRoles() { + return semanticRoles; + } + + /** + * Gets the sentiment. + * + *

The sentiment of the content. + * + * @return the sentiment + */ + public SentimentResult getSentiment() { + return sentiment; + } + + /** + * Gets the syntax. + * + *

Tokens and sentences returned from syntax analysis. + * + * @return the syntax + */ + public SyntaxResult getSyntax() { + return syntax; + } +} 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 new file mode 100644 index 00000000000..6914af72970 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalysisResultsUsage.java @@ -0,0 +1,63 @@ +/* + * (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; + +/** 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. + * + * @return the features + */ + public Long getFeatures() { + return features; + } + + /** + * Gets the textCharacters. + * + *

Number of text characters processed. + * + * @return the textCharacters + */ + public Long getTextCharacters() { + return textCharacters; + } + + /** + * Gets the textUnits. + * + *

Number of 10,000-character units processed. + * + * @return the textUnits + */ + public Long getTextUnits() { + return 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 new file mode 100644 index 00000000000..3aca7aa0dea --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/AnalyzeOptions.java @@ -0,0 +1,337 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 analyze options. */ +public class AnalyzeOptions extends GenericModel { + + protected Features features; + protected String text; + protected String html; + protected String url; + protected Boolean clean; + protected String xpath; + protected Boolean fallbackToRaw; + protected Boolean returnAnalyzedText; + protected String language; + protected Long limitTextCharacters; + + /** Builder. */ + public static class Builder { + private Features features; + private String text; + private String html; + private String url; + private Boolean clean; + private String xpath; + private Boolean fallbackToRaw; + private Boolean returnAnalyzedText; + 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; + this.html = analyzeOptions.html; + this.url = analyzeOptions.url; + this.clean = analyzeOptions.clean; + this.xpath = analyzeOptions.xpath; + this.fallbackToRaw = analyzeOptions.fallbackToRaw; + this.returnAnalyzedText = analyzeOptions.returnAnalyzedText; + this.language = analyzeOptions.language; + this.limitTextCharacters = analyzeOptions.limitTextCharacters; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param features the features + */ + public Builder(Features features) { + this.features = features; + } + + /** + * Builds a AnalyzeOptions. + * + * @return the new AnalyzeOptions instance + */ + public AnalyzeOptions build() { + return new AnalyzeOptions(this); + } + + /** + * Set the features. + * + * @param features the features + * @return the AnalyzeOptions builder + */ + public Builder features(Features features) { + this.features = features; + return this; + } + + /** + * Set the text. + * + * @param text the text + * @return the AnalyzeOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the html. + * + * @param html the html + * @return the AnalyzeOptions builder + */ + public Builder html(String html) { + this.html = html; + return this; + } + + /** + * Set the url. + * + * @param url the url + * @return the AnalyzeOptions builder + */ + public Builder url(String url) { + this.url = url; + return this; + } + + /** + * Set the clean. + * + * @param clean the clean + * @return the AnalyzeOptions builder + */ + public Builder clean(Boolean clean) { + this.clean = clean; + return this; + } + + /** + * Set the xpath. + * + * @param xpath the xpath + * @return the AnalyzeOptions builder + */ + public Builder xpath(String xpath) { + this.xpath = xpath; + return this; + } + + /** + * Set the fallbackToRaw. + * + * @param fallbackToRaw the fallbackToRaw + * @return the AnalyzeOptions builder + */ + public Builder fallbackToRaw(Boolean fallbackToRaw) { + this.fallbackToRaw = fallbackToRaw; + return this; + } + + /** + * Set the returnAnalyzedText. + * + * @param returnAnalyzedText the returnAnalyzedText + * @return the AnalyzeOptions builder + */ + public Builder returnAnalyzedText(Boolean returnAnalyzedText) { + this.returnAnalyzedText = returnAnalyzedText; + return this; + } + + /** + * Set the language. + * + * @param language the language + * @return the AnalyzeOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + + /** + * Set the limitTextCharacters. + * + * @param limitTextCharacters the limitTextCharacters + * @return the AnalyzeOptions builder + */ + public Builder limitTextCharacters(long limitTextCharacters) { + this.limitTextCharacters = limitTextCharacters; + return this; + } + } + + protected AnalyzeOptions() {} + + protected AnalyzeOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.features, "features cannot be null"); + features = builder.features; + text = builder.text; + html = builder.html; + url = builder.url; + clean = builder.clean; + xpath = builder.xpath; + fallbackToRaw = builder.fallbackToRaw; + returnAnalyzedText = builder.returnAnalyzedText; + language = builder.language; + limitTextCharacters = builder.limitTextCharacters; + } + + /** + * New builder. + * + * @return a AnalyzeOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the features. + * + *

Specific features to analyze the document for. + * + * @return the features + */ + public Features features() { + return features; + } + + /** + * Gets the text. + * + *

The plain text to analyze. One of the `text`, `html`, or `url` parameters is required. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the html. + * + *

The HTML file to analyze. One of the `text`, `html`, or `url` parameters is required. + * + * @return the html + */ + public String html() { + return html; + } + + /** + * Gets the url. + * + *

The webpage to analyze. One of the `text`, `html`, or `url` parameters is required. + * + * @return the url + */ + public String url() { + return url; + } + + /** + * Gets the clean. + * + *

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 + */ + public Boolean clean() { + return clean; + } + + /** + * Gets the 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`. + * + * @return the xpath + */ + public String xpath() { + return xpath; + } + + /** + * Gets the fallbackToRaw. + * + *

Whether to use raw HTML content if text cleaning fails. + * + * @return the fallbackToRaw + */ + public Boolean fallbackToRaw() { + return fallbackToRaw; + } + + /** + * Gets the returnAnalyzedText. + * + *

Whether or not to return the analyzed text. + * + * @return the returnAnalyzedText + */ + public Boolean returnAnalyzedText() { + return 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. For + * more information, see [Language + * support](https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understanding-language-support). + * + * @return the language + */ + public String language() { + return language; + } + + /** + * Gets the limitTextCharacters. + * + *

Sets the maximum number of characters that are processed by the service. + * + * @return the limitTextCharacters + */ + public Long limitTextCharacters() { + return 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 new file mode 100644 index 00000000000..fe2522fe1a5 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Author.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The author of the analyzed content. */ +public class Author extends GenericModel { + + protected String name; + + protected Author() {} + + /** + * Gets the name. + * + *

Name of the author. + * + * @return the name + */ + public String getName() { + return 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 new file mode 100644 index 00000000000..1712a720993 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesOptions.java @@ -0,0 +1,145 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * 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. + */ +public class CategoriesOptions extends GenericModel { + + protected Boolean explanation; + protected Long limit; + protected String model; + + /** Builder. */ + public static class Builder { + private Boolean explanation; + private Long limit; + 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() {} + + /** + * Builds a CategoriesOptions. + * + * @return the new CategoriesOptions instance + */ + public CategoriesOptions build() { + return new CategoriesOptions(this); + } + + /** + * Set the explanation. + * + * @param explanation the explanation + * @return the CategoriesOptions builder + */ + public Builder explanation(Boolean explanation) { + this.explanation = explanation; + return this; + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the CategoriesOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the CategoriesOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + protected CategoriesOptions() {} + + protected CategoriesOptions(Builder builder) { + explanation = builder.explanation; + limit = builder.limit; + model = builder.model; + } + + /** + * New builder. + * + * @return a CategoriesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the explanation. + * + *

Set this to `true` to return explanations for each categorization. **This is available only + * for English categories.**. + * + * @return the explanation + */ + public Boolean explanation() { + return explanation; + } + + /** + * Gets the limit. + * + *

Maximum number of categories to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the model. + * + *

(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. **This is available only for English + * categories.**. + * + * @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/CategoriesRelevantText.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java new file mode 100644 index 00000000000..aba897fc07a --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesRelevantText.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..f95533fa5b3 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResult.java @@ -0,0 +1,60 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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 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 + */ + public String getLabel() { + return label; + } + + /** + * Gets the score. + * + *

Confidence score for the category classification. Higher values indicate greater confidence. + * + * @return the score + */ + public Double getScore() { + return score; + } + + /** + * Gets the explanation. + * + *

Information that helps to explain what contributed to the categories result. + * + * @return the explanation + */ + public CategoriesResultExplanation getExplanation() { + return 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 new file mode 100644 index 00000000000..089fa972b46 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/CategoriesResultExplanation.java @@ -0,0 +1,39 @@ +/* + * (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; + +/** 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. + * + * @return the relevantText + */ + public List getRelevantText() { + return 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 new file mode 100644 index 00000000000..be8cdcb7225 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsOptions.java @@ -0,0 +1,89 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 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. + */ +public class ConceptsOptions extends GenericModel { + + protected Long limit; + + /** 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() {} + + /** + * Builds a ConceptsOptions. + * + * @return the new ConceptsOptions instance + */ + public ConceptsOptions build() { + return new ConceptsOptions(this); + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the ConceptsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + } + + protected ConceptsOptions() {} + + protected ConceptsOptions(Builder builder) { + limit = builder.limit; + } + + /** + * New builder. + * + * @return a ConceptsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the limit. + * + *

Maximum number of concepts 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/ConceptsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java new file mode 100644 index 00000000000..9d366586b83 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ConceptsResult.java @@ -0,0 +1,61 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the relevance. + * + *

Relevance score between 0 and 1. Higher scores indicate greater relevance. + * + * @return the relevance + */ + public Double getRelevance() { + return relevance; + } + + /** + * Gets the dbpediaResource. + * + *

Link to the corresponding DBpedia resource. + * + * @return the dbpediaResource + */ + public String getDbpediaResource() { + return 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 new file mode 100644 index 00000000000..fb737d5264f --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelOptions.java @@ -0,0 +1,94 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 deleteModel options. */ +public class DeleteModelOptions extends GenericModel { + + protected String modelId; + + /** 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 with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a DeleteModelOptions. + * + * @return the new DeleteModelOptions instance + */ + 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() {} + + 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/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 new file mode 100644 index 00000000000..faaf4959157 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DeleteModelResults.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Delete model results. */ +public class DeleteModelResults extends GenericModel { + + protected String deleted; + + protected DeleteModelResults() {} + + /** + * Gets the deleted. + * + *

model_id of the deleted model. + * + * @return the deleted + */ + public String getDeleted() { + return 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 new file mode 100644 index 00000000000..250d583320d --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DisambiguationResult.java @@ -0,0 +1,63 @@ +/* + * (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; + +/** 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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the dbpediaResource. + * + *

Link to the corresponding DBpedia resource. + * + * @return the dbpediaResource + */ + public String getDbpediaResource() { + return dbpediaResource; + } + + /** + * Gets the subtype. + * + *

Entity subtype information. + * + * @return the subtype + */ + public List getSubtype() { + return 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 new file mode 100644 index 00000000000..ac257609564 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentEmotionResults.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the emotion + */ + public EmotionScores getEmotion() { + return 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 new file mode 100644 index 00000000000..273f8541f9a --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/DocumentSentimentResults.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the label + */ + public String getLabel() { + return label; + } + + /** + * Gets the score. + * + *

Sentiment score from -1 (negative) to 1 (positive). + * + * @return the score + */ + public Double getScore() { + return 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 new file mode 100644 index 00000000000..b407d78062e --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionOptions.java @@ -0,0 +1,133 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.ArrayList; +import java.util.List; + +/** + * 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. + */ +public class EmotionOptions extends GenericModel { + + protected Boolean document; + protected List targets; + + /** 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() {} + + /** + * Builds a EmotionOptions. + * + * @return the new EmotionOptions instance + */ + public EmotionOptions build() { + return new EmotionOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.targets == null) { + this.targets = new ArrayList(); + } + this.targets.add(targets); + return this; + } + + /** + * Set the document. + * + * @param document the document + * @return the EmotionOptions 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 EmotionOptions builder + */ + public Builder targets(List targets) { + this.targets = targets; + return this; + } + } + + protected EmotionOptions() {} + + protected EmotionOptions(Builder builder) { + document = builder.document; + targets = builder.targets; + } + + /** + * New builder. + * + * @return a EmotionOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the document. + * + *

Set this to `false` to hide document-level emotion results. + * + * @return the document + */ + public Boolean document() { + return document; + } + + /** + * Gets the targets. + * + *

Emotion results will be returned for each target string that is found in the document. + * + * @return the targets + */ + public List targets() { + return 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 new file mode 100644 index 00000000000..61801a19037 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionResult.java @@ -0,0 +1,51 @@ +/* + * (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.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. + */ +public class EmotionResult extends GenericModel { + + protected DocumentEmotionResults document; + protected List targets; + + protected EmotionResult() {} + + /** + * Gets the document. + * + *

Emotion results for the document as a whole. + * + * @return the document + */ + public DocumentEmotionResults getDocument() { + return document; + } + + /** + * Gets the targets. + * + *

Emotion results for specified targets. + * + * @return the targets + */ + public List getTargets() { + return 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 new file mode 100644 index 00000000000..69284585b16 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EmotionScores.java @@ -0,0 +1,84 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** EmotionScores. */ +public class EmotionScores extends GenericModel { + + protected Double anger; + protected Double disgust; + protected Double fear; + 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. + * + * @return the anger + */ + public Double getAnger() { + return anger; + } + + /** + * Gets the disgust. + * + *

Disgust score from 0 to 1. A higher score means that the text is more likely to convey + * disgust. + * + * @return the disgust + */ + public Double getDisgust() { + return disgust; + } + + /** + * Gets the fear. + * + *

Fear score from 0 to 1. A higher score means that the text is more likely to convey fear. + * + * @return the fear + */ + public Double getFear() { + return fear; + } + + /** + * Gets the joy. + * + *

Joy score from 0 to 1. A higher score means that the text is more likely to convey joy. + * + * @return the joy + */ + public Double getJoy() { + return joy; + } + + /** + * Gets the sadness. + * + *

Sadness score from 0 to 1. A higher score means that the text is more likely to convey + * sadness. + * + * @return the sadness + */ + public Double getSadness() { + return 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 new file mode 100644 index 00000000000..6e898aa5da6 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesOptions.java @@ -0,0 +1,197 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * 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. + */ +public class EntitiesOptions extends GenericModel { + + protected Long limit; + protected Boolean mentions; + protected String model; + protected Boolean sentiment; + protected Boolean emotion; + + /** Builder. */ + public static class Builder { + private Long limit; + private Boolean mentions; + private String model; + 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; + this.model = entitiesOptions.model; + this.sentiment = entitiesOptions.sentiment; + this.emotion = entitiesOptions.emotion; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a EntitiesOptions. + * + * @return the new EntitiesOptions instance + */ + public EntitiesOptions build() { + return new EntitiesOptions(this); + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the EntitiesOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the mentions. + * + * @param mentions the mentions + * @return the EntitiesOptions builder + */ + public Builder mentions(Boolean mentions) { + this.mentions = mentions; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the EntitiesOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the EntitiesOptions builder + */ + public Builder sentiment(Boolean sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the EntitiesOptions builder + */ + public Builder emotion(Boolean emotion) { + this.emotion = emotion; + return this; + } + } + + protected EntitiesOptions() {} + + protected EntitiesOptions(Builder builder) { + limit = builder.limit; + mentions = builder.mentions; + model = builder.model; + sentiment = builder.sentiment; + emotion = builder.emotion; + } + + /** + * New builder. + * + * @return a EntitiesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the limit. + * + *

Maximum number of entities to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the mentions. + * + *

Set this to `true` to return locations of entity mentions. + * + * @return the mentions + */ + public Boolean mentions() { + return mentions; + } + + /** + * Gets the model. + * + *

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. + * + * @return the model + */ + public String model() { + return model; + } + + /** + * Gets the sentiment. + * + *

Set this to `true` to return sentiment information for detected entities. + * + * @return the sentiment + */ + public Boolean sentiment() { + return sentiment; + } + + /** + * Gets the emotion. + * + *

Set this to `true` to analyze emotion for detected keywords. + * + * @return the emotion + */ + public Boolean emotion() { + return 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 new file mode 100644 index 00000000000..ae4a66a1b96 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntitiesResult.java @@ -0,0 +1,135 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * The important people, places, geopolitical entities and other types of entities in your content. + */ +public class EntitiesResult extends GenericModel { + + protected String type; + protected String text; + protected Double relevance; + protected Double confidence; + protected List mentions; + protected Long count; + protected EmotionScores emotion; + protected FeatureSentimentResults sentiment; + protected DisambiguationResult disambiguation; + + protected EntitiesResult() {} + + /** + * Gets the type. + * + *

Entity type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the text. + * + *

The name of the entity. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the relevance. + * + *

Relevance score from 0 to 1. Higher values indicate greater relevance. + * + * @return the relevance + */ + public Double getRelevance() { + return relevance; + } + + /** + * 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. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } + + /** + * Gets the mentions. + * + *

Entity mentions and locations. + * + * @return the mentions + */ + public List getMentions() { + return mentions; + } + + /** + * Gets the count. + * + *

How many times the entity was mentioned in the text. + * + * @return the count + */ + public Long getCount() { + return count; + } + + /** + * Gets the emotion. + * + *

Emotion analysis results for the entity, enabled with the `emotion` option. + * + * @return the emotion + */ + public EmotionScores getEmotion() { + return emotion; + } + + /** + * Gets the sentiment. + * + *

Sentiment analysis results for the entity, enabled with the `sentiment` option. + * + * @return the sentiment + */ + public FeatureSentimentResults getSentiment() { + return sentiment; + } + + /** + * Gets the disambiguation. + * + *

Disambiguation information for the entity. + * + * @return the disambiguation + */ + public DisambiguationResult getDisambiguation() { + return 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 new file mode 100644 index 00000000000..487ddc0e493 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/EntityMention.java @@ -0,0 +1,61 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** EntityMention. */ +public class EntityMention extends GenericModel { + + protected String text; + protected List location; + protected Double confidence; + + protected EntityMention() {} + + /** + * Gets the text. + * + *

Entity mention text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the location. + * + *

Character offsets indicating the beginning and end of the mention in the analyzed text. + * + * @return the location + */ + public List getLocation() { + return location; + } + + /** + * 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. + * + * @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/FeatureSentimentResults.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java new file mode 100644 index 00000000000..bba6e3e19b1 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/FeatureSentimentResults.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** FeatureSentimentResults. */ +public class FeatureSentimentResults extends GenericModel { + + protected Double score; + + protected FeatureSentimentResults() {} + + /** + * Gets the score. + * + *

Sentiment score from -1 (negative) to 1 (positive). + * + * @return the score + */ + public Double getScore() { + return 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 new file mode 100644 index 00000000000..203f312f5d9 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Features.java @@ -0,0 +1,384 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.Map; + +/** 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 Map metadata; + protected RelationsOptions relations; + + @SerializedName("semantic_roles") + protected SemanticRolesOptions semanticRoles; + + protected SentimentOptions sentiment; + protected CategoriesOptions categories; + protected SyntaxOptions syntax; + + /** Builder. */ + public static class Builder { + private ClassificationsOptions classifications; + private ConceptsOptions concepts; + private EmotionOptions emotion; + private EntitiesOptions entities; + private KeywordsOptions keywords; + 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; + this.keywords = features.keywords; + this.metadata = features.metadata; + this.relations = features.relations; + this.semanticRoles = features.semanticRoles; + this.sentiment = features.sentiment; + this.categories = features.categories; + this.syntax = features.syntax; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Builds a 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. + * + * @param concepts the concepts + * @return the Features builder + */ + public Builder concepts(ConceptsOptions concepts) { + this.concepts = concepts; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the Features builder + */ + public Builder emotion(EmotionOptions emotion) { + this.emotion = emotion; + return this; + } + + /** + * Set the entities. + * + * @param entities the entities + * @return the Features builder + */ + public Builder entities(EntitiesOptions entities) { + this.entities = entities; + return this; + } + + /** + * Set the keywords. + * + * @param keywords the keywords + * @return the Features builder + */ + public Builder keywords(KeywordsOptions keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the metadata. + * + * @param metadata the metadata + * @return the Features builder + */ + public Builder metadata(Map metadata) { + this.metadata = metadata; + return this; + } + + /** + * Set the relations. + * + * @param relations the relations + * @return the Features builder + */ + public Builder relations(RelationsOptions relations) { + this.relations = relations; + return this; + } + + /** + * Set the semanticRoles. + * + * @param semanticRoles the semanticRoles + * @return the Features builder + */ + public Builder semanticRoles(SemanticRolesOptions semanticRoles) { + this.semanticRoles = semanticRoles; + return this; + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the Features builder + */ + public Builder sentiment(SentimentOptions sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the categories. + * + * @param categories the categories + * @return the Features builder + */ + public Builder categories(CategoriesOptions categories) { + this.categories = categories; + return this; + } + + /** + * Set the syntax. + * + * @param syntax the syntax + * @return the Features builder + */ + public Builder syntax(SyntaxOptions syntax) { + this.syntax = syntax; + return this; + } + } + + protected Features() {} + + protected Features(Builder builder) { + classifications = builder.classifications; + concepts = builder.concepts; + emotion = builder.emotion; + entities = builder.entities; + keywords = builder.keywords; + metadata = builder.metadata; + relations = builder.relations; + semanticRoles = builder.semanticRoles; + sentiment = builder.sentiment; + categories = builder.categories; + syntax = builder.syntax; + } + + /** + * New builder. + * + * @return a Features builder + */ + 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. + * + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, + * Spanish. + * + * @return the concepts + */ + public ConceptsOptions concepts() { + return 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`. + * + *

Supported languages: English. + * + * @return the emotion + */ + public EmotionOptions emotion() { + return emotion; + } + + /** + * Gets the entities. + * + *

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. + * + * @return the entities + */ + public EntitiesOptions entities() { + return entities; + } + + /** + * Gets the keywords. + * + *

Returns important keywords in the content. + * + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish, Swedish. + * + * @return the keywords + */ + public KeywordsOptions keywords() { + return 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. + * + * @return the 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". 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. + * + * @return the relations + */ + public RelationsOptions relations() { + return relations; + } + + /** + * Gets the semanticRoles. + * + *

Parses sentences into subject, action, and object form. + * + *

Supported languages: English, German, Japanese, Korean, Spanish. + * + * @return the semanticRoles + */ + public SemanticRolesOptions semanticRoles() { + return 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`. + * + *

Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, Portuguese, + * Russian, Spanish. + * + * @return the sentiment + */ + public SentimentOptions sentiment() { + return sentiment; + } + + /** + * Gets the categories. + * + *

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. + * + * @return the categories + */ + public CategoriesOptions categories() { + return categories; + } + + /** + * Gets the syntax. + * + *

Returns tokens and sentences from the input text. + * + * @return the syntax + */ + public SyntaxOptions syntax() { + return 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 new file mode 100644 index 00000000000..8533f4b7eee --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Feed.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the link + */ + public String getLink() { + return 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 new file mode 100644 index 00000000000..7ffccb18c05 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsOptions.java @@ -0,0 +1,141 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 important keywords in the content. + * + *

Supported languages: English, French, German, Italian, Japanese, Korean, Portuguese, Russian, + * Spanish, Swedish. + */ +public class KeywordsOptions extends GenericModel { + + protected Long limit; + protected Boolean sentiment; + protected Boolean emotion; + + /** 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() {} + + /** + * Builds a KeywordsOptions. + * + * @return the new KeywordsOptions instance + */ + public KeywordsOptions build() { + return new KeywordsOptions(this); + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the KeywordsOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the sentiment. + * + * @param sentiment the sentiment + * @return the KeywordsOptions builder + */ + public Builder sentiment(Boolean sentiment) { + this.sentiment = sentiment; + return this; + } + + /** + * Set the emotion. + * + * @param emotion the emotion + * @return the KeywordsOptions builder + */ + public Builder emotion(Boolean emotion) { + this.emotion = emotion; + return this; + } + } + + protected KeywordsOptions() {} + + protected KeywordsOptions(Builder builder) { + limit = builder.limit; + sentiment = builder.sentiment; + emotion = builder.emotion; + } + + /** + * New builder. + * + * @return a KeywordsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the limit. + * + *

Maximum number of keywords to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the sentiment. + * + *

Set this to `true` to return sentiment information for detected keywords. + * + * @return the sentiment + */ + public Boolean sentiment() { + return sentiment; + } + + /** + * Gets the emotion. + * + *

Set this to `true` to analyze emotion for detected keywords. + * + * @return the emotion + */ + public Boolean emotion() { + return 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 new file mode 100644 index 00000000000..3dd6486a425 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/KeywordsResult.java @@ -0,0 +1,82 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 important keywords in the content, organized by relevance. */ +public class KeywordsResult extends GenericModel { + + protected Long count; + protected Double relevance; + protected String text; + protected EmotionScores emotion; + protected FeatureSentimentResults sentiment; + + protected KeywordsResult() {} + + /** + * Gets the count. + * + *

Number of times the keyword appears in the analyzed text. + * + * @return the count + */ + public Long getCount() { + return count; + } + + /** + * Gets the relevance. + * + *

Relevance score from 0 to 1. Higher values indicate greater relevance. + * + * @return the relevance + */ + public Double getRelevance() { + return relevance; + } + + /** + * Gets the text. + * + *

The keyword text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the emotion. + * + *

Emotion analysis results for the keyword, enabled with the `emotion` option. + * + * @return the emotion + */ + public EmotionScores getEmotion() { + return emotion; + } + + /** + * Gets the sentiment. + * + *

Sentiment analysis results for the keyword, enabled with the `sentiment` option. + * + * @return the sentiment + */ + public FeatureSentimentResults getSentiment() { + return 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 new file mode 100644 index 00000000000..f9b3351075b --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsOptions.java @@ -0,0 +1,22 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 listModels options. */ +public class ListModelsOptions extends GenericModel { + + /** 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 new file mode 100644 index 00000000000..d563798e8a7 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/ListModelsResults.java @@ -0,0 +1,35 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @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/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/Model.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java new file mode 100644 index 00000000000..b2d52519904 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/Model.java @@ -0,0 +1,162 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** 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. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * Gets the modelId. + * + *

Unique model ID. + * + * @return the modelId + */ + public String getModelId() { + return modelId; + } + + /** + * Gets the language. + * + *

ISO 639-1 code that indicates the language of the model. + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the description. + * + *

Model description. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * 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 modelVersion. + * + *

The model version, if it was manually provided in Watson Knowledge Studio. + * + * @return the modelVersion + */ + public String getModelVersion() { + return modelVersion; + } + + /** + * Gets the version. + * + *

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; + } + + /** + * Gets the versionDescription. + * + *

The description of the version, if it was manually provided in Watson Knowledge Studio. + * + * @return the versionDescription + */ + public String getVersionDescription() { + return versionDescription; + } + + /** + * Gets the created. + * + *

A dateTime indicating when the model was created. + * + * @return the created + */ + public Date getCreated() { + return 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 new file mode 100644 index 00000000000..0ec3aac25b7 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationArgument.java @@ -0,0 +1,59 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the location. + * + *

Character offsets indicating the beginning and end of the mention in the analyzed text. + * + * @return the location + */ + public List getLocation() { + return location; + } + + /** + * Gets the text. + * + *

Text that corresponds to the argument. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..b30e086b966 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationEntity.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the type. + * + *

Entity type. + * + * @return the type + */ + public String getType() { + return 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 new file mode 100644 index 00000000000..a951875ec62 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsOptions.java @@ -0,0 +1,94 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * 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. + */ +public class RelationsOptions extends GenericModel { + + protected String model; + + /** 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() {} + + /** + * Builds a RelationsOptions. + * + * @return the new RelationsOptions instance + */ + public RelationsOptions build() { + return new RelationsOptions(this); + } + + /** + * Set the model. + * + * @param model the model + * @return the RelationsOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + } + + protected RelationsOptions() {} + + protected RelationsOptions(Builder builder) { + model = builder.model; + } + + /** + * New builder. + * + * @return a RelationsOptions 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 to override the default model. + * + * @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/RelationsResult.java b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java new file mode 100644 index 00000000000..ac9d74d8c21 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/RelationsResult.java @@ -0,0 +1,71 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** The relations between entities found in the content. */ +public class RelationsResult extends GenericModel { + + protected Double score; + protected String sentence; + protected String type; + protected List arguments; + + protected RelationsResult() {} + + /** + * Gets the score. + * + *

Confidence score for the relation. Higher values indicate greater confidence. + * + * @return the score + */ + public Double getScore() { + return score; + } + + /** + * Gets the sentence. + * + *

The sentence that contains the relation. + * + * @return the sentence + */ + public String getSentence() { + return sentence; + } + + /** + * Gets the type. + * + *

The type of the relation. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the arguments. + * + *

Entity mentions that are involved in the relation. + * + * @return the arguments + */ + public List getArguments() { + return 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 new file mode 100644 index 00000000000..f100951811b --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesEntity.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SemanticRolesEntity. */ +public class SemanticRolesEntity extends GenericModel { + + protected String type; + protected String text; + + protected SemanticRolesEntity() {} + + /** + * Gets the type. + * + *

Entity type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the text. + * + *

The entity text. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..fc9b439e080 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesKeyword.java @@ -0,0 +1,34 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SemanticRolesKeyword. */ +public class SemanticRolesKeyword extends GenericModel { + + protected String text; + + protected SemanticRolesKeyword() {} + + /** + * Gets the text. + * + *

The keyword text. + * + * @return the text + */ + public String getText() { + return 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 new file mode 100644 index 00000000000..e6a5b2db9cd --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesOptions.java @@ -0,0 +1,140 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** + * Parses sentences into subject, action, and object form. + * + *

Supported languages: English, German, Japanese, Korean, Spanish. + */ +public class SemanticRolesOptions extends GenericModel { + + protected Long limit; + protected Boolean keywords; + protected Boolean entities; + + /** 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() {} + + /** + * Builds a SemanticRolesOptions. + * + * @return the new SemanticRolesOptions instance + */ + public SemanticRolesOptions build() { + return new SemanticRolesOptions(this); + } + + /** + * Set the limit. + * + * @param limit the limit + * @return the SemanticRolesOptions builder + */ + public Builder limit(long limit) { + this.limit = limit; + return this; + } + + /** + * Set the keywords. + * + * @param keywords the keywords + * @return the SemanticRolesOptions builder + */ + public Builder keywords(Boolean keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the entities. + * + * @param entities the entities + * @return the SemanticRolesOptions builder + */ + public Builder entities(Boolean entities) { + this.entities = entities; + return this; + } + } + + protected SemanticRolesOptions() {} + + protected SemanticRolesOptions(Builder builder) { + limit = builder.limit; + keywords = builder.keywords; + entities = builder.entities; + } + + /** + * New builder. + * + * @return a SemanticRolesOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the limit. + * + *

Maximum number of semantic_roles results to return. + * + * @return the limit + */ + public Long limit() { + return limit; + } + + /** + * Gets the keywords. + * + *

Set this to `true` to return keyword information for subjects and objects. + * + * @return the keywords + */ + public Boolean keywords() { + return keywords; + } + + /** + * Gets the entities. + * + *

Set this to `true` to return entity information for subjects and objects. + * + * @return the entities + */ + public Boolean entities() { + return 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 new file mode 100644 index 00000000000..d7893ac0310 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResult.java @@ -0,0 +1,70 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 object containing the actions and the objects the actions act upon. */ +public class SemanticRolesResult extends GenericModel { + + protected String sentence; + protected SemanticRolesResultSubject subject; + protected SemanticRolesResultAction action; + protected SemanticRolesResultObject object; + + protected SemanticRolesResult() {} + + /** + * Gets the sentence. + * + *

Sentence from the source that contains the subject, action, and object. + * + * @return the sentence + */ + public String getSentence() { + return sentence; + } + + /** + * Gets the subject. + * + *

The extracted subject from the sentence. + * + * @return the subject + */ + public SemanticRolesResultSubject getSubject() { + return subject; + } + + /** + * Gets the action. + * + *

The extracted action from the sentence. + * + * @return the action + */ + public SemanticRolesResultAction getAction() { + return action; + } + + /** + * Gets the object. + * + *

The extracted object from the sentence. + * + * @return the object + */ + public SemanticRolesResultObject getObject() { + return 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 new file mode 100644 index 00000000000..713e7503e35 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultAction.java @@ -0,0 +1,56 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the normalized. + * + *

normalized version of the action. + * + * @return the normalized + */ + public String getNormalized() { + return normalized; + } + + /** + * Gets the verb. + * + * @return the verb + */ + public SemanticRolesVerb getVerb() { + return verb; + } +} 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 new file mode 100644 index 00000000000..b36755c9614 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultObject.java @@ -0,0 +1,47 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** The extracted object from the sentence. */ +public class SemanticRolesResultObject extends GenericModel { + + protected String text; + protected List keywords; + + protected SemanticRolesResultObject() {} + + /** + * Gets the text. + * + *

Object text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the keywords. + * + *

An array of extracted keywords. + * + * @return the keywords + */ + public List getKeywords() { + return 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 new file mode 100644 index 00000000000..681fd2cd912 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesResultSubject.java @@ -0,0 +1,59 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the entities. + * + *

An array of extracted entities. + * + * @return the entities + */ + public List getEntities() { + return entities; + } + + /** + * Gets the keywords. + * + *

An array of extracted keywords. + * + * @return the keywords + */ + public List getKeywords() { + return 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 new file mode 100644 index 00000000000..cc636811f96 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SemanticRolesVerb.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** SemanticRolesVerb. */ +public class SemanticRolesVerb extends GenericModel { + + protected String text; + protected String tense; + + protected SemanticRolesVerb() {} + + /** + * Gets the text. + * + *

The keyword text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the tense. + * + *

Verb tense. + * + * @return the tense + */ + public String getTense() { + return 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 new file mode 100644 index 00000000000..d80e08b277d --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentenceResult.java @@ -0,0 +1,47 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** SentenceResult. */ +public class SentenceResult extends GenericModel { + + protected String text; + protected List location; + + protected SentenceResult() {} + + /** + * Gets the text. + * + *

The sentence. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the location. + * + *

Character offsets indicating the beginning and end of the sentence in the analyzed text. + * + * @return the location + */ + public List getLocation() { + return 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 new file mode 100644 index 00000000000..4737f1cd3e3 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentOptions.java @@ -0,0 +1,134 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.ArrayList; +import java.util.List; + +/** + * 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. + */ +public class SentimentOptions extends GenericModel { + + protected Boolean document; + protected List targets; + + /** 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() {} + + /** + * Builds a SentimentOptions. + * + * @return the new SentimentOptions instance + */ + public SentimentOptions build() { + return new SentimentOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.targets == null) { + this.targets = new ArrayList(); + } + this.targets.add(targets); + return this; + } + + /** + * Set the document. + * + * @param document the document + * @return the SentimentOptions 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 SentimentOptions builder + */ + public Builder targets(List targets) { + this.targets = targets; + return this; + } + } + + protected SentimentOptions() {} + + protected SentimentOptions(Builder builder) { + document = builder.document; + targets = builder.targets; + } + + /** + * New builder. + * + * @return a SentimentOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the document. + * + *

Set this to `false` to hide document-level sentiment results. + * + * @return the document + */ + public Boolean document() { + return document; + } + + /** + * Gets the targets. + * + *

Sentiment results will be returned for each target string that is found in the document. + * + * @return the targets + */ + public List targets() { + return 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 new file mode 100644 index 00000000000..5f2b473a7bc --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SentimentResult.java @@ -0,0 +1,47 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the document + */ + public DocumentSentimentResults getDocument() { + return document; + } + + /** + * Gets the targets. + * + *

The targeted sentiment to analyze. + * + * @return the targets + */ + public List getTargets() { + return 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 new file mode 100644 index 00000000000..575000c34a1 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptions.java @@ -0,0 +1,110 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Returns tokens and sentences from the input text. */ +public class SyntaxOptions extends GenericModel { + + protected SyntaxOptionsTokens tokens; + protected Boolean sentences; + + /** 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() {} + + /** + * Builds a SyntaxOptions. + * + * @return the new SyntaxOptions instance + */ + public SyntaxOptions build() { + return new SyntaxOptions(this); + } + + /** + * Set the tokens. + * + * @param tokens the tokens + * @return the SyntaxOptions builder + */ + public Builder tokens(SyntaxOptionsTokens tokens) { + this.tokens = tokens; + return this; + } + + /** + * Set the sentences. + * + * @param sentences the sentences + * @return the SyntaxOptions builder + */ + public Builder sentences(Boolean sentences) { + this.sentences = sentences; + return this; + } + } + + protected SyntaxOptions() {} + + protected SyntaxOptions(Builder builder) { + tokens = builder.tokens; + sentences = builder.sentences; + } + + /** + * New builder. + * + * @return a SyntaxOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the tokens. + * + *

Tokenization options. + * + * @return the tokens + */ + public SyntaxOptionsTokens tokens() { + return tokens; + } + + /** + * Gets the sentences. + * + *

Set this to `true` to return sentence information. + * + * @return the sentences + */ + public Boolean sentences() { + return 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 new file mode 100644 index 00000000000..fc9e061ef39 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxOptionsTokens.java @@ -0,0 +1,113 @@ +/* + * (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; + +/** Tokenization options. */ +public class SyntaxOptionsTokens extends GenericModel { + + protected Boolean lemma; + + @SerializedName("part_of_speech") + protected Boolean partOfSpeech; + + /** 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() {} + + /** + * Builds a SyntaxOptionsTokens. + * + * @return the new SyntaxOptionsTokens instance + */ + public SyntaxOptionsTokens build() { + return new SyntaxOptionsTokens(this); + } + + /** + * Set the lemma. + * + * @param lemma the lemma + * @return the SyntaxOptionsTokens builder + */ + public Builder lemma(Boolean lemma) { + this.lemma = lemma; + return this; + } + + /** + * Set the partOfSpeech. + * + * @param partOfSpeech the partOfSpeech + * @return the SyntaxOptionsTokens builder + */ + public Builder partOfSpeech(Boolean partOfSpeech) { + this.partOfSpeech = partOfSpeech; + return this; + } + } + + protected SyntaxOptionsTokens() {} + + protected SyntaxOptionsTokens(Builder builder) { + lemma = builder.lemma; + partOfSpeech = builder.partOfSpeech; + } + + /** + * New builder. + * + * @return a SyntaxOptionsTokens builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the lemma. + * + *

Set this to `true` to return the lemma for each token. + * + * @return the lemma + */ + public Boolean lemma() { + return lemma; + } + + /** + * Gets the partOfSpeech. + * + *

Set this to `true` to return the part of speech for each token. + * + * @return the partOfSpeech + */ + public Boolean partOfSpeech() { + return 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 new file mode 100644 index 00000000000..c82095c628c --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/SyntaxResult.java @@ -0,0 +1,43 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Tokens and sentences returned from syntax analysis. */ +public class SyntaxResult extends GenericModel { + + protected List tokens; + protected List sentences; + + protected SyntaxResult() {} + + /** + * Gets the tokens. + * + * @return the tokens + */ + public List getTokens() { + return tokens; + } + + /** + * Gets the sentences. + * + * @return the sentences + */ + public List getSentences() { + return sentences; + } +} 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 new file mode 100644 index 00000000000..229645afa57 --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedEmotionResults.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** Emotion results for a specified target. */ +public class TargetedEmotionResults extends GenericModel { + + protected String text; + protected EmotionScores emotion; + + protected TargetedEmotionResults() {} + + /** + * Gets the text. + * + *

Targeted text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the emotion. + * + *

The emotion results for the target. + * + * @return the emotion + */ + public EmotionScores getEmotion() { + return 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 new file mode 100644 index 00000000000..4b46acd47aa --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TargetedSentimentResults.java @@ -0,0 +1,46 @@ +/* + * (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.ibm.cloud.sdk.core.service.model.GenericModel; + +/** TargetedSentimentResults. */ +public class TargetedSentimentResults extends GenericModel { + + protected String text; + protected Double score; + + protected TargetedSentimentResults() {} + + /** + * Gets the text. + * + *

Targeted text. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the score. + * + *

Sentiment score from -1 (negative) to 1 (positive). + * + * @return the score + */ + public Double getScore() { + return 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 new file mode 100644 index 00000000000..123a3df65ee --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/model/TokenResult.java @@ -0,0 +1,117 @@ +/* + * (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; + +/** TokenResult. */ +public class TokenResult extends GenericModel { + + /** + * 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. */ + String ADJ = "ADJ"; + /** ADP. */ + String ADP = "ADP"; + /** ADV. */ + String ADV = "ADV"; + /** AUX. */ + String AUX = "AUX"; + /** CCONJ. */ + String CCONJ = "CCONJ"; + /** DET. */ + String DET = "DET"; + /** INTJ. */ + String INTJ = "INTJ"; + /** NOUN. */ + String NOUN = "NOUN"; + /** NUM. */ + String NUM = "NUM"; + /** PART. */ + String PART = "PART"; + /** PRON. */ + String PRON = "PRON"; + /** PROPN. */ + String PROPN = "PROPN"; + /** PUNCT. */ + String PUNCT = "PUNCT"; + /** SCONJ. */ + String SCONJ = "SCONJ"; + /** SYM. */ + String SYM = "SYM"; + /** VERB. */ + String VERB = "VERB"; + /** X. */ + String X = "X"; + } + + 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. + * + * @return the text + */ + public String getText() { + return text; + } + + /** + * Gets the partOfSpeech. + * + *

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 + */ + public String getPartOfSpeech() { + return partOfSpeech; + } + + /** + * Gets the location. + * + *

Character offsets indicating the beginning and end of the token in the analyzed text. + * + * @return the location + */ + public List getLocation() { + return location; + } + + /** + * Gets the lemma. + * + *

The [lemma](https://wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + * + * @return the lemma + */ + public String getLemma() { + return 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 new file mode 100644 index 00000000000..7afb2ae5b5c --- /dev/null +++ b/natural-language-understanding/src/main/java/com/ibm/watson/natural_language_understanding/v1/package-info.java @@ -0,0 +1,14 @@ +/* + * (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. + */ +/** Natural Language Understanding v1. */ +package com.ibm.watson.natural_language_understanding.v1; diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java b/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java deleted file mode 100644 index cd601a8eb43..00000000000 --- a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java +++ /dev/null @@ -1,547 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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 java.io.FileInputStream; -import java.util.Arrays; -import java.util.List; - -import org.junit.Assume; -import org.junit.Before; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Author; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionScores; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EntitiesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EntitiesResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.KeywordsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.KeywordsResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.MetadataOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.MetadataResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.RelationsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.SemanticRolesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.SemanticRolesResult; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.SentimentOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.TargetedSentimentResults; -import com.ibm.watson.developer_cloud.util.RetryRunner; - -/** - * 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."; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("natural_language_understanding.username"); - String password = getProperty("natural_language_understanding.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new NaturalLanguageUnderstanding("2017-02-27"); - service.setDefaultHeaders(getDefaultHeaders()); - service.setUsernameAndPassword(username, password); - service.setEndPoint(getProperty("natural_language_understanding.url")); - } - - /** - * Default test for HTML input. - * - * @throws Exception the exception - */ - @Test - 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(); - - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - } - - /** - * Default test for text input. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextIsSuccessful() throws Exception { - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - } - - /** - * Default test for URL input. - * - * @throws Exception the exception - */ - @Test - 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(); - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .url(url) - .features(features) - .returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertNotNull(results.getAnalyzedText()); - } - - /** - * Analyze given test input text for concepts. - * - * @throws Exception the 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(); - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertNotNull(results.getAnalyzedText()); - assertNotNull(results.getConcepts()); - for (ConceptsResult concept : results.getConcepts()) { - assertNotNull(concept.getText()); - assertNotNull(concept.getDbpediaResource()); - assertNotNull(concept.getRelevance()); - } - } - - /** - * Analyze test HTML for concepts. - * - * @throws Exception the exception - */ - @Test - 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(); - Features features = new Features.Builder().concepts(concepts).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertNotNull(results.getAnalyzedText()); - assertNotNull(results.getConcepts()); - for (ConceptsResult concept : results.getConcepts()) { - assertNotNull(concept.getText()); - assertNotNull(concept.getDbpediaResource()); - assertNotNull(concept.getRelevance()); - } - } - - /** - * Analyze input text for emotions without targets. - * - * @throws Exception the 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."; - - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertNotNull(results.getAnalyzedText()); - assertNotNull(results.getEmotion()); - assertNotNull(results.getEmotion().getDocument()); - assertNotNull(results.getEmotion().getDocument().getEmotion()); - - EmotionScores scores = results.getEmotion().getDocument().getEmotion(); - assertNotNull(scores.getAnger()); - assertNotNull(scores.getDisgust()); - assertNotNull(scores.getFear()); - assertNotNull(scores.getJoy()); - assertNotNull(scores.getSadness()); - - assertNull(results.getEmotion().getTargets()); - } - - /** - * Analyze input text for entities. - * - * @throws Exception the 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."; - - EntitiesOptions entities = new EntitiesOptions.Builder() - .limit(2) - .sentiment(true) - .build(); - - Features features = new Features.Builder() - .entities(entities) - .build(); - - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .text(text) - .features(features) - .returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertNotNull(results.getEntities()); - assertTrue(results.getEntities().size() == 2); - - for (EntitiesResult result : results.getEntities()) { - assertNotNull(result.getCount()); - assertNotNull(result.getRelevance()); - assertNotNull(result.getText()); - assertNotNull(result.getType()); - assertNotNull(result.getSentiment()); - } - } - - /** - * Analyze input text for keywords. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextForKeywordsIsSuccessful() throws Exception { - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertNotNull(results.getKeywords()); - - for (KeywordsResult result : results.getKeywords()) { - assertNotNull(result.getRelevance()); - assertNotNull(result.getText()); - assertNotNull(result.getSentiment()); - } - } - - /** - * Analyze html input for metadata. - * - * @throws Exception the exception - */ - @Test - public void analyzeHtmlForMetadataIsSuccessful() throws Exception { - String testHtmlFileName = "src/test/resources/natural_language_understanding/testArticle.html"; - String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); - 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()) - .build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder() - .html(html) - .features(features) - .returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getMetadata()); - MetadataResult result = results.getMetadata(); - assertNotNull(result.getTitle()); - assertEquals(result.getTitle(), fileTitle); - assertNotNull(result.getPublicationDate()); - assertEquals(result.getPublicationDate(), fileDate); - assertNotNull(result.getAuthors()); - List authors = result.getAuthors(); - assertEquals(authors.size(), 1); - assertEquals(authors.get(0).getName(), fileAuthor); - } - - /** - * Analyze input text for relations. - * - * @throws Exception the 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getRelations()); - } - - /** - * Analyze input text for semantic roles. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextForSemanticRolesIsSuccessful() throws Exception { - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getSemanticRoles()); - for (SemanticRolesResult result : results.getSemanticRoles()) { - assertEquals(result.getSentence(), text); - if (result.getSubject() != null) { - assertNotNull(result.getSubject().getText()); - } - if (result.getAction() != null) { - assertNotNull(result.getAction().getText()); - } - if (result.getObject() != null) { - assertNotNull(result.getObject().getText()); - } - } - } - - /** - * Analyze input text for sentiment with targets. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextForSentimentWithTargetsIsSuccessful() throws Exception { - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getSentiment()); - assertNotNull(results.getSentiment().getDocument()); - assertNotNull(results.getSentiment().getDocument().getScore()); - assertNotNull(results.getSentiment().getTargets()); - for (TargetedSentimentResults result : results.getSentiment().getTargets()) { - assertNotNull(result.getText()); - assertNotNull(result.getScore()); - } - } - - /** - * Analyze input text for sentiment without targets. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextForSentimentWithoutTargetsIsSuccessful() throws Exception { - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getSentiment()); - assertNotNull(results.getSentiment().getDocument()); - assertNotNull(results.getSentiment().getDocument().getScore()); - assertNull(results.getSentiment().getTargets()); - } - - /** - * Analyze input text for categories. - * - * @throws Exception the exception - */ - @Test - public void analyzeTextForCategoriesIsSuccessful() throws Exception { - Features features = new Features.Builder().categories(new CategoriesOptions()).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getAnalyzedText(), text); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getCategories()); - for (CategoriesResult result : results.getCategories()) { - assertNotNull(result.getLabel()); - assertNotNull(result.getScore()); - } - } - - /** - * Analyze html for disambiguation. - * - * @throws Exception the exception - */ - @Test - 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(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertEquals(results.getLanguage(), "en"); - assertNotNull(results.getEntities()); - assertTrue(results.getEntities().size() == 1); - for (EntitiesResult result : results.getEntities()) { - assertNotNull(result.getDisambiguation()); - assertEquals(result.getDisambiguation().getName(), "CNN"); - assertEquals(result.getDisambiguation().getDbpediaResource(), "http://dbpedia.org/resource/CNN"); - assertNotNull(result.getDisambiguation().getSubtype()); - assertTrue(result.getDisambiguation().getSubtype().size() > 0); - } - } - - /** - * Analyze text while setting a character limit on the analyzed passage. - * - * @throws Exception the 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."; - - Long characterLimit = 10L; - Features features = new Features.Builder().categories(new CategoriesOptions()).build(); - AnalyzeOptions parameters = new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true) - .limitTextCharacters(characterLimit).build(); - - AnalysisResults results = service.analyze(parameters).execute(); - - assertNotNull(results); - assertNotNull(results.getAnalyzedText()); - assertTrue(results.getAnalyzedText().length() == characterLimit); - } -} diff --git a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java b/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java deleted file mode 100644 index 0da55acd339..00000000000 --- a/natural-language-understanding/src/test/java/com/ibm/watson/developer_cloud/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java +++ /dev/null @@ -1,276 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.natural_language_understanding.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalysisResults; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.AnalyzeOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.CategoriesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ConceptsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.DeleteModelOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EmotionOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.EntitiesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.Features; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.KeywordsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.ListModelsResults; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.MetadataOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.RelationsOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.SemanticRolesOptions; -import com.ibm.watson.developer_cloud.natural_language_understanding.v1.model.SentimentOptions; -import okhttp3.mockwebserver.RecordedRequest; -import org.junit.Before; -import org.junit.Test; - -import java.io.FileInputStream; -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; - -/** - * The Class NaturalLanguageunderstandingTest. - */ -public class NaturalLanguageUnderstandingTest extends WatsonServiceUnitTest { - private static final String MODELS_PATH = "/v1/models?version=2017-02-27"; - private static final String DELETE_PATH = "/v1/models/foo?version=2017-02-27"; - private static final String ANALYZE_PATH = "/v1/analyze?version=2017-02-27"; - private static final String RESOURCE = "src/test/resources/natural_language_understanding/"; - - 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("2017-02-27"); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - modelId = "foo"; - models = loadFixture(RESOURCE + "models.json", ListModelsResults.class); - analyzeResults = loadFixture(RESOURCE + "analyze.json", AnalysisResults.class); - } - - /** - * Test analyze. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException - */ - @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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); - } - - /** - * Test analyze with null parameters. Test different constructor - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testAnalyzeNullParams() throws InterruptedException { - NaturalLanguageUnderstanding service1 = new NaturalLanguageUnderstanding("2017-02-27", "username", "password"); - service1.setUsernameAndPassword("", ""); - service1.setEndPoint(getMockWebServerUrl()); - - 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 = service1.analyze(builder.build()).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(ANALYZE_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(analyzeResults, response); - } - - /** - * Test some of the model constructors. pump up the code coverage numbers - * - * @throws InterruptedException the interrupted exception - */ - @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(); - 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(); - 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(); - } - - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testListModels() throws InterruptedException { - server.enqueue(jsonResponse(models)); - final ListModelsResults response = service.listModels().execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(MODELS_PATH, request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(models, response); - } - - /** - * Test delete model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteModel() throws InterruptedException { - server.enqueue(jsonResponse(null)); - DeleteModelOptions deleteOptions = new DeleteModelOptions.Builder(modelId).build(); - final Void response = service.deleteModel(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(DELETE_PATH, request.getPath()); - assertEquals("DELETE", request.getMethod()); - assertEquals(null, response); - } - - // START NEGATIVE TESTS - /** - * Test delete model with a null model ID. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullModelId() { - service.deleteModel(null).execute(); - } - - /** - * Test constructor with null version. - */ - @Test(expected = IllegalArgumentException.class) - public void testNullVersion() { - @SuppressWarnings("unused") - NaturalLanguageUnderstanding service2 = new NaturalLanguageUnderstanding(null); - } - -} 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 new file mode 100644 index 00000000000..401c2f94fa8 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingIT.java @@ -0,0 +1,1127 @@ +/* + * (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; + +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.*; +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; + +/** 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."; + + /** + * Sets up the tests. + * + * @throws Exception the exception + */ + /* + * (non-Javadoc) + * @see com.ibm.watson.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + String apiKey = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_APIKEY"); + String serviceUrl = System.getenv("NATURAL_LANGUAGE_UNDERSTANDING_URL"); + + 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(serviceUrl); + } + + /** + * Default test for HTML input. + * + * @throws Exception the exception + */ + @Test + 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(); + + Features features = new Features.Builder().concepts(concepts).build(); + AnalyzeOptions parameters = new AnalyzeOptions.Builder().html(html).features(features).build(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + } + + /** + * Default test for text input. + * + * @throws Exception the exception + */ + @Test + public void analyzeTextIsSuccessful() throws Exception { + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + } + + /** + * Default test for URL input. + * + * @throws Exception the exception + */ + @Test + 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(); + Features features = new Features.Builder().concepts(concepts).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().url(url).features(features).returnAnalyzedText(true).build(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertNotNull(results.getAnalyzedText()); + } + + /** + * Analyze given test input text for concepts. + * + * @throws Exception the 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(); + Features features = new Features.Builder().concepts(concepts).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertNotNull(results.getAnalyzedText()); + assertNotNull(results.getConcepts()); + for (ConceptsResult concept : results.getConcepts()) { + assertNotNull(concept.getText()); + assertNotNull(concept.getDbpediaResource()); + assertNotNull(concept.getRelevance()); + } + } + + /** + * Analyze test HTML for concepts. + * + * @throws Exception the exception + */ + @Test + 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(); + Features features = new Features.Builder().concepts(concepts).build(); + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().html(html).features(features).returnAnalyzedText(true).build(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertNotNull(results.getAnalyzedText()); + assertNotNull(results.getConcepts()); + for (ConceptsResult concept : results.getConcepts()) { + assertNotNull(concept.getText()); + assertNotNull(concept.getDbpediaResource()); + assertNotNull(concept.getRelevance()); + } + } + + /** + * Analyze input text for emotions without targets. + * + * @throws Exception the 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."; + + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertNotNull(results.getAnalyzedText()); + assertNotNull(results.getEmotion()); + assertNotNull(results.getEmotion().getDocument()); + assertNotNull(results.getEmotion().getDocument().getEmotion()); + + EmotionScores scores = results.getEmotion().getDocument().getEmotion(); + assertNotNull(scores.getAnger()); + assertNotNull(scores.getDisgust()); + assertNotNull(scores.getFear()); + assertNotNull(scores.getJoy()); + assertNotNull(scores.getSadness()); + + assertNull(results.getEmotion().getTargets()); + } + + /** + * Analyze input text for entities. + * + * @throws Exception the 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."; + + EntitiesOptions entities = new EntitiesOptions.Builder().limit(2).sentiment(true).build(); + + Features features = new Features.Builder().entities(entities).build(); + + AnalyzeOptions parameters = + new AnalyzeOptions.Builder().text(text).features(features).returnAnalyzedText(true).build(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertNotNull(results.getEntities()); + assertTrue(results.getEntities().size() <= 2); + + for (EntitiesResult result : results.getEntities()) { + assertNotNull(result.getCount()); + assertNotNull(result.getRelevance()); + assertNotNull(result.getText()); + assertNotNull(result.getType()); + assertNotNull(result.getSentiment()); + } + } + + /** + * Analyze input text for keywords. + * + * @throws Exception the exception + */ + @Test + public void analyzeTextForKeywordsIsSuccessful() throws Exception { + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertNotNull(results.getKeywords()); + + for (KeywordsResult result : results.getKeywords()) { + assertNotNull(result.getRelevance()); + assertNotNull(result.getText()); + assertNotNull(result.getSentiment()); + } + } + + /** + * Analyze html input for metadata. + * + * @throws Exception the exception + */ + @Test + public void analyzeHtmlForMetadataIsSuccessful() throws Exception { + String testHtmlFileName = "src/test/resources/natural_language_understanding/testArticle.html"; + String html = getStringFromInputStream(new FileInputStream(testHtmlFileName)); + 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 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()); + FeaturesResultsMetadata result = results.getMetadata(); + assertNotNull(result.getTitle()); + assertEquals(result.getTitle(), fileTitle); + assertNotNull(result.getPublicationDate()); + assertEquals(result.getPublicationDate(), fileDate); + assertNotNull(result.getAuthors()); + List authors = result.getAuthors(); + assertEquals(authors.size(), 1); + assertEquals(authors.get(0).getName(), fileAuthor); + } + + /** + * Analyze input text for relations. + * + * @throws Exception the 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getRelations()); + } + + /** + * Analyze input text for semantic roles. + * + * @throws Exception the exception + */ + @Test + public void analyzeTextForSemanticRolesIsSuccessful() throws Exception { + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getSemanticRoles()); + for (SemanticRolesResult result : results.getSemanticRoles()) { + assertEquals(result.getSentence(), text); + if (result.getSubject() != null) { + assertNotNull(result.getSubject().getText()); + } + if (result.getAction() != null) { + assertNotNull(result.getAction().getText()); + } + if (result.getObject() != null) { + assertNotNull(result.getObject().getText()); + } + } + } + + /** + * Analyze input text for sentiment with targets. + * + * @throws Exception the exception + */ + @Test + public void analyzeTextForSentimentWithTargetsIsSuccessful() throws Exception { + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getSentiment()); + assertNotNull(results.getSentiment().getDocument()); + assertNotNull(results.getSentiment().getDocument().getScore()); + assertNotNull(results.getSentiment().getTargets()); + for (TargetedSentimentResults result : results.getSentiment().getTargets()) { + assertNotNull(result.getText()); + assertNotNull(result.getScore()); + } + } + + /** + * Analyze input text for sentiment without targets. + * + * @throws Exception the exception + */ + @Test + public void analyzeTextForSentimentWithoutTargetsIsSuccessful() throws Exception { + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getSentiment()); + assertNotNull(results.getSentiment().getDocument()); + assertNotNull(results.getSentiment().getDocument().getScore()); + assertNull(results.getSentiment().getTargets()); + } + + /** + * Analyze input text for categories. + * + * @throws Exception the 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getAnalyzedText(), text); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getCategories()); + for (CategoriesResult result : results.getCategories()) { + assertNotNull(result.getLabel()); + assertNotNull(result.getScore()); + } + } + + /** + * Analyze html for disambiguation. + * + * @throws Exception the exception + */ + @Test + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + assertEquals(results.getLanguage(), "en"); + assertNotNull(results.getEntities()); + assertTrue(results.getEntities().size() == 1); + for (EntitiesResult result : results.getEntities()) { + assertNotNull(result.getDisambiguation()); + assertEquals(result.getDisambiguation().getName(), "CNN"); + assertEquals( + result.getDisambiguation().getDbpediaResource(), "http://dbpedia.org/resource/CNN"); + assertNotNull(result.getDisambiguation().getSubtype()); + assertTrue(result.getDisambiguation().getSubtype().size() > 0); + } + } + + /** + * Analyze text while setting a character limit on the analyzed passage. + * + * @throws Exception the 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."; + + 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(); + + AnalysisResults results = service.analyze(parameters).execute().getResult(); + + assertNotNull(results); + 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 new file mode 100644 index 00000000000..36e1f0ace91 --- /dev/null +++ b/natural-language-understanding/src/test/java/com/ibm/watson/natural_language_understanding/v1/NaturalLanguageUnderstandingTest.java @@ -0,0 +1,970 @@ +/* + * (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.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.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.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.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); + } + + // 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"); + } + + // Test the analyze operation with and without retries enabled + @Test + public void testAnalyzeWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testAnalyzeWOptions(); + + 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 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 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 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 testListCategoriesModelsWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testListCategoriesModelsWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testListCategoriesModelsWOptions(); + } + + // Test the getCategoriesModel operation with a valid options model parameter + @Test + 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"); + } + + // Test the getCategoriesModel operation with and without retries enabled + @Test + public void testGetCategoriesModelWRetries() throws Throwable { + naturalLanguageUnderstandingService.enableRetries(4, 30); + testGetCategoriesModelWOptions(); + + naturalLanguageUnderstandingService.disableRetries(); + testGetCategoriesModelWOptions(); + } + + // 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 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/natural-language-understanding/src/test/resources/natural_language_understanding/analyze.json b/natural-language-understanding/src/test/resources/natural_language_understanding/analyze.json index ec8025fc71e..d75a0190c0d 100644 --- a/natural-language-understanding/src/test/resources/natural_language_understanding/analyze.json +++ b/natural-language-understanding/src/test/resources/natural_language_understanding/analyze.json @@ -1,200 +1,267 @@ { - "language":"en", - "retrieved_url":"https://www.ibm.com/us-en/", - "categories":[ - { - "score":0.594296, - "label":"/technology and computing/software" - }, - { - "score":0.448495, - "label":"/science/mathematics/statistics" - }, - { - "score":0.426429, - "label":"/business and industrial" + "usage": { + "features": 100, + "text_characters": 1000, + "text_units": 10000 + }, + "language": "en", + "retrieved_url": "https://www.ibm.com/us-en/", + "analyzed_text": "some text", + "categories": [ + { + "score": 0.894113, + "label": "/technology and computing/enterprise technology", + "explanation": { + "relevant_text": [ + { + "text": "abcd" + } + ] } - ], - "concepts":[ - { - "text":"Social network service", - "relevance":"0.92186", - "dbpedia_resource":"http://dbpedia.org/resource/Social_network_service" - }, + }, + { + "score": 0.877948, + "label": "/business and industrial/business software", + "explanation": { + "relevant_text": [ + { + "text": "efgh" + } + ] + } + }, + { + "score": 0.85497, + "label": "/business and industrial/business operations/management/business process", + "explanation": { + "relevant_text": [ + { + "text": "ijkl" + } + ] + } + } + ], + "concepts": [ + { + "text": "Cloud computing", + "relevance": 0.917397, + "dbpedia_resource": "http://dbpedia.org/resource/Cloud_computing" + }, + { + "text": "Jim Whitehurst", + "relevance": 0.914318, + "dbpedia_resource": "http://dbpedia.org/resource/Jim_Whitehurst" + }, + { + "text": "Thomas J. Watson", + "relevance": 0.761069, + "dbpedia_resource": "http://dbpedia.org/resource/Thomas_J._Watson" + }, + { + "text": "Lotus Software", + "relevance": 0.746045, + "dbpedia_resource": "http://dbpedia.org/resource/Lotus_Software" + }, + { + "text": "Thomas J. Watson Research Center", + "relevance": 0.71023, + "dbpedia_resource": "http://dbpedia.org/resource/Thomas_J._Watson_Research_Center" + } + ], + "emotion": { + "targets": [ { - "text":"Thomas J. Watson", - "relevance":"0.871908", - "dbpedia_resource":"http://dbpedia.org/resource/Thomas_J._Watson" + "text": "apples", + "emotion": { + "sadness": 0.057003, + "joy": 0.800853, + "fear": 0.043714, + "disgust": 0.01978, + "anger": 0.118953 + } }, { - "text":"Lotus Software", - "relevance":"0.839578", - "dbpedia_resource":"http://dbpedia.org/resource/Lotus_Software" + "text": "oranges", + "emotion": { + "sadness": 0.237816, + "joy": 0.356436, + "fear": 0.094531, + "disgust": 0.079112, + "anger": 0.33624 + } } - ], - "emotion":{ - "targets":[ - { - "text":"apples", - "emotion":{ - "sadness":0.057003, - "joy":0.800853, - "fear":0.043714, - "disgust":0.01978, - "anger":0.118953 - } - }, - { - "text":"oranges", - "emotion":{ - "sadness":0.237816, - "joy":0.356436, - "fear":0.094531, - "disgust":0.079112, - "anger":0.33624 - } - } - ], - "document":{ - "emotion":{ - "sadness":0.076745, - "joy":0.667881, - "fear":0.039932, - "disgust":0.028915, - "anger":0.247133 - } + ], + "document": { + "emotion": { + "sadness": 0.076745, + "joy": 0.667881, + "fear": 0.039932, + "disgust": 0.028915, + "anger": 0.247133 } - }, - "metadata":{ - "title":"IBM - United States", - "publication_date":"2016-08-01T18:25:43.511Z", - "feeds":[ - { - "link":"https://www.feed.example/rss" - } - ], - "authors":[ - { - "name":"Example G. Author" - } - ] - }, - "relations":[ + } + }, + "metadata": { + "title": "IBM - United States", + "publication_date": "2016-08-01T18:25:43.511Z", + "feeds": [ + { + "link": "https://www.feed.example/rss" + } + ], + "authors": [ { - "type":"awardedTo", - "sentence":"Leonardo DiCaprio won Best Actor in a Leading Role for his performance.", - "score":0.6787, - "arguments":[ + "name": "Example G. Author" + } + ] + }, + "relations": [ + { + "type": "awardedTo", + "sentence": "Leonardo DiCaprio won Best Actor in a Leading Role for his performance.", + "score": 0.6787, + "arguments": [ + { + "text": "Best Actor", + "entities": [ { - "text":"Best Actor", - "entities":[ - { - "type":"EntertainmentAward", - "text":"Best Actor" - } - ] - }, + "type": "EntertainmentAward", + "text": "Best Actor" + } + ] + }, + { + "text": "Leonardo DiCaprio", + "entities": [ { - "text":"Leonardo DiCaprio", - "entities":[ - { - "type":"Person", - "text":"Leonardo DiCaprio" - } - ] + "type": "Person", + "text": "Leonardo DiCaprio" } - ] + ] + } + ] + } + ], + "semantic_roles": [ + { + "sentence": "IBM has one of the largest workforces in the world", + "subject": { + "text": "IBM" + }, + "action": { + "verb": { + "text": "have", + "tense": "present" + }, + "text": "has", + "normalized": "have" + }, + "object": { + "text": "one of the largest workforces in the world" } - ], - "semantic_roles":[ + } + ], + "sentiment": { + "document": { + "score": 0.256829 + }, + "targets": [ { - "sentence":"IBM has one of the largest workforces in the world", - "subject":{ - "text":"IBM" - }, - "action":{ - "verb":{ - "text":"have", - "tense":"present" - }, - "text":"has", - "normalized":"have" - }, - "object":{ - "text":"one of the largest workforces in the world" - } + "text": "stocks", + "score": 0.387744 + } + ] + }, + "keywords": [ + { + "text": "American multinational technology", + "sentiment": { + "score": 0.312231 + }, + "relevance": 0.993518, + "emotion": { + "sadness": 0.357113, + "joy": 0.221593, + "fear": 0.078444, + "disgust": 0.378436, + "anger": 0.067114 } - ], - "sentiment":{ - "document":{ - "score":0.256829 + }, + { + "text": "New York", + "sentiment": { + "score": 0 }, - "targets":[ - { - "text":"stocks", - "score":0.387744 - } + "relevance": 0.613816, + "emotion": { + "sadness": 0.350735, + "joy": 0.48397, + "fear": 0.145972, + "disgust": 0.023062, + "anger": 0.039178 + } + } + ], + "entities": [ + { + "type": "Company", + "text": "IBM", + "sentiment": { + "score": 0.312231 + }, + "relevance": 0.33, + "emotion": { + "sadness": 0.357113, + "joy": 0.221593, + "fear": 0.078444, + "disgust": 0.378436, + "anger": 0.067114 + }, + "disambiguation": { + "subtype": [ + "SoftwareLicense", + "OperatingSystemDeveloper", + "ProcessorManufacturer", + "SoftwareDeveloper", + "CompanyFounder", + "ProgrammingLanguageDesigner", + "ProgrammingLanguageDeveloper" + ], + "name": "IBM", + "dbpedia_resource": "http://dbpedia.org/resource/IBM" + }, + "count": 1, + "confidence": 0.5, + "mentions": [ + { + "text": "text", + "location": [ + 0 + ], + "confidence": 0.5 + } ] - }, - "keywords":[ + } + ], + "syntax": { + "tokens": [ { - "text":"American multinational technology", - "sentiment":{ - "score":0.312231 - }, - "relevance":0.993518, - "emotion":{ - "sadness":0.357113, - "joy":0.221593, - "fear":0.078444, - "disgust":0.378436, - "anger":0.067114 - } + "text": "Ginni", + "part_of_speech": "PROPN", + "location": [ + 0, + 5 + ] }, { - "text":"New York", - "sentiment":{ - "score":0 - }, - "relevance":0.613816, - "emotion":{ - "sadness":0.350735, - "joy":0.48397, - "fear":0.145972, - "disgust":0.023062, - "anger":0.039178 - } - } - ], - "entities":[ - { - "type":"Company", - "text":"IBM", - "sentiment":{ - "score":0.312231 - }, - "relevance":0.33, - "emotion":{ - "sadness":0.357113, - "joy":0.221593, - "fear":0.078444, - "disgust":0.378436, - "anger":0.067114 - }, - "disambiguation":{ - "subtype":[ - "SoftwareLicense", - "OperatingSystemDeveloper", - "ProcessorManufacturer", - "SoftwareDeveloper", - "CompanyFounder", - "ProgrammingLanguageDesigner", - "ProgrammingLanguageDeveloper" - ], - "name":"IBM", - "dbpedia_resource":"http://dbpedia.org/resource/IBM" - }, - "count":1 + "text": "Rometty", + "part_of_speech": "PROPN", + "location": [ + 6, + 13 + ] } - ] + ] + } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..6083d66d424 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,838 @@ +{ + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "@babel/code-frame": { + "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.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.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", + "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.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": "^9.0.0", + "lodash": "^4.17.4" + } + }, + "@semantic-release/error": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@semantic-release/error/-/error-2.2.0.tgz", + "integrity": "sha512-9Tj/qn+y2j+sjCI3Jd+qseGtHjOAeg7dU2/lVcqIQ9TV3QDaDXDYXcoOHU+7o2Hwh8L8ymL4gfuO7KxDs3q2zg==" + }, + "@semantic-release/exec": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/exec/-/exec-5.0.0.tgz", + "integrity": "sha512-t7LWXIvDJQbuGCy2WmMG51WyaGSLTvZBv9INvcI4S0kn+QjnnVVUMhcioIqhb0r3yqqarMzHVcABFug0q0OXjw==", + "requires": { + "@semantic-release/error": "^2.1.0", + "aggregate-error": "^3.0.0", + "debug": "^4.0.0", + "execa": "^4.0.0", + "lodash": "^4.17.4", + "parse-json": "^5.0.0" + } + }, + "@semantic-release/git": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@semantic-release/git/-/git-9.0.0.tgz", + "integrity": "sha512-AZ4Zha5NAPAciIJH3ipzw/WU9qLAn8ENaoVAhD6srRPxTpTzuV3NhNh14rcAo8Paj9dO+5u4rTKcpetOBluYVw==", + "requires": { + "@semantic-release/error": "^2.1.0", + "aggregate-error": "^3.0.0", + "debug": "^4.0.0", + "dir-glob": "^3.0.0", + "execa": "^4.0.0", + "lodash": "^4.17.4", + "micromatch": "^4.0.0", + "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.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" + } + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "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", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==" + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "cross-spawn": { + "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", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "requires": { + "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", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "requires": { + "path-type": "^4.0.0" + } + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "execa": { + "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", + "human-signals": "^1.1.1", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.0", + "onetime": "^5.1.0", + "signal-exit": "^3.0.2", + "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", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "fs-extra": { + "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": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "get-stream": { + "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.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", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==" + }, + "is-arrayish": { + "version": "0.2.1", + "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", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==" + }, + "isexe": { + "version": "2.0.0", + "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-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": "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", + "universalify": "^2.0.0" + } + }, + "lines-and-columns": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=" + }, + "lodash": { + "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.4", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", + "integrity": "sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg==", + "requires": { + "braces": "^3.0.1", + "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", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "ms": { + "version": "2.1.2", + "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", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "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.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-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==" + }, + "picomatch": { + "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", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", + "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", + "requires": { + "end-of-stream": "^1.1.0", + "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", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit": { + "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", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "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": "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", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/personality-insights/README.md b/personality-insights/README.md deleted file mode 100755 index 2de12488bc2..00000000000 --- a/personality-insights/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# Personality Insights - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - personality-insights - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:personality-insights:6.1.0' -``` - -## 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 -PersonalityInsights service = new PersonalityInsights("2016-10-19"); -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(); -System.out.println(profile); -``` - -**Note:** Don't forget to update the `text` variable! - -[personality_insights]: https://console.bluemix.net/docs/services/personality-insights/index.html diff --git a/personality-insights/build.gradle b/personality-insights/build.gradle deleted file mode 100644 index 30c93752665..00000000000 --- a/personality-insights/build.gradle +++ /dev/null @@ -1,112 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'personality-insights' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Personality Insights Service' - url 'https://console.bluemix.net/docs/services/personality-insights/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java deleted file mode 100644 index 0ffdf26c076..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsights.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3; - -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import java.io.InputStream; - -/** - * 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://console.bluemix.net/docs/services/personality-insights/models.html). - * * For information about the meaning of the consumption preferences, see [Consumption - * preferences](https://console.bluemix.net/docs/services/personality-insights/preferences.html). - * - * **Note:** Request logging is disabled for the Personality Insights service. The service neither logs nor retains data - * from requests and responses, regardless of whether the `X-Watson-Learning-Opt-Out` request header is set. - * - * @version v3 - * @see Personality Insights - */ -public class PersonalityInsights extends WatsonService { - - private static final String SERVICE_NAME = "personality_insights"; - private static final String URL = "https://gateway.watsonplatform.net/personality-insights/api"; - - private String versionDate; - - /** - * Instantiates a new `PersonalityInsights`. - * - * @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) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `PersonalityInsights` with username and password. - * - * @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 username the username - * @param password the password - */ - public PersonalityInsights(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `PersonalityInsights` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public PersonalityInsights(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * 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; for more information, see [Providing - * sufficient input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient). The - * service analyzes text in Arabic, English, Japanese, Korean, or Spanish and returns its results in a variety of - * languages. You can provide plain text, HTML, or JSON input by specifying the **Content-Type** parameter; the - * default is `text/plain`. Request a JSON or comma-separated values (CSV) response by specifying the **Accept** - * parameter; CSV output includes a fixed number of columns and optional headers. - * - * 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 detailed information about calling the service and the responses it can generate, see [Requesting a - * profile](https://console.bluemix.net/docs/services/personality-insights/input.html), [Understanding a JSON - * profile](https://console.bluemix.net/docs/services/personality-insights/output.html), and [Understanding a CSV - * profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). - * - * @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) { - Validator.notNull(profileOptions, "profileOptions cannot be null"); - String[] pathSegments = { "v3/profile" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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.consumptionPreferences() != null) { - builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); - } - if (profileOptions.contentType().equalsIgnoreCase(ProfileOptions.ContentType.APPLICATION_JSON)) { - builder.bodyJson(GsonSingleton.getGson().toJsonTree(profileOptions.content()).getAsJsonObject()); - } else { - builder.bodyContent(profileOptions.body(), profileOptions.contentType()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Profile.class)); - } - - /** - * 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; for more information, see [Providing - * sufficient input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient). The - * service analyzes text in Arabic, English, Japanese, Korean, or Spanish and returns its results in a variety of - * languages. You can provide plain text, HTML, or JSON input by specifying the **Content-Type** parameter; the - * default is `text/plain`. Request a JSON or comma-separated values (CSV) response by specifying the **Accept** - * parameter; CSV output includes a fixed number of columns and optional headers. - * - * 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 detailed information about calling the service and the responses it can generate, see [Requesting a - * profile](https://console.bluemix.net/docs/services/personality-insights/input.html), [Understanding a JSON - * profile](https://console.bluemix.net/docs/services/personality-insights/output.html), and [Understanding a CSV - * profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html). - * - * @param profileOptions the {@link ProfileOptions} containing the options for the call - * @param includeHeaders the boolean saying whether or not to include headers in the response - * @return a {@link ServiceCall} with a response type of {@link InputStream} - */ - public ServiceCall profileAsCsv(ProfileOptions profileOptions, boolean includeHeaders) { - Validator.notNull(profileOptions, "profileOptions cannot be null"); - String[] pathSegments = { "v3/profile" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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.consumptionPreferences() != null) { - builder.query("consumption_preferences", String.valueOf(profileOptions.consumptionPreferences())); - } - if (profileOptions.contentType().equalsIgnoreCase(ProfileOptions.ContentType.APPLICATION_JSON)) { - builder.bodyJson(GsonSingleton.getGson().toJsonTree(profileOptions.content()).getAsJsonObject()); - } else { - builder.bodyContent(profileOptions.body(), profileOptions.contentType()); - } - - builder.header(HttpHeaders.ACCEPT, HttpMediaType.TEXT_CSV); - builder.query("csv_headers", includeHeaders); - - return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream()); - } - -} diff --git a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Behavior.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Behavior.java deleted file mode 100644 index 1fa60de1ee9..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Behavior.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Behavior. - */ -public class Behavior extends GenericModel { - - @SerializedName("trait_id") - private String traitId; - private String name; - private String category; - private 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/developer_cloud/personality_insights/v3/model/ConsumptionPreferences.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ConsumptionPreferences.java deleted file mode 100644 index c587a0f7c5d..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ConsumptionPreferences.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ConsumptionPreferences. - */ -public class ConsumptionPreferences extends GenericModel { - - @SerializedName("consumption_preference_id") - private String consumptionPreferenceId; - private String name; - private 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/developer_cloud/personality_insights/v3/model/ConsumptionPreferencesCategory.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ConsumptionPreferencesCategory.java deleted file mode 100644 index ce15138cee7..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ConsumptionPreferencesCategory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ConsumptionPreferencesCategory. - */ -public class ConsumptionPreferencesCategory extends GenericModel { - - @SerializedName("consumption_preference_category_id") - private String consumptionPreferenceCategoryId; - private String name; - @SerializedName("consumption_preferences") - private 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/developer_cloud/personality_insights/v3/model/Content.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Content.java deleted file mode 100644 index f8685060638..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Content.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * Content. - */ -public class Content extends GenericModel { - - private List contentItems; - - /** - * Builder. - */ - public static class Builder { - private List contentItems; - - private Builder(Content content) { - 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) { - 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; - } - } - - private Content(Builder builder) { - 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/developer_cloud/personality_insights/v3/model/ContentItem.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ContentItem.java deleted file mode 100644 index 848d7a49da7..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ContentItem.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * ContentItem. - */ -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"; - } - - 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; - - /** - * 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) { - content = contentItem.content; - id = contentItem.id; - created = contentItem.created; - updated = contentItem.updated; - contenttype = contentItem.contenttype; - language = contentItem.language; - parentid = contentItem.parentid; - reply = contentItem.reply; - 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; - } - } - - private ContentItem(Builder builder) { - 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/developer_cloud/personality_insights/v3/model/Profile.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Profile.java deleted file mode 100644 index d2fc4c058f2..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Profile.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Profile. - */ -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") - private String processedLanguage; - @SerializedName("word_count") - private Long wordCount; - @SerializedName("word_count_message") - private String wordCountMessage; - private List personality; - private List needs; - private List values; - private List behavior; - @SerializedName("consumption_preferences") - private List consumptionPreferences; - private 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. - * - * Warning messages associated with the input text submitted with 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/developer_cloud/personality_insights/v3/model/ProfileOptions.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java deleted file mode 100644 index 90483b30051..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/ProfileOptions.java +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The profile options. - */ -public class ProfileOptions extends GenericModel { - - /** - * The type of the input: application/json, text/html, or text/plain. A character encoding can be specified by - * including a `charset` parameter. For example, 'text/html;charset=utf-8'. - */ - public interface ContentType { - /** application/json. */ - String APPLICATION_JSON = "application/json"; - /** text/html. */ - String TEXT_HTML = "text/html"; - /** text/plain. */ - String TEXT_PLAIN = "text/plain"; - } - - /** - * 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"; - } - - private Content content; - private String body; - private String contentType; - private String contentLanguage; - private String acceptLanguage; - private Boolean rawScores; - private 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 consumptionPreferences; - - private Builder(ProfileOptions profileOptions) { - content = profileOptions.content; - body = profileOptions.body; - contentType = profileOptions.contentType; - contentLanguage = profileOptions.contentLanguage; - acceptLanguage = profileOptions.acceptLanguage; - rawScores = profileOptions.rawScores; - 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 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 = ProfileOptions.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 = ProfileOptions.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 = ProfileOptions.ContentType.TEXT_PLAIN; - return this; - } - } - - private ProfileOptions(Builder builder) { - Validator.isTrue(builder.contentType != null, "contentType cannot be null"); - content = builder.content; - body = builder.body; - contentType = builder.contentType; - contentLanguage = builder.contentLanguage; - acceptLanguage = builder.acceptLanguage; - rawScores = builder.rawScores; - 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://console.bluemix.net/docs/services/personality-insights/input.html#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://console.bluemix.net/docs/services/personality-insights/input.html#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: application/json, text/html, or text/plain. A character encoding can be specified by - * including a `charset` parameter. For example, 'text/html;charset=utf-8'. - * - * @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 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/developer_cloud/personality_insights/v3/model/Trait.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Trait.java deleted file mode 100644 index 6404ba05716..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Trait.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Trait. - */ -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") - private String traitId; - private String name; - private String category; - private Double percentile; - @SerializedName("raw_score") - private Double rawScore; - private Boolean significant; - private 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/developer_cloud/personality_insights/v3/model/Warning.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Warning.java deleted file mode 100644 index b3641552316..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/model/Warning.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Warning. - */ -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") - private String warningId; - private 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/developer_cloud/personality_insights/v3/package-info.java b/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/package-info.java deleted file mode 100644 index 4be02e1e2f0..00000000000 --- a/personality-insights/src/main/java/com/ibm/watson/developer_cloud/personality_insights/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.personality_insights.v3; diff --git a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsIT.java b/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsIT.java deleted file mode 100644 index ec412470124..00000000000 --- a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsIT.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Arrays; -import java.util.Date; -import java.util.UUID; - -import com.google.common.io.CharStreams; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ConsumptionPreferences; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Content; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions; - -/** - * 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_DATE_2016_10_19 = "2016-10-19"; - - /* - * (non-Javadoc) - * @see com.ibm.watson.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("personality_insights.username"); - String password = getProperty("personality_insights.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new PersonalityInsights(VERSION_DATE_2016_10_19); - service.setUsernameAndPassword(username, password); - service.setEndPoint(getProperty("personality_insights.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test example in Readme. - */ - @Test - public void testReadme() { - // PersonalityInsights service = new PersonalityInsights("2016-10-19"); - // 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(); - 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(); - - 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, false).execute(); - 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).build(); - InputStream result = service.profileAsCsv(options, true).execute(); - 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(Arrays.asList(cItem)).build(); - ProfileOptions options = new ProfileOptions.Builder() - .content(content) - .consumptionPreferences(true) - .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .rawScores(true) - .build(); - Profile profile = service.profile(options).execute(); - - 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).getChildren()); - 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(Arrays.asList(cItem)) - .build(); - ProfileOptions options = new ProfileOptions.Builder() - .content(content) - .consumptionPreferences(true) - .rawScores(true) - .build(); - Profile profile = service.profile(options).execute(); - - 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(); - assertProfile(profile); - } -} diff --git a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java b/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java deleted file mode 100644 index 1a7a82d3b88..00000000000 --- a/personality-insights/src/test/java/com/ibm/watson/developer_cloud/personality_insights/v3/PersonalityInsightsTest.java +++ /dev/null @@ -1,237 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.personality_insights.v3; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.io.FileNotFoundException; -import java.util.Date; -import java.util.UUID; - -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Content; -import org.junit.Before; -import org.junit.Test; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ContentItem; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile; -import com.ibm.watson.developer_cloud.personality_insights.v3.model.ProfileOptions; - -import okhttp3.mockwebserver.RecordedRequest; - -/** - * 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 = "2016-10-19"; - 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, "", ""); - service.setEndPoint(getMockWebServerUrl()); - } - - /** - * Negative - Test constructor with null version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithNullVersionDate() { - new PersonalityInsights(null); - } - - /** - * Negative - Test constructor with empty version date. - */ - @Test(expected = IllegalArgumentException.class) - public void testConstructorWithEmptyVersionDate() { - new PersonalityInsights(""); - } - - /** - * 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2016-10-19", 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2016-10-19", request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("en", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT.toString(), 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PROFILE_PATH + "?version=2016-10-19&raw_scores=true&consumption_preferences=true", request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals("es", request.getHeader(HttpHeaders.CONTENT_LANGUAGE)); - assertEquals(HttpMediaType.TEXT.toString(), 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); - } - - /** - * Negative - Test profile options builder without content (of any type). - */ - @Test(expected = IllegalArgumentException.class) - public void testProfileOptionsBuilderWithoutContent() { - final ProfileOptions options = new ProfileOptions.Builder() - .contentLanguage(ProfileOptions.ContentLanguage.ES) - .acceptLanguage(ProfileOptions.AcceptLanguage.EN) - .build(); - } -} 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/settings.gradle b/settings.gradle deleted file mode 100644 index 7669733fe39..00000000000 --- a/settings.gradle +++ /dev/null @@ -1,4 +0,0 @@ -rootProject.name = 'parent' -include ':assistant', ':conversation', ':core', ':discovery', ':language-translator', ':natural-language-classifier', - ':natural-language-understanding', ':personality-insights', ':speech-to-text', ':text-to-speech', - ':tone-analyzer', ':visual-recognition', ':java-sdk' diff --git a/speech-to-text/README.md b/speech-to-text/README.md index 96ea315871f..1776270acf3 100755 --- a/speech-to-text/README.md +++ b/speech-to-text/README.md @@ -3,25 +3,28 @@ ## Installation ##### Maven + ```xml - com.ibm.watson.developer_cloud + com.ibm.watson speech-to-text - 6.1.0 + 16.1.0 ``` ##### Gradle + ```gradle -'com.ibm.watson.developer_cloud:speech-to-text:6.1.0' +'com.ibm.watson:speech-to-text:16.1.0' ``` ## Usage + Use the [Speech to Text][speech_to_text] service to recognize the text from a .wav file. ```java -SpeechToText service = new SpeechToText(); -service.setUsernameAndPassword("", ""); +Authenticator authenticator = new IamAuthenticator(""); +SpeechToText service = new SpeechToText(authenticator); File audio = new File("src/test/resources/sample1.wav"); @@ -30,29 +33,28 @@ RecognizeOptions options = new RecognizeOptions.Builder() .contentType(HttpMediaType.AUDIO_WAV) .build(); -SpeechRecognitionResults transcript = service.recognize(options).execute(); +SpeechRecognitionResults transcript = service.recognize(options).execute().getResult(); 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 -SpeechToText service = new SpeechToText(); -service.setUsernameAndPassword("", ""); +Authenticator authenticator = new IamAuthenticator(""); +SpeechToText service = new SpeechToText(authenticator); 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() { @Override - public void onTranscription(SpeechRecognitionResults speechResults) { + public void onTranscription(Response speechResults) { System.out.println(speechResults); } }); @@ -60,51 +62,5 @@ service.recognizeUsingWebSocket(options, new BaseRecognizeCallback() { // wait 20 seconds for the asynchronous response Thread.sleep(20000); ``` -#### Microphone example -Use your microphone to recognize audio for 30 seconds. - -```java -SpeechToText service = new SpeechToText(); -service.setUsernameAndPassword("", ""); - -// Signed PCM AudioFormat with 16kHz, 16 bit sample size, mono -int sampleRate = 16000; -AudioFormat format = new AudioFormat(sampleRate, 16, 1, true, false); -DataLine.Info info = new DataLine.Info(TargetDataLine.class, format); - -if (!AudioSystem.isLineSupported(info)) { - System.out.println("Line not supported"); - System.exit(0); -} - -TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); -line.open(format); -line.start(); - -AudioInputStream audio = new AudioInputStream(line); - -RecognizeOptions options = new RecognizeOptions.Builder() - .interimResults(true) -//.inactivityTimeout(5) // use this to stop listening when the speaker pauses, i.e. for 5s - .audio(audio) - .contentType(HttpMediaType.AUDIO_RAW + "; rate=" + sampleRate) - .build(); - -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); - -// closing the WebSockets underlying InputStream will close the WebSocket itself. -line.stop(); -line.close(); - -System.out.println("Fin."); -``` -[speech_to_text]: https://console.bluemix.net/docs/services/speech-to-text/index.html +[speech_to_text]: https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-about diff --git a/speech-to-text/build.gradle b/speech-to-text/build.gradle deleted file mode 100644 index 4b205c0f70b..00000000000 --- a/speech-to-text/build.gradle +++ /dev/null @@ -1,117 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'speech-to-text' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Speech to Text Service' - url 'https://console.bluemix.net/docs/services/speech-to-text/index.html' - - 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' - } - - 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' - } - } - } - } - } -} 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/developer_cloud/speech_to_text/v1/SpeechToText.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java deleted file mode 100644 index da43726ff0f..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToText.java +++ /dev/null @@ -1,1519 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.InputStreamRequestBody; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CheckJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CheckJobsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpora; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListAcousticModelsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListLanguageModelsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListModelsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJob; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RegisterCallbackOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RegisterStatus; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ResetAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ResetLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UnregisterCallbackOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UpgradeAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UpgradeLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.SpeechToTextWebSocketListener; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import okhttp3.HttpUrl; -import okhttp3.MediaType; -import okhttp3.MultipartBody; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.WebSocket; - -/** - * The IBM® Speech to Text service provides an API that uses IBM's speech-recognition capabilities to produce - * transcripts of spoken audio. The service can transcribe speech from various languages and audio formats. It addition - * to basic transcription, the service can produce detailed information about many aspects of the audio. For most - * languages, the service supports two sampling rates, broadband and narrowband. It returns all JSON response content in - * the UTF-8 character set. For more information about the service, see the [IBM® Cloud - * documentation](https://console.bluemix.net/docs/services/speech-to-text/index.html). - * - * ### API usage guidelines - * * **Audio formats:** The service accepts audio in many formats (MIME types). See [Audio - * formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). - * * **HTTP interfaces:** The service provides three HTTP interfaces for speech recognition. The sessionless interface - * includes a single synchronous method. The session-based interface includes multiple synchronous methods for - * maintaining a long, multi-turn exchange with the service. And the asynchronous interface provides multiple methods - * that use registered callbacks and polling for non-blocking recognition. See [The HTTP REST - * interface](https://console.bluemix.net/docs/services/speech-to-text/http.html) and [The asynchronous HTTP - * interface](https://console.bluemix.net/docs/services/speech-to-text/async.html). - * * **WebSocket interface:** The service also offers a WebSocket interface for speech recognition. The WebSocket - * interface provides a full-duplex, low-latency communication channel. Clients send requests and audio to the service - * and receive results over a single connection in an asynchronous fashion. See [The WebSocket - * interface](https://console.bluemix.net/docs/services/speech-to-text/websockets.html). - * * **Customization:** 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. - * Language model customization is generally available for production use by most supported languages; acoustic model - * customization is beta functionality that is available for all supported languages. See [The customization - * interface](https://console.bluemix.net/docs/services/speech-to-text/custom.html). - * * **Customization IDs:** Many methods accept a customization ID to identify a custom language or custom acoustic - * model. Customization IDs are Globally Unique Identifiers (GUIDs). They are hexadecimal strings that have the format - * `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. - * * **`X-Watson-Learning-Opt-Out`:** By default, all Watson services log requests and their results. Logging is done - * only to improve the services for future users. The logged data is not shared or made public. To prevent IBM from - * accessing your data for general service improvements, set the `X-Watson-Learning-Opt-Out` request header to `true` - * for all requests. You must set the header on each request that you do not want IBM to access for general service - * improvements. - * - * Methods of the customization interface do not log corpora, words, and audio resources that you use to build custom - * models. Your training data is never used to improve the service's base models. However, the service does log such - * data when a custom model is used with a recognition request. You must set the `X-Watson-Learning-Opt-Out` request - * header to `true` to prevent IBM from accessing the data to improve the service. - * * **`X-Watson-Metadata`**: This header allows you to associate a customer ID with data that is passed with a request. - * If necessary, you can use the **Delete labeled data** method to delete the data for a customer ID. See [Information - * security](https://console.bluemix.net/docs/services/speech-to-text/information-security.html). - * - * @version v1 - * @see Speech to Text - */ -public class SpeechToText extends WatsonService { - - private static final String SERVICE_NAME = "speech_to_text"; - private static final String URL = "https://stream.watsonplatform.net/speech-to-text/api"; - - /** - * Instantiates a new `SpeechToText`. - * - */ - public SpeechToText() { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - } - - /** - * Instantiates a new `SpeechToText` with username and password. - * - * @param username the username - * @param password the password - */ - public SpeechToText(String username, String password) { - this(); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `SpeechToText` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @param iamOptions the options for authenticating through IAM - */ - public SpeechToText(IamOptions iamOptions) { - this(); - setIamCredentials(iamOptions); - } - - /** - * Get a model. - * - * Retrieves information about 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. - * - * @param getModelOptions the {@link GetModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModel} - */ - public ServiceCall getModel(GetModelOptions getModelOptions) { - Validator.notNull(getModelOptions, "getModelOptions cannot be null"); - String[] pathSegments = { "v1/models" }; - String[] pathParameters = { getModelOptions.modelId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SpeechModel.class)); - } - - /** - * List models. - * - * Retrieves a list of 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. - * - * @param listModelsOptions the {@link ListModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} - */ - public ServiceCall listModels(ListModelsOptions listModelsOptions) { - String[] pathSegments = { "v1/models" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listModelsOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SpeechModels.class)); - } - - /** - * List models. - * - * Retrieves a list of 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. - * - * @return a {@link ServiceCall} with a response type of {@link SpeechModels} - */ - public ServiceCall listModels() { - return listModels(null); - } - - /** - * Recognize audio (sessionless). - * - * Sends audio and returns transcription results for a sessionless recognition request. Returns only the final - * results; to enable interim results, use session-based requests or the WebSocket API. The service imposes a data - * size limit of 100 MB. It 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.) - * - * ### 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 server closes the connection (status code 408) if the - * service receives no data chunk for 30 seconds and the service has no audio to transcribe for 30 seconds. The server - * also closes the connection (status code 400) if no speech is detected for `inactivity_timeout` seconds of audio - * (not processing time); use the `inactivity_timeout` parameter to change the default of 30 seconds. - * - * ### Audio formats (content types) - * - * Use the `Content-Type` header to specify the audio format (MIME type) of the audio. The service accepts the - * following formats: - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `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` - * - * For information about the supported audio formats, including specifying the sampling rate, channels, and endianness - * for the indicated formats, see [Audio - * formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). - * - * ### Multipart speech recognition - * - * The method also supports multipart recognition requests. 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. - * - * The multipart approach is intended for use 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. - * - * For information about submitting a multipart request, see [Submitting multipart requests as form - * data](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-multi). - * - * @param recognizeOptions the {@link RecognizeOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link SpeechRecognitionResults} - */ - public ServiceCall recognize(RecognizeOptions recognizeOptions) { - Validator.notNull(recognizeOptions, "recognizeOptions cannot be null"); - String[] pathSegments = { "v1/recognize" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.header("Content-Type", recognizeOptions.contentType()); - if (recognizeOptions.model() != null) { - builder.query("model", recognizeOptions.model()); - } - if (recognizeOptions.customizationId() != null) { - builder.query("customization_id", recognizeOptions.customizationId()); - } - if (recognizeOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", recognizeOptions.acousticCustomizationId()); - } - if (recognizeOptions.baseModelVersion() != null) { - builder.query("base_model_version", recognizeOptions.baseModelVersion()); - } - if (recognizeOptions.customizationWeight() != null) { - builder.query("customization_weight", String.valueOf(recognizeOptions.customizationWeight())); - } - if (recognizeOptions.inactivityTimeout() != null) { - builder.query("inactivity_timeout", String.valueOf(recognizeOptions.inactivityTimeout())); - } - if (recognizeOptions.keywords() != null) { - builder.query("keywords", RequestUtils.join(recognizeOptions.keywords(), ",")); - } - if (recognizeOptions.keywordsThreshold() != null) { - builder.query("keywords_threshold", String.valueOf(recognizeOptions.keywordsThreshold())); - } - if (recognizeOptions.maxAlternatives() != null) { - builder.query("max_alternatives", String.valueOf(recognizeOptions.maxAlternatives())); - } - if (recognizeOptions.wordAlternativesThreshold() != null) { - builder.query("word_alternatives_threshold", String.valueOf(recognizeOptions - .wordAlternativesThreshold())); - } - if (recognizeOptions.wordConfidence() != null) { - builder.query("word_confidence", String.valueOf(recognizeOptions.wordConfidence())); - } - if (recognizeOptions.timestamps() != null) { - builder.query("timestamps", String.valueOf(recognizeOptions.timestamps())); - } - if (recognizeOptions.profanityFilter() != null) { - builder.query("profanity_filter", String.valueOf(recognizeOptions.profanityFilter())); - } - if (recognizeOptions.smartFormatting() != null) { - builder.query("smart_formatting", String.valueOf(recognizeOptions.smartFormatting())); - } - if (recognizeOptions.speakerLabels() != null) { - builder.query("speaker_labels", String.valueOf(recognizeOptions.speakerLabels())); - } - builder.body(InputStreamRequestBody.create(MediaType.parse(recognizeOptions.contentType()), - recognizeOptions.audio())); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(SpeechRecognitionResults.class)); - } - - /** - * 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) { - Validator.notNull(recognizeOptions, "recognizeOptions cannot be null"); - Validator.notNull(recognizeOptions.audio(), "audio cannot be null"); - Validator.notNull(callback, "callback cannot be null"); - - HttpUrl.Builder urlBuilder = HttpUrl.parse(getEndPoint() + "/v1/recognize").newBuilder(); - - if (recognizeOptions.model() != null) { - urlBuilder.addQueryParameter("model", recognizeOptions.model()); - } - if (recognizeOptions.customizationId() != null) { - urlBuilder.addQueryParameter("customization_id", recognizeOptions.customizationId()); - } - if (recognizeOptions.acousticCustomizationId() != null) { - urlBuilder.addQueryParameter("acoustic_customization_id", recognizeOptions.acousticCustomizationId()); - } - if (recognizeOptions.baseModelVersion() != null) { - urlBuilder.addQueryParameter("base_model_version", recognizeOptions.baseModelVersion()); - } - if (recognizeOptions.customizationWeight() != null) { - urlBuilder.addQueryParameter("customization_weight", - String.valueOf(recognizeOptions.customizationWeight())); - } - - 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)); - } - - /** - * 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 submit the request with the service credentials of the user who created the job. - * - * 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 user. - * - * @param checkJobOptions the {@link CheckJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} - */ - public ServiceCall checkJob(CheckJobOptions checkJobOptions) { - Validator.notNull(checkJobOptions, "checkJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - String[] pathParameters = { checkJobOptions.id() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(RecognitionJob.class)); - } - - /** - * Check jobs. - * - * Returns the ID and status of the latest 100 outstanding jobs associated with the service 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. - * - * @param checkJobsOptions the {@link CheckJobsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} - */ - public ServiceCall checkJobs(CheckJobsOptions checkJobsOptions) { - String[] pathSegments = { "v1/recognitions" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (checkJobsOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(RecognitionJobs.class)); - } - - /** - * Check jobs. - * - * Returns the ID and status of the latest 100 outstanding jobs associated with the service 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. - * - * @return a {@link ServiceCall} with a response type of {@link RecognitionJobs} - */ - public ServiceCall checkJobs() { - return checkJobs(null); - } - - /** - * Create a job. - * - * Creates a job for a new asynchronous recognition request. The job is owned by the user whose service 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. For detailed usage information - * about the two approaches, including callback notifications, see [Creating a - * job](https://console.bluemix.net/docs/services/speech-to-text/async.html#create). 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. The service imposes - * a data size limit of 100 MB. It 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.) - * - * ### Audio formats (content types) - * - * Use the `Content-Type` parameter to specify the audio format (MIME type) of the audio: - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `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` - * - * For information about the supported audio formats, including specifying the sampling rate, channels, and endianness - * for the indicated formats, see [Audio - * formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). - * - * @param createJobOptions the {@link CreateJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RecognitionJob} - */ - public ServiceCall createJob(CreateJobOptions createJobOptions) { - Validator.notNull(createJobOptions, "createJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.header("Content-Type", createJobOptions.contentType()); - if (createJobOptions.model() != null) { - builder.query("model", createJobOptions.model()); - } - if (createJobOptions.callbackUrl() != null) { - builder.query("callback_url", createJobOptions.callbackUrl()); - } - if (createJobOptions.events() != null) { - builder.query("events", createJobOptions.events()); - } - if (createJobOptions.userToken() != null) { - builder.query("user_token", createJobOptions.userToken()); - } - if (createJobOptions.resultsTtl() != null) { - builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); - } - if (createJobOptions.customizationId() != null) { - builder.query("customization_id", createJobOptions.customizationId()); - } - if (createJobOptions.acousticCustomizationId() != null) { - builder.query("acoustic_customization_id", createJobOptions.acousticCustomizationId()); - } - if (createJobOptions.baseModelVersion() != null) { - builder.query("base_model_version", createJobOptions.baseModelVersion()); - } - if (createJobOptions.customizationWeight() != null) { - builder.query("customization_weight", String.valueOf(createJobOptions.customizationWeight())); - } - if (createJobOptions.inactivityTimeout() != null) { - builder.query("inactivity_timeout", String.valueOf(createJobOptions.inactivityTimeout())); - } - if (createJobOptions.keywords() != null) { - builder.query("keywords", RequestUtils.join(createJobOptions.keywords(), ",")); - } - if (createJobOptions.keywordsThreshold() != null) { - builder.query("keywords_threshold", String.valueOf(createJobOptions.keywordsThreshold())); - } - if (createJobOptions.maxAlternatives() != null) { - builder.query("max_alternatives", String.valueOf(createJobOptions.maxAlternatives())); - } - if (createJobOptions.wordAlternativesThreshold() != null) { - builder.query("word_alternatives_threshold", String.valueOf(createJobOptions.wordAlternativesThreshold())); - } - if (createJobOptions.wordConfidence() != null) { - builder.query("word_confidence", String.valueOf(createJobOptions.wordConfidence())); - } - if (createJobOptions.timestamps() != null) { - builder.query("timestamps", String.valueOf(createJobOptions.timestamps())); - } - if (createJobOptions.profanityFilter() != null) { - builder.query("profanity_filter", String.valueOf(createJobOptions.profanityFilter())); - } - if (createJobOptions.smartFormatting() != null) { - builder.query("smart_formatting", String.valueOf(createJobOptions.smartFormatting())); - } - if (createJobOptions.speakerLabels() != null) { - builder.query("speaker_labels", String.valueOf(createJobOptions.speakerLabels())); - } - builder.body(InputStreamRequestBody.create(MediaType.parse(createJobOptions.contentType()), createJobOptions - .audio())); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(RecognitionJob.class)); - } - - /** - * 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 submit the request with the service credentials of the user who created the job. - * - * @param deleteJobOptions the {@link DeleteJobOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { - Validator.notNull(deleteJobOptions, "deleteJobOptions cannot be null"); - String[] pathSegments = { "v1/recognitions" }; - String[] pathParameters = { deleteJobOptions.id() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 - * 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. For more information, see [Registering a - * callback URL](https://console.bluemix.net/docs/services/speech-to-text/async.html#register). - * - * @param registerCallbackOptions the {@link RegisterCallbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link RegisterStatus} - */ - public ServiceCall registerCallback(RegisterCallbackOptions registerCallbackOptions) { - Validator.notNull(registerCallbackOptions, "registerCallbackOptions cannot be null"); - String[] pathSegments = { "v1/register_callback" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query("callback_url", registerCallbackOptions.callbackUrl()); - if (registerCallbackOptions.userSecret() != null) { - builder.query("user_secret", registerCallbackOptions.userSecret()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(RegisterStatus.class)); - } - - /** - * 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. - * - * @param unregisterCallbackOptions the {@link UnregisterCallbackOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall unregisterCallback(UnregisterCallbackOptions unregisterCallbackOptions) { - Validator.notNull(unregisterCallbackOptions, "unregisterCallbackOptions cannot be null"); - String[] pathSegments = { "v1/unregister_callback" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query("callback_url", unregisterCallbackOptions.callbackUrl()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param createLanguageModelOptions the {@link CreateLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} - */ - public ServiceCall createLanguageModel(CreateLanguageModelOptions createLanguageModelOptions) { - Validator.notNull(createLanguageModelOptions, "createLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createLanguageModelOptions.name()); - contentJson.addProperty("base_model_name", createLanguageModelOptions.baseModelName()); - if (createLanguageModelOptions.dialect() != null) { - contentJson.addProperty("dialect", createLanguageModelOptions.dialect()); - } - if (createLanguageModelOptions.description() != null) { - contentJson.addProperty("description", createLanguageModelOptions.description()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LanguageModel.class)); - } - - /** - * 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 to the model, is currently being processed. You must use credentials for the instance of the service that - * owns a model to delete it. - * - * @param deleteLanguageModelOptions the {@link DeleteLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteLanguageModel(DeleteLanguageModelOptions deleteLanguageModelOptions) { - Validator.notNull(deleteLanguageModelOptions, "deleteLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { deleteLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param getLanguageModelOptions the {@link GetLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModel} - */ - public ServiceCall getLanguageModel(GetLanguageModelOptions getLanguageModelOptions) { - Validator.notNull(getLanguageModelOptions, "getLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { getLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LanguageModel.class)); - } - - /** - * 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. - * - * @param listLanguageModelsOptions the {@link ListLanguageModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} - */ - public ServiceCall listLanguageModels(ListLanguageModelsOptions listLanguageModelsOptions) { - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listLanguageModelsOptions != null) { - if (listLanguageModelsOptions.language() != null) { - builder.query("language", listLanguageModelsOptions.language()); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(LanguageModels.class)); - } - - /** - * 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. - * - * @return a {@link ServiceCall} with a response type of {@link LanguageModels} - */ - public ServiceCall listLanguageModels() { - return listLanguageModels(null); - } - - /** - * Reset a custom language model. - * - * Resets a custom language model by removing all corpora 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. - * - * @param resetLanguageModelOptions the {@link ResetLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLanguageModelOptions) { - Validator.notNull(resetLanguageModelOptions, "resetLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "reset" }; - String[] pathParameters = { resetLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * Train a custom language model. - * - * Initiates the training of a custom language model with new corpora, custom words, or both. After adding, modifying, - * or deleting corpora or words 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. 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 **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 - * `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 corpora or words, until the existing - * request completes. - * - * 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 words to the model. - * * No training data (corpora or words) have been added to the custom model. - * * One or more words that were added to the custom model have invalid sounds-like pronunciations that you must fix. - * - * @param trainLanguageModelOptions the {@link TrainLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall trainLanguageModel(TrainLanguageModelOptions trainLanguageModelOptions) { - Validator.notNull(trainLanguageModelOptions, "trainLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "train" }; - String[] pathParameters = { trainLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (trainLanguageModelOptions.wordTypeToAdd() != null) { - builder.query("word_type_to_add", trainLanguageModelOptions.wordTypeToAdd()); - } - if (trainLanguageModelOptions.customizationWeight() != null) { - builder.query("customization_weight", String.valueOf(trainLanguageModelOptions.customizationWeight())); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 **List a custom language model** method to poll the model's status. - * 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 more information, see [Upgrading custom - * models](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html). - * - * @param upgradeLanguageModelOptions the {@link UpgradeLanguageModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall upgradeLanguageModel(UpgradeLanguageModelOptions upgradeLanguageModelOptions) { - Validator.notNull(upgradeLanguageModelOptions, "upgradeLanguageModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "upgrade_model" }; - String[] pathParameters = { upgradeLanguageModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. For guidelines about adding a corpus text file and for - * information about how the service parses a corpus file, see [Preparing a corpus text - * file](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#prepareCorpus). - * - * 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 corpora or words 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 any word that is 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, using 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 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 corpora combined. Also, you can add no more than 30 thousand custom (OOV) words to a model; this - * includes words that the service extracts from corpora and words that you add directly. - * - * @param addCorpusOptions the {@link AddCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { - Validator.notNull(addCorpusOptions, "addCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { addCorpusOptions.customizationId(), addCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (addCorpusOptions.allowOverwrite() != null) { - builder.query("allow_overwrite", String.valueOf(addCorpusOptions.allowOverwrite())); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - String corpusFileContentType = addCorpusOptions.corpusFileContentType() == null - ? "text/plain" : addCorpusOptions.corpusFileContentType(); - RequestBody corpusFileBody = RequestUtils.inputStreamBody(addCorpusOptions.corpusFile(), corpusFileContentType); - multipartBuilder.addFormDataPart("corpus_file", addCorpusOptions.corpusFilename(), corpusFileBody); - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * Delete a corpus. - * - * Deletes an existing corpus from a custom language model. The service removes any out-of-vocabulary (OOV) words - * associated with the corpus from the custom model's words resource unless they were also added by another corpus or - * they have been 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. - * - * @param deleteCorpusOptions the {@link DeleteCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { - Validator.notNull(deleteCorpusOptions, "deleteCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { deleteCorpusOptions.customizationId(), deleteCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param getCorpusOptions the {@link GetCorpusOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpus} - */ - public ServiceCall getCorpus(GetCorpusOptions getCorpusOptions) { - Validator.notNull(getCorpusOptions, "getCorpusOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { getCorpusOptions.customizationId(), getCorpusOptions.corpusName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Corpus.class)); - } - - /** - * 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. - * - * @param listCorporaOptions the {@link ListCorporaOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Corpora} - */ - public ServiceCall listCorpora(ListCorporaOptions listCorporaOptions) { - Validator.notNull(listCorporaOptions, "listCorporaOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "corpora" }; - String[] pathParameters = { listCorporaOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Corpora.class)); - } - - /** - * 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 found in each corpus 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 30 thousand - * custom (OOV) words, including words that the service extracts from corpora 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. For information about pronunciation - * rules, see [Using the sounds_like - * field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#soundsLike). - * * 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 corpora training data. For - * example, you might indicate that the word `IBM(trademark)` is to be displayed as `IBM™`. For more - * information, see [Using the display_as - * field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#displayAs). - * - * - * 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. - * - * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addWord(AddWordOptions addWordOptions) { - Validator.notNull(addWordOptions, "addWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordOptions.customizationId(), addWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - if (addWordOptions.word() != null) { - contentJson.addProperty("word", addWordOptions.word()); - } - if (addWordOptions.soundsLike() != null) { - contentJson.add("sounds_like", GsonSingleton.getGson().toJsonTree(addWordOptions.soundsLike())); - } - if (addWordOptions.displayAs() != null) { - contentJson.addProperty("display_as", addWordOptions.displayAs()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 found in each corpus 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 30 thousand custom (OOV) words, including words that the service extracts from corpora 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 `Words` object, which is an array of `Word` 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. For information about pronunciation - * rules, see [Using the sounds_like - * field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#soundsLike). - * * 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 corpora training data. For - * example, you might indicate that the word `IBM(trademark)` is to be displayed as `IBM™`. For more - * information, see [Using the display_as - * field](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#displayAs). - * - * - * 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 training a model. - * - * 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 - * accept requests to add new corpora or words 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. - * - * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addWords(AddWordsOptions addWordsOptions) { - Validator.notNull(addWordsOptions, "addWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - contentJson.add("words", GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 - * must use credentials for the instance of the service that owns a model to delete its words. - * - * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { - Validator.notNull(deleteWordOptions, "deleteWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 query information about its words. - * - * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Word} - */ - public ServiceCall getWord(GetWordOptions getWordOptions) { - Validator.notNull(getWordOptions, "getWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.wordName() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Word.class)); - } - - /** - * 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. You can also indicate the order in which the service is to return words; by - * default, words are listed in ascending alphabetical order. You must use credentials for the instance of the service - * that owns a model to query information about its words. - * - * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} - */ - public ServiceCall listWords(ListWordsOptions listWordsOptions) { - Validator.notNull(listWordsOptions, "listWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { listWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (listWordsOptions.wordType() != null) { - builder.query("word_type", listWordsOptions.wordType()); - } - if (listWordsOptions.sort() != null) { - builder.query("sort", listWordsOptions.sort()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Words.class)); - } - - /** - * 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. - * - * @param createAcousticModelOptions the {@link CreateAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} - */ - public ServiceCall createAcousticModel(CreateAcousticModelOptions createAcousticModelOptions) { - Validator.notNull(createAcousticModelOptions, "createAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createAcousticModelOptions.name()); - contentJson.addProperty("base_model_name", createAcousticModelOptions.baseModelName()); - if (createAcousticModelOptions.description() != null) { - contentJson.addProperty("description", createAcousticModelOptions.description()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AcousticModel.class)); - } - - /** - * 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. - * - * @param deleteAcousticModelOptions the {@link DeleteAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteAcousticModel(DeleteAcousticModelOptions deleteAcousticModelOptions) { - Validator.notNull(deleteAcousticModelOptions, "deleteAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - String[] pathParameters = { deleteAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param getAcousticModelOptions the {@link GetAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModel} - */ - public ServiceCall getAcousticModel(GetAcousticModelOptions getAcousticModelOptions) { - Validator.notNull(getAcousticModelOptions, "getAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations" }; - String[] pathParameters = { getAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AcousticModel.class)); - } - - /** - * 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. - * - * @param listAcousticModelsOptions the {@link ListAcousticModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} - */ - public ServiceCall listAcousticModels(ListAcousticModelsOptions listAcousticModelsOptions) { - String[] pathSegments = { "v1/acoustic_customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listAcousticModelsOptions != null) { - if (listAcousticModelsOptions.language() != null) { - builder.query("language", listAcousticModelsOptions.language()); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AcousticModels.class)); - } - - /** - * 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. - * - * @return a {@link ServiceCall} with a response type of {@link AcousticModels} - */ - public ServiceCall listAcousticModels() { - return listAcousticModels(null); - } - - /** - * 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. You must use credentials for the - * instance of the service that owns a model to reset it. - * - * @param resetAcousticModelOptions the {@link ResetAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcousticModelOptions) { - Validator.notNull(resetAcousticModelOptions, "resetAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "reset" }; - String[] pathParameters = { resetAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 **List 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 `Customization` 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 accept subsequent training requests, or requests to add new audio resources, until the - * existing 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. Specify 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 information about creating a separate - * custom language model, see [Creating a custom language - * model](https://console.bluemix.net/docs/services/speech-to-text/language-create.html). - * - * 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 50 hours of audio data. - * * One or more of the custom model's audio resources is invalid. - * - * @param trainAcousticModelOptions the {@link TrainAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall trainAcousticModel(TrainAcousticModelOptions trainAcousticModelOptions) { - Validator.notNull(trainAcousticModelOptions, "trainAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "train" }; - String[] pathParameters = { trainAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (trainAcousticModelOptions.customLanguageModelId() != null) { - builder.query("custom_language_model_id", trainAcousticModelOptions.customLanguageModelId()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 **List a custom acoustic model** method to poll the model's status. - * 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 accept subsequent requests for the model until the upgrade 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. - * - * For more information, see [Upgrading custom - * models](https://console.bluemix.net/docs/services/speech-to-text/custom-upgrade.html). - * - * @param upgradeAcousticModelOptions the {@link UpgradeAcousticModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall upgradeAcousticModel(UpgradeAcousticModelOptions upgradeAcousticModelOptions) { - Validator.notNull(upgradeAcousticModelOptions, "upgradeAcousticModelOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "upgrade_model" }; - String[] pathParameters = { upgradeAcousticModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (upgradeAcousticModelOptions.customLanguageModelId() != null) { - builder.query("custom_language_model_id", upgradeAcousticModelOptions.customLanguageModelId()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. But the addition of one audio resource must be fully complete before you can add another. - * You must add a minimum of 10 minutes and a maximum of 50 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 add additional audio resources to a custom acoustic model, or to train the model, until the - * service's analysis of all audio files for the current request completes. - * - * To determine the status of the service's analysis of the audio, use the **List an audio resource** method to poll - * the status of the audio. The method accepts the GUID 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`. - * - * ### 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: - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `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` - * - * For information about the supported audio formats, including specifying the sampling rate, channels, and endianness - * for the indicated formats, see [Audio - * formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). - * - * **Note:** 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`. - * - * ### 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. - * - * All audio files contained in the archive must have the same audio format. Use the `Contained-Content-Type` - * parameter to specify the format of the contained audio files. The parameter accepts all of the audio formats - * supported for use with speech recognition and with the `Content-Type` header, including the `rate`, `channels`, and - * `endianness` parameters that are used with some formats. The default contained audio format is `audio/wav`. - * - * @param addAudioOptions the {@link AddAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addAudio(AddAudioOptions addAudioOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - builder.header("Content-Type", addAudioOptions.contentType()); - if (addAudioOptions.containedContentType() != null) { - builder.header("Contained-Content-Type", addAudioOptions.containedContentType()); - } - if (addAudioOptions.allowOverwrite() != null) { - builder.query("allow_overwrite", String.valueOf(addAudioOptions.allowOverwrite())); - } - builder.body(InputStreamRequestBody.create(MediaType.parse(addAudioOptions.contentType()), addAudioOptions - .audioResource())); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 current interface 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** method. You must use credentials for the instance of the service - * that owns a model to delete its audio resources. - * - * @param deleteAudioOptions the {@link DeleteAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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 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, which is important for checking the service's - * analysis of the resource in response to a request to add it to the custom model. You must use credentials for the - * instance of the service that owns a model to list its audio resources. - * - * @param getAudioOptions the {@link GetAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioListing} - */ - public ServiceCall getAudio(GetAudioOptions getAudioOptions) { - 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(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AudioListing.class)); - } - - /** - * 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. - * - * @param listAudioOptions the {@link ListAudioOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link AudioResources} - */ - public ServiceCall listAudio(ListAudioOptions listAudioOptions) { - Validator.notNull(listAudioOptions, "listAudioOptions cannot be null"); - String[] pathSegments = { "v1/acoustic_customizations", "audio" }; - String[] pathParameters = { listAudioOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(AudioResources.class)); - } - - /** - * 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. - * - * You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes the - * data. For more information about customer IDs and about using this method, see [Information - * security](https://console.bluemix.net/docs/services/speech-to-text/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModel.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModel.java deleted file mode 100644 index 8396a748c37..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModel.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AcousticModel. - */ -public class AcousticModel extends GenericModel { - - /** - * The current status of the custom acoustic model: - * * `pending` indicates that the model was created but is waiting either for training data to be added or for the - * service to finish analyzing added data. - * * `ready` indicates that the model contains data and is ready to be trained. - * * `training` indicates that the model is currently being trained. - * * `available` indicates that the model is trained and ready to use. - * * `upgrading` indicates that the model is currently being upgraded. - * * `failed` indicates that training of the model failed. - */ - public interface Status { - /** pending. */ - String PENDING = "pending"; - /** ready. */ - String READY = "ready"; - /** training. */ - String TRAINING = "training"; - /** available. */ - String AVAILABLE = "available"; - /** upgrading. */ - String UPGRADING = "upgrading"; - /** failed. */ - String FAILED = "failed"; - } - - @SerializedName("customization_id") - private String customizationId; - private String created; - private String language; - private List versions; - private String owner; - private String name; - private String description; - @SerializedName("base_model_name") - private String baseModelName; - private String status; - private Long progress; - private String warnings; - - /** - * 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. - * - * @return the customizationId - */ - public String getCustomizationId() { - return customizationId; - } - - /** - * 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`). - * - * @return the created - */ - public String getCreated() { - return created; - } - - /** - * Gets the language. - * - * The language identifier of the custom acoustic model (for example, `en-US`). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * 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. - * - * @return the versions - */ - public List getVersions() { - return versions; - } - - /** - * Gets the owner. - * - * The GUID of the service credentials for the instance of the service that owns the custom acoustic model. - * - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the name. - * - * The name of the custom acoustic model. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the description. - * - * The description of the custom acoustic model. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the baseModelName. - * - * The name of the language model for which the custom acoustic model was created. - * - * @return the baseModelName - */ - public String getBaseModelName() { - return baseModelName; - } - - /** - * Gets the status. - * - * The current status of the custom acoustic model: - * * `pending` indicates that the model was created but is waiting either for training data to be added or for the - * service to finish analyzing added data. - * * `ready` indicates that the model contains data and is ready to be trained. - * * `training` indicates that the model is currently being trained. - * * `available` indicates that the model is trained and ready to use. - * * `upgrading` indicates that the model is currently being upgraded. - * * `failed` indicates that training of the model failed. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * 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. - * - * @return the progress - */ - public Long getProgress() { - return progress; - } - - /** - * 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. - * - * @return the warnings - */ - public String getWarnings() { - return warnings; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModels.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModels.java deleted file mode 100644 index c300f48f627..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AcousticModels.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AcousticModels. - */ -public class AcousticModels extends GenericModel { - - private List customizations; - - /** - * Gets the customizations. - * - * An array of objects that provides information about each available custom acoustic model. The array is empty if the - * requesting service credentials own no custom acoustic models (if no language is specified) or own no custom - * acoustic models for the specified language. - * - * @return the customizations - */ - public List getCustomizations() { - return customizations; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddAudioOptions.java deleted file mode 100644 index 1e48b8bc747..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddAudioOptions.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addAudio options. - */ -public class AddAudioOptions extends GenericModel { - - /** - * The type of the input: application/zip, application/gzip, audio/basic, audio/flac, audio/l16, audio/mp3, - * audio/mpeg, audio/mulaw, audio/ogg, audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, - * audio/webm;codecs=opus, or audio/webm;codecs=vorbis. - */ - public interface ContentType { - /** application/zip. */ - String APPLICATION_ZIP = "application/zip"; - /** application/gzip. */ - String APPLICATION_GZIP = "application/gzip"; - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - /** - * For an archive-type resource, specifies the format of the audio files contained in the archive file. The parameter - * accepts all of the audio formats supported for use with speech recognition, including the `rate`, `channels`, and - * `endianness` parameters that are used with some formats. For a complete list of supported audio formats, see [Audio - * formats](/docs/services/speech-to-text/input.html#formats). - */ - public interface ContainedContentType { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - private String customizationId; - private String audioName; - private InputStream audioResource; - private String contentType; - private String containedContentType; - private Boolean allowOverwrite; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String audioName; - private InputStream audioResource; - private String contentType; - private String containedContentType; - private Boolean allowOverwrite; - - private Builder(AddAudioOptions addAudioOptions) { - customizationId = addAudioOptions.customizationId; - audioName = addAudioOptions.audioName; - audioResource = addAudioOptions.audioResource; - contentType = addAudioOptions.contentType; - containedContentType = addAudioOptions.containedContentType; - allowOverwrite = addAudioOptions.allowOverwrite; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param audioName the audioName - */ - public Builder(String customizationId, String audioName) { - this.customizationId = customizationId; - this.audioName = audioName; - } - - /** - * Builds a AddAudioOptions. - * - * @return the addAudioOptions - */ - public AddAudioOptions build() { - return new AddAudioOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the AddAudioOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the audioName. - * - * @param audioName the audioName - * @return the AddAudioOptions builder - */ - public Builder audioName(String audioName) { - this.audioName = audioName; - return this; - } - - /** - * Set the audioResource. - * - * @param audioResource the audioResource - * @return the AddAudioOptions builder - */ - public Builder audioResource(InputStream audioResource) { - this.audioResource = audioResource; - return this; - } - - /** - * Set the contentType. - * - * @param contentType the contentType - * @return the AddAudioOptions builder - */ - public Builder contentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Set the containedContentType. - * - * @param containedContentType the containedContentType - * @return the AddAudioOptions builder - */ - public Builder containedContentType(String containedContentType) { - this.containedContentType = containedContentType; - return this; - } - - /** - * Set the allowOverwrite. - * - * @param allowOverwrite the allowOverwrite - * @return the AddAudioOptions builder - */ - public Builder allowOverwrite(Boolean allowOverwrite) { - this.allowOverwrite = allowOverwrite; - return this; - } - - /** - * Set the audioResource. - * - * @param audioResource the audioResource - * @return the AddAudioOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder audioResource(File audioResource) throws FileNotFoundException { - this.audioResource = new FileInputStream(audioResource); - return this; - } - } - - private AddAudioOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.audioName, "audioName cannot be empty"); - Validator.isTrue(builder.contentType != null, "contentType cannot be null"); - customizationId = builder.customizationId; - audioName = builder.audioName; - audioResource = builder.audioResource; - contentType = builder.contentType; - containedContentType = builder.containedContentType; - allowOverwrite = builder.allowOverwrite; - } - - /** - * New builder. - * - * @return a AddAudioOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the audioName. - * - * The name of the audio resource for the custom acoustic model. When adding an audio resource, do not include spaces - * in the name; use a localized name that matches the language of the custom model. - * - * @return the audioName - */ - public String audioName() { - return audioName; - } - - /** - * Gets the audioResource. - * - * @return the audioResource - */ - public InputStream audioResource() { - return audioResource; - } - - /** - * Gets the contentType. - * - * The type of the input: application/zip, application/gzip, audio/basic, audio/flac, audio/l16, audio/mp3, - * audio/mpeg, audio/mulaw, audio/ogg, audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, - * audio/webm;codecs=opus, or audio/webm;codecs=vorbis. - * - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * Gets the containedContentType. - * - * For an archive-type resource, specifies the format of the audio files contained in the archive file. The parameter - * accepts all of the audio formats supported for use with speech recognition, including the `rate`, `channels`, and - * `endianness` parameters that are used with some formats. For a complete list of supported audio formats, see [Audio - * formats](/docs/services/speech-to-text/input.html#formats). - * - * @return the containedContentType - */ - public String containedContentType() { - return containedContentType; - } - - /** - * Gets the allowOverwrite. - * - * If `true`, the specified corpus or audio resource overwrites an existing corpus or audio resource with the same - * name. If `false` (the default), the request fails if a corpus or audio resource with the same name already exists. - * The parameter has no effect if a corpus or audio resource with the same name does not already exist. - * - * @return the allowOverwrite - */ - public Boolean allowOverwrite() { - return allowOverwrite; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddCorpusOptions.java deleted file mode 100644 index f3b3d6527f4..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddCorpusOptions.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addCorpus options. - */ -public class AddCorpusOptions extends GenericModel { - - private String customizationId; - private String corpusName; - private InputStream corpusFile; - private String corpusFilename; - private Boolean allowOverwrite; - private String corpusFileContentType; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String corpusName; - private InputStream corpusFile; - private String corpusFilename; - private Boolean allowOverwrite; - private String corpusFileContentType; - - private Builder(AddCorpusOptions addCorpusOptions) { - customizationId = addCorpusOptions.customizationId; - corpusName = addCorpusOptions.corpusName; - corpusFile = addCorpusOptions.corpusFile; - corpusFilename = addCorpusOptions.corpusFilename; - allowOverwrite = addCorpusOptions.allowOverwrite; - corpusFileContentType = addCorpusOptions.corpusFileContentType; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param corpusName the corpusName - * @param corpusFile the corpusFile - */ - public Builder(String customizationId, String corpusName, InputStream corpusFile) { - this.customizationId = customizationId; - this.corpusName = corpusName; - this.corpusFile = corpusFile; - } - - /** - * Builds a AddCorpusOptions. - * - * @return the addCorpusOptions - */ - public AddCorpusOptions build() { - return new AddCorpusOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the AddCorpusOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the corpusName. - * - * @param corpusName the corpusName - * @return the AddCorpusOptions builder - */ - public Builder corpusName(String corpusName) { - this.corpusName = corpusName; - return this; - } - - /** - * Set the corpusFileContentType. - * - * @param corpusFileContentType the corpusFileContentType - * @return the AddCorpusOptions builder - */ - public Builder corpusFileContentType(String corpusFileContentType) { - this.corpusFileContentType = corpusFileContentType; - return this; - } - - /** - * Set the corpusFile. - * - * @param corpusFile the corpusFile - * @return the AddCorpusOptions builder - */ - public Builder corpusFile(InputStream corpusFile) { - this.corpusFile = corpusFile; - return this; - } - - /** - * Set the corpusFilename. - * - * @param corpusFilename the corpusFilename - * @return the AddCorpusOptions builder - */ - public Builder corpusFilename(String corpusFilename) { - this.corpusFilename = corpusFilename; - return this; - } - - /** - * Set the allowOverwrite. - * - * @param allowOverwrite the allowOverwrite - * @return the AddCorpusOptions builder - */ - public Builder allowOverwrite(Boolean allowOverwrite) { - this.allowOverwrite = allowOverwrite; - return this; - } - - /** - * Set the corpusFile. - * - * @param corpusFile the corpusFile - * @return the AddCorpusOptions builder - * - * @throws FileNotFoundException if the file could not be found - */ - public Builder corpusFile(File corpusFile) throws FileNotFoundException { - this.corpusFile = new FileInputStream(corpusFile); - this.corpusFilename = corpusFile.getName(); - return this; - } - } - - private AddCorpusOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.corpusName, "corpusName cannot be empty"); - Validator.notNull(builder.corpusFile, "corpusFile cannot be null"); - customizationId = builder.customizationId; - corpusName = builder.corpusName; - corpusFile = builder.corpusFile; - corpusFilename = builder.corpusFilename; - allowOverwrite = builder.allowOverwrite; - corpusFileContentType = builder.corpusFileContentType; - } - - /** - * New builder. - * - * @return a AddCorpusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the corpusName. - * - * The name of the corpus for the custom language model. When adding a corpus, do not include spaces in the name; use - * a localized name that matches the language of the custom model; and do not use the name `user`, which is reserved - * by the service to denote custom words added or modified by the user. - * - * @return the corpusName - */ - public String corpusName() { - return 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. With cURL, use the - * `--data-binary` option to upload the file for the request. - * - * @return the corpusFile - */ - public InputStream corpusFile() { - return corpusFile; - } - - /** - * Gets the corpusFilename. - * - * The filename for corpusFile. - * - * @return the corpusFilename - */ - public String corpusFilename() { - return corpusFilename; - } - - /** - * Gets the allowOverwrite. - * - * If `true`, the specified corpus or audio resource overwrites an existing corpus or audio resource with the same - * name. If `false` (the default), the request fails if a corpus or audio resource with the same name already exists. - * The parameter has no effect if a corpus or audio resource with the same name does not already exist. - * - * @return the allowOverwrite - */ - public Boolean allowOverwrite() { - return allowOverwrite; - } - - /** - * Gets the corpusFileContentType. - * - * The content type of corpusFile. Values for this parameter can be obtained from the HttpMediaType class. - * - * @return the corpusFileContentType - */ - public String corpusFileContentType() { - return corpusFileContentType; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordOptions.java deleted file mode 100644 index a49f866314a..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordOptions.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addWord options. - */ -public class AddWordOptions extends GenericModel { - - private String customizationId; - private String wordName; - private String word; - private List soundsLike; - private String displayAs; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String wordName; - private String word; - private List soundsLike; - private String displayAs; - - private Builder(AddWordOptions addWordOptions) { - customizationId = addWordOptions.customizationId; - wordName = addWordOptions.wordName; - word = addWordOptions.word; - soundsLike = addWordOptions.soundsLike; - displayAs = addWordOptions.displayAs; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param wordName the wordName - */ - public Builder(String customizationId, String wordName) { - this.customizationId = customizationId; - this.wordName = wordName; - } - - /** - * Builds a AddWordOptions. - * - * @return the addWordOptions - */ - public AddWordOptions build() { - return new AddWordOptions(this); - } - - /** - * Adds an soundsLike to soundsLike. - * - * @param soundsLike the new soundsLike - * @return the AddWordOptions builder - */ - public Builder addSoundsLike(String soundsLike) { - Validator.notNull(soundsLike, "soundsLike cannot be null"); - if (this.soundsLike == null) { - this.soundsLike = new ArrayList(); - } - this.soundsLike.add(soundsLike); - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the AddWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the wordName. - * - * @param wordName the wordName - * @return the AddWordOptions builder - */ - public Builder wordName(String wordName) { - this.wordName = wordName; - return this; - } - - /** - * Set the word. - * - * @param word the word - * @return the AddWordOptions builder - */ - public Builder word(String word) { - this.word = word; - return this; - } - - /** - * Set the soundsLike. - * Existing soundsLike will be replaced. - * - * @param soundsLike the soundsLike - * @return the AddWordOptions builder - */ - public Builder soundsLike(List soundsLike) { - this.soundsLike = soundsLike; - return this; - } - - /** - * Set the displayAs. - * - * @param displayAs the displayAs - * @return the AddWordOptions builder - */ - public Builder displayAs(String displayAs) { - this.displayAs = displayAs; - return this; - } - } - - private AddWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.wordName, "wordName cannot be empty"); - customizationId = builder.customizationId; - wordName = builder.wordName; - word = builder.word; - soundsLike = builder.soundsLike; - displayAs = builder.displayAs; - } - - /** - * New builder. - * - * @return a AddWordOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the wordName. - * - * The custom word for the custom language model. When you add or update a custom word with the **Add a custom word** - * method, do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of compound - * words. - * - * @return the wordName - */ - public String wordName() { - return 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. - * - * Omit this field for the **Add a custom word** method. - * - * @return the word - */ - public String word() { - return word; - } - - /** - * 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. A word can have at most five sounds-like pronunciations, and a pronunciation can include - * at most 40 characters not including spaces. - * - * @return the soundsLike - */ - public List soundsLike() { - return 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. - * - * @return the displayAs - */ - public String displayAs() { - return displayAs; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordsOptions.java deleted file mode 100644 index 22555bebaca..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AddWordsOptions.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addWords options. - */ -public class AddWordsOptions extends GenericModel { - - private String customizationId; - private List words; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private List words; - - private Builder(AddWordsOptions addWordsOptions) { - customizationId = addWordsOptions.customizationId; - words = addWordsOptions.words; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param words the words - */ - public Builder(String customizationId, List words) { - this.customizationId = customizationId; - this.words = words; - } - - /** - * Builds a AddWordsOptions. - * - * @return the addWordsOptions - */ - public AddWordsOptions build() { - return new AddWordsOptions(this); - } - - /** - * Adds an words to words. - * - * @param words the new words - * @return the AddWordsOptions builder - */ - public Builder addWords(CustomWord words) { - Validator.notNull(words, "words cannot be null"); - if (this.words == null) { - this.words = new ArrayList(); - } - this.words.add(words); - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the AddWordsOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the words. - * Existing words will be replaced. - * - * @param words the words - * @return the AddWordsOptions builder - */ - public Builder words(List words) { - this.words = words; - return this; - } - } - - private AddWordsOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notNull(builder.words, "words cannot be null"); - customizationId = builder.customizationId; - words = builder.words; - } - - /** - * New builder. - * - * @return a AddWordsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the words. - * - * An array of objects that provides information about each custom word that is to be added to or updated in the - * custom language model. - * - * @return the words - */ - public List words() { - return words; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioDetails.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioDetails.java deleted file mode 100644 index 899dce083bf..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioDetails.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AudioDetails. - */ -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 - * that does not contain audio, such as a JPEG file). - */ - public interface Type { - /** audio. */ - String AUDIO = "audio"; - /** archive. */ - String ARCHIVE = "archive"; - /** undetermined. */ - String UNDETERMINED = "undetermined"; - } - - /** - * **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. - */ - public interface Compression { - /** zip. */ - String ZIP = "zip"; - /** gzip. */ - String GZIP = "gzip"; - } - - private String type; - private String codec; - private Long frequency; - private String compression; - - /** - * 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 - * that does not contain audio, such as a JPEG file). - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Gets the codec. - * - * **For an audio-type resource,** the codec in which the audio is encoded. Omitted for an archive-type resource. - * - * @return the codec - */ - public String getCodec() { - return codec; - } - - /** - * 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. - * - * @return the frequency - */ - public Long getFrequency() { - return frequency; - } - - /** - * 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 - * - * Omitted for an audio-type resource. - * - * @return the compression - */ - public String getCompression() { - return compression; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioListing.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioListing.java deleted file mode 100644 index bda0761d57e..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioListing.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AudioListing. - */ -public class AudioListing extends GenericModel { - - /** - * **For an audio-type resource,** the status of the resource: - * * `ok` indicates that the service has successfully analyzed the audio data. The data can be used to train the - * custom model. - * * `being_processed` indicates that 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` indicates that 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. - */ - public interface Status { - /** ok. */ - String OK = "ok"; - /** being_processed. */ - String BEING_PROCESSED = "being_processed"; - /** invalid. */ - String INVALID = "invalid"; - } - - private Double duration; - private String name; - private AudioDetails details; - private String status; - private AudioResource container; - private List audio; - - /** - * Gets the duration. - * - * **For an audio-type resource,** the total seconds of audio in the resource. The value is always a whole number. - * Omitted for an archive-type resource. - * - * @return the duration - */ - public Double getDuration() { - return duration; - } - - /** - * Gets the name. - * - * **For an audio-type resource,** the user-specified name of the resource. Omitted for an archive-type resource. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * 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. - * - * @return the details - */ - public AudioDetails getDetails() { - return details; - } - - /** - * Gets the status. - * - * **For an audio-type resource,** the status of the resource: - * * `ok` indicates that the service has successfully analyzed the audio data. The data can be used to train the - * custom model. - * * `being_processed` indicates that 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` indicates that 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. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * 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. - * - * @return the container - */ - public AudioResource getContainer() { - return container; - } - - /** - * 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. - * - * @return the audio - */ - public List getAudio() { - return audio; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResource.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResource.java deleted file mode 100644 index fdbcf0c3f9f..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResource.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AudioResource. - */ -public class AudioResource extends GenericModel { - - /** - * The status of the audio resource: - * * `ok` indicates that the service has successfully analyzed the audio data. The data can be used to train the - * custom model. - * * `being_processed` indicates that 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` indicates that 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. */ - String OK = "ok"; - /** being_processed. */ - String BEING_PROCESSED = "being_processed"; - /** invalid. */ - String INVALID = "invalid"; - } - - private Double duration; - private String name; - private AudioDetails details; - private String status; - - /** - * Gets the duration. - * - * The total seconds of audio in the audio resource. The value is always a whole number. - * - * @return the duration - */ - public Double getDuration() { - return duration; - } - - /** - * Gets the name. - * - * **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. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * 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. - * - * @return the details - */ - public AudioDetails getDetails() { - return details; - } - - /** - * Gets the status. - * - * The status of the audio resource: - * * `ok` indicates that the service has successfully analyzed the audio data. The data can be used to train the - * custom model. - * * `being_processed` indicates that 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` indicates that 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 - */ - public String getStatus() { - return status; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResources.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResources.java deleted file mode 100644 index 1376cfb015f..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/AudioResources.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * AudioResources. - */ -public class AudioResources extends GenericModel { - - @SerializedName("total_minutes_of_audio") - private Double totalMinutesOfAudio; - private List audio; - - /** - * 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. - * - * @return the totalMinutesOfAudio - */ - public Double getTotalMinutesOfAudio() { - return totalMinutesOfAudio; - } - - /** - * 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. - * - * @return the audio - */ - public List getAudio() { - return audio; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobOptions.java deleted file mode 100644 index 425dce258f8..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The checkJob options. - */ -public class CheckJobOptions extends GenericModel { - - private String id; - - /** - * Builder. - */ - public static class Builder { - private String id; - - private Builder(CheckJobOptions checkJobOptions) { - id = checkJobOptions.id; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param id the id - */ - public Builder(String id) { - this.id = id; - } - - /** - * Builds a CheckJobOptions. - * - * @return the checkJobOptions - */ - public CheckJobOptions build() { - return new CheckJobOptions(this); - } - - /** - * Set the id. - * - * @param id the id - * @return the CheckJobOptions builder - */ - public Builder id(String id) { - this.id = id; - return this; - } - } - - private CheckJobOptions(Builder builder) { - Validator.notEmpty(builder.id, "id cannot be empty"); - id = builder.id; - } - - /** - * New builder. - * - * @return a CheckJobOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the id. - * - * The ID of the asynchronous job. - * - * @return the id - */ - public String id() { - return id; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobsOptions.java deleted file mode 100644 index 22c72726201..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CheckJobsOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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); - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpora.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpora.java deleted file mode 100644 index fcf2188ccf0..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpora.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Corpora. - */ -public class Corpora extends GenericModel { - - private List corpora; - - /** - * Gets the corpora. - * - * An array of 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 - */ - public List getCorpora() { - return corpora; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpus.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpus.java deleted file mode 100644 index 8b8dfa88385..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Corpus.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Corpus. - */ -public class Corpus extends GenericModel { - - /** - * The status of the corpus: - * * `analyzed` indicates that the service has successfully analyzed the corpus; the custom model can be trained with - * data from the corpus. - * * `being_processed` indicates that the service is still analyzing the corpus; the service cannot accept requests to - * add new corpora or words, or to train the custom model. - * * `undetermined` indicates that the service encountered an error while processing the corpus. - */ - public interface Status { - /** analyzed. */ - String ANALYZED = "analyzed"; - /** being_processed. */ - String BEING_PROCESSED = "being_processed"; - /** undetermined. */ - String UNDETERMINED = "undetermined"; - } - - private String name; - @SerializedName("total_words") - private Long totalWords; - @SerializedName("out_of_vocabulary_words") - private Long outOfVocabularyWords; - private String status; - private String error; - - /** - * Gets the name. - * - * The name of the corpus. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the totalWords. - * - * The total number of words in the corpus. The value is `0` while the corpus is being processed. - * - * @return the totalWords - */ - public Long getTotalWords() { - return totalWords; - } - - /** - * Gets the outOfVocabularyWords. - * - * The number of OOV words in the corpus. The value is `0` while the corpus is being processed. - * - * @return the outOfVocabularyWords - */ - public Long getOutOfVocabularyWords() { - return outOfVocabularyWords; - } - - /** - * Gets the status. - * - * The status of the corpus: - * * `analyzed` indicates that the service has successfully analyzed the corpus; the custom model can be trained with - * data from the corpus. - * * `being_processed` indicates that the service is still analyzing the corpus; the service cannot accept requests to - * add new corpora or words, or to train the custom model. - * * `undetermined` indicates that the service encountered an error while processing the corpus. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * 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'`. - * - * @return the error - */ - public String getError() { - return error; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateAcousticModelOptions.java deleted file mode 100644 index 2816b18e470..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateAcousticModelOptions.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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. To determine whether a base model supports acoustic model - * customization, refer to [Language support for - * customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport). - */ - public interface BaseModelName { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** ko-KR_BroadbandModel. */ - String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; - /** ko-KR_NarrowbandModel. */ - String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - private String name; - private String baseModelName; - private String description; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String baseModelName; - private String description; - - private Builder(CreateAcousticModelOptions createAcousticModelOptions) { - name = createAcousticModelOptions.name; - baseModelName = createAcousticModelOptions.baseModelName; - description = createAcousticModelOptions.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - * @param baseModelName the baseModelName - */ - public Builder(String name, String baseModelName) { - this.name = name; - this.baseModelName = baseModelName; - } - - /** - * Builds a CreateAcousticModelOptions. - * - * @return the createAcousticModelOptions - */ - public CreateAcousticModelOptions build() { - return new CreateAcousticModelOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateAcousticModelOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the baseModelName. - * - * @param baseModelName the baseModelName - * @return the CreateAcousticModelOptions builder - */ - public Builder baseModelName(String baseModelName) { - this.baseModelName = baseModelName; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateAcousticModelOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - private CreateAcousticModelOptions(Builder builder) { - Validator.notNull(builder.name, "name cannot be null"); - Validator.notNull(builder.baseModelName, "baseModelName cannot be null"); - name = builder.name; - baseModelName = builder.baseModelName; - description = builder.description; - } - - /** - * New builder. - * - * @return a CreateAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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`. - * - * @return the name - */ - public String name() { - return 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. To determine whether a base model supports acoustic model - * customization, refer to [Language support for - * customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport). - * - * @return the baseModelName - */ - public String baseModelName() { - return baseModelName; - } - - /** - * Gets the description. - * - * A description of the new custom acoustic model. Use a localized description that matches the language of the custom - * model. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateJobOptions.java deleted file mode 100644 index 33c10aab108..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateJobOptions.java +++ /dev/null @@ -1,798 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.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.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createJob options. - */ -public class CreateJobOptions extends GenericModel { - - /** - * The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, - * audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, or - * audio/webm;codecs=vorbis. - */ - public interface ContentType { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - /** - * The identifier of the model that is to be used for the recognition request or, for the **Create a session** method, - * with the new session. - */ - public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** ko-KR_BroadbandModel. */ - String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; - /** ko-KR_NarrowbandModel. */ - String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - /** - * 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. Omit the parameter to subscribe to the default events: `recognitions.started`, `recognitions.completed`, and - * `recognitions.failed`. The `recognitions.completed` and `recognitions.completed_with_results` events are - * incompatible; you can specify only of the two events. If the job does not include a callback URL, omit the - * parameter. - */ - public interface Events { - /** recognitions.started. */ - String RECOGNITIONS_STARTED = "recognitions.started"; - /** recognitions.completed. */ - String RECOGNITIONS_COMPLETED = "recognitions.completed"; - /** recognitions.completed_with_results. */ - String RECOGNITIONS_COMPLETED_WITH_RESULTS = "recognitions.completed_with_results"; - /** recognitions.failed. */ - String RECOGNITIONS_FAILED = "recognitions.failed"; - } - - private InputStream audio; - private String contentType; - private String model; - private String callbackUrl; - private String events; - private String userToken; - private Long resultsTtl; - private String customizationId; - 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 Boolean speakerLabels; - - /** - * Builder. - */ - public static class Builder { - private InputStream audio; - private String contentType; - private String model; - private String callbackUrl; - private String events; - private String userToken; - private Long resultsTtl; - private String customizationId; - 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 Boolean speakerLabels; - - private Builder(CreateJobOptions createJobOptions) { - audio = createJobOptions.audio; - contentType = createJobOptions.contentType; - model = createJobOptions.model; - callbackUrl = createJobOptions.callbackUrl; - events = createJobOptions.events; - userToken = createJobOptions.userToken; - resultsTtl = createJobOptions.resultsTtl; - customizationId = createJobOptions.customizationId; - acousticCustomizationId = createJobOptions.acousticCustomizationId; - baseModelVersion = createJobOptions.baseModelVersion; - customizationWeight = createJobOptions.customizationWeight; - inactivityTimeout = createJobOptions.inactivityTimeout; - keywords = createJobOptions.keywords; - keywordsThreshold = createJobOptions.keywordsThreshold; - maxAlternatives = createJobOptions.maxAlternatives; - wordAlternativesThreshold = createJobOptions.wordAlternativesThreshold; - wordConfidence = createJobOptions.wordConfidence; - timestamps = createJobOptions.timestamps; - profanityFilter = createJobOptions.profanityFilter; - smartFormatting = createJobOptions.smartFormatting; - speakerLabels = createJobOptions.speakerLabels; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CreateJobOptions. - * - * @return the createJobOptions - */ - public CreateJobOptions build() { - return new CreateJobOptions(this); - } - - /** - * Adds an keyword to keywords. - * - * @param keyword the new keyword - * @return the CreateJobOptions builder - */ - public Builder addKeyword(String keyword) { - 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 CreateJobOptions builder - */ - public Builder audio(InputStream audio) { - this.audio = audio; - return this; - } - - /** - * Set the contentType. - * - * @param contentType the contentType - * @return the CreateJobOptions builder - */ - public Builder contentType(String contentType) { - this.contentType = contentType; - return this; - } - - /** - * Set the model. - * - * @param model the model - * @return the CreateJobOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the callbackUrl. - * - * @param callbackUrl the callbackUrl - * @return the CreateJobOptions builder - */ - public Builder callbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - return this; - } - - /** - * Set the events. - * - * @param events the events - * @return the CreateJobOptions builder - */ - public Builder events(String events) { - this.events = events; - return this; - } - - /** - * Set the userToken. - * - * @param userToken the userToken - * @return the CreateJobOptions builder - */ - public Builder userToken(String userToken) { - this.userToken = userToken; - return this; - } - - /** - * Set the resultsTtl. - * - * @param resultsTtl the resultsTtl - * @return the CreateJobOptions builder - */ - public Builder resultsTtl(long resultsTtl) { - this.resultsTtl = resultsTtl; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the CreateJobOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the acousticCustomizationId. - * - * @param acousticCustomizationId the acousticCustomizationId - * @return the CreateJobOptions builder - */ - public Builder acousticCustomizationId(String acousticCustomizationId) { - this.acousticCustomizationId = acousticCustomizationId; - return this; - } - - /** - * Set the baseModelVersion. - * - * @param baseModelVersion the baseModelVersion - * @return the CreateJobOptions builder - */ - public Builder baseModelVersion(String baseModelVersion) { - this.baseModelVersion = baseModelVersion; - return this; - } - - /** - * Set the customizationWeight. - * - * @param customizationWeight the customizationWeight - * @return the CreateJobOptions builder - */ - public Builder customizationWeight(Double customizationWeight) { - this.customizationWeight = customizationWeight; - return this; - } - - /** - * Set the inactivityTimeout. - * - * @param inactivityTimeout the inactivityTimeout - * @return the CreateJobOptions 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 CreateJobOptions builder - */ - public Builder keywords(List keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the keywordsThreshold. - * - * @param keywordsThreshold the keywordsThreshold - * @return the CreateJobOptions builder - */ - public Builder keywordsThreshold(Float keywordsThreshold) { - this.keywordsThreshold = keywordsThreshold; - return this; - } - - /** - * Set the maxAlternatives. - * - * @param maxAlternatives the maxAlternatives - * @return the CreateJobOptions builder - */ - public Builder maxAlternatives(long maxAlternatives) { - this.maxAlternatives = maxAlternatives; - return this; - } - - /** - * Set the wordAlternativesThreshold. - * - * @param wordAlternativesThreshold the wordAlternativesThreshold - * @return the CreateJobOptions builder - */ - public Builder wordAlternativesThreshold(Float wordAlternativesThreshold) { - this.wordAlternativesThreshold = wordAlternativesThreshold; - return this; - } - - /** - * Set the wordConfidence. - * - * @param wordConfidence the wordConfidence - * @return the CreateJobOptions builder - */ - public Builder wordConfidence(Boolean wordConfidence) { - this.wordConfidence = wordConfidence; - return this; - } - - /** - * Set the timestamps. - * - * @param timestamps the timestamps - * @return the CreateJobOptions builder - */ - public Builder timestamps(Boolean timestamps) { - this.timestamps = timestamps; - return this; - } - - /** - * Set the profanityFilter. - * - * @param profanityFilter the profanityFilter - * @return the CreateJobOptions builder - */ - public Builder profanityFilter(Boolean profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - * Set the smartFormatting. - * - * @param smartFormatting the smartFormatting - * @return the CreateJobOptions builder - */ - public Builder smartFormatting(Boolean smartFormatting) { - this.smartFormatting = smartFormatting; - return this; - } - - /** - * Set the speakerLabels. - * - * @param speakerLabels the speakerLabels - * @return the CreateJobOptions builder - */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; - 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 { - this.audio = new FileInputStream(audio); - return this; - } - } - - private CreateJobOptions(Builder builder) { - Validator.isTrue(builder.contentType != null, "contentType cannot be null"); - audio = builder.audio; - contentType = builder.contentType; - model = builder.model; - callbackUrl = builder.callbackUrl; - events = builder.events; - userToken = builder.userToken; - resultsTtl = builder.resultsTtl; - customizationId = builder.customizationId; - 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; - speakerLabels = builder.speakerLabels; - } - - /** - * New builder. - * - * @return a CreateJobOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the audio. - * - * @return the audio - */ - public InputStream audio() { - return audio; - } - - /** - * Gets the contentType. - * - * The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, - * audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, or - * audio/webm;codecs=vorbis. - * - * @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 or, for the **Create a session** method, - * with the new session. - * - * @return the model - */ - public String model() { - return 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. Omit the parameter to poll the service for job completion and results. You can - * include the same callback URL with any number of job creation requests. 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 - */ - public String callbackUrl() { - return 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. Omit the parameter to subscribe to the default events: `recognitions.started`, `recognitions.completed`, and - * `recognitions.failed`. The `recognitions.completed` and `recognitions.completed_with_results` events are - * incompatible; you can specify only of the two events. If the job does not include a callback URL, omit the - * parameter. - * - * @return the events - */ - public String events() { - return 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. - * - * @return the userToken - */ - public String userToken() { - return 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. - * - * @return the resultsTtl - */ - public Long resultsTtl() { - return resultsTtl; - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of a custom language model that is to be used with the recognition request or, for the - * **Create a session** method, with the new session. The base model of the specified custom language model must match - * the model specified with the `model` parameter. You must make the request with service credentials created for the - * instance of the service that owns the custom model. By default, no custom language model is used. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the acousticCustomizationId. - * - * The customization ID (GUID) of a custom acoustic model that is to be used with the recognition request or, for the - * **Create a session** method, with the new session. The base model of the specified custom acoustic model must match - * the model specified with the `model` parameter. You must make the request with service credentials created for the - * instance of the service that owns the custom model. By default, no custom acoustic model is used. - * - * @return the acousticCustomizationId - */ - public String acousticCustomizationId() { - return acousticCustomizationId; - } - - /** - * Gets the baseModelVersion. - * - * The version of the specified base model that is to be used with recognition request or, for the **Create a - * session** method, with the new session. 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. For more - * information, see [Base model version](https://console.bluemix.net/docs/services/speech-to-text/input.html#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 or, for - * sessions, with the **Create a session** method, 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. - * - * @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 submitted audio, the connection is - * closed with a 400 error. Useful for stopping audio submission from a live microphone when a user simply walks away. - * Use `-1` for infinity. - * - * @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 tokens. Keywords are - * spotted only in the final hypothesis, not in interim results. 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. - * - * @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 and 1 inclusive. No keyword - * spotting is performed if you omit the parameter. If you specify a threshold, you must also specify one or more - * keywords. - * - * @return the keywordsThreshold - */ - public Float keywordsThreshold() { - return keywordsThreshold; - } - - /** - * Gets the maxAlternatives. - * - * The maximum number of alternative transcripts to be returned. By default, a single transcription is returned. - * - * @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 and 1 inclusive. No alternative words are computed if you omit the - * parameter. - * - * @return the wordAlternativesThreshold - */ - public Float wordAlternativesThreshold() { - return wordAlternativesThreshold; - } - - /** - * Gets the wordConfidence. - * - * If `true`, a confidence measure in the range of 0 to 1 is returned for each word. By default, no word confidence - * measures are returned. - * - * @return the wordConfidence - */ - public Boolean wordConfidence() { - return wordConfidence; - } - - /** - * Gets the timestamps. - * - * If `true`, time alignment is returned for each word. By default, no timestamps are returned. - * - * @return the timestamps - */ - public Boolean timestamps() { - return timestamps; - } - - /** - * Gets the profanityFilter. - * - * If `true` (the default), 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. - * - * @return the profanityFilter - */ - public Boolean profanityFilter() { - return profanityFilter; - } - - /** - * Gets the smartFormatting. - * - * If `true`, 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, also converts certain keyword strings to punctuation symbols. By default, no smart formatting is - * performed. Applies to US English and Spanish transcription only. - * - * @return the smartFormatting - */ - public Boolean smartFormatting() { - return 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, no speaker labels are returned. Setting `speaker_labels` to `true` forces the - * `timestamps` parameter to be `true`, regardless of whether you specify `false` for the parameter. - * - * To determine whether a language model supports speaker labels, use the **Get models** method and check that the - * attribute `speaker_labels` is set to `true`. You can also refer to [Speaker - * labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels). - * - * @return the speakerLabels - */ - public Boolean speakerLabels() { - return speakerLabels; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateLanguageModelOptions.java deleted file mode 100644 index 432084d8d45..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateLanguageModelOptions.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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. To determine whether a base model supports language model - * customization, request information about the base model and check that the attribute `custom_language_model` is set - * to `true`, or refer to [Language support for - * customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport). - */ - public interface BaseModelName { - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** ko-KR_BroadbandModel. */ - String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; - /** ko-KR_NarrowbandModel. */ - String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; - } - - private String name; - private String baseModelName; - private String dialect; - private String description; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String baseModelName; - private String dialect; - private String description; - - private Builder(CreateLanguageModelOptions createLanguageModelOptions) { - name = createLanguageModelOptions.name; - baseModelName = createLanguageModelOptions.baseModelName; - dialect = createLanguageModelOptions.dialect; - description = createLanguageModelOptions.description; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - * @param baseModelName the baseModelName - */ - public Builder(String name, String baseModelName) { - this.name = name; - this.baseModelName = baseModelName; - } - - /** - * Builds a CreateLanguageModelOptions. - * - * @return the createLanguageModelOptions - */ - public CreateLanguageModelOptions build() { - return new CreateLanguageModelOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateLanguageModelOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Set the baseModelName. - * - * @param baseModelName the baseModelName - * @return the CreateLanguageModelOptions builder - */ - public Builder baseModelName(String baseModelName) { - this.baseModelName = baseModelName; - return this; - } - - /** - * Set the dialect. - * - * @param dialect the dialect - * @return the CreateLanguageModelOptions builder - */ - public Builder dialect(String dialect) { - this.dialect = dialect; - return this; - } - - /** - * Set the description. - * - * @param description the description - * @return the CreateLanguageModelOptions builder - */ - public Builder description(String description) { - this.description = description; - return this; - } - } - - private CreateLanguageModelOptions(Builder builder) { - Validator.notNull(builder.name, "name cannot be null"); - Validator.notNull(builder.baseModelName, "baseModelName cannot be null"); - name = builder.name; - baseModelName = builder.baseModelName; - dialect = builder.dialect; - description = builder.description; - } - - /** - * New builder. - * - * @return a CreateLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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`. - * - * @return the name - */ - public String name() { - return 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. To determine whether a base model supports language model - * customization, request information about the base model and check that the attribute `custom_language_model` is set - * to `true`, or refer to [Language support for - * customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport). - * - * @return the baseModelName - */ - public String baseModelName() { - return baseModelName; - } - - /** - * Gets the dialect. - * - * The dialect of the specified language that is to be used with the custom language model. The parameter is - * meaningful only for Spanish models, for which the service creates a custom language model that is suited for speech - * in one of the following dialects: - * * `es-ES` for Castilian Spanish (the default) - * * `es-LA` for Latin American Spanish - * * `es-US` for North American (Mexican) Spanish - * - * A specified dialect must be valid for the base model. By default, the dialect matches the language of the base - * model; for example, `en-US` for either of the US English language models. - * - * @return the dialect - */ - public String dialect() { - return dialect; - } - - /** - * Gets the description. - * - * A description of the new custom language model. Use a localized description that matches the language of the custom - * model. - * - * @return the description - */ - public String description() { - return description; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateSessionOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateSessionOptions.java deleted file mode 100644 index a747788c3af..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CreateSessionOptions.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The createSession options. - */ -public class CreateSessionOptions extends GenericModel { - - /** - * The identifier of the model to be used by the new session. (Use `GET /v1/models` or `GET /v1/models/{model_id}` for - * information about available models.). - */ - public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - private String model; - private String customizationId; - private String acousticCustomizationId; - private Double customizationWeight; - private String version; - - /** - * Builder. - */ - public static class Builder { - private String model; - private String customizationId; - private String acousticCustomizationId; - private Double customizationWeight; - private String version; - - private Builder(CreateSessionOptions createSessionOptions) { - model = createSessionOptions.model; - customizationId = createSessionOptions.customizationId; - acousticCustomizationId = createSessionOptions.acousticCustomizationId; - customizationWeight = createSessionOptions.customizationWeight; - version = createSessionOptions.version; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a CreateSessionOptions. - * - * @return the createSessionOptions - */ - public CreateSessionOptions build() { - return new CreateSessionOptions(this); - } - - /** - * Set the model. - * - * @param model the model - * @return the CreateSessionOptions builder - */ - public Builder model(String model) { - this.model = model; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the CreateSessionOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the acousticCustomizationId. - * - * @param acousticCustomizationId the acousticCustomizationId - * @return the CreateSessionOptions builder - */ - public Builder acousticCustomizationId(String acousticCustomizationId) { - this.acousticCustomizationId = acousticCustomizationId; - return this; - } - - /** - * Set the customizationWeight. - * - * @param customizationWeight the customizationWeight - * @return the CreateSessionOptions builder - */ - public Builder customizationWeight(Double customizationWeight) { - this.customizationWeight = customizationWeight; - return this; - } - - /** - * Set the version. - * - * @param version the version - * @return the CreateSessionOptions builder - */ - public Builder version(String version) { - this.version = version; - return this; - } - } - - private CreateSessionOptions(Builder builder) { - model = builder.model; - customizationId = builder.customizationId; - acousticCustomizationId = builder.acousticCustomizationId; - customizationWeight = builder.customizationWeight; - version = builder.version; - } - - /** - * New builder. - * - * @return a CreateSessionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the model. - * - * The identifier of the model to be used by the new session. (Use `GET /v1/models` or `GET /v1/models/{model_id}` for - * information about available models.). - * - * @return the model - */ - public String model() { - return model; - } - - /** - * Gets the customizationId. - * - * The GUID of a custom language model that is to be used with the new session. The base model of the specified custom - * language model must match the model specified with the `model` parameter. You must make the request with service - * credentials created for the instance of the service that owns the custom model. By default, no custom language - * model is used. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the acousticCustomizationId. - * - * The GUID of a custom acoustic model that is to be used with the new session. The base model of the specified custom - * acoustic model must match the model specified with the `model` parameter. You must make the request with service - * credentials created for the instance of the service that owns the custom model. By default, no custom acoustic - * model is used. - * - * @return the acousticCustomizationId - */ - public String acousticCustomizationId() { - return acousticCustomizationId; - } - - /** - * Gets the customizationWeight. - * - * If you specify a `customization_id` when you create the session, you can use the `customization_weight` parameter - * to tell the service how much weight to give to words from the custom language model compared to those from the base - * model for recognition requests made with the session. 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. - * - * @return the customizationWeight - */ - public Double customizationWeight() { - return customizationWeight; - } - - /** - * Gets the version. - * - * The version of the specified base `model` that is to be used with the new session. 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. For more information, see [Base model - * version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version). - * - * @return the version - */ - public String version() { - return version; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CustomWord.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CustomWord.java deleted file mode 100644 index 20d9a73c84b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/CustomWord.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CustomWord. - */ -public class CustomWord extends GenericModel { - - private String word; - @SerializedName("sounds_like") - private List soundsLike; - @SerializedName("display_as") - private String displayAs; - - /** - * 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. - * - * Omit this field for the **Add a custom word** method. - * - * @return the word - */ - public String getWord() { - return word; - } - - /** - * 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. A word can have at most five sounds-like pronunciations, and a pronunciation can include - * at most 40 characters not including spaces. - * - * @return the soundsLike - */ - public List getSoundsLike() { - return 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. - * - * @return the displayAs - */ - public String getDisplayAs() { - return displayAs; - } - - /** - * Sets the word. - * - * @param word the new word - */ - public void setWord(final String word) { - this.word = word; - } - - /** - * Sets the soundsLike. - * - * @param soundsLike the new soundsLike - */ - public void setSoundsLike(final List soundsLike) { - this.soundsLike = soundsLike; - } - - /** - * Sets the displayAs. - * - * @param displayAs the new displayAs - */ - public void setDisplayAs(final String displayAs) { - this.displayAs = displayAs; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAcousticModelOptions.java deleted file mode 100644 index 86ca656d427..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAcousticModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteAcousticModel options. - */ -public class DeleteAcousticModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(DeleteAcousticModelOptions deleteAcousticModelOptions) { - customizationId = deleteAcousticModelOptions.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 DeleteAcousticModelOptions. - * - * @return the deleteAcousticModelOptions - */ - public DeleteAcousticModelOptions build() { - return new DeleteAcousticModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteAcousticModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private DeleteAcousticModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a DeleteAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAudioOptions.java deleted file mode 100644 index a01b216768a..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteAudioOptions.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteAudio options. - */ -public class DeleteAudioOptions extends GenericModel { - - private String customizationId; - private String audioName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String audioName; - - private Builder(DeleteAudioOptions deleteAudioOptions) { - customizationId = deleteAudioOptions.customizationId; - audioName = deleteAudioOptions.audioName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param audioName the audioName - */ - public Builder(String customizationId, String audioName) { - this.customizationId = customizationId; - this.audioName = audioName; - } - - /** - * Builds a DeleteAudioOptions. - * - * @return the deleteAudioOptions - */ - public DeleteAudioOptions build() { - return new DeleteAudioOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteAudioOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the audioName. - * - * @param audioName the audioName - * @return the DeleteAudioOptions builder - */ - public Builder audioName(String audioName) { - this.audioName = audioName; - return this; - } - } - - private DeleteAudioOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.audioName, "audioName cannot be empty"); - customizationId = builder.customizationId; - audioName = builder.audioName; - } - - /** - * New builder. - * - * @return a DeleteAudioOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the audioName. - * - * The name of the audio resource for the custom acoustic model. When adding an audio resource, do not include spaces - * in the name; use a localized name that matches the language of the custom model. - * - * @return the audioName - */ - public String audioName() { - return audioName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteCorpusOptions.java deleted file mode 100644 index 9e73a2df178..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteCorpusOptions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteCorpus options. - */ -public class DeleteCorpusOptions extends GenericModel { - - private String customizationId; - private String corpusName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String corpusName; - - private Builder(DeleteCorpusOptions deleteCorpusOptions) { - customizationId = deleteCorpusOptions.customizationId; - corpusName = deleteCorpusOptions.corpusName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param corpusName the corpusName - */ - public Builder(String customizationId, String corpusName) { - this.customizationId = customizationId; - this.corpusName = corpusName; - } - - /** - * Builds a DeleteCorpusOptions. - * - * @return the deleteCorpusOptions - */ - public DeleteCorpusOptions build() { - return new DeleteCorpusOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteCorpusOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the corpusName. - * - * @param corpusName the corpusName - * @return the DeleteCorpusOptions builder - */ - public Builder corpusName(String corpusName) { - this.corpusName = corpusName; - return this; - } - } - - private DeleteCorpusOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.corpusName, "corpusName cannot be empty"); - customizationId = builder.customizationId; - corpusName = builder.corpusName; - } - - /** - * New builder. - * - * @return a DeleteCorpusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the corpusName. - * - * The name of the corpus for the custom language model. When adding a corpus, do not include spaces in the name; use - * a localized name that matches the language of the custom model; and do not use the name `user`, which is reserved - * by the service to denote custom words added or modified by the user. - * - * @return the corpusName - */ - public String corpusName() { - return corpusName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteJobOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteJobOptions.java deleted file mode 100644 index 565bb27d23f..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteJobOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteJob options. - */ -public class DeleteJobOptions extends GenericModel { - - private String id; - - /** - * Builder. - */ - public static class Builder { - private String id; - - private Builder(DeleteJobOptions deleteJobOptions) { - id = deleteJobOptions.id; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param id the id - */ - public Builder(String id) { - this.id = id; - } - - /** - * Builds a DeleteJobOptions. - * - * @return the deleteJobOptions - */ - public DeleteJobOptions build() { - return new DeleteJobOptions(this); - } - - /** - * Set the id. - * - * @param id the id - * @return the DeleteJobOptions builder - */ - public Builder id(String id) { - this.id = id; - return this; - } - } - - private DeleteJobOptions(Builder builder) { - Validator.notEmpty(builder.id, "id cannot be empty"); - id = builder.id; - } - - /** - * New builder. - * - * @return a DeleteJobOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the id. - * - * The ID of the asynchronous job. - * - * @return the id - */ - public String id() { - return id; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteLanguageModelOptions.java deleted file mode 100644 index b3f08027632..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteLanguageModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteLanguageModel options. - */ -public class DeleteLanguageModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(DeleteLanguageModelOptions deleteLanguageModelOptions) { - customizationId = deleteLanguageModelOptions.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 DeleteLanguageModelOptions. - * - * @return the deleteLanguageModelOptions - */ - public DeleteLanguageModelOptions build() { - return new DeleteLanguageModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteLanguageModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private DeleteLanguageModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a DeleteLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteSessionOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteSessionOptions.java deleted file mode 100644 index 6a7b089261a..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteSessionOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteSession options. - */ -public class DeleteSessionOptions extends GenericModel { - - private String sessionId; - - /** - * Builder. - */ - public static class Builder { - private String sessionId; - - private Builder(DeleteSessionOptions deleteSessionOptions) { - sessionId = deleteSessionOptions.sessionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param sessionId the sessionId - */ - public Builder(String sessionId) { - this.sessionId = sessionId; - } - - /** - * Builds a DeleteSessionOptions. - * - * @return the deleteSessionOptions - */ - public DeleteSessionOptions build() { - return new DeleteSessionOptions(this); - } - - /** - * Set the sessionId. - * - * @param sessionId the sessionId - * @return the DeleteSessionOptions builder - */ - public Builder sessionId(String sessionId) { - this.sessionId = sessionId; - return this; - } - } - - private DeleteSessionOptions(Builder builder) { - Validator.notEmpty(builder.sessionId, "sessionId cannot be empty"); - sessionId = builder.sessionId; - } - - /** - * New builder. - * - * @return a DeleteSessionOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the sessionId. - * - * The ID of the session to be deleted. - * - * @return the sessionId - */ - public String sessionId() { - return sessionId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteUserDataOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index 6734d7e1a64..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteWordOptions.java deleted file mode 100644 index e6003bdfab2..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/DeleteWordOptions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteWord options. - */ -public class DeleteWordOptions extends GenericModel { - - private String customizationId; - private String wordName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String wordName; - - private Builder(DeleteWordOptions deleteWordOptions) { - customizationId = deleteWordOptions.customizationId; - wordName = deleteWordOptions.wordName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param wordName the wordName - */ - public Builder(String customizationId, String wordName) { - this.customizationId = customizationId; - this.wordName = wordName; - } - - /** - * Builds a DeleteWordOptions. - * - * @return the deleteWordOptions - */ - public DeleteWordOptions build() { - return new DeleteWordOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the wordName. - * - * @param wordName the wordName - * @return the DeleteWordOptions builder - */ - public Builder wordName(String wordName) { - this.wordName = wordName; - return this; - } - } - - private DeleteWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.wordName, "wordName cannot be empty"); - customizationId = builder.customizationId; - wordName = builder.wordName; - } - - /** - * New builder. - * - * @return a DeleteWordOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the wordName. - * - * The custom word for the custom language model. When you add or update a custom word with the **Add a custom word** - * method, do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of compound - * words. - * - * @return the wordName - */ - public String wordName() { - return wordName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAcousticModelOptions.java deleted file mode 100644 index c38bea5b5c4..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAcousticModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getAcousticModel options. - */ -public class GetAcousticModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(GetAcousticModelOptions getAcousticModelOptions) { - customizationId = getAcousticModelOptions.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 GetAcousticModelOptions. - * - * @return the getAcousticModelOptions - */ - public GetAcousticModelOptions build() { - return new GetAcousticModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetAcousticModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private GetAcousticModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a GetAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAudioOptions.java deleted file mode 100644 index 10261bd90a6..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetAudioOptions.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getAudio options. - */ -public class GetAudioOptions extends GenericModel { - - private String customizationId; - private String audioName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String audioName; - - private Builder(GetAudioOptions getAudioOptions) { - customizationId = getAudioOptions.customizationId; - audioName = getAudioOptions.audioName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param audioName the audioName - */ - public Builder(String customizationId, String audioName) { - this.customizationId = customizationId; - this.audioName = audioName; - } - - /** - * Builds a GetAudioOptions. - * - * @return the getAudioOptions - */ - public GetAudioOptions build() { - return new GetAudioOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetAudioOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the audioName. - * - * @param audioName the audioName - * @return the GetAudioOptions builder - */ - public Builder audioName(String audioName) { - this.audioName = audioName; - return this; - } - } - - private GetAudioOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.audioName, "audioName cannot be empty"); - customizationId = builder.customizationId; - audioName = builder.audioName; - } - - /** - * New builder. - * - * @return a GetAudioOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the audioName. - * - * The name of the audio resource for the custom acoustic model. When adding an audio resource, do not include spaces - * in the name; use a localized name that matches the language of the custom model. - * - * @return the audioName - */ - public String audioName() { - return audioName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetCorpusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetCorpusOptions.java deleted file mode 100644 index fa891f2668e..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetCorpusOptions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getCorpus options. - */ -public class GetCorpusOptions extends GenericModel { - - private String customizationId; - private String corpusName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String corpusName; - - private Builder(GetCorpusOptions getCorpusOptions) { - customizationId = getCorpusOptions.customizationId; - corpusName = getCorpusOptions.corpusName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param corpusName the corpusName - */ - public Builder(String customizationId, String corpusName) { - this.customizationId = customizationId; - this.corpusName = corpusName; - } - - /** - * Builds a GetCorpusOptions. - * - * @return the getCorpusOptions - */ - public GetCorpusOptions build() { - return new GetCorpusOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetCorpusOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the corpusName. - * - * @param corpusName the corpusName - * @return the GetCorpusOptions builder - */ - public Builder corpusName(String corpusName) { - this.corpusName = corpusName; - return this; - } - } - - private GetCorpusOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.corpusName, "corpusName cannot be empty"); - customizationId = builder.customizationId; - corpusName = builder.corpusName; - } - - /** - * New builder. - * - * @return a GetCorpusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the corpusName. - * - * The name of the corpus for the custom language model. When adding a corpus, do not include spaces in the name; use - * a localized name that matches the language of the custom model; and do not use the name `user`, which is reserved - * by the service to denote custom words added or modified by the user. - * - * @return the corpusName - */ - public String corpusName() { - return corpusName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetLanguageModelOptions.java deleted file mode 100644 index 80ef7d7d4e9..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetLanguageModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getLanguageModel options. - */ -public class GetLanguageModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(GetLanguageModelOptions getLanguageModelOptions) { - customizationId = getLanguageModelOptions.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 GetLanguageModelOptions. - * - * @return the getLanguageModelOptions - */ - public GetLanguageModelOptions build() { - return new GetLanguageModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetLanguageModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private GetLanguageModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a GetLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetModelOptions.java deleted file mode 100644 index 5f90d25331b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetModelOptions.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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 models** method. - */ - public interface ModelId { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** ko-KR_BroadbandModel. */ - String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; - /** ko-KR_NarrowbandModel. */ - String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - private String modelId; - - /** - * Builder. - */ - public static class Builder { - private String modelId; - - private Builder(GetModelOptions getModelOptions) { - 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; - } - } - - private GetModelOptions(Builder builder) { - 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. - * - * The identifier of the model in the form of its name from the output of the **Get models** method. - * - * @return the modelId - */ - public String modelId() { - return modelId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetSessionStatusOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetSessionStatusOptions.java deleted file mode 100644 index 7de46708993..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetSessionStatusOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getSessionStatus options. - */ -public class GetSessionStatusOptions extends GenericModel { - - private String sessionId; - - /** - * Builder. - */ - public static class Builder { - private String sessionId; - - private Builder(GetSessionStatusOptions getSessionStatusOptions) { - sessionId = getSessionStatusOptions.sessionId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param sessionId the sessionId - */ - public Builder(String sessionId) { - this.sessionId = sessionId; - } - - /** - * Builds a GetSessionStatusOptions. - * - * @return the getSessionStatusOptions - */ - public GetSessionStatusOptions build() { - return new GetSessionStatusOptions(this); - } - - /** - * Set the sessionId. - * - * @param sessionId the sessionId - * @return the GetSessionStatusOptions builder - */ - public Builder sessionId(String sessionId) { - this.sessionId = sessionId; - return this; - } - } - - private GetSessionStatusOptions(Builder builder) { - Validator.notEmpty(builder.sessionId, "sessionId cannot be empty"); - sessionId = builder.sessionId; - } - - /** - * New builder. - * - * @return a GetSessionStatusOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the sessionId. - * - * The ID of the session for the recognition task. - * - * @return the sessionId - */ - public String sessionId() { - return sessionId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetWordOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetWordOptions.java deleted file mode 100644 index bb5cc12de62..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/GetWordOptions.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getWord options. - */ -public class GetWordOptions extends GenericModel { - - private String customizationId; - private String wordName; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String wordName; - - private Builder(GetWordOptions getWordOptions) { - customizationId = getWordOptions.customizationId; - wordName = getWordOptions.wordName; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param wordName the wordName - */ - public Builder(String customizationId, String wordName) { - this.customizationId = customizationId; - this.wordName = wordName; - } - - /** - * Builds a GetWordOptions. - * - * @return the getWordOptions - */ - public GetWordOptions build() { - return new GetWordOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the wordName. - * - * @param wordName the wordName - * @return the GetWordOptions builder - */ - public Builder wordName(String wordName) { - this.wordName = wordName; - return this; - } - } - - private GetWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.wordName, "wordName cannot be empty"); - customizationId = builder.customizationId; - wordName = builder.wordName; - } - - /** - * New builder. - * - * @return a GetWordOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the wordName. - * - * The custom word for the custom language model. When you add or update a custom word with the **Add a custom word** - * method, do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect the tokens of compound - * words. - * - * @return the wordName - */ - public String wordName() { - return wordName; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/KeywordResult.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/KeywordResult.java deleted file mode 100644 index 60845e85294..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/KeywordResult.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * KeywordResult. - */ -public class KeywordResult extends GenericModel { - - @SerializedName("normalized_text") - private String normalizedText; - @SerializedName("start_time") - private Double startTime; - @SerializedName("end_time") - private Double endTime; - private Double confidence; - - /** - * Gets the normalizedText. - * - * A specified keyword normalized to the spoken phrase that matched in the audio input. - * - * @return the normalizedText - */ - public String getNormalizedText() { - return normalizedText; - } - - /** - * Gets the startTime. - * - * The start time in seconds of the keyword match. - * - * @return the startTime - */ - public Double getStartTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * The end time in seconds of the keyword match. - * - * @return the endTime - */ - public Double getEndTime() { - return endTime; - } - - /** - * Gets the confidence. - * - * A confidence score for the keyword match in the range of 0 to 1. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModel.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModel.java deleted file mode 100644 index 0697605a729..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModel.java +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LanguageModel. - */ -public class LanguageModel extends GenericModel { - - /** - * The current status of the custom language model: - * * `pending` indicates that the model was created but is waiting either for training data to be added or for the - * service to finish analyzing added data. - * * `ready` indicates that the model contains data and is ready to be trained. - * * `training` indicates that the model is currently being trained. - * * `available` indicates that the model is trained and ready to use. - * * `upgrading` indicates that the model is currently being upgraded. - * * `failed` indicates that training of the model failed. - */ - public interface Status { - /** pending. */ - String PENDING = "pending"; - /** ready. */ - String READY = "ready"; - /** training. */ - String TRAINING = "training"; - /** available. */ - String AVAILABLE = "available"; - /** upgrading. */ - String UPGRADING = "upgrading"; - /** failed. */ - String FAILED = "failed"; - } - - @SerializedName("customization_id") - private String customizationId; - private String created; - private String language; - private String dialect; - private List versions; - private String owner; - private String name; - private String description; - @SerializedName("base_model_name") - private String baseModelName; - private String status; - private Long progress; - private String warnings; - - /** - * 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. - * - * @return the customizationId - */ - public String getCustomizationId() { - return customizationId; - } - - /** - * 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`). - * - * @return the created - */ - public String getCreated() { - return created; - } - - /** - * Gets the language. - * - * The language identifier of the custom language model (for example, `en-US`). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the dialect. - * - * The dialect of the language for the custom language model. By default, the dialect 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 (the default) - * * `es-LA` for Latin American Spanish - * * `es-US` for North American (Mexican) Spanish. - * - * @return the dialect - */ - public String getDialect() { - return dialect; - } - - /** - * 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. - * - * @return the versions - */ - public List getVersions() { - return versions; - } - - /** - * Gets the owner. - * - * The GUID of the service credentials for the instance of the service that owns the custom language model. - * - * @return the owner - */ - public String getOwner() { - return owner; - } - - /** - * Gets the name. - * - * The name of the custom language model. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the description. - * - * The description of the custom language model. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the baseModelName. - * - * The name of the language model for which the custom language model was created. - * - * @return the baseModelName - */ - public String getBaseModelName() { - return baseModelName; - } - - /** - * Gets the status. - * - * The current status of the custom language model: - * * `pending` indicates that the model was created but is waiting either for training data to be added or for the - * service to finish analyzing added data. - * * `ready` indicates that the model contains data and is ready to be trained. - * * `training` indicates that the model is currently being trained. - * * `available` indicates that the model is trained and ready to use. - * * `upgrading` indicates that the model is currently being upgraded. - * * `failed` indicates that training of the model failed. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * 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. - * - * @return the progress - */ - public Long getProgress() { - return progress; - } - - /** - * 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. - * - * @return the warnings - */ - public String getWarnings() { - return warnings; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModels.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModels.java deleted file mode 100644 index fde3038c259..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/LanguageModels.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * LanguageModels. - */ -public class LanguageModels extends GenericModel { - - private List customizations; - - /** - * Gets the customizations. - * - * An array of objects that provides information about each available custom language model. The array is empty if the - * requesting service credentials own no custom language models (if no language is specified) or own no custom - * language models for the specified language. - * - * @return the customizations - */ - public List getCustomizations() { - return customizations; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAcousticModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAcousticModelsOptions.java deleted file mode 100644 index 9f96c0785f1..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAcousticModelsOptions.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listAcousticModels options. - */ -public class ListAcousticModelsOptions extends GenericModel { - - private String language; - - /** - * Builder. - */ - public static class Builder { - private String language; - - private Builder(ListAcousticModelsOptions listAcousticModelsOptions) { - language = listAcousticModelsOptions.language; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListAcousticModelsOptions. - * - * @return the listAcousticModelsOptions - */ - public ListAcousticModelsOptions build() { - return new ListAcousticModelsOptions(this); - } - - /** - * Set the language. - * - * @param language the language - * @return the ListAcousticModelsOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - } - - private ListAcousticModelsOptions(Builder builder) { - language = builder.language; - } - - /** - * New builder. - * - * @return a ListAcousticModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 owned by the requesting service - * credentials. - * - * @return the language - */ - public String language() { - return language; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAudioOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAudioOptions.java deleted file mode 100644 index c62b1c78b63..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListAudioOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listAudio options. - */ -public class ListAudioOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(ListAudioOptions listAudioOptions) { - customizationId = listAudioOptions.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 ListAudioOptions. - * - * @return the listAudioOptions - */ - public ListAudioOptions build() { - return new ListAudioOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ListAudioOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private ListAudioOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a ListAudioOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListCorporaOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListCorporaOptions.java deleted file mode 100644 index 4ce050a9911..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListCorporaOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listCorpora options. - */ -public class ListCorporaOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(ListCorporaOptions listCorporaOptions) { - customizationId = listCorporaOptions.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 ListCorporaOptions. - * - * @return the listCorporaOptions - */ - public ListCorporaOptions build() { - return new ListCorporaOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ListCorporaOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private ListCorporaOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a ListCorporaOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListLanguageModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListLanguageModelsOptions.java deleted file mode 100644 index 9219db0d43d..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListLanguageModelsOptions.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listLanguageModels options. - */ -public class ListLanguageModelsOptions extends GenericModel { - - private String language; - - /** - * Builder. - */ - public static class Builder { - private String language; - - private Builder(ListLanguageModelsOptions listLanguageModelsOptions) { - language = listLanguageModelsOptions.language; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a ListLanguageModelsOptions. - * - * @return the listLanguageModelsOptions - */ - public ListLanguageModelsOptions build() { - return new ListLanguageModelsOptions(this); - } - - /** - * Set the language. - * - * @param language the language - * @return the ListLanguageModelsOptions builder - */ - public Builder language(String language) { - this.language = language; - return this; - } - } - - private ListLanguageModelsOptions(Builder builder) { - language = builder.language; - } - - /** - * New builder. - * - * @return a ListLanguageModelsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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 owned by the requesting service - * credentials. - * - * @return the language - */ - public String language() { - return language; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListModelsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListModelsOptions.java deleted file mode 100644 index 1a64a4015e4..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListModelsOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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); - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListWordsOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListWordsOptions.java deleted file mode 100644 index 7e9cee4c6ef..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ListWordsOptions.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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. - * * `corpora` shows only OOV that were extracted from corpora. - */ - public interface WordType { - /** all. */ - String ALL = "all"; - /** user. */ - String USER = "user"; - /** corpora. */ - String CORPORA = "corpora"; - } - - /** - * 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 cURL, URL encode the `+` symbol as `%2B`. - */ - public interface Sort { - /** alphabetical. */ - String ALPHABETICAL = "alphabetical"; - /** count. */ - String COUNT = "count"; - } - - private String customizationId; - private String wordType; - private String sort; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String wordType; - private String sort; - - private Builder(ListWordsOptions listWordsOptions) { - customizationId = listWordsOptions.customizationId; - wordType = listWordsOptions.wordType; - sort = listWordsOptions.sort; - } - - /** - * 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 ListWordsOptions. - * - * @return the listWordsOptions - */ - public ListWordsOptions build() { - return new ListWordsOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ListWordsOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the wordType. - * - * @param wordType the wordType - * @return the ListWordsOptions builder - */ - public Builder wordType(String wordType) { - this.wordType = wordType; - return this; - } - - /** - * Set the sort. - * - * @param sort the sort - * @return the ListWordsOptions builder - */ - public Builder sort(String sort) { - this.sort = sort; - return this; - } - } - - private ListWordsOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - wordType = builder.wordType; - sort = builder.sort; - } - - /** - * New builder. - * - * @return a ListWordsOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return 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. - * * `corpora` shows only OOV that were extracted from corpora. - * - * @return the wordType - */ - public String wordType() { - return 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 cURL, URL encode the `+` symbol as `%2B`. - * - * @return the sort - */ - public String sort() { - return sort; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/MultipartRecognition.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/MultipartRecognition.java deleted file mode 100644 index f82986adc1b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/MultipartRecognition.java +++ /dev/null @@ -1,522 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * MultipartRecognition. - */ -public class MultipartRecognition extends GenericModel { - - /** - * The audio format (MIME type) of the audio in the following parts: - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `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 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` - * - * All data parts must have the same audio format. For information about the supported audio formats, including - * specifying the sampling rate, channels, and endianness for the indicated formats, see [Audio formats] - * (https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). The information includes links to - * a number of Internet sites that provide technical and usage details about the different formats. - */ - public interface PartContentType { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - @SerializedName("part_content_type") - private String partContentType; - @SerializedName("data_parts_count") - private Long dataPartsCount; - @SerializedName("sequence_id") - private Long sequenceId; - @SerializedName("inactivity_timeout") - private Long inactivityTimeout; - private List keywords; - @SerializedName("keywords_threshold") - private Float keywordsThreshold; - @SerializedName("max_alternatives") - private Long maxAlternatives; - @SerializedName("word_alternatives_threshold") - private Float wordAlternativesThreshold; - @SerializedName("word_confidence") - private Boolean wordConfidence; - private Boolean timestamps; - @SerializedName("profanity_filter") - private Boolean profanityFilter; - @SerializedName("smart_formatting") - private Boolean smartFormatting; - @SerializedName("speaker_labels") - private Boolean speakerLabels; - - /** - * Builder. - */ - public static class Builder { - private String partContentType; - private Long dataPartsCount; - private Long sequenceId; - 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 Boolean speakerLabels; - - private Builder(MultipartRecognition multipartRecognition) { - partContentType = multipartRecognition.partContentType; - dataPartsCount = multipartRecognition.dataPartsCount; - sequenceId = multipartRecognition.sequenceId; - inactivityTimeout = multipartRecognition.inactivityTimeout; - keywords = multipartRecognition.keywords; - keywordsThreshold = multipartRecognition.keywordsThreshold; - maxAlternatives = multipartRecognition.maxAlternatives; - wordAlternativesThreshold = multipartRecognition.wordAlternativesThreshold; - wordConfidence = multipartRecognition.wordConfidence; - timestamps = multipartRecognition.timestamps; - profanityFilter = multipartRecognition.profanityFilter; - smartFormatting = multipartRecognition.smartFormatting; - speakerLabels = multipartRecognition.speakerLabels; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a MultipartRecognition. - * - * @return the customWord - */ - public MultipartRecognition build() { - return new MultipartRecognition(this); - } - - /** - * Adds a keyword to keywords. - * - * @param keyword the new keyword - * @return the MultipartRecognition builder - */ - public Builder addKeyword(String keyword) { - Validator.notNull(keywords, "soundsLike cannot be null"); - if (this.keywords == null) { - this.keywords = new ArrayList(); - } - this.keywords.add(keyword); - return this; - } - - /** - * Set the partContentType. - * - * @param partContentType the partContentType - * @return the MultipartRecognition builder - */ - public Builder partContentType(String partContentType) { - this.partContentType = partContentType; - return this; - } - - /** - * Set the dataPartsCount. - * - * @param dataPartsCount the dataPartsCount - * @return the MultipartRecognition builder - */ - public Builder dataPartsCount(Long dataPartsCount) { - this.dataPartsCount = dataPartsCount; - return this; - } - - /** - * Set the sequenceId. - * - * @param sequenceId the sequenceId - * @return the MultipartRecognition builder - */ - public Builder sequenceId(Long sequenceId) { - this.sequenceId = sequenceId; - return this; - } - - /** - * Set the inactivityTimeout. - * - * @param inactivityTimeout the inactivityTimeout - * @return the MultipartRecognition 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 MultipartRecognition builder - */ - public Builder keywords(List keywords) { - this.keywords = keywords; - return this; - } - - /** - * Set the keywordsThreshold. - * - * @param keywordsThreshold the keywordsThreshold - * @return the MultipartRecognition builder - */ - public Builder keywordsThreshold(Float keywordsThreshold) { - this.keywordsThreshold = keywordsThreshold; - return this; - } - - /** - * Set the maxAlternatives. - * - * @param maxAlternatives the maxAlternatives - * @return the MultipartRecognition builder - */ - public Builder maxAlternatives(Long maxAlternatives) { - this.maxAlternatives = maxAlternatives; - return this; - } - - /** - * Set the wordAlternativesThreshold. - * - * @param wordAlternativesThreshold the wordAlternativesThreshold - * @return the MultipartRecognition builder - */ - public Builder wordAlternativesThreshold(Float wordAlternativesThreshold) { - this.wordAlternativesThreshold = wordAlternativesThreshold; - return this; - } - - /** - * Set the wordConfidence. - * - * @param wordConfidence the wordConfidence - * @return the MultipartRecognition builder - */ - public Builder wordConfidence(Boolean wordConfidence) { - this.wordConfidence = wordConfidence; - return this; - } - - /** - * Set the timestamps. - * - * @param timestamps the timestamps - * @return the MultipartRecognition builder - */ - public Builder timestamps(Boolean timestamps) { - this.timestamps = timestamps; - return this; - } - - /** - * Set the profanityFilter. - * - * @param profanityFilter the profanityFilter - * @return the MultipartRecognition builder - */ - public Builder profanityFilter(Boolean profanityFilter) { - this.profanityFilter = profanityFilter; - return this; - } - - /** - * Set the smartFormatting. - * - * @param smartFormatting the smartFormatting - * @return the MultipartRecognition builder - */ - public Builder smartFormatting(Boolean smartFormatting) { - this.smartFormatting = smartFormatting; - return this; - } - - /** - * Set the speakerLabels. - * - * @param speakerLabels the speakerLabels - * @return the MultipartRecognition builder - */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; - return this; - } - } - - private MultipartRecognition(Builder builder) { - Validator.isTrue(builder.partContentType != null, "partContentType cannot be null"); - partContentType = builder.partContentType; - dataPartsCount = builder.dataPartsCount; - sequenceId = builder.sequenceId; - 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; - speakerLabels = builder.speakerLabels; - } - - /** - * New builder. - * - * @return a MultipartRecognition builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the partContentType. - * - * The audio format (MIME type) of the audio in the following parts: - * * `audio/basic` (Use only with narrowband models.) - * * `audio/flac` - * * `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 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` - * - * All data parts must have the same audio format. For information about the supported audio formats, including - * specifying the sampling rate, channels, and endianness for the indicated formats, see [Audio formats] - * (https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html). The information includes links to - * a number of Internet sites that provide technical and usage details about the different formats. - * - * @return the partContentType - */ - public String partContentType() { - return partContentType; - } - - /** - * Gets the dataPartsCount. - * - * The number of audio data parts (audio files) sent with the request. Server-side end-of-stream detection is - * applied to the last (and possibly the only) data part. If omitted, the number of parts is determined from the - * request itself. - * - * @return the dataPartsCount - */ - public Long dataPartsCount() { - return dataPartsCount; - } - - /** - * Gets the sequenceId. - * - * The sequence ID for all data parts of this recognition task in the form of a user-specified integer. If - * omitted, no sequence ID is associated with the recognition task. Used only for session-based requests. - * - * @return the sequenceId - */ - public Long sequenceId() { - return sequenceId; - } - - /** - * Gets the inactivityTimeout. - * - * The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is - * closed with a 400 error and, for session-based methods, with `session_closed` set to `true`. Useful for stopping - * audio submission from a live microphone when a user simply walks away. Use `-1` for infinity. - * - * @return the inactivityTimeout - */ - public Long inactivityTimeout() { - return inactivityTimeout; - } - - /** - * Gets the keywords. - * - * Array of keyword strings to spot in the audio. Each keyword string can include one or more tokens. Keywords are - * spotted only in the final hypothesis, not in interim results (if supported by the method). 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. - * - * @return the keywords - */ - public List keywords() { - return keywords; - } - - /** - * Gets the keywordsThreshold. - * - * 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 and 1 inclusive. No - * keyword spotting is performed if you omit the parameter. If you specify a threshold, you must also specify one - * or more keywords. - * - * @return the keywordsThreshold - */ - public Float keywordsThreshold() { - return keywordsThreshold; - } - - /** - * Gets the maxAlternatives. - * - * Maximum number of alternative transcripts to be returned. By default, a single transcription is returned. - * - * @return the maxAlternatives - */ - public Long maxAlternatives() { - return maxAlternatives; - } - - /** - * Gets the wordAlternativesThreshold. - * - * 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 and 1 inclusive. No alternative words are computed if you omit the - * parameter. - * - * @return the wordAlternativesThreshold - */ - public Float wordAlternativesThreshold() { - return wordAlternativesThreshold; - } - - /** - * Gets the wordConfidence. - * - * If `true`, a confidence measure in the range 0 to 1 is returned for each word. - * - * @return the wordConfidence - */ - public Boolean wordConfidence() { - return wordConfidence; - } - - /** - * Gets the timestamps. - * - * If `true`, time alignment for each word is returned. - * - * @return the timestamps - */ - public Boolean timestamps() { - return timestamps; - } - - /** - * Gets the profanityFilter. - * - * If `true` (the default), 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. - * - * @return the profanityFilter - */ - public Boolean profanityFilter() { - return profanityFilter; - } - - /** - * Gets the smartFormatting. - * - * If `true`, 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. If - * `false` (the default), no formatting is performed. Applies to US English transcription only. - * - * @return the smartFormatting - */ - public Boolean smartFormatting() { - return smartFormatting; - } - - /** - * Gets the speakerLabels. - * - * Indicates whether labels that identify which words were spoken by which participants in a multi-person exchange - * are to be included in the response. The default is `false`; no speaker labels are returned. Setting - * `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you specify - * `false` for the parameter.\n\n To determine whether a language model supports speaker labels, use the `GET - * /v1/models` method and check that the attribute `speaker_labels` is set to `true`. You can also refer to - * [Speaker labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels). - * - * @return the speakerLabels - */ - public Boolean speakerLabels() { - return speakerLabels; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJob.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJob.java deleted file mode 100644 index b3c4b90c012..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJob.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * RecognitionJob. - */ -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. - * * `failed`: The job failed. - */ - public interface Status { - /** waiting. */ - String WAITING = "waiting"; - /** processing. */ - String PROCESSING = "processing"; - /** completed. */ - String COMPLETED = "completed"; - /** failed. */ - String FAILED = "failed"; - } - - private String id; - private String status; - private String created; - private String updated; - private String url; - @SerializedName("user_token") - private String userToken; - private List results; - private List warnings; - - /** - * Gets the id. - * - * The ID of the asynchronous job. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * 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. - * * `failed`: The job failed. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * 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`). - * - * @return the created - */ - public String getCreated() { - return created; - } - - /** - * 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. - * - * @return the updated - */ - public String getUpdated() { - return updated; - } - - /** - * 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. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * 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. - * - * @return the userToken - */ - public String getUserToken() { - return userToken; - } - - /** - * 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. - * - * @return the results - */ - public List getResults() { - return results; - } - - /** - * 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. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJobs.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJobs.java deleted file mode 100644 index 02878b9f597..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognitionJobs.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * RecognitionJobs. - */ -public class RecognitionJobs extends GenericModel { - - private List recognitions; - - /** - * Gets the recognitions. - * - * An array of 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 - */ - public List getRecognitions() { - return recognitions; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeOptions.java deleted file mode 100644 index 4293fcb12da..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RecognizeOptions.java +++ /dev/null @@ -1,677 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.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.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The recognize options. - */ -public class RecognizeOptions extends GenericModel { - - /** - * The identifier of the model to be used for the recognition request. (Use `GET /v1/models` for a list of available - * models.). - */ - public interface Model { - /** ar-AR_BroadbandModel. */ - String AR_AR_BROADBANDMODEL = "ar-AR_BroadbandModel"; - /** en-GB_BroadbandModel. */ - String EN_GB_BROADBANDMODEL = "en-GB_BroadbandModel"; - /** en-GB_NarrowbandModel. */ - String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; - /** en-US_BroadbandModel. */ - String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; - /** en-US_NarrowbandModel. */ - String EN_US_NARROWBANDMODEL = "en-US_NarrowbandModel"; - /** es-ES_BroadbandModel. */ - String ES_ES_BROADBANDMODEL = "es-ES_BroadbandModel"; - /** es-ES_NarrowbandModel. */ - String ES_ES_NARROWBANDMODEL = "es-ES_NarrowbandModel"; - /** fr-FR_BroadbandModel. */ - String FR_FR_BROADBANDMODEL = "fr-FR_BroadbandModel"; - /** ja-JP_BroadbandModel. */ - String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; - /** ja-JP_NarrowbandModel. */ - String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; - /** pt-BR_BroadbandModel. */ - String PT_BR_BROADBANDMODEL = "pt-BR_BroadbandModel"; - /** pt-BR_NarrowbandModel. */ - String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; - /** zh-CN_BroadbandModel. */ - String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; - /** zh-CN_NarrowbandModel. */ - String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; - } - - /** - * The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, - * audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, - * audio/webm;codecs=vorbis, or multipart/form-data. - */ - public interface ContentType { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16. */ - String AUDIO_L16 = "audio/l16"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw. */ - String AUDIO_MULAW = "audio/mulaw"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - /** multipart/form-data. */ - String MULTIPART_FORM_DATA = "multipart/form-data"; - } - - private String model; - private String customizationId; - private String acousticCustomizationId; - private Double customizationWeight; - private String baseModelVersion; - private transient InputStream audio; - @SerializedName("content-type") - private String contentType; - 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 Boolean speakerLabels; - private Boolean interimResults; - - /** - * Builder. - */ - public static class Builder { - private String model; - private String customizationId; - private String acousticCustomizationId; - private Double customizationWeight; - private String baseModelVersion; - private InputStream audio; - private String contentType; - 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 Boolean speakerLabels; - private Boolean interimResults; - - private Builder(RecognizeOptions recognizeOptions) { - model = recognizeOptions.model; - customizationId = recognizeOptions.customizationId; - acousticCustomizationId = recognizeOptions.acousticCustomizationId; - customizationWeight = recognizeOptions.customizationWeight; - baseModelVersion = recognizeOptions.baseModelVersion; - audio = recognizeOptions.audio; - contentType = recognizeOptions.contentType; - inactivityTimeout = recognizeOptions.inactivityTimeout; - keywords = recognizeOptions.keywords; - keywordsThreshold = recognizeOptions.keywordsThreshold; - maxAlternatives = recognizeOptions.maxAlternatives; - wordAlternativesThreshold = recognizeOptions.wordAlternativesThreshold; - wordConfidence = recognizeOptions.wordConfidence; - timestamps = recognizeOptions.timestamps; - profanityFilter = recognizeOptions.profanityFilter; - smartFormatting = recognizeOptions.smartFormatting; - speakerLabels = recognizeOptions.speakerLabels; - interimResults = recognizeOptions.interimResults; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a RecognizeOptions. - * - * @return the recognizeOptions - */ - public RecognizeOptions build() { - return new RecognizeOptions(this); - } - - /** - * Adds an keyword to keywords. - * - * @param keyword the new keyword - * @return the RecognizeOptions builder - */ - public Builder addKeyword(String keyword) { - Validator.notNull(keyword, "keyword cannot be null"); - if (this.keywords == null) { - this.keywords = new ArrayList(); - } - this.keywords.add(keyword); - 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 customizationId. - * - * @param customizationId the customizationId - * @return the RecognizeOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - 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 customizationWeight. - * - * @param customizationWeight the customizationWeight - * @return the RecognizeOptions builder - */ - public Builder customizationWeight(Double customizationWeight) { - this.customizationWeight = customizationWeight; - 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 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 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 speakerLabels. - * - * @param speakerLabels the speakerLabels - * @return the RecognizeOptions builder - */ - public Builder speakerLabels(Boolean speakerLabels) { - this.speakerLabels = speakerLabels; - 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 interimResults. - * - * @param interimResults the interimResults - * @return the RecognizeOptions builder - */ - public Builder interimResults(Boolean interimResults) { - this.interimResults = interimResults; - return this; - } - } - - private RecognizeOptions(Builder builder) { - model = builder.model; - customizationId = builder.customizationId; - acousticCustomizationId = builder.acousticCustomizationId; - customizationWeight = builder.customizationWeight; - baseModelVersion = builder.baseModelVersion; - audio = builder.audio; - contentType = builder.contentType; - 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; - speakerLabels = builder.speakerLabels; - interimResults = builder.interimResults; - } - - /** - * New builder. - * - * @return a RecognizeOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the model. - * - * The identifier of the model to be used for the recognition request. (Use `GET /v1/models` for a list of available - * models.). - * - * @return the model - */ - public String model() { - return model; - } - - /** - * Gets the customizationId. - * - * The GUID of a custom language model that is to be used with the 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 service - * credentials created for the instance of the service that owns the custom model. By default, no custom language - * model is used. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the acousticCustomizationId. - * - * The GUID of a custom acoustic model that is to be used with the 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 service - * credentials created for the instance of the service that owns the custom model. By default, no custom acoustic - * model is used. - * - * @return the acousticCustomizationId - */ - public String acousticCustomizationId() { - return acousticCustomizationId; - } - - /** - * Gets the customizationWeight. - * - * If you specify a `customization_id` with the request, you can use the `customization_weight` parameter to tell 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. 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. - * - * @return the customizationWeight - */ - public Double customizationWeight() { - return customizationWeight; - } - - /** - * Gets the baseModelVersion. - * - * The baseModelVersion of the specified base `model` that is to be used for speech recognition. 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. For more information, see [Base model - * version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version). - * - * @return the baseModelVersion - */ - public String baseModelVersion() { - return baseModelVersion; - } - - /** - * Gets the audio. - * - * @return the audio - */ - public InputStream audio() { - return audio; - } - - /** - * Gets the contentType. - * - * The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, - * audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, - * audio/webm;codecs=vorbis, or multipart/form-data. - * - * @return the contentType - */ - public String contentType() { - return contentType; - } - - /** - * Gets the inactivityTimeout. - * - * NON-MULTIPART ONLY: The time in seconds after which, if only silence (no speech) is detected in submitted audio, - * the connection is closed with a 400 error. Useful for stopping audio submission from a live microphone when a user - * simply walks away. Use `-1` for infinity. - * - * @return the inactivityTimeout - */ - public Long inactivityTimeout() { - return inactivityTimeout; - } - - /** - * Gets the keywords. - * - * NON-MULTIPART ONLY: Array of keyword strings to spot in the audio. Each keyword string can include one or more - * tokens. Keywords are spotted only in the final hypothesis, not in interim results. 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. - * - * @return the keywords - */ - public List keywords() { - return keywords; - } - - /** - * Gets the keywordsThreshold. - * - * NON-MULTIPART ONLY: 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 and 1 - * inclusive. No keyword spotting is performed if you omit the parameter. If you specify a threshold, you must also - * specify one or more keywords. - * - * @return the keywordsThreshold - */ - public Float keywordsThreshold() { - return keywordsThreshold; - } - - /** - * Gets the maxAlternatives. - * - * NON-MULTIPART ONLY: Maximum number of alternative transcripts to be returned. By default, a single transcription is - * returned. - * - * @return the maxAlternatives - */ - public Long maxAlternatives() { - return maxAlternatives; - } - - /** - * Gets the wordAlternativesThreshold. - * - * NON-MULTIPART ONLY: 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 and 1 inclusive. No alternative words are computed - * if you omit the parameter. - * - * @return the wordAlternativesThreshold - */ - public Float wordAlternativesThreshold() { - return wordAlternativesThreshold; - } - - /** - * Gets the wordConfidence. - * - * NON-MULTIPART ONLY: If `true`, confidence measure per word is returned. - * - * @return the wordConfidence - */ - public Boolean wordConfidence() { - return wordConfidence; - } - - /** - * Gets the timestamps. - * - * NON-MULTIPART ONLY: If `true`, time alignment for each word is returned. - * - * @return the timestamps - */ - public Boolean timestamps() { - return timestamps; - } - - /** - * Gets the profanityFilter. - * - * NON-MULTIPART ONLY: If `true` (the default), 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. - * - * @return the profanityFilter - */ - public Boolean profanityFilter() { - return profanityFilter; - } - - /** - * Gets the smartFormatting. - * - * NON-MULTIPART ONLY: If `true`, 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. If `false` (the default), no formatting is performed. Applies to US English transcription only. - * - * @return the smartFormatting - */ - public Boolean smartFormatting() { - return smartFormatting; - } - - /** - * Gets the speakerLabels. - * - * NON-MULTIPART ONLY: Indicates whether labels that identify which words were spoken by which participants in a - * multi-person exchange are to be included in the response. The default is `false`; no speaker labels are returned. - * Setting `speaker_labels` to `true` forces the `timestamps` parameter to be `true`, regardless of whether you - * specify `false` for the parameter. To determine whether a language model supports speaker labels, use the `GET - * /v1/models` method and check that the attribute `speaker_labels` is set to `true`. You can also refer to [Speaker - * labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels). - * - * @return the speakerLabels - */ - public Boolean speakerLabels() { - return speakerLabels; - } - - /** - * Gets the interimResults. - * - * Indicates whether the service is to return interim results. If true, interim results are returned as a stream of - * JSON {@link SpeechRecognitionResults} objects. If false (the default), the response is a single - * {@link SpeechRecognitionResults} object with final results only. - * - * @return the interimResults - */ - public Boolean interimResults() { - return interimResults; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterCallbackOptions.java deleted file mode 100644 index 73e408ca430..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterCallbackOptions.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The registerCallback options. - */ -public class RegisterCallbackOptions extends GenericModel { - - private String callbackUrl; - private String userSecret; - - /** - * Builder. - */ - public static class Builder { - private String callbackUrl; - private String userSecret; - - private Builder(RegisterCallbackOptions registerCallbackOptions) { - callbackUrl = registerCallbackOptions.callbackUrl; - userSecret = registerCallbackOptions.userSecret; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param callbackUrl the callbackUrl - */ - public Builder(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - /** - * Builds a RegisterCallbackOptions. - * - * @return the registerCallbackOptions - */ - public RegisterCallbackOptions build() { - return new RegisterCallbackOptions(this); - } - - /** - * Set the callbackUrl. - * - * @param callbackUrl the callbackUrl - * @return the RegisterCallbackOptions builder - */ - public Builder callbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - return this; - } - - /** - * Set the userSecret. - * - * @param userSecret the userSecret - * @return the RegisterCallbackOptions builder - */ - public Builder userSecret(String userSecret) { - this.userSecret = userSecret; - return this; - } - } - - private RegisterCallbackOptions(Builder builder) { - Validator.notNull(builder.callbackUrl, "callbackUrl cannot be null"); - callbackUrl = builder.callbackUrl; - userSecret = builder.userSecret; - } - - /** - * New builder. - * - * @return a RegisterCallbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * 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. - * - * @return the callbackUrl - */ - public String callbackUrl() { - return 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. - * - * @return the userSecret - */ - public String userSecret() { - return userSecret; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterStatus.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterStatus.java deleted file mode 100644 index a1a13c5eaa7..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/RegisterStatus.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * RegisterStatus. - */ -public class RegisterStatus extends GenericModel { - - /** - * The current status of the job: - * * `created` if the callback URL was successfully white-listed as a result of the call. - * * `already created` if the URL was already white-listed. - */ - public interface Status { - /** created. */ - String CREATED = "created"; - /** already created. */ - String ALREADY_CREATED = "already created"; - } - - private String status; - private String url; - - /** - * Gets the status. - * - * The current status of the job: - * * `created` if the callback URL was successfully white-listed as a result of the call. - * * `already created` if the URL was already white-listed. - * - * @return the status - */ - public String getStatus() { - return status; - } - - /** - * Gets the url. - * - * The callback URL that is successfully registered. - * - * @return the url - */ - public String getUrl() { - return url; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetAcousticModelOptions.java deleted file mode 100644 index 459a208c133..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetAcousticModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The resetAcousticModel options. - */ -public class ResetAcousticModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(ResetAcousticModelOptions resetAcousticModelOptions) { - customizationId = resetAcousticModelOptions.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 ResetAcousticModelOptions. - * - * @return the resetAcousticModelOptions - */ - public ResetAcousticModelOptions build() { - return new ResetAcousticModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ResetAcousticModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private ResetAcousticModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a ResetAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetLanguageModelOptions.java deleted file mode 100644 index 46ac7ac219c..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/ResetLanguageModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The resetLanguageModel options. - */ -public class ResetLanguageModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(ResetLanguageModelOptions resetLanguageModelOptions) { - customizationId = resetLanguageModelOptions.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 ResetLanguageModelOptions. - * - * @return the resetLanguageModelOptions - */ - public ResetLanguageModelOptions build() { - return new ResetLanguageModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ResetLanguageModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private ResetLanguageModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a ResetLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeakerLabelsResult.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeakerLabelsResult.java deleted file mode 100644 index c4c019bb421..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeakerLabelsResult.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeakerLabelsResult. - */ -public class SpeakerLabelsResult extends GenericModel { - - private Float from; - private Float to; - private Long speaker; - private Float confidence; - @SerializedName("final") - private Boolean finalResults; - - /** - * 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; - } - - /** - * 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. - * - * @return the speaker - */ - public Long getSpeaker() { - return speaker; - } - - /** - * Gets the confidence. - * - * A score that indicates the service's confidence in its identification of the speaker in the range of 0 to 1. - * - * @return the confidence - */ - public Float getConfidence() { - return confidence; - } - - /** - * Gets the finalResults. - * - * 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 finalResults - */ - public Boolean isFinalResults() { - return finalResults; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModel.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModel.java deleted file mode 100644 index 22c386d4910..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModel.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeechModel. - */ -public class SpeechModel extends GenericModel { - - private String name; - private String language; - private Long rate; - private String url; - @SerializedName("supported_features") - private SupportedFeatures supportedFeatures; - private String description; - private String sessions; - - /** - * Gets the name. - * - * The name of the model for use as an identifier in calls to the service (for example, `en-US_BroadbandModel`). - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the language. - * - * The language identifier of the model (for example, `en-US`). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the rate. - * - * The sampling rate (minimum acceptable rate for audio) used by the model in Hertz. - * - * @return the rate - */ - public Long getRate() { - return rate; - } - - /** - * Gets the url. - * - * The URI for the model. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * Gets the supportedFeatures. - * - * Describes the additional service features supported with the model. - * - * @return the supportedFeatures - */ - public SupportedFeatures getSupportedFeatures() { - return supportedFeatures; - } - - /** - * Gets the description. - * - * Brief description of the model. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the sessions. - * - * The URI for the model for use with the **Create a session** method. This field is returned only by the **Get a - * model** method. - * - * @return the sessions - */ - public String getSessions() { - return sessions; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModels.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModels.java deleted file mode 100644 index 6c986032df3..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechModels.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeechModels. - */ -public class SpeechModels extends GenericModel { - - private List models; - - /** - * Gets the models. - * - * An array of objects that provides information about each available model. - * - * @return the models - */ - public List getModels() { - return models; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionAlternative.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionAlternative.java deleted file mode 100644 index 00397a12362..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionAlternative.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeechRecognitionAlternative. - */ -public class SpeechRecognitionAlternative extends GenericModel { - - private String transcript; - private Double confidence; - private List timestamps; - @SerializedName("word_confidence") - private List wordConfidence; - - /** - * Gets the transcript. - * - * A transcription of the audio. - * - * @return the transcript - */ - public String getTranscript() { - return transcript; - } - - /** - * Gets the confidence. - * - * A score that indicates the service's confidence in the transcript in the range of 0 to 1. Returned only for the - * best alternative and only with results marked as final. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } - - /** - * 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. Example: `[["hello",0.0,1.2],["world",1.2,2.5]]`. Returned - * only for the best alternative. - * - * @return the timestamps - */ - public List getTimestamps() { - return timestamps; - } - - /** - * 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 to 1. Example: `[["hello",0.95],["world",0.866]]`. Returned - * only for the best alternative and only with results marked as final. - * - * @return the wordConfidence - */ - public List getWordConfidence() { - return wordConfidence; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResult.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResult.java deleted file mode 100644 index 51d6b6c824b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResult.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeechRecognitionResult. - */ -public class SpeechRecognitionResult extends GenericModel { - - @SerializedName("final") - private Boolean finalResults; - private List alternatives; - @SerializedName("keywords_result") - private Map> keywordsResult; - @SerializedName("word_alternatives") - private List wordAlternatives; - - /** - * Gets the finalResults. - * - * 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. - * - * @return the finalResults - */ - public Boolean isFinalResults() { - return finalResults; - } - - /** - * Gets the alternatives. - * - * An array of alternative transcripts. The `alternatives` array can include additional requested output such as word - * confidence or timestamps. - * - * @return the alternatives - */ - public List getAlternatives() { - return alternatives; - } - - /** - * 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. A keyword for which no matches are found is omitted from the array. The array - * is omitted if no matches are found for any keywords. - * - * @return the keywordsResult - */ - public Map> getKeywordsResult() { - return keywordsResult; - } - - /** - * Gets the wordAlternatives. - * - * An array of alternative hypotheses found for words of the input audio if a `word_alternatives_threshold` is - * specified. - * - * @return the wordAlternatives - */ - public List getWordAlternatives() { - return wordAlternatives; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResults.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResults.java deleted file mode 100644 index b70a4446f51..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechRecognitionResults.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SpeechRecognitionResults. - */ -public class SpeechRecognitionResults extends GenericModel { - - private List results; - @SerializedName("result_index") - private Long resultIndex; - @SerializedName("speaker_labels") - private List speakerLabels; - private List warnings; - - /** - * Gets the results. - * - * An array 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. - * - * @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 only for additional - * results that it sends for new audio for the same request. - * - * @return the resultIndex - */ - public Long getResultIndex() { - return resultIndex; - } - - /** - * Gets the speakerLabels. - * - * An array that identifies which words were spoken by which speakers in a multi-person exchange. Returned in the - * response only if `speaker_labels` 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 - */ - public List getSpeakerLabels() { - return speakerLabels; - } - - /** - * 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."` - * - * In both cases, the request succeeds despite the warnings. - * - * @return the warnings - */ - public List getWarnings() { - return warnings; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SupportedFeatures.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SupportedFeatures.java deleted file mode 100644 index 30c422e1229..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SupportedFeatures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SupportedFeatures. - */ -public class SupportedFeatures extends GenericModel { - - @SerializedName("custom_language_model") - private Boolean customLanguageModel; - @SerializedName("speaker_labels") - private Boolean speakerLabels; - - /** - * Gets the customLanguageModel. - * - * Indicates whether the customization interface can be used to create a custom language model based on the language - * model. - * - * @return the customLanguageModel - */ - public Boolean isCustomLanguageModel() { - return customLanguageModel; - } - - /** - * Gets the speakerLabels. - * - * Indicates whether the `speaker_labels` parameter can be used with the language model. - * - * @return the speakerLabels - */ - public Boolean isSpeakerLabels() { - return speakerLabels; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainAcousticModelOptions.java deleted file mode 100644 index aa3db74c93c..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainAcousticModelOptions.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The trainAcousticModel options. - */ -public class TrainAcousticModelOptions extends GenericModel { - - private String customizationId; - private String customLanguageModelId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String customLanguageModelId; - - private Builder(TrainAcousticModelOptions trainAcousticModelOptions) { - customizationId = trainAcousticModelOptions.customizationId; - customLanguageModelId = trainAcousticModelOptions.customLanguageModelId; - } - - /** - * 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 TrainAcousticModelOptions. - * - * @return the trainAcousticModelOptions - */ - public TrainAcousticModelOptions build() { - return new TrainAcousticModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the TrainAcousticModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the customLanguageModelId. - * - * @param customLanguageModelId the customLanguageModelId - * @return the TrainAcousticModelOptions builder - */ - public Builder customLanguageModelId(String customLanguageModelId) { - this.customLanguageModelId = customLanguageModelId; - return this; - } - } - - private TrainAcousticModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - customLanguageModelId = builder.customLanguageModelId; - } - - /** - * New builder. - * - * @return a TrainAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return 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. - * - * @return the customLanguageModelId - */ - public String customLanguageModelId() { - return customLanguageModelId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainLanguageModelOptions.java deleted file mode 100644 index d0aae0682f5..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/TrainLanguageModelOptions.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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 - * were added or modified by the user. - * * `user` trains the model only on new words that were added or modified by the user; the model is not trained on - * new words extracted from corpora. - */ - public interface WordTypeToAdd { - /** all. */ - String ALL = "all"; - /** user. */ - String USER = "user"; - } - - private String customizationId; - private String wordTypeToAdd; - private Double customizationWeight; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String wordTypeToAdd; - private Double customizationWeight; - - private Builder(TrainLanguageModelOptions trainLanguageModelOptions) { - customizationId = trainLanguageModelOptions.customizationId; - wordTypeToAdd = trainLanguageModelOptions.wordTypeToAdd; - customizationWeight = trainLanguageModelOptions.customizationWeight; - } - - /** - * 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 TrainLanguageModelOptions. - * - * @return the trainLanguageModelOptions - */ - public TrainLanguageModelOptions build() { - return new TrainLanguageModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the TrainLanguageModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the wordTypeToAdd. - * - * @param wordTypeToAdd the wordTypeToAdd - * @return the TrainLanguageModelOptions builder - */ - public Builder wordTypeToAdd(String wordTypeToAdd) { - this.wordTypeToAdd = wordTypeToAdd; - return this; - } - - /** - * Set the customizationWeight. - * - * @param customizationWeight the customizationWeight - * @return the TrainLanguageModelOptions builder - */ - public Builder customizationWeight(Double customizationWeight) { - this.customizationWeight = customizationWeight; - return this; - } - } - - private TrainLanguageModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - wordTypeToAdd = builder.wordTypeToAdd; - customizationWeight = builder.customizationWeight; - } - - /** - * New builder. - * - * @return a TrainLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return 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 - * were added or modified by the user. - * * `user` trains the model only on new words that were added or modified by the user; the model is not trained on - * new words extracted from corpora. - * - * @return the wordTypeToAdd - */ - public String wordTypeToAdd() { - return 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. - * - * 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. - * - * @return the customizationWeight - */ - public Double customizationWeight() { - return customizationWeight; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UnregisterCallbackOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UnregisterCallbackOptions.java deleted file mode 100644 index 2faec4e6b92..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UnregisterCallbackOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The unregisterCallback options. - */ -public class UnregisterCallbackOptions extends GenericModel { - - private String callbackUrl; - - /** - * Builder. - */ - public static class Builder { - private String callbackUrl; - - private Builder(UnregisterCallbackOptions unregisterCallbackOptions) { - callbackUrl = unregisterCallbackOptions.callbackUrl; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param callbackUrl the callbackUrl - */ - public Builder(String callbackUrl) { - this.callbackUrl = callbackUrl; - } - - /** - * Builds a UnregisterCallbackOptions. - * - * @return the unregisterCallbackOptions - */ - public UnregisterCallbackOptions build() { - return new UnregisterCallbackOptions(this); - } - - /** - * Set the callbackUrl. - * - * @param callbackUrl the callbackUrl - * @return the UnregisterCallbackOptions builder - */ - public Builder callbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - return this; - } - } - - private UnregisterCallbackOptions(Builder builder) { - Validator.notNull(builder.callbackUrl, "callbackUrl cannot be null"); - callbackUrl = builder.callbackUrl; - } - - /** - * New builder. - * - * @return a UnregisterCallbackOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the callbackUrl. - * - * The callback URL that is to be unregistered. - * - * @return the callbackUrl - */ - public String callbackUrl() { - return callbackUrl; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeAcousticModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeAcousticModelOptions.java deleted file mode 100644 index 99d303a01c6..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeAcousticModelOptions.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The upgradeAcousticModel options. - */ -public class UpgradeAcousticModelOptions extends GenericModel { - - private String customizationId; - private String customLanguageModelId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String customLanguageModelId; - - private Builder(UpgradeAcousticModelOptions upgradeAcousticModelOptions) { - customizationId = upgradeAcousticModelOptions.customizationId; - customLanguageModelId = upgradeAcousticModelOptions.customLanguageModelId; - } - - /** - * 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 UpgradeAcousticModelOptions. - * - * @return the upgradeAcousticModelOptions - */ - public UpgradeAcousticModelOptions build() { - return new UpgradeAcousticModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the UpgradeAcousticModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the customLanguageModelId. - * - * @param customLanguageModelId the customLanguageModelId - * @return the UpgradeAcousticModelOptions builder - */ - public Builder customLanguageModelId(String customLanguageModelId) { - this.customLanguageModelId = customLanguageModelId; - return this; - } - } - - private UpgradeAcousticModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - customLanguageModelId = builder.customLanguageModelId; - } - - /** - * New builder. - * - * @return a UpgradeAcousticModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom acoustic model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return 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. - * - * @return the customLanguageModelId - */ - public String customLanguageModelId() { - return customLanguageModelId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeLanguageModelOptions.java deleted file mode 100644 index 94119ef051b..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/UpgradeLanguageModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The upgradeLanguageModel options. - */ -public class UpgradeLanguageModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(UpgradeLanguageModelOptions upgradeLanguageModelOptions) { - customizationId = upgradeLanguageModelOptions.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 UpgradeLanguageModelOptions. - * - * @return the upgradeLanguageModelOptions - */ - public UpgradeLanguageModelOptions build() { - return new UpgradeLanguageModelOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the UpgradeLanguageModelOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private UpgradeLanguageModelOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a UpgradeLanguageModelOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the customizationId. - * - * The customization ID (GUID) of the custom language model. You must make the request with service credentials - * created for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Word.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Word.java deleted file mode 100644 index 2b051057610..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Word.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Word. - */ -public class Word extends GenericModel { - - private String word; - @SerializedName("sounds_like") - private List soundsLike; - @SerializedName("display_as") - private String displayAs; - private Long count; - private List source; - private List error; - - /** - * Gets the word. - * - * A word from the custom model's words resource. The spelling of the word is used to train the model. - * - * @return the word - */ - public String getWord() { - return word; - } - - /** - * 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. - * - * @return the soundsLike - */ - public List getSoundsLike() { - return soundsLike; - } - - /** - * 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. - * - * @return the displayAs - */ - public String getDisplayAs() { - return displayAs; - } - - /** - * 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. - * - * @return the count - */ - public Long getCount() { - return count; - } - - /** - * 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`. - * - * @return the source - */ - public List getSource() { - return source; - } - - /** - * 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. - * - * @return the error - */ - public List getError() { - return error; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResult.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResult.java deleted file mode 100644 index cf8ec52a294..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResult.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WordAlternativeResult. - */ -public class WordAlternativeResult extends GenericModel { - - private Double confidence; - private String word; - - /** - * Gets the confidence. - * - * A confidence score for the word alternative hypothesis in the range of 0 to 1. - * - * @return the confidence - */ - public Double getConfidence() { - return confidence; - } - - /** - * Gets the word. - * - * An alternative hypothesis for a word from the input audio. - * - * @return the word - */ - public String getWord() { - return word; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResults.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResults.java deleted file mode 100644 index 9f954bf4c9d..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordAlternativeResults.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WordAlternativeResults. - */ -public class WordAlternativeResults extends GenericModel { - - @SerializedName("start_time") - private Double startTime; - @SerializedName("end_time") - private Double endTime; - private List alternatives; - - /** - * Gets the startTime. - * - * The start time in seconds of the word from the input audio that corresponds to the word alternatives. - * - * @return the startTime - */ - public Double getStartTime() { - return startTime; - } - - /** - * Gets the endTime. - * - * The end time in seconds of the word from the input audio that corresponds to the word alternatives. - * - * @return the endTime - */ - public Double getEndTime() { - return endTime; - } - - /** - * Gets the alternatives. - * - * An array of alternative hypotheses for a word from the input audio. - * - * @return the alternatives - */ - public List getAlternatives() { - return alternatives; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordError.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordError.java deleted file mode 100644 index 01eaa7bffd8..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/WordError.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * WordError. - */ -public class WordError extends GenericModel { - - private String element; - - /** - * Gets the element. - * - * A key-value pair that describes an error associated with the definition of a word in the words resource. Each 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}'."` You must correct the error before you can train the model. - * - * @return the element - */ - public String getElement() { - return element; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Words.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Words.java deleted file mode 100644 index 041ab5a753f..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/Words.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Words. - */ -public class Words extends GenericModel { - - private List words; - - /** - * Gets the words. - * - * An array of 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 - */ - public List getWords() { - return words; - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/package-info.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/package-info.java deleted file mode 100644 index 3b5109b66b9..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/BaseRecognizeCallback.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/BaseRecognizeCallback.java deleted file mode 100755 index f6d9a741b62..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/BaseRecognizeCallback.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.websocket; - -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An empty implementation of {@link RecognizeCallback} interface. - */ -public class BaseRecognizeCallback implements RecognizeCallback { - - private static final Logger LOG = Logger.getLogger(BaseRecognizeCallback.class.getName()); - - /* - * (non-Javadoc) - * @see - * com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onTranscription(com. - * ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults) - */ - public void onTranscription(SpeechRecognitionResults speechResults) { - }; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onConnected() - */ - public void onConnected() { - }; - - /* - * (non-Javadoc) - * @see - * com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onError(java.lang - * .Exception) - */ - public void onError(Exception e) { - LOG.log(Level.SEVERE, e.getMessage(), e); - }; - - /* - * (non-Javadoc) - * @see - * com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onDisconnected() - */ - public void onDisconnected() { - }; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.speech_to_text.v1.websocket - * .RecognizeCallback#onInactivityTimeout(java.lang.RuntimeException) - */ - @Override - public void onInactivityTimeout(RuntimeException runtimeException) { - }; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onListening() - */ - @Override - public void onListening() { - }; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback#onTranscriptionComplete() - */ - @Override - public void onTranscriptionComplete() { - }; - -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/RecognizeCallback.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/RecognizeCallback.java deleted file mode 100755 index d46a0295606..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/RecognizeCallback.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.websocket; - -import com.ibm.watson.developer_cloud.speech_to_text.v1.SpeechToText; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; - -import okhttp3.WebSocket; - -/** - * The recognize callback used during a {@link WebSocket} recognition by the {@link SpeechToText} service. - */ -public interface RecognizeCallback { - - /** - * Called when a {@link SpeechRecognitionResults} was received. - * - * @param speechResults the speech results - */ - void onTranscription(SpeechRecognitionResults speechResults); - - /** - * Called when a WebSocket connection was made. - */ - void onConnected(); - - /** - * Called when there is an error in the Web Socket connection. - * - * @param e the exception - */ - void onError(Exception e); - - /** - * Called when a WebSocket connection was closed. - */ - void onDisconnected(); - - /** - * Called when there is an inactivity timeout. - * - * @param runtimeException the runtime exception - */ - void onInactivityTimeout(RuntimeException runtimeException); - - /** - * Called when the service is listening for audio. - */ - void onListening(); - - /** - * 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/developer_cloud/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java deleted file mode 100755 index aa3ebb49428..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.websocket; - -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.watson.developer_cloud.speech_to_text.v1.SpeechToText; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -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; - -/** - * 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. - * - * @see SpeechToText - */ -public final class SpeechToTextWebSocketListener extends WebSocketListener { - - private static final String AUDIO_TO_WEB_SOCKET = "AudioToWebSocketThread"; - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - private static final Logger LOG = Logger.getLogger(SpeechToTextWebSocketListener.class.getName()); - - private static final String STATE = "state"; - private static final String MODEL = "model"; - private static final String START = "start"; - private static final String STOP = "stop"; - private static final String ACTION = "action"; - private static final int ONE_KB = 1024; - private static final String ERROR = "error"; - private static final String RESULTS = "results"; - private static final String SPEAKER_LABELS = "speaker_labels"; - private static final String CUSTOMIZATION_ID = "customization_id"; - private static final String ACOUSTIC_CUSTOMIZATION_ID = "acoustic_customization_id"; - private static final String CUSTOMIZATION_WEIGHT = "customization_weight"; - private static final String VERSION = "base_model_version"; - - private static final String TIMEOUT_PREFIX = "No speech detected for"; - - private final InputStream stream; - private final RecognizeOptions options; - private final RecognizeCallback callback; - private WebSocket socket; - private boolean socketOpen = true; - private Thread audioThread = null; - private boolean isListening = false; - private static final int CLOSE_NORMAL = 1000; - - /** - * Instantiates a new speech to text web socket listener. - * - * @param options the recognize options - * @param callback the callback - */ - public SpeechToTextWebSocketListener(final RecognizeOptions options, final RecognizeCallback callback) { - this.stream = options.audio(); - this.options = options; - this.callback = callback; - } - - /* - * (non-Javadoc) - * @see okhttp3.WebSocketListener#onClosing(okhttp3.WebSocket, int, java.lang.String) - */ - @Override - public void onClosing(WebSocket webSocket, int code, String reason) { - socketOpen = false; - callback.onDisconnected(); - } - - /* - * (non-Javadoc) - * @see okhttp3.WebSocketListener#onFailure(okhttp3.WebSocket, java.lang.Throwable, okhttp3.Response) - */ - @Override - public void onFailure(WebSocket webSocket, Throwable t, Response response) { - socketOpen = false; - if (t instanceof Exception) { - callback.onError((Exception) t); - } else { - callback.onError(new Exception(t)); - } - } - - /* - * (non-Javadoc) - * @see okhttp3.WebSocketListener#onMessage(okhttp3.WebSocket, java.lang.String) - */ - @Override - public void onMessage(WebSocket webSocket, String message) { - JsonObject json = new JsonParser().parse(message).getAsJsonObject(); - if (json.has(ERROR)) { - String error = json.get(ERROR).getAsString(); - - // Only call onError() if a real error occurred. The STT service sends - // {"error" : "No speech detected for 5s"} for valid timeouts, configured by - // RecognizeUsingWebSocketOptions.Builder.inactivityTimeout() - if (!error.startsWith(TIMEOUT_PREFIX)) { - callback.onError(new RuntimeException(error)); - } else { - // notify that the service timeouts because of inactivity - callback.onInactivityTimeout(new RuntimeException(error)); - } - } else if (json.has(RESULTS) || json.has(SPEAKER_LABELS)) { - callback.onTranscription(GSON.fromJson(message, SpeechRecognitionResults.class)); - - } else if (json.has(STATE)) { - // A listen state after everything has been sent over indicates everything has been processed - if (!isListening) { - isListening = true; - } else { - callback.onTranscriptionComplete(); - socket.close(CLOSE_NORMAL, "Transcription completed"); - return; - } - - // notify that the service is ready to receive audio - callback.onListening(); - } - } - - /* - * (non-Javadoc) - * @see okhttp3.WebSocketListener#onOpen(okhttp3.WebSocket, okhttp3.Response) - */ - @Override - public void onOpen(final WebSocket socket, Response response) { - callback.onConnected(); - this.socket = socket; - if (!socket.send(buildStartMessage(options))) { - callback.onError(new IOException("WebSocket unavailable")); - } else { - // 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.start(); - } - } - - /** - * Send input stream. - * - * @param inputStream the input stream - */ - 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 - // closed. Elsewise AudioInputStream.read() blocks until enough audio frames are read. - while (((read = inputStream.read(buffer)) > 0) && socketOpen) { - if (read == ONE_KB) { - socket.send(ByteString.of(buffer)); - } else { - socket.send(ByteString.of(Arrays.copyOfRange(buffer, 0, read))); - } - } - } catch (IOException e) { - LOG.log(Level.SEVERE, e.getMessage(), e); - } finally { - try { - inputStream.close(); - } catch (IOException e) { - // do nothing - the InputStream may have already been closed externally. - } - } - } - - /** - * Builds the start message. - * - * @param options the options - * @return the request - */ - private String buildStartMessage(RecognizeOptions 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(ACOUSTIC_CUSTOMIZATION_ID); - startMessage.remove(CUSTOMIZATION_WEIGHT); - startMessage.remove(VERSION); - startMessage.addProperty(ACTION, START); - return startMessage.toString(); - } - - /** - * Builds the stop message. - * - * @return the string - */ - private String buildStopMessage() { - JsonObject stopMessage = new JsonObject(); - stopMessage.addProperty(ACTION, STOP); - return stopMessage.toString(); - } -} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/package-info.java b/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/package-info.java deleted file mode 100644 index 183896c50be..00000000000 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -/** - * This package contains interfaces and implementations to work with Websocket in Speech to Text. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1.websocket; 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 new file mode 100644 index 00000000000..e26990f3a52 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/SpeechToText.java @@ -0,0 +1,2804 @@ +/* + * (C) Copyright IBM Corp. 2016, 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. + */ + +/* + * 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; +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.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.AddWordsOptions; +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.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; +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.DeleteCorpusOptions; +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.DeleteWordOptions; +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.LanguageModel; +import com.ibm.watson.speech_to_text.v1.model.LanguageModels; +import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; +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.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; +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; +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.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.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 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. + * + *

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. + * + *

Language model customization and grammars are available for most previous- and next-generation + * models. Acoustic model customization is available for all previous-generation models. + * + *

API Version: 1.0.0 See: https://cloud.ibm.com/docs/speech-to-text + */ +public class SpeechToText extends BaseService { + + /** Default service name used when configuring the `SpeechToText` client. */ + public static final String DEFAULT_SERVICE_NAME = "speech_to_text"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.speech-to-text.watson.cloud.ibm.com"; + + /** + * 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)); + } + + /** + * Constructs an instance of the `SpeechToText` client. The default service name and specified + * authenticator are used to configure the client instance. + * + * @param authenticator the {@link Authenticator} instance to be configured for this client + */ + public SpeechToText(Authenticator authenticator) { + this(DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `SpeechToText` client. The specified service name is used to + * configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + */ + public SpeechToText(String serviceName) { + this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `SpeechToText` client. The specified service name and + * authenticator are used to configure the client instance. + * + * @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); + setServiceUrl(DEFAULT_SERVICE_URL); + 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. 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:** [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 result of type {@link SpeechModels} + */ + public ServiceCall listModels(ListModelsOptions listModelsOptions) { + 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"); + 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. 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:** [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 result of type {@link SpeechModels} + */ + public ServiceCall listModels() { + return listModels(null); + } + + /** + * 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. + * + *

**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 result of type {@link SpeechModel} + */ + public ServiceCall getModel(GetModelOptions getModelOptions) { + 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()); + 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.) + * + *

**See also:** [Making a basic HTTP + * request](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-http#HTTP-basic). + * + *

### 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) + * * [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:** [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 result of type {@link SpeechRecognitionResults} + */ + public ServiceCall recognize(RecognizeOptions recognizeOptions) { + 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()); + } + builder.header("Accept", "application/json"); + if (recognizeOptions.contentType() != null) { + builder.header("Content-Type", recognizeOptions.contentType()); + } + if (recognizeOptions.model() != null) { + builder.query("model", String.valueOf(recognizeOptions.model())); + } + if (recognizeOptions.speechBeginEvent() != null) { + builder.query("speech_begin_event", String.valueOf(recognizeOptions.speechBeginEvent())); + } + if (recognizeOptions.languageCustomizationId() != null) { + builder.query( + "language_customization_id", String.valueOf(recognizeOptions.languageCustomizationId())); + } + if (recognizeOptions.acousticCustomizationId() != null) { + builder.query( + "acoustic_customization_id", String.valueOf(recognizeOptions.acousticCustomizationId())); + } + if (recognizeOptions.baseModelVersion() != null) { + builder.query("base_model_version", String.valueOf(recognizeOptions.baseModelVersion())); + } + if (recognizeOptions.customizationWeight() != null) { + builder.query("customization_weight", String.valueOf(recognizeOptions.customizationWeight())); + } + if (recognizeOptions.inactivityTimeout() != null) { + builder.query("inactivity_timeout", String.valueOf(recognizeOptions.inactivityTimeout())); + } + if (recognizeOptions.keywords() != null) { + builder.query("keywords", RequestUtils.join(recognizeOptions.keywords(), ",")); + } + if (recognizeOptions.keywordsThreshold() != null) { + builder.query("keywords_threshold", String.valueOf(recognizeOptions.keywordsThreshold())); + } + if (recognizeOptions.maxAlternatives() != null) { + builder.query("max_alternatives", String.valueOf(recognizeOptions.maxAlternatives())); + } + if (recognizeOptions.wordAlternativesThreshold() != null) { + builder.query( + "word_alternatives_threshold", + String.valueOf(recognizeOptions.wordAlternativesThreshold())); + } + if (recognizeOptions.wordConfidence() != null) { + builder.query("word_confidence", String.valueOf(recognizeOptions.wordConfidence())); + } + if (recognizeOptions.timestamps() != null) { + builder.query("timestamps", String.valueOf(recognizeOptions.timestamps())); + } + if (recognizeOptions.profanityFilter() != null) { + builder.query("profanity_filter", String.valueOf(recognizeOptions.profanityFilter())); + } + 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.grammarName() != null) { + builder.query("grammar_name", String.valueOf(recognizeOptions.grammarName())); + } + if (recognizeOptions.redaction() != null) { + builder.query("redaction", String.valueOf(recognizeOptions.redaction())); + } + if (recognizeOptions.audioMetrics() != null) { + builder.query("audio_metrics", String.valueOf(recognizeOptions.audioMetrics())); + } + if (recognizeOptions.endOfPhraseSilenceTime() != null) { + 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())); + } + 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); + } + + /** + * Register a callback. + * + *

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. + * + *

**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 result of type {@link RegisterStatus} + */ + 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", String.valueOf(registerCallbackOptions.callbackUrl())); + if (registerCallbackOptions.userSecret() != null) { + builder.query("user_secret", String.valueOf(registerCallbackOptions.userSecret())); + } + 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 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 + * 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 void result + */ + public ServiceCall unregisterCallback(UnregisterCallbackOptions unregisterCallbackOptions) { + 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", String.valueOf(unregisterCallbackOptions.callbackUrl())); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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](#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) + * * [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:** [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 result of type {@link RecognitionJob} + */ + public ServiceCall createJob(CreateJobOptions createJobOptions) { + 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()); + } + builder.header("Accept", "application/json"); + if (createJobOptions.contentType() != null) { + builder.header("Content-Type", createJobOptions.contentType()); + } + if (createJobOptions.model() != null) { + builder.query("model", String.valueOf(createJobOptions.model())); + } + if (createJobOptions.callbackUrl() != null) { + builder.query("callback_url", String.valueOf(createJobOptions.callbackUrl())); + } + if (createJobOptions.events() != null) { + builder.query("events", String.valueOf(createJobOptions.events())); + } + if (createJobOptions.userToken() != null) { + builder.query("user_token", String.valueOf(createJobOptions.userToken())); + } + if (createJobOptions.resultsTtl() != null) { + builder.query("results_ttl", String.valueOf(createJobOptions.resultsTtl())); + } + if (createJobOptions.languageCustomizationId() != null) { + builder.query( + "language_customization_id", String.valueOf(createJobOptions.languageCustomizationId())); + } + if (createJobOptions.acousticCustomizationId() != null) { + builder.query( + "acoustic_customization_id", String.valueOf(createJobOptions.acousticCustomizationId())); + } + if (createJobOptions.baseModelVersion() != null) { + builder.query("base_model_version", String.valueOf(createJobOptions.baseModelVersion())); + } + if (createJobOptions.customizationWeight() != null) { + builder.query("customization_weight", String.valueOf(createJobOptions.customizationWeight())); + } + if (createJobOptions.inactivityTimeout() != null) { + builder.query("inactivity_timeout", String.valueOf(createJobOptions.inactivityTimeout())); + } + if (createJobOptions.keywords() != null) { + builder.query("keywords", RequestUtils.join(createJobOptions.keywords(), ",")); + } + if (createJobOptions.keywordsThreshold() != null) { + builder.query("keywords_threshold", String.valueOf(createJobOptions.keywordsThreshold())); + } + if (createJobOptions.maxAlternatives() != null) { + builder.query("max_alternatives", String.valueOf(createJobOptions.maxAlternatives())); + } + if (createJobOptions.wordAlternativesThreshold() != null) { + builder.query( + "word_alternatives_threshold", + String.valueOf(createJobOptions.wordAlternativesThreshold())); + } + if (createJobOptions.wordConfidence() != null) { + builder.query("word_confidence", String.valueOf(createJobOptions.wordConfidence())); + } + if (createJobOptions.timestamps() != null) { + builder.query("timestamps", String.valueOf(createJobOptions.timestamps())); + } + if (createJobOptions.profanityFilter() != null) { + builder.query("profanity_filter", String.valueOf(createJobOptions.profanityFilter())); + } + 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.grammarName() != null) { + builder.query("grammar_name", String.valueOf(createJobOptions.grammarName())); + } + if (createJobOptions.redaction() != null) { + builder.query("redaction", String.valueOf(createJobOptions.redaction())); + } + if (createJobOptions.processingMetrics() != null) { + builder.query("processing_metrics", String.valueOf(createJobOptions.processingMetrics())); + } + if (createJobOptions.processingMetricsInterval() != null) { + 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())); + } + if (createJobOptions.splitTranscriptAtPhraseEnd() != null) { + 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[(#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 + * 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 result of type {@link RecognitionJobs} + */ + public ServiceCall checkJobs(CheckJobsOptions checkJobsOptions) { + 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"); + 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[(#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 + * jobs](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async#jobs). + * + * @return a {@link ServiceCall} with a result of type {@link RecognitionJobs} + */ + public ServiceCall checkJobs() { + return checkJobs(null); + } + + /** + * 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. + * + *

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 + * 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 result of type {@link RecognitionJob} + */ + public ServiceCall checkJob(CheckJobOptions checkJobOptions) { + 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()); + 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. + * + *

**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 void result + */ + public ServiceCall deleteJob(DeleteJobOptions deleteJobOptions) { + 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); + } + + /** + * 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. + * + *

**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"); + 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()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createLanguageModelOptions.name()); + contentJson.addProperty("base_model_name", createLanguageModelOptions.baseModelName()); + if (createLanguageModelOptions.dialect() != null) { + contentJson.addProperty("dialect", createLanguageModelOptions.dialect()); + } + if (createLanguageModelOptions.description() != null) { + contentJson.addProperty("description", createLanguageModelOptions.description()); + } + builder.bodyJson(contentJson); + 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. + * + *

**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 result of type {@link LanguageModels} + */ + 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.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. + * + *

**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 result of type {@link LanguageModels} + */ + public ServiceCall listLanguageModels() { + return listLanguageModels(null); + } + + /** + * 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. + * + *

**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 result of type {@link LanguageModel} + */ + 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()); + 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. + * + *

**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 void result + */ + 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); + } + + /** + * 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](#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"); + 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", String.valueOf(trainLanguageModelOptions.wordTypeToAdd())); + } + if (trainLanguageModelOptions.customizationWeight() != null) { + builder.query( + "customization_weight", String.valueOf(trainLanguageModelOptions.customizationWeight())); + } + if (trainLanguageModelOptions.strict() != null) { + builder.query("strict", String.valueOf(trainLanguageModelOptions.strict())); + } + 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. + * + *

**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 void result + */ + public ServiceCall resetLanguageModel(ResetLanguageModelOptions resetLanguageModelOptions) { + 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); + } + + /** + * 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](#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"); + 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); + } + + /** + * List 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 + * 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 result of type {@link Corpora} + */ + public ServiceCall listCorpora(ListCorporaOptions listCorporaOptions) { + 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()); + 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](#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 void result + */ + public ServiceCall addCorpus(AddCorpusOptions addCorpusOptions) { + 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()); + } + builder.header("Accept", "application/json"); + 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); + } + + /** + * Get a corpus. + * + *

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 + * 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 result of type {@link Corpus} + */ + public ServiceCall getCorpus(GetCorpusOptions getCorpusOptions) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a corpus. + * + *

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 + * 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 void result + */ + public ServiceCall deleteCorpus(DeleteCorpusOptions deleteCorpusOptions) { + 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); + } + + /** + * 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, _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 + * 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 result of type {@link Words} + */ + public ServiceCall listWords(ListWordsOptions listWordsOptions) { + 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", String.valueOf(listWordsOptions.wordType())); + } + if (listWordsOptions.sort() != null) { + builder.query("sort", String.valueOf(listWordsOptions.sort())); + } + 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. 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](#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 void result + */ + public ServiceCall addWords(AddWordsOptions addWordsOptions) { + 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())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Add a custom word. + * + *

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 void result + */ + public ServiceCall addWord(AddWordOptions addWordOptions) { + 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()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + 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())); + } + if (addWordOptions.displayAs() != null) { + contentJson.addProperty("display_as", addWordOptions.displayAs()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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. + * + *

**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 result of type {@link Word} + */ + public ServiceCall getWord(GetWordOptions getWordOptions) { + 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()); + 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 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 + * 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 void result + */ + public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { + 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); + } + + /** + * List 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) + * * [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 result of type {@link Grammars} + */ + public ServiceCall listGrammars(ListGrammarsOptions listGrammarsOptions) { + 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()); + 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](#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) * + * [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 void result + */ + public ServiceCall addGrammar(AddGrammarOptions addGrammarOptions) { + 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()); + } + builder.header("Accept", "application/json"); + builder.header("Content-Type", addGrammarOptions.contentType()); + if (addGrammarOptions.allowOverwrite() != null) { + builder.query("allow_overwrite", String.valueOf(addGrammarOptions.allowOverwrite())); + } + builder.bodyContent( + addGrammarOptions.contentType(), null, null, addGrammarOptions.grammarFile()); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a grammar. + * + *

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) + * * [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 result of type {@link Grammar} + */ + public ServiceCall getGrammar(GetGrammarOptions getGrammarOptions) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a grammar. + * + *

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"); + 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); + } + + /** + * 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. + * + *

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. + * + *

**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 result of type {@link AcousticModel} + */ + 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()); + } + builder.header("Accept", "application/json"); + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("name", createAcousticModelOptions.name()); + contentJson.addProperty("base_model_name", createAcousticModelOptions.baseModelName()); + if (createAcousticModelOptions.description() != null) { + contentJson.addProperty("description", createAcousticModelOptions.description()); + } + builder.bodyJson(contentJson); + 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. + * + *

**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). + * + * @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) { + 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.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. + * + *

**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 result of type {@link AcousticModels} + */ + public ServiceCall listAcousticModels() { + return listAcousticModels(null); + } + + /** + * 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. + * + *

**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). + * + * @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"); + 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()); + 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. + * + *

**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 + * 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 void result + */ + 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); + } + + /** + * 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. 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 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"); + 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", + 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()); + 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. + * + *

**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 + * 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 void result + */ + public ServiceCall resetAcousticModel(ResetAcousticModelOptions resetAcousticModelOptions) { + 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); + } + + /** + * 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](#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"); + 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", + String.valueOf(upgradeAcousticModelOptions.customLanguageModelId())); + } + if (upgradeAcousticModelOptions.force() != null) { + builder.query("force", String.valueOf(upgradeAcousticModelOptions.force())); + } + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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. + * + *

**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 + * 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 result of type {@link AudioResources} + */ + public ServiceCall listAudio(ListAudioOptions listAudioOptions) { + 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()); + 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](#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:** [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 void result + */ + public ServiceCall addAudio(AddAudioOptions addAudioOptions) { + 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()); + } + builder.header("Accept", "application/json"); + if (addAudioOptions.contentType() != null) { + builder.header("Content-Type", addAudioOptions.contentType()); + } + if (addAudioOptions.containedContentType() != null) { + builder.header("Contained-Content-Type", addAudioOptions.containedContentType()); + } + if (addAudioOptions.allowOverwrite() != null) { + builder.query("allow_overwrite", String.valueOf(addAudioOptions.allowOverwrite())); + } + builder.bodyContent(addAudioOptions.contentType(), null, null, addAudioOptions.audioResource()); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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. + * + *

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. + * + *

**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 + * 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 result of type {@link AudioListing} + */ + public ServiceCall getAudio(GetAudioOptions getAudioOptions) { + 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()); + 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. + * + *

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. + * + *

**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 + * 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 void result + */ + public ServiceCall deleteAudio(DeleteAudioOptions deleteAudioOptions) { + 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); + } + + /** + * 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. 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 + * 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 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(), "/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", String.valueOf(deleteUserDataOptions.customerId())); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + 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 new file mode 100644 index 00000000000..3c4cf150b89 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModel.java @@ -0,0 +1,219 @@ +/* + * (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.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. */ +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. + */ + public interface Status { + /** pending. */ + String PENDING = "pending"; + /** ready. */ + String READY = "ready"; + /** training. */ + String TRAINING = "training"; + /** available. */ + String AVAILABLE = "available"; + /** upgrading. */ + String UPGRADING = "upgrading"; + /** failed. */ + String FAILED = "failed"; + } + + @SerializedName("customization_id") + protected String customizationId; + + protected String created; + protected String updated; + protected String language; + protected List versions; + 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](#createacousticmodel) method returns only this field of the object; it does not return + * the other fields. + * + * @return the customizationId + */ + public String getCustomizationId() { + return customizationId; + } + + /** + * 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`). + * + * @return the created + */ + public String getCreated() { + return created; + } + + /** + * 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). + * + * @return the updated + */ + public String getUpdated() { + return updated; + } + + /** + * Gets the language. + * + *

The language identifier of the custom acoustic model (for example, `en-US`). + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * 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 to a new version of its base model. + * Otherwise, only a single version is shown. + * + * @return the versions + */ + public List getVersions() { + return versions; + } + + /** + * Gets the owner. + * + *

The GUID of the credentials for the instance of the service that owns the custom acoustic + * model. + * + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * Gets the name. + * + *

The name of the custom acoustic model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

The description of the custom acoustic model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the baseModelName. + * + *

The name of the language model for which the custom acoustic model was created. + * + * @return the baseModelName + */ + public String getBaseModelName() { + return baseModelName; + } + + /** + * 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. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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. + * + * @return the progress + */ + public Long getProgress() { + return progress; + } + + /** + * 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. + * + * @return the warnings + */ + public String getWarnings() { + return 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 new file mode 100644 index 00000000000..81dfdf516de --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AcousticModels.java @@ -0,0 +1,38 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the customizations + */ + public List getCustomizations() { + return 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 new file mode 100644 index 00000000000..3fdded026ec --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddAudioOptions.java @@ -0,0 +1,328 @@ +/* + * (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.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 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 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. + * + *

_For an audio-type resource_, omit the header. + */ + public interface ContainedContentType { + /** audio/alaw. */ + String AUDIO_ALAW = "audio/alaw"; + /** audio/basic. */ + String AUDIO_BASIC = "audio/basic"; + /** audio/flac. */ + String AUDIO_FLAC = "audio/flac"; + /** audio/g729. */ + String AUDIO_G729 = "audio/g729"; + /** audio/l16. */ + String AUDIO_L16 = "audio/l16"; + /** audio/mp3. */ + String AUDIO_MP3 = "audio/mp3"; + /** audio/mpeg. */ + String AUDIO_MPEG = "audio/mpeg"; + /** audio/mulaw. */ + String AUDIO_MULAW = "audio/mulaw"; + /** audio/ogg. */ + String AUDIO_OGG = "audio/ogg"; + /** audio/ogg;codecs=opus. */ + String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; + /** audio/ogg;codecs=vorbis. */ + String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; + /** audio/wav. */ + String AUDIO_WAV = "audio/wav"; + /** audio/webm. */ + String AUDIO_WEBM = "audio/webm"; + /** audio/webm;codecs=opus. */ + String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; + /** audio/webm;codecs=vorbis. */ + String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; + } + + protected String customizationId; + protected String audioName; + protected InputStream audioResource; + protected String contentType; + protected String containedContentType; + protected Boolean allowOverwrite; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String audioName; + private InputStream audioResource; + private String contentType; + 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; + this.audioResource = addAudioOptions.audioResource; + this.contentType = addAudioOptions.contentType; + this.containedContentType = addAudioOptions.containedContentType; + this.allowOverwrite = addAudioOptions.allowOverwrite; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param audioName the audioName + * @param audioResource the audioResource + */ + public Builder(String customizationId, String audioName, InputStream audioResource) { + this.customizationId = customizationId; + this.audioName = audioName; + this.audioResource = audioResource; + } + + /** + * Builds a AddAudioOptions. + * + * @return the new AddAudioOptions instance + */ + public AddAudioOptions build() { + return new AddAudioOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddAudioOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the audioName. + * + * @param audioName the audioName + * @return the AddAudioOptions builder + */ + public Builder audioName(String audioName) { + this.audioName = audioName; + return this; + } + + /** + * Set the audioResource. + * + * @param audioResource the audioResource + * @return the AddAudioOptions builder + */ + public Builder audioResource(InputStream audioResource) { + this.audioResource = audioResource; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the AddAudioOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the containedContentType. + * + * @param containedContentType the containedContentType + * @return the AddAudioOptions builder + */ + public Builder containedContentType(String containedContentType) { + this.containedContentType = containedContentType; + return this; + } + + /** + * Set the allowOverwrite. + * + * @param allowOverwrite the allowOverwrite + * @return the AddAudioOptions builder + */ + public Builder allowOverwrite(Boolean allowOverwrite) { + this.allowOverwrite = allowOverwrite; + return this; + } + + /** + * Set the audioResource. + * + * @param audioResource the audioResource + * @return the AddAudioOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder audioResource(File audioResource) throws FileNotFoundException { + this.audioResource = new FileInputStream(audioResource); + return this; + } + } + + 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"); + customizationId = builder.customizationId; + audioName = builder.audioName; + audioResource = builder.audioResource; + contentType = builder.contentType; + containedContentType = builder.containedContentType; + allowOverwrite = builder.allowOverwrite; + } + + /** + * New builder. + * + * @return a AddAudioOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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. + * + * @return the audioName + */ + public String audioName() { + return 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. + * + *

With the `curl` command, use the `--data-binary` option to upload the file for the request. + * + * @return the audioResource + */ + public InputStream audioResource() { + return 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 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 + */ + public String contentType() { + return 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 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. + * + *

_For an audio-type resource_, omit the header. + * + * @return the containedContentType + */ + public String containedContentType() { + return 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. + * + * @return the allowOverwrite + */ + public Boolean allowOverwrite() { + return 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 new file mode 100644 index 00000000000..d302ff9f437 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddCorpusOptions.java @@ -0,0 +1,219 @@ +/* + * (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.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 addCorpus options. */ +public class AddCorpusOptions extends GenericModel { + + protected String customizationId; + protected String corpusName; + protected InputStream corpusFile; + protected Boolean allowOverwrite; + + /** 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; + this.corpusFile = addCorpusOptions.corpusFile; + this.allowOverwrite = addCorpusOptions.allowOverwrite; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param corpusName the corpusName + * @param corpusFile the corpusFile + */ + public Builder(String customizationId, String corpusName, InputStream corpusFile) { + this.customizationId = customizationId; + this.corpusName = corpusName; + this.corpusFile = corpusFile; + } + + /** + * Builds a AddCorpusOptions. + * + * @return the new AddCorpusOptions instance + */ + public AddCorpusOptions build() { + return new AddCorpusOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddCorpusOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the corpusName. + * + * @param corpusName the corpusName + * @return the AddCorpusOptions builder + */ + public Builder corpusName(String corpusName) { + this.corpusName = corpusName; + return this; + } + + /** + * Set the corpusFile. + * + * @param corpusFile the corpusFile + * @return the AddCorpusOptions builder + */ + public Builder corpusFile(InputStream corpusFile) { + this.corpusFile = corpusFile; + return this; + } + + /** + * Set the allowOverwrite. + * + * @param allowOverwrite the allowOverwrite + * @return the AddCorpusOptions builder + */ + public Builder allowOverwrite(Boolean allowOverwrite) { + this.allowOverwrite = allowOverwrite; + return this; + } + + /** + * Set the corpusFile. + * + * @param corpusFile the corpusFile + * @return the AddCorpusOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder corpusFile(File corpusFile) throws FileNotFoundException { + this.corpusFile = new FileInputStream(corpusFile); + return this; + } + } + + 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"); + customizationId = builder.customizationId; + corpusName = builder.corpusName; + corpusFile = builder.corpusFile; + allowOverwrite = builder.allowOverwrite; + } + + /** + * New builder. + * + * @return a AddCorpusOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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. + * + * @return the corpusName + */ + public String corpusName() { + return 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. + * + *

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. + * + * @return the corpusFile + */ + public InputStream corpusFile() { + return 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. + * + * @return the allowOverwrite + */ + public Boolean allowOverwrite() { + return 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 new file mode 100644 index 00000000000..624b969f57d --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddGrammarOptions.java @@ -0,0 +1,250 @@ +/* + * (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.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 addGrammar options. */ +public class AddGrammarOptions extends GenericModel { + + protected String customizationId; + protected String grammarName; + protected InputStream grammarFile; + protected String contentType; + protected Boolean allowOverwrite; + + /** Builder. */ + public static class Builder { + private String customizationId; + private String grammarName; + private InputStream grammarFile; + 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; + this.grammarFile = addGrammarOptions.grammarFile; + this.contentType = addGrammarOptions.contentType; + this.allowOverwrite = addGrammarOptions.allowOverwrite; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param grammarName the grammarName + * @param grammarFile the grammarFile + * @param contentType the contentType + */ + public Builder( + String customizationId, String grammarName, InputStream grammarFile, String contentType) { + this.customizationId = customizationId; + this.grammarName = grammarName; + this.grammarFile = grammarFile; + this.contentType = contentType; + } + + /** + * Builds a AddGrammarOptions. + * + * @return the new AddGrammarOptions instance + */ + public AddGrammarOptions build() { + return new AddGrammarOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddGrammarOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the grammarName. + * + * @param grammarName the grammarName + * @return the AddGrammarOptions builder + */ + public Builder grammarName(String grammarName) { + this.grammarName = grammarName; + return this; + } + + /** + * Set the grammarFile. + * + * @param grammarFile the grammarFile + * @return the AddGrammarOptions builder + */ + public Builder grammarFile(InputStream grammarFile) { + this.grammarFile = grammarFile; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the AddGrammarOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the allowOverwrite. + * + * @param allowOverwrite the allowOverwrite + * @return the AddGrammarOptions builder + */ + public Builder allowOverwrite(Boolean allowOverwrite) { + this.allowOverwrite = allowOverwrite; + return this; + } + + /** + * Set the grammarFile. + * + * @param grammarFile the grammarFile + * @return the AddGrammarOptions builder + * @throws FileNotFoundException if the file could not be found + */ + public Builder grammarFile(File grammarFile) throws FileNotFoundException { + this.grammarFile = new FileInputStream(grammarFile); + return this; + } + } + + 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"); + customizationId = builder.customizationId; + grammarName = builder.grammarName; + grammarFile = builder.grammarFile; + contentType = builder.contentType; + allowOverwrite = builder.allowOverwrite; + } + + /** + * New builder. + * + * @return a AddGrammarOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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. + * + * @return the grammarName + */ + public String grammarName() { + return 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. + * + *

With the `curl` command, use the `--data-binary` option to upload the file for the request. + * + * @return the grammarFile + */ + public InputStream grammarFile() { + return 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. + * + * @return the contentType + */ + public String contentType() { + return 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. + * + * @return the allowOverwrite + */ + public Boolean allowOverwrite() { + return 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 new file mode 100644 index 00000000000..5a0f1767848 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordOptions.java @@ -0,0 +1,296 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** 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. */ + 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 with required properties. + * + * @param customizationId the customizationId + * @param wordName the wordName + */ + public Builder(String customizationId, String wordName) { + this.customizationId = customizationId; + this.wordName = wordName; + } + + /** + * Builds a AddWordOptions. + * + * @return the new AddWordOptions instance + */ + public AddWordOptions build() { + return new AddWordOptions(this); + } + + /** + * 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 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"); + if (this.soundsLike == null) { + this.soundsLike = new ArrayList(); + } + this.soundsLike.add(soundsLike); + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the wordName. + * + * @param wordName the wordName + * @return the AddWordOptions builder + */ + public Builder wordName(String wordName) { + this.wordName = wordName; + return this; + } + + /** + * Set the word. + * + * @param word the word + * @return the AddWordOptions builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + + /** + * 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 + */ + public Builder soundsLike(List soundsLike) { + this.soundsLike = soundsLike; + return this; + } + + /** + * Set the displayAs. + * + * @param displayAs the displayAs + * @return the AddWordOptions builder + */ + public Builder displayAs(String displayAs) { + this.displayAs = displayAs; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + wordName = builder.wordName; + word = builder.word; + mappingOnly = builder.mappingOnly; + soundsLike = builder.soundsLike; + displayAs = builder.displayAs; + } + + /** + * New builder. + * + * @return a AddWordOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the wordName. + * + *

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). + * + * @return the wordName + */ + public String wordName() { + return wordName; + } + + /** + * Gets the word. + * + *

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](#addword) method. + * + * @return the word + */ + 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. + * + *

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 leading or trailing spaces. A Japanese pronunciation can include + * at most 25 characters, not including leading or trailing spaces. + * + * @return the soundsLike + */ + public List soundsLike() { + return 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. + * + *

_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 + */ + public String displayAs() { + return 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 new file mode 100644 index 00000000000..b8ed50e4b53 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AddWordsOptions.java @@ -0,0 +1,145 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The addWords options. */ +public class AddWordsOptions extends GenericModel { + + protected String customizationId; + protected List words; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param words the words + */ + public Builder(String customizationId, List words) { + this.customizationId = customizationId; + this.words = words; + } + + /** + * Builds a AddWordsOptions. + * + * @return the new AddWordsOptions instance + */ + public AddWordsOptions build() { + return new AddWordsOptions(this); + } + + /** + * Adds a new element to 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"); + if (this.words == null) { + this.words = new ArrayList(); + } + this.words.add(words); + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddWordsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the words. Existing words will be replaced. + * + * @param words the words + * @return the AddWordsOptions builder + */ + public Builder words(List words) { + this.words = words; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + words = builder.words; + } + + /** + * New builder. + * + * @return a AddWordsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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. + * + * @return the words + */ + public List words() { + return 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 new file mode 100644 index 00000000000..b51fe9da578 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioDetails.java @@ -0,0 +1,107 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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 + * that does not contain audio, such as a JPEG file). + */ + public interface Type { + /** audio. */ + String AUDIO = "audio"; + /** archive. */ + String ARCHIVE = "archive"; + /** undetermined. */ + String UNDETERMINED = "undetermined"; + } + + /** + * _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. + */ + public interface Compression { + /** zip. */ + String ZIP = "zip"; + /** gzip. */ + String GZIP = "gzip"; + } + + protected String type; + protected String codec; + 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 + * that does not contain audio, such as a JPEG file). + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Gets the codec. + * + *

_For an audio-type resource_, the codec in which the audio is encoded. Omitted for an + * archive-type resource. + * + * @return the codec + */ + public String getCodec() { + return codec; + } + + /** + * 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. + * + * @return the frequency + */ + public Long getFrequency() { + return frequency; + } + + /** + * 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 + * + *

Omitted for an audio-type resource. + * + * @return the compression + */ + public String getCompression() { + return 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 new file mode 100644 index 00000000000..0cbaf3a2f23 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioListing.java @@ -0,0 +1,129 @@ +/* + * (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.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. */ +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). + * + *

Omitted for an archive-type resource. + */ + public interface Status { + /** ok. */ + String OK = "ok"; + /** being_processed. */ + String BEING_PROCESSED = "being_processed"; + /** invalid. */ + String INVALID = "invalid"; + } + + protected Long duration; + protected String name; + protected AudioDetails details; + protected String 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. + * + * @return the duration + */ + public Long getDuration() { + return duration; + } + + /** + * Gets the name. + * + *

_For an audio-type resource_, the user-specified name of the resource. Omitted for an + * archive-type resource. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * 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. + * + * @return the details + */ + public AudioDetails getDetails() { + return details; + } + + /** + * 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). + * + *

Omitted for an archive-type resource. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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. + * + * @return the container + */ + public AudioResource getContainer() { + return container; + } + + /** + * 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. + * + * @return the audio + */ + public List getAudio() { + return 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 new file mode 100644 index 00000000000..8d5215cce88 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetrics.java @@ -0,0 +1,55 @@ +/* + * (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.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** + * If audio metrics are requested, information about the signal characteristics of the input audio. + */ +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. + * + * @return the samplingInterval + */ + public Float getSamplingInterval() { + return samplingInterval; + } + + /** + * Gets the accumulated. + * + *

Detailed information about the signal characteristics of the input audio. + * + * @return the accumulated + */ + public AudioMetricsDetails getAccumulated() { + return 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 new file mode 100644 index 00000000000..da9a1d6e18c --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsDetails.java @@ -0,0 +1,171 @@ +/* + * (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.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. */ +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. + * + * @return the xFinal + */ + public Boolean isXFinal() { + return xFinal; + } + + /** + * Gets the endTime. + * + *

The end time in seconds of the block of audio to which the metrics apply. + * + * @return the endTime + */ + public Float getEndTime() { + return endTime; + } + + /** + * 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. + * + * @return the signalToNoiseRatio + */ + public Float getSignalToNoiseRatio() { + return signalToNoiseRatio; + } + + /** + * 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. + * + * @return the speechRatio + */ + public Float getSpeechRatio() { + return speechRatio; + } + + /** + * 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. + * + * @return the highFrequencyLoss + */ + public Float getHighFrequencyLoss() { + return highFrequencyLoss; + } + + /** + * Gets the directCurrentOffset. + * + *

An array of `AudioMetricsHistogramBin` objects that defines a histogram of the cumulative + * direct current (DC) component of the audio signal. + * + * @return the directCurrentOffset + */ + public List getDirectCurrentOffset() { + return directCurrentOffset; + } + + /** + * 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. + * + * @return the clippingRate + */ + public List getClippingRate() { + return clippingRate; + } + + /** + * 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). + * + * @return the speechLevel + */ + public List getSpeechLevel() { + return speechLevel; + } + + /** + * 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). + * + * @return the nonSpeechLevel + */ + public List getNonSpeechLevel() { + return 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 new file mode 100644 index 00000000000..9c277eeca70 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioMetricsHistogramBin.java @@ -0,0 +1,64 @@ +/* + * (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.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. + */ +public class AudioMetricsHistogramBin extends GenericModel { + + protected Float begin; + protected Float end; + protected Long count; + + protected AudioMetricsHistogramBin() {} + + /** + * Gets the begin. + * + *

The lower boundary of the bin in the histogram. + * + * @return the begin + */ + public Float getBegin() { + return begin; + } + + /** + * Gets the end. + * + *

The upper boundary of the bin in the histogram. + * + * @return the end + */ + public Float getEnd() { + return end; + } + + /** + * Gets the count. + * + *

The number of values in the bin of the histogram. + * + * @return the count + */ + public Long getCount() { + return 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 new file mode 100644 index 00000000000..cd578042150 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResource.java @@ -0,0 +1,100 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + */ + public interface Status { + /** ok. */ + String OK = "ok"; + /** being_processed. */ + String BEING_PROCESSED = "being_processed"; + /** invalid. */ + String INVALID = "invalid"; + } + + protected Long duration; + protected String name; + protected AudioDetails details; + protected String status; + + protected AudioResource() {} + + /** + * Gets the duration. + * + *

The total seconds of audio in the audio resource. + * + * @return the duration + */ + public Long getDuration() { + return duration; + } + + /** + * Gets the name. + * + *

_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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * 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. + * + * @return the details + */ + public AudioDetails getDetails() { + return details; + } + + /** + * 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. + * + * @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/AudioResources.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java new file mode 100644 index 00000000000..f9f2cf10233 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/AudioResources.java @@ -0,0 +1,54 @@ +/* + * (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.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. */ +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. + * + * @return the totalMinutesOfAudio + */ + public Double getTotalMinutesOfAudio() { + return totalMinutesOfAudio; + } + + /** + * 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. + * + * @return the audio + */ + public List getAudio() { + return 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 new file mode 100644 index 00000000000..f8f6e57fb33 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobOptions.java @@ -0,0 +1,96 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The checkJob options. */ +public class CheckJobOptions extends GenericModel { + + protected String id; + + /** 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 with required properties. + * + * @param id the id + */ + public Builder(String id) { + this.id = id; + } + + /** + * Builds a CheckJobOptions. + * + * @return the new CheckJobOptions instance + */ + public CheckJobOptions build() { + return new CheckJobOptions(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the CheckJobOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + } + + protected CheckJobOptions() {} + + protected CheckJobOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, "id cannot be empty"); + id = builder.id; + } + + /** + * New builder. + * + * @return a CheckJobOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the id + */ + public String id() { + return 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 new file mode 100644 index 00000000000..6fb9c6211bb --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CheckJobsOptions.java @@ -0,0 +1,23 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The checkJobs options. */ +public class CheckJobsOptions extends GenericModel { + + /** 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 new file mode 100644 index 00000000000..2e6d64cd4d0 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpora.java @@ -0,0 +1,37 @@ +/* + * (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.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. */ +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. + * + * @return the corpora + */ + public List getCorpora() { + return 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 new file mode 100644 index 00000000000..6dba06236a1 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Corpus.java @@ -0,0 +1,117 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +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. + */ + public interface Status { + /** analyzed. */ + String ANALYZED = "analyzed"; + /** being_processed. */ + String BEING_PROCESSED = "being_processed"; + /** undetermined. */ + String UNDETERMINED = "undetermined"; + } + + 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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the totalWords. + * + *

The total number of words in the corpus. The value is `0` while the corpus is being + * processed. + * + * @return the totalWords + */ + public Long getTotalWords() { + return totalWords; + } + + /** + * Gets the outOfVocabularyWords. + * + *

_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 + */ + public Long getOutOfVocabularyWords() { + return outOfVocabularyWords; + } + + /** + * 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. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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'`. + * + * @return the error + */ + public String getError() { + return 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 new file mode 100644 index 00000000000..6eac9eeef2c --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateAcousticModelOptions.java @@ -0,0 +1,267 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +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. + * + *

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-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. */ + String EN_GB_NARROWBANDMODEL = "en-GB_NarrowbandModel"; + /** en-US_BroadbandModel. */ + String EN_US_BROADBANDMODEL = "en-US_BroadbandModel"; + /** en-US_NarrowbandModel. */ + 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. */ + String FR_FR_NARROWBANDMODEL = "fr-FR_NarrowbandModel"; + /** it-IT_BroadbandModel. */ + String IT_IT_BROADBANDMODEL = "it-IT_BroadbandModel"; + /** it-IT_NarrowbandModel. */ + String IT_IT_NARROWBANDMODEL = "it-IT_NarrowbandModel"; + /** ja-JP_BroadbandModel. */ + String JA_JP_BROADBANDMODEL = "ja-JP_BroadbandModel"; + /** ja-JP_NarrowbandModel. */ + String JA_JP_NARROWBANDMODEL = "ja-JP_NarrowbandModel"; + /** ko-KR_BroadbandModel. */ + String KO_KR_BROADBANDMODEL = "ko-KR_BroadbandModel"; + /** ko-KR_NarrowbandModel. */ + String KO_KR_NARROWBANDMODEL = "ko-KR_NarrowbandModel"; + /** nl-NL_BroadbandModel. */ + 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. */ + String PT_BR_NARROWBANDMODEL = "pt-BR_NarrowbandModel"; + /** zh-CN_BroadbandModel. */ + String ZH_CN_BROADBANDMODEL = "zh-CN_BroadbandModel"; + /** zh-CN_NarrowbandModel. */ + String ZH_CN_NARROWBANDMODEL = "zh-CN_NarrowbandModel"; + } + + protected String name; + protected String baseModelName; + protected String description; + + /** 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 with required properties. + * + * @param name the name + * @param baseModelName the baseModelName + */ + public Builder(String name, String baseModelName) { + this.name = name; + this.baseModelName = baseModelName; + } + + /** + * Builds a CreateAcousticModelOptions. + * + * @return the new CreateAcousticModelOptions instance + */ + public CreateAcousticModelOptions build() { + return new CreateAcousticModelOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateAcousticModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the baseModelName. + * + * @param baseModelName the baseModelName + * @return the CreateAcousticModelOptions builder + */ + public Builder baseModelName(String baseModelName) { + this.baseModelName = baseModelName; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateAcousticModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + 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"); + name = builder.name; + baseModelName = builder.baseModelName; + description = builder.description; + } + + /** + * New builder. + * + * @return a CreateAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

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 + */ + public String name() { + return 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. + * + *

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 + */ + public String baseModelName() { + return baseModelName; + } + + /** + * Gets the description. + * + *

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 + */ + public String description() { + return 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 new file mode 100644 index 00000000000..08bec5f8135 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptions.java @@ -0,0 +1,1464 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.util.ArrayList; +import java.util.List; + +/** The createJob options. */ +public class CreateJobOptions extends GenericModel { + + /** + * 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-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](#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. */ + String RECOGNITIONS_STARTED = "recognitions.started"; + /** recognitions.completed. */ + String RECOGNITIONS_COMPLETED = "recognitions.completed"; + /** recognitions.completed_with_results. */ + String RECOGNITIONS_COMPLETED_WITH_RESULTS = "recognitions.completed_with_results"; + /** recognitions.failed. */ + String RECOGNITIONS_FAILED = "recognitions.failed"; + } + + protected InputStream audio; + protected String contentType; + protected String model; + protected String callbackUrl; + protected String events; + protected String userToken; + protected Long resultsTtl; + 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 processingMetrics; + protected Float processingMetricsInterval; + 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. */ + public static class Builder { + private InputStream audio; + private String contentType; + private String model; + private String callbackUrl; + private String events; + private String userToken; + private Long resultsTtl; + 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 processingMetrics; + private Float processingMetricsInterval; + 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; + this.model = createJobOptions.model; + this.callbackUrl = createJobOptions.callbackUrl; + this.events = createJobOptions.events; + this.userToken = createJobOptions.userToken; + this.resultsTtl = createJobOptions.resultsTtl; + this.languageCustomizationId = createJobOptions.languageCustomizationId; + this.acousticCustomizationId = createJobOptions.acousticCustomizationId; + this.baseModelVersion = createJobOptions.baseModelVersion; + this.customizationWeight = createJobOptions.customizationWeight; + this.inactivityTimeout = createJobOptions.inactivityTimeout; + this.keywords = createJobOptions.keywords; + this.keywordsThreshold = createJobOptions.keywordsThreshold; + this.maxAlternatives = createJobOptions.maxAlternatives; + this.wordAlternativesThreshold = createJobOptions.wordAlternativesThreshold; + this.wordConfidence = createJobOptions.wordConfidence; + this.timestamps = createJobOptions.timestamps; + this.profanityFilter = createJobOptions.profanityFilter; + this.smartFormatting = createJobOptions.smartFormatting; + this.smartFormattingVersion = createJobOptions.smartFormattingVersion; + this.speakerLabels = createJobOptions.speakerLabels; + this.grammarName = createJobOptions.grammarName; + this.redaction = createJobOptions.redaction; + this.processingMetrics = createJobOptions.processingMetrics; + this.processingMetricsInterval = createJobOptions.processingMetricsInterval; + 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 with required properties. + * + * @param audio the audio + */ + public Builder(InputStream audio) { + this.audio = audio; + } + + /** + * Builds a CreateJobOptions. + * + * @return the new CreateJobOptions instance + */ + public CreateJobOptions build() { + return new CreateJobOptions(this); + } + + /** + * Adds a new element to keywords. + * + * @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"); + if (this.keywords == null) { + this.keywords = new ArrayList(); + } + this.keywords.add(keyword); + return this; + } + + /** + * Set the audio. + * + * @param audio the audio + * @return the CreateJobOptions builder + */ + public Builder audio(InputStream audio) { + this.audio = audio; + return this; + } + + /** + * Set the contentType. + * + * @param contentType the contentType + * @return the CreateJobOptions builder + */ + public Builder contentType(String contentType) { + this.contentType = contentType; + return this; + } + + /** + * Set the model. + * + * @param model the model + * @return the CreateJobOptions builder + */ + public Builder model(String model) { + this.model = model; + return this; + } + + /** + * Set the callbackUrl. + * + * @param callbackUrl the callbackUrl + * @return the CreateJobOptions builder + */ + public Builder callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Set the events. + * + * @param events the events + * @return the CreateJobOptions builder + */ + public Builder events(String events) { + this.events = events; + return this; + } + + /** + * Set the userToken. + * + * @param userToken the userToken + * @return the CreateJobOptions builder + */ + public Builder userToken(String userToken) { + this.userToken = userToken; + return this; + } + + /** + * Set the resultsTtl. + * + * @param resultsTtl the resultsTtl + * @return the CreateJobOptions builder + */ + public Builder resultsTtl(long resultsTtl) { + this.resultsTtl = resultsTtl; + return this; + } + + /** + * Set the languageCustomizationId. + * + * @param languageCustomizationId the languageCustomizationId + * @return the CreateJobOptions builder + */ + public Builder languageCustomizationId(String languageCustomizationId) { + this.languageCustomizationId = languageCustomizationId; + return this; + } + + /** + * Set the acousticCustomizationId. + * + * @param acousticCustomizationId the acousticCustomizationId + * @return the CreateJobOptions builder + */ + public Builder acousticCustomizationId(String acousticCustomizationId) { + this.acousticCustomizationId = acousticCustomizationId; + return this; + } + + /** + * Set the baseModelVersion. + * + * @param baseModelVersion the baseModelVersion + * @return the CreateJobOptions builder + */ + public Builder baseModelVersion(String baseModelVersion) { + this.baseModelVersion = baseModelVersion; + return this; + } + + /** + * Set the customizationWeight. + * + * @param customizationWeight the customizationWeight + * @return the CreateJobOptions builder + */ + public Builder customizationWeight(Double customizationWeight) { + this.customizationWeight = customizationWeight; + return this; + } + + /** + * Set the inactivityTimeout. + * + * @param inactivityTimeout the inactivityTimeout + * @return the CreateJobOptions 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 CreateJobOptions builder + */ + public Builder keywords(List keywords) { + this.keywords = keywords; + return this; + } + + /** + * Set the keywordsThreshold. + * + * @param keywordsThreshold the keywordsThreshold + * @return the CreateJobOptions builder + */ + public Builder keywordsThreshold(Float keywordsThreshold) { + this.keywordsThreshold = keywordsThreshold; + return this; + } + + /** + * Set the maxAlternatives. + * + * @param maxAlternatives the maxAlternatives + * @return the CreateJobOptions builder + */ + public Builder maxAlternatives(long maxAlternatives) { + this.maxAlternatives = maxAlternatives; + return this; + } + + /** + * Set the wordAlternativesThreshold. + * + * @param wordAlternativesThreshold the wordAlternativesThreshold + * @return the CreateJobOptions builder + */ + public Builder wordAlternativesThreshold(Float wordAlternativesThreshold) { + this.wordAlternativesThreshold = wordAlternativesThreshold; + return this; + } + + /** + * Set the wordConfidence. + * + * @param wordConfidence the wordConfidence + * @return the CreateJobOptions builder + */ + public Builder wordConfidence(Boolean wordConfidence) { + this.wordConfidence = wordConfidence; + return this; + } + + /** + * Set the timestamps. + * + * @param timestamps the timestamps + * @return the CreateJobOptions builder + */ + public Builder timestamps(Boolean timestamps) { + this.timestamps = timestamps; + return this; + } + + /** + * Set the profanityFilter. + * + * @param profanityFilter the profanityFilter + * @return the CreateJobOptions builder + */ + public Builder profanityFilter(Boolean profanityFilter) { + this.profanityFilter = profanityFilter; + return this; + } + + /** + * Set the smartFormatting. + * + * @param smartFormatting the smartFormatting + * @return the CreateJobOptions builder + */ + public Builder smartFormatting(Boolean smartFormatting) { + this.smartFormatting = smartFormatting; + return this; + } + + /** + * Set the smartFormattingVersion. + * + * @param smartFormattingVersion the smartFormattingVersion + * @return the CreateJobOptions builder + */ + public Builder smartFormattingVersion(long smartFormattingVersion) { + this.smartFormattingVersion = smartFormattingVersion; + return this; + } + + /** + * Set the speakerLabels. + * + * @param speakerLabels the speakerLabels + * @return the CreateJobOptions builder + */ + public Builder speakerLabels(Boolean speakerLabels) { + this.speakerLabels = speakerLabels; + return this; + } + + /** + * Set the grammarName. + * + * @param grammarName the grammarName + * @return the CreateJobOptions builder + */ + public Builder grammarName(String grammarName) { + this.grammarName = grammarName; + return this; + } + + /** + * Set the redaction. + * + * @param redaction the redaction + * @return the CreateJobOptions builder + */ + public Builder redaction(Boolean redaction) { + this.redaction = redaction; + return this; + } + + /** + * Set the processingMetrics. + * + * @param processingMetrics the processingMetrics + * @return the CreateJobOptions builder + */ + public Builder processingMetrics(Boolean processingMetrics) { + this.processingMetrics = processingMetrics; + return this; + } + + /** + * Set the processingMetricsInterval. + * + * @param processingMetricsInterval the processingMetricsInterval + * @return the CreateJobOptions builder + */ + public Builder processingMetricsInterval(Float processingMetricsInterval) { + this.processingMetricsInterval = processingMetricsInterval; + return this; + } + + /** + * Set the audioMetrics. + * + * @param audioMetrics the audioMetrics + * @return the CreateJobOptions builder + */ + public Builder audioMetrics(Boolean audioMetrics) { + this.audioMetrics = audioMetrics; + return this; + } + + /** + * Set the endOfPhraseSilenceTime. + * + * @param endOfPhraseSilenceTime the endOfPhraseSilenceTime + * @return the CreateJobOptions builder + */ + public Builder endOfPhraseSilenceTime(Double endOfPhraseSilenceTime) { + this.endOfPhraseSilenceTime = endOfPhraseSilenceTime; + return this; + } + + /** + * Set the splitTranscriptAtPhraseEnd. + * + * @param splitTranscriptAtPhraseEnd the splitTranscriptAtPhraseEnd + * @return the CreateJobOptions builder + */ + public Builder splitTranscriptAtPhraseEnd(Boolean splitTranscriptAtPhraseEnd) { + this.splitTranscriptAtPhraseEnd = 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 { + this.audio = new FileInputStream(audio); + return this; + } + } + + protected CreateJobOptions() {} + + protected CreateJobOptions(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; + callbackUrl = builder.callbackUrl; + events = builder.events; + userToken = builder.userToken; + resultsTtl = builder.resultsTtl; + 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; + processingMetrics = builder.processingMetrics; + processingMetricsInterval = builder.processingMetricsInterval; + audioMetrics = builder.audioMetrics; + endOfPhraseSilenceTime = builder.endOfPhraseSilenceTime; + splitTranscriptAtPhraseEnd = builder.splitTranscriptAtPhraseEnd; + speechDetectorSensitivity = builder.speechDetectorSensitivity; + sadModule = builder.sadModule; + backgroundAudioSuppression = builder.backgroundAudioSuppression; + lowLatency = builder.lowLatency; + characterInsertionBias = builder.characterInsertionBias; + } + + /** + * New builder. + * + * @return a CreateJobOptions 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 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 + */ + public String model() { + return model; + } + + /** + * Gets the callbackUrl. + * + *

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. + * + * @return the callbackUrl + */ + public String callbackUrl() { + return 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](#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 + */ + public String events() { + return 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. + * + * @return the userToken + */ + public String userToken() { + return 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. + * + * @return the resultsTtl + */ + public Long resultsTtl() { + return resultsTtl; + } + + /** + * 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 [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. + * + * @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 [Using a custom acoustic model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acousticUse). + * + * @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 [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 + */ + 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 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 + * + *

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 [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 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-spotting#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-spotting#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-metadata#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-spotting#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-metadata#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-metadata#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. + * + *

**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 + */ + 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:** 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-formatting#smart-formatting). + * + * @return the smartFormatting + */ + public Boolean smartFormatting() { + return smartFormatting; + } + + /** + * Gets the smartFormattingVersion. + * + *

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 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. * _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. + * + *

See [Speaker + * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-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 [Using a grammar for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarUse). + * + * @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:** 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-formatting#numeric-redaction). + * + * @return the redaction + */ + public Boolean redaction() { + return 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. + * + *

See [Processing + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing-metrics). + * + * @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. + * + *

See [Processing + * metrics](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-metrics#processing-metrics). + * + * @return the processingMetricsInterval + */ + public Float processingMetricsInterval() { + return 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. + * + *

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. + * + *

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-parsing#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. 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-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 new file mode 100644 index 00000000000..1df17a2d56f --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CreateLanguageModelOptions.java @@ -0,0 +1,381 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +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. + * + *

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; + protected String baseModelName; + protected String dialect; + protected String description; + + /** 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; + this.dialect = createLanguageModelOptions.dialect; + this.description = createLanguageModelOptions.description; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param name the name + * @param baseModelName the baseModelName + */ + public Builder(String name, String baseModelName) { + this.name = name; + this.baseModelName = baseModelName; + } + + /** + * Builds a CreateLanguageModelOptions. + * + * @return the new CreateLanguageModelOptions instance + */ + public CreateLanguageModelOptions build() { + return new CreateLanguageModelOptions(this); + } + + /** + * Set the name. + * + * @param name the name + * @return the CreateLanguageModelOptions builder + */ + public Builder name(String name) { + this.name = name; + return this; + } + + /** + * Set the baseModelName. + * + * @param baseModelName the baseModelName + * @return the CreateLanguageModelOptions builder + */ + public Builder baseModelName(String baseModelName) { + this.baseModelName = baseModelName; + return this; + } + + /** + * Set the dialect. + * + * @param dialect the dialect + * @return the CreateLanguageModelOptions builder + */ + public Builder dialect(String dialect) { + this.dialect = dialect; + return this; + } + + /** + * Set the description. + * + * @param description the description + * @return the CreateLanguageModelOptions builder + */ + public Builder description(String description) { + this.description = description; + return this; + } + } + + 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"); + name = builder.name; + baseModelName = builder.baseModelName; + dialect = builder.dialect; + description = builder.description; + } + + /** + * New builder. + * + * @return a CreateLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the name. + * + *

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 + */ + public String name() { + return 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. + * + *

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 + */ + public String baseModelName() { + return baseModelName; + } + + /** + * Gets the dialect. + * + *

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. + * + *

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) + * + *

All values that you pass for the `dialect` field are case-insensitive. + * + * @return the dialect + */ + public String dialect() { + return dialect; + } + + /** + * Gets the description. + * + *

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 + */ + public String description() { + return 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 new file mode 100644 index 00000000000..ced6c0ff1fa --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/CustomWord.java @@ -0,0 +1,230 @@ +/* + * (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.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. */ +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. */ + 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() {} + + /** + * Builds a CustomWord. + * + * @return the new CustomWord instance + */ + public CustomWord build() { + return new CustomWord(this); + } + + /** + * Adds a new element to mappingOnly. + * + * @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"); + if (this.soundsLike == null) { + this.soundsLike = new ArrayList(); + } + this.soundsLike.add(soundsLike); + return this; + } + + /** + * Set the word. + * + * @param word the word + * @return the CustomWord builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + + /** + * 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 + */ + public Builder soundsLike(List soundsLike) { + this.soundsLike = soundsLike; + return this; + } + + /** + * Set the displayAs. + * + * @param displayAs the displayAs + * @return the CustomWord builder + */ + public Builder displayAs(String displayAs) { + this.displayAs = displayAs; + return this; + } + } + + protected CustomWord() {} + + protected CustomWord(Builder builder) { + word = builder.word; + mappingOnly = builder.mappingOnly; + soundsLike = builder.soundsLike; + displayAs = builder.displayAs; + } + + /** + * New builder. + * + * @return a CustomWord builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the word. + * + *

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](#addword) method. + * + * @return the word + */ + 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. + * + *

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 leading or trailing spaces. A Japanese pronunciation can include + * at most 25 characters, not including leading or trailing spaces. + * + * @return the soundsLike + */ + public List soundsLike() { + return 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. + * + *

_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 + */ + public String displayAs() { + return 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 new file mode 100644 index 00000000000..0ae5fa6aa46 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAcousticModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteAcousticModel options. */ +public class DeleteAcousticModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a DeleteAcousticModelOptions. + * + * @return the new DeleteAcousticModelOptions instance + */ + public DeleteAcousticModelOptions build() { + return new DeleteAcousticModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteAcousticModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected DeleteAcousticModelOptions() {} + + protected DeleteAcousticModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a DeleteAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..3000e4b7fd6 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteAudioOptions.java @@ -0,0 +1,127 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteAudio options. */ +public class DeleteAudioOptions extends GenericModel { + + protected String customizationId; + protected String audioName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param audioName the audioName + */ + public Builder(String customizationId, String audioName) { + this.customizationId = customizationId; + this.audioName = audioName; + } + + /** + * Builds a DeleteAudioOptions. + * + * @return the new DeleteAudioOptions instance + */ + public DeleteAudioOptions build() { + return new DeleteAudioOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteAudioOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the audioName. + * + * @param audioName the audioName + * @return the DeleteAudioOptions builder + */ + public Builder audioName(String audioName) { + this.audioName = audioName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + audioName = builder.audioName; + } + + /** + * New builder. + * + * @return a DeleteAudioOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the audioName. + * + *

The name of the audio resource for the custom acoustic model. + * + * @return the audioName + */ + public String audioName() { + return 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 new file mode 100644 index 00000000000..38da85caf58 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteCorpusOptions.java @@ -0,0 +1,128 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteCorpus options. */ +public class DeleteCorpusOptions extends GenericModel { + + protected String customizationId; + protected String corpusName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param corpusName the corpusName + */ + public Builder(String customizationId, String corpusName) { + this.customizationId = customizationId; + this.corpusName = corpusName; + } + + /** + * Builds a DeleteCorpusOptions. + * + * @return the new DeleteCorpusOptions instance + */ + public DeleteCorpusOptions build() { + return new DeleteCorpusOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteCorpusOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the corpusName. + * + * @param corpusName the corpusName + * @return the DeleteCorpusOptions builder + */ + public Builder corpusName(String corpusName) { + this.corpusName = corpusName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + corpusName = builder.corpusName; + } + + /** + * New builder. + * + * @return a DeleteCorpusOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the corpusName. + * + *

The name of the corpus for the custom language model. + * + * @return the corpusName + */ + public String corpusName() { + return 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 new file mode 100644 index 00000000000..d0ea19aae03 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteGrammarOptions.java @@ -0,0 +1,128 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteGrammar options. */ +public class DeleteGrammarOptions extends GenericModel { + + protected String customizationId; + protected String grammarName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param grammarName the grammarName + */ + public Builder(String customizationId, String grammarName) { + this.customizationId = customizationId; + this.grammarName = grammarName; + } + + /** + * Builds a DeleteGrammarOptions. + * + * @return the new DeleteGrammarOptions instance + */ + public DeleteGrammarOptions build() { + return new DeleteGrammarOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteGrammarOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the grammarName. + * + * @param grammarName the grammarName + * @return the DeleteGrammarOptions builder + */ + public Builder grammarName(String grammarName) { + this.grammarName = grammarName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + grammarName = builder.grammarName; + } + + /** + * New builder. + * + * @return a DeleteGrammarOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the grammarName. + * + *

The name of the grammar for the custom language model. + * + * @return the grammarName + */ + public String grammarName() { + return 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 new file mode 100644 index 00000000000..5c8b627c4df --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteJobOptions.java @@ -0,0 +1,96 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteJob options. */ +public class DeleteJobOptions extends GenericModel { + + protected String id; + + /** 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 with required properties. + * + * @param id the id + */ + public Builder(String id) { + this.id = id; + } + + /** + * Builds a DeleteJobOptions. + * + * @return the new DeleteJobOptions instance + */ + public DeleteJobOptions build() { + return new DeleteJobOptions(this); + } + + /** + * Set the id. + * + * @param id the id + * @return the DeleteJobOptions builder + */ + public Builder id(String id) { + this.id = id; + return this; + } + } + + protected DeleteJobOptions() {} + + protected DeleteJobOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.id, "id cannot be empty"); + id = builder.id; + } + + /** + * New builder. + * + * @return a DeleteJobOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the id + */ + public String id() { + return 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 new file mode 100644 index 00000000000..4b62168fa7c --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteLanguageModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteLanguageModel options. */ +public class DeleteLanguageModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a DeleteLanguageModelOptions. + * + * @return the new DeleteLanguageModelOptions instance + */ + public DeleteLanguageModelOptions build() { + return new DeleteLanguageModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteLanguageModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected DeleteLanguageModelOptions() {} + + protected DeleteLanguageModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a DeleteLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..5ec4a6e2f81 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/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.speech_to_text.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; + + /** + * 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/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 new file mode 100644 index 00000000000..66a05516390 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/DeleteWordOptions.java @@ -0,0 +1,129 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteWord options. */ +public class DeleteWordOptions extends GenericModel { + + protected String customizationId; + protected String wordName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param wordName the wordName + */ + public Builder(String customizationId, String wordName) { + this.customizationId = customizationId; + this.wordName = wordName; + } + + /** + * Builds a DeleteWordOptions. + * + * @return the new DeleteWordOptions instance + */ + public DeleteWordOptions build() { + return new DeleteWordOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the wordName. + * + * @param wordName the wordName + * @return the DeleteWordOptions builder + */ + public Builder wordName(String wordName) { + this.wordName = wordName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + wordName = builder.wordName; + } + + /** + * New builder. + * + * @return a DeleteWordOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 + * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). + * + * @return the wordName + */ + public String wordName() { + return wordName; + } +} 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 new file mode 100644 index 00000000000..db822dc80db --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAcousticModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getAcousticModel options. */ +public class GetAcousticModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a GetAcousticModelOptions. + * + * @return the new GetAcousticModelOptions instance + */ + public GetAcousticModelOptions build() { + return new GetAcousticModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetAcousticModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected GetAcousticModelOptions() {} + + protected GetAcousticModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a GetAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..a729388fa79 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetAudioOptions.java @@ -0,0 +1,127 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getAudio options. */ +public class GetAudioOptions extends GenericModel { + + protected String customizationId; + protected String audioName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param audioName the audioName + */ + public Builder(String customizationId, String audioName) { + this.customizationId = customizationId; + this.audioName = audioName; + } + + /** + * Builds a GetAudioOptions. + * + * @return the new GetAudioOptions instance + */ + public GetAudioOptions build() { + return new GetAudioOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetAudioOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the audioName. + * + * @param audioName the audioName + * @return the GetAudioOptions builder + */ + public Builder audioName(String audioName) { + this.audioName = audioName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + audioName = builder.audioName; + } + + /** + * New builder. + * + * @return a GetAudioOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the audioName. + * + *

The name of the audio resource for the custom acoustic model. + * + * @return the audioName + */ + public String audioName() { + return 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 new file mode 100644 index 00000000000..90c113454a8 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetCorpusOptions.java @@ -0,0 +1,128 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getCorpus options. */ +public class GetCorpusOptions extends GenericModel { + + protected String customizationId; + protected String corpusName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param corpusName the corpusName + */ + public Builder(String customizationId, String corpusName) { + this.customizationId = customizationId; + this.corpusName = corpusName; + } + + /** + * Builds a GetCorpusOptions. + * + * @return the new GetCorpusOptions instance + */ + public GetCorpusOptions build() { + return new GetCorpusOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetCorpusOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the corpusName. + * + * @param corpusName the corpusName + * @return the GetCorpusOptions builder + */ + public Builder corpusName(String corpusName) { + this.corpusName = corpusName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + corpusName = builder.corpusName; + } + + /** + * New builder. + * + * @return a GetCorpusOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the corpusName. + * + *

The name of the corpus for the custom language model. + * + * @return the corpusName + */ + public String corpusName() { + return 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 new file mode 100644 index 00000000000..b401ae65612 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetGrammarOptions.java @@ -0,0 +1,128 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getGrammar options. */ +public class GetGrammarOptions extends GenericModel { + + protected String customizationId; + protected String grammarName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param grammarName the grammarName + */ + public Builder(String customizationId, String grammarName) { + this.customizationId = customizationId; + this.grammarName = grammarName; + } + + /** + * Builds a GetGrammarOptions. + * + * @return the new GetGrammarOptions instance + */ + public GetGrammarOptions build() { + return new GetGrammarOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetGrammarOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the grammarName. + * + * @param grammarName the grammarName + * @return the GetGrammarOptions builder + */ + public Builder grammarName(String grammarName) { + this.grammarName = grammarName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + grammarName = builder.grammarName; + } + + /** + * New builder. + * + * @return a GetGrammarOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the grammarName. + * + *

The name of the grammar for the custom language model. + * + * @return the grammarName + */ + public String grammarName() { + return 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 new file mode 100644 index 00000000000..900ac96b2eb --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetLanguageModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getLanguageModel options. */ +public class GetLanguageModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a GetLanguageModelOptions. + * + * @return the new GetLanguageModelOptions instance + */ + public GetLanguageModelOptions build() { + return new GetLanguageModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetLanguageModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected GetLanguageModelOptions() {} + + protected GetLanguageModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a GetLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..6c0d50d0cb0 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetModelOptions.java @@ -0,0 +1,275 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +public class GetModelOptions extends GenericModel { + + /** + * The identifier of the model in the form of its name from the output of the [List + * models](#listmodels) method. + */ + public interface ModelId { + /** 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. */ + 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 with required properties. + * + * @param modelId the modelId + */ + public Builder(String modelId) { + this.modelId = modelId; + } + + /** + * Builds a GetModelOptions. + * + * @return the new GetModelOptions instance + */ + 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() {} + + 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. + * + *

The identifier of the model in the form of its name from the output of the [List + * models](#listmodels) method. + * + * @return the modelId + */ + public String modelId() { + return 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 new file mode 100644 index 00000000000..524cd1a8558 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/GetWordOptions.java @@ -0,0 +1,129 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getWord options. */ +public class GetWordOptions extends GenericModel { + + protected String customizationId; + protected String wordName; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param wordName the wordName + */ + public Builder(String customizationId, String wordName) { + this.customizationId = customizationId; + this.wordName = wordName; + } + + /** + * Builds a GetWordOptions. + * + * @return the new GetWordOptions instance + */ + public GetWordOptions build() { + return new GetWordOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the wordName. + * + * @param wordName the wordName + * @return the GetWordOptions builder + */ + public Builder wordName(String wordName) { + this.wordName = wordName; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + wordName = builder.wordName; + } + + /** + * New builder. + * + * @return a GetWordOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 + * encoding](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-corporaWords#charEncoding). + * + * @return the wordName + */ + public String wordName() { + return 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 new file mode 100644 index 00000000000..8a25e68554a --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammar.java @@ -0,0 +1,101 @@ +/* + * (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.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. */ +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. + */ + public interface Status { + /** analyzed. */ + String ANALYZED = "analyzed"; + /** being_processed. */ + String BEING_PROCESSED = "being_processed"; + /** undetermined. */ + String UNDETERMINED = "undetermined"; + } + + 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. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the outOfVocabularyWords. + * + *

_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 + */ + public Long getOutOfVocabularyWords() { + return outOfVocabularyWords; + } + + /** + * 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. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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'.`. + * + * @return the error + */ + public String getError() { + return 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 new file mode 100644 index 00000000000..7422e9a85e5 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Grammars.java @@ -0,0 +1,37 @@ +/* + * (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.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. */ +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. + * + * @return the grammars + */ + public List getGrammars() { + return 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 new file mode 100644 index 00000000000..fe90e3cd122 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/KeywordResult.java @@ -0,0 +1,78 @@ +/* + * (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.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. */ +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. + * + * @return the normalizedText + */ + public String getNormalizedText() { + return normalizedText; + } + + /** + * Gets the startTime. + * + *

The start time in seconds of the keyword match. + * + * @return the startTime + */ + public Double getStartTime() { + return startTime; + } + + /** + * Gets the endTime. + * + *

The end time in seconds of the keyword match. + * + * @return the endTime + */ + public Double getEndTime() { + return endTime; + } + + /** + * Gets the confidence. + * + *

A confidence score for the keyword match in the range of 0.0 to 1.0. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } +} 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 new file mode 100644 index 00000000000..ab0193e50c0 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModel.java @@ -0,0 +1,257 @@ +/* + * (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.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. */ +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. + */ + public interface Status { + /** pending. */ + String PENDING = "pending"; + /** ready. */ + String READY = "ready"; + /** training. */ + String TRAINING = "training"; + /** available. */ + String AVAILABLE = "available"; + /** upgrading. */ + String UPGRADING = "upgrading"; + /** failed. */ + String FAILED = "failed"; + } + + @SerializedName("customization_id") + protected String customizationId; + + protected String created; + protected String updated; + protected String language; + protected String dialect; + protected List versions; + 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](#createlanguagemodel) method returns only this field of the object; it does not return + * the other fields. + * + * @return the customizationId + */ + public String getCustomizationId() { + return customizationId; + } + + /** + * 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`). + * + * @return the created + */ + public String getCreated() { + return created; + } + + /** + * 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). + * + * @return the updated + */ + public String getUpdated() { + return updated; + } + + /** + * Gets the language. + * + *

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 + */ + public String getLanguage() { + return language; + } + + /** + * Gets the dialect. + * + *

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. + * + * @return the dialect + */ + public String getDialect() { + return dialect; + } + + /** + * 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 to a new version of its base model. + * Otherwise, only a single version is shown. + * + * @return the versions + */ + public List getVersions() { + return versions; + } + + /** + * Gets the owner. + * + *

The GUID of the credentials for the instance of the service that owns the custom language + * model. + * + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * Gets the name. + * + *

The name of the custom language model. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the description. + * + *

The description of the custom language model. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the baseModelName. + * + *

The name of the language model for which the custom language model was created. + * + * @return the baseModelName + */ + public String getBaseModelName() { + return baseModelName; + } + + /** + * 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. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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. + * + * @return the progress + */ + public Long getProgress() { + return progress; + } + + /** + * 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. + * + * @return the error + */ + public String getError() { + return error; + } + + /** + * 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. + * + * @return the warnings + */ + public String getWarnings() { + return 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 new file mode 100644 index 00000000000..c26a36ca848 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/LanguageModels.java @@ -0,0 +1,38 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the customizations + */ + public List getCustomizations() { + return 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 new file mode 100644 index 00000000000..75b5d54c6fe --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAcousticModelsOptions.java @@ -0,0 +1,157 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listAcousticModels options. */ +public class ListAcousticModelsOptions extends GenericModel { + + /** + * 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() {} + + /** + * Builds a ListAcousticModelsOptions. + * + * @return the new ListAcousticModelsOptions instance + */ + public ListAcousticModelsOptions build() { + return new ListAcousticModelsOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the ListAcousticModelsOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + } + + protected ListAcousticModelsOptions() {} + + protected ListAcousticModelsOptions(Builder builder) { + language = builder.language; + } + + /** + * New builder. + * + * @return a ListAcousticModelsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

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() { + return 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 new file mode 100644 index 00000000000..46a7039e15c --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListAudioOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listAudio options. */ +public class ListAudioOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListAudioOptions. + * + * @return the new ListAudioOptions instance + */ + public ListAudioOptions build() { + return new ListAudioOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListAudioOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ListAudioOptions() {} + + protected ListAudioOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ListAudioOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..16c14e53d85 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListCorporaOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listCorpora options. */ +public class ListCorporaOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListCorporaOptions. + * + * @return the new ListCorporaOptions instance + */ + public ListCorporaOptions build() { + return new ListCorporaOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListCorporaOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ListCorporaOptions() {} + + protected ListCorporaOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ListCorporaOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..e60400e45ba --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListGrammarsOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listGrammars options. */ +public class ListGrammarsOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListGrammarsOptions. + * + * @return the new ListGrammarsOptions instance + */ + public ListGrammarsOptions build() { + return new ListGrammarsOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListGrammarsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ListGrammarsOptions() {} + + protected ListGrammarsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ListGrammarsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..0351b5fa6c0 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListLanguageModelsOptions.java @@ -0,0 +1,157 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listLanguageModels options. */ +public class ListLanguageModelsOptions extends GenericModel { + + /** + * 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() {} + + /** + * Builds a ListLanguageModelsOptions. + * + * @return the new ListLanguageModelsOptions instance + */ + public ListLanguageModelsOptions build() { + return new ListLanguageModelsOptions(this); + } + + /** + * Set the language. + * + * @param language the language + * @return the ListLanguageModelsOptions builder + */ + public Builder language(String language) { + this.language = language; + return this; + } + } + + protected ListLanguageModelsOptions() {} + + protected ListLanguageModelsOptions(Builder builder) { + language = builder.language; + } + + /** + * New builder. + * + * @return a ListLanguageModelsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the language. + * + *

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() { + return 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 new file mode 100644 index 00000000000..e85ed232e1d --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListModelsOptions.java @@ -0,0 +1,23 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listModels options. */ +public class ListModelsOptions extends GenericModel { + + /** 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 new file mode 100644 index 00000000000..189430c56c0 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ListWordsOptions.java @@ -0,0 +1,198 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + *

_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. */ + String ALL = "all"; + /** user. */ + String USER = "user"; + /** corpora. */ + String CORPORA = "corpora"; + /** grammars. */ + String GRAMMARS = "grammars"; + } + + /** + * 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. */ + String ALPHABETICAL = "alphabetical"; + /** count. */ + String COUNT = "count"; + } + + protected String customizationId; + protected String wordType; + protected String sort; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListWordsOptions. + * + * @return the new ListWordsOptions instance + */ + public ListWordsOptions build() { + return new ListWordsOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListWordsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the wordType. + * + * @param wordType the wordType + * @return the ListWordsOptions builder + */ + public Builder wordType(String wordType) { + this.wordType = wordType; + return this; + } + + /** + * Set the sort. + * + * @param sort the sort + * @return the ListWordsOptions builder + */ + public Builder sort(String sort) { + this.sort = sort; + return this; + } + } + + protected ListWordsOptions() {} + + protected ListWordsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + wordType = builder.wordType; + sort = builder.sort; + } + + /** + * New builder. + * + * @return a ListWordsOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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. + * + *

_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 + */ + public String wordType() { + return 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`. + * + * @return the sort + */ + public String sort() { + return 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 new file mode 100644 index 00000000000..13909777a86 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessedAudio.java @@ -0,0 +1,91 @@ +/* + * (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.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. */ +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. + * + * @return the received + */ + public Float getReceived() { + return received; + } + + /** + * 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. + * + * @return the seenByEngine + */ + public Float getSeenByEngine() { + return seenByEngine; + } + + /** + * Gets the transcription. + * + *

The seconds of audio that the service has processed for speech recognition as of this + * response. + * + * @return the transcription + */ + public Float getTranscription() { + return transcription; + } + + /** + * 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. + * + * @return the speakerLabels + */ + public Float getSpeakerLabels() { + return 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 new file mode 100644 index 00000000000..f67da215252 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ProcessingMetrics.java @@ -0,0 +1,81 @@ +/* + * (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.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](#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. + * + * @return the processedAudio + */ + public ProcessedAudio getProcessedAudio() { + return processedAudio; + } + + /** + * 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. + * + * @return the wallClockSinceFirstByteReceived + */ + public Float getWallClockSinceFirstByteReceived() { + return wallClockSinceFirstByteReceived; + } + + /** + * 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. + * + *

Use the field to identify why the service generated the response and to filter different + * results if necessary. + * + * @return the periodic + */ + public Boolean isPeriodic() { + return 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 new file mode 100644 index 00000000000..08ac9875f2e --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJob.java @@ -0,0 +1,164 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** 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. + * * `failed`: The job failed. + */ + public interface Status { + /** waiting. */ + String WAITING = "waiting"; + /** processing. */ + String PROCESSING = "processing"; + /** completed. */ + String COMPLETED = "completed"; + /** failed. */ + String FAILED = "failed"; + } + + protected String id; + protected String 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. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * 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. + * * `failed`: The job failed. + * + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * 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`). + * + * @return the created + */ + public String getCreated() { + return created; + } + + /** + * 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](#checkjobs) and [Check a job[(#checkjob) methods. + * + * @return the updated + */ + public String getUpdated() { + return updated; + } + + /** + * Gets the url. + * + *

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 + */ + public String getUrl() { + return url; + } + + /** + * 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](#checkjobs) method. + * + * @return the userToken + */ + public String getUserToken() { + return userToken; + } + + /** + * 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](#checkjob) method. + * + * @return the results + */ + public List getResults() { + return results; + } + + /** + * 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](#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 + */ + public List getWarnings() { + return 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 new file mode 100644 index 00000000000..89280df2bc1 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognitionJobs.java @@ -0,0 +1,37 @@ +/* + * (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.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. */ +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. + * + * @return the recognitions + */ + public List getRecognitions() { + return 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 new file mode 100644 index 00000000000..0b7ee243a22 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptions.java @@ -0,0 +1,1266 @@ +/* + * (C) Copyright IBM Corp. 2016, 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.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 java.util.ArrayList; +import java.util.List; + +/** The recognize options. */ +public class RecognizeOptions extends GenericModel { + + /** + * 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-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 InputStream audio; + protected String contentType; + protected String model; + protected Boolean speechBeginEvent; + 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 Long sadModule; + protected Float backgroundAudioSuppression; + protected Boolean lowLatency; + protected Float characterInsertionBias; + + /** Builder. */ + public static class Builder { + private InputStream audio; + private String contentType; + private String model; + private Boolean speechBeginEvent; + 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 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.languageCustomizationId = recognizeOptions.languageCustomizationId; + this.acousticCustomizationId = recognizeOptions.acousticCustomizationId; + this.baseModelVersion = recognizeOptions.baseModelVersion; + this.customizationWeight = recognizeOptions.customizationWeight; + this.inactivityTimeout = recognizeOptions.inactivityTimeout; + this.keywords = recognizeOptions.keywords; + this.keywordsThreshold = recognizeOptions.keywordsThreshold; + this.maxAlternatives = recognizeOptions.maxAlternatives; + this.wordAlternativesThreshold = recognizeOptions.wordAlternativesThreshold; + this.wordConfidence = recognizeOptions.wordConfidence; + this.timestamps = recognizeOptions.timestamps; + this.profanityFilter = recognizeOptions.profanityFilter; + this.smartFormatting = recognizeOptions.smartFormatting; + this.smartFormattingVersion = recognizeOptions.smartFormattingVersion; + this.speakerLabels = recognizeOptions.speakerLabels; + this.grammarName = recognizeOptions.grammarName; + this.redaction = recognizeOptions.redaction; + this.audioMetrics = recognizeOptions.audioMetrics; + 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 with required properties. + * + * @param audio the audio + */ + public Builder(InputStream audio) { + this.audio = audio; + } + + /** + * Builds a RecognizeOptions. + * + * @return the new RecognizeOptions instance + */ + public RecognizeOptions build() { + return new RecognizeOptions(this); + } + + /** + * Adds a new element to keywords. + * + * @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"); + 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 speechBeginEvent. + * + * @param speechBeginEvent the speechBeginEvent + * @return the RecognizeOptions builder + */ + public Builder speechBeginEvent(Boolean speechBeginEvent) { + this.speechBeginEvent = speechBeginEvent; + 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 sadModule. + * + * @param sadModule the sadModule + * @return the RecognizeOptions builder + */ + public Builder sadModule(long sadModule) { + this.sadModule = sadModule; + 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 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; + } + } + + protected RecognizeOptions() {} + + protected RecognizeOptions(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; + speechBeginEvent = builder.speechBeginEvent; + 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; + sadModule = builder.sadModule; + backgroundAudioSuppression = builder.backgroundAudioSuppression; + lowLatency = builder.lowLatency; + characterInsertionBias = builder.characterInsertionBias; + } + + /** + * 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 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 + */ + 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 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 [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. + * + * @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 [Using a custom acoustic model for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-acousticUse). + * + * @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 [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 + */ + 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 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 + * + *

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 [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 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-spotting#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-spotting#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-metadata#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-spotting#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-metadata#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-metadata#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. + * + *

**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 + */ + 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:** 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-formatting#smart-formatting). + * + * @return the smartFormatting + */ + public Boolean smartFormatting() { + return smartFormatting; + } + + /** + * Gets the smartFormattingVersion. + * + *

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 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. * _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. + * + *

See [Speaker + * labels](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-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 [Using a grammar for speech + * recognition](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-grammarUse). + * + * @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:** 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-formatting#numeric-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. + * + *

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-parsing#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. 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-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/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 new file mode 100644 index 00000000000..ed05bba31c9 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterCallbackOptions.java @@ -0,0 +1,129 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The registerCallback options. */ +public class RegisterCallbackOptions extends GenericModel { + + protected String callbackUrl; + protected String userSecret; + + /** 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 with required properties. + * + * @param callbackUrl the callbackUrl + */ + public Builder(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** + * Builds a RegisterCallbackOptions. + * + * @return the new RegisterCallbackOptions instance + */ + public RegisterCallbackOptions build() { + return new RegisterCallbackOptions(this); + } + + /** + * Set the callbackUrl. + * + * @param callbackUrl the callbackUrl + * @return the RegisterCallbackOptions builder + */ + public Builder callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Set the userSecret. + * + * @param userSecret the userSecret + * @return the RegisterCallbackOptions builder + */ + public Builder userSecret(String userSecret) { + this.userSecret = userSecret; + return this; + } + } + + protected RegisterCallbackOptions() {} + + protected RegisterCallbackOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.callbackUrl, "callbackUrl cannot be null"); + callbackUrl = builder.callbackUrl; + userSecret = builder.userSecret; + } + + /** + * New builder. + * + * @return a RegisterCallbackOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the callbackUrl. + * + *

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 + */ + public String callbackUrl() { + return 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. + * + * @return the userSecret + */ + public String userSecret() { + return 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 new file mode 100644 index 00000000000..c9fe53a67a5 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/RegisterStatus.java @@ -0,0 +1,59 @@ +/* + * (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.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. */ +public class RegisterStatus extends GenericModel { + + /** + * 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. */ + String CREATED = "created"; + /** already created. */ + String ALREADY_CREATED = "already created"; + } + + protected String status; + protected String url; + + protected RegisterStatus() {} + + /** + * Gets the status. + * + *

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 + */ + public String getStatus() { + return status; + } + + /** + * Gets the url. + * + *

The callback URL that is successfully registered. + * + * @return the url + */ + public String getUrl() { + return 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 new file mode 100644 index 00000000000..041a3d36884 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetAcousticModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The resetAcousticModel options. */ +public class ResetAcousticModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ResetAcousticModelOptions. + * + * @return the new ResetAcousticModelOptions instance + */ + public ResetAcousticModelOptions build() { + return new ResetAcousticModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ResetAcousticModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ResetAcousticModelOptions() {} + + protected ResetAcousticModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ResetAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..99459ac4926 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/ResetLanguageModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The resetLanguageModel options. */ +public class ResetLanguageModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ResetLanguageModelOptions. + * + * @return the new ResetLanguageModelOptions instance + */ + public ResetLanguageModelOptions build() { + return new ResetLanguageModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ResetLanguageModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ResetLanguageModelOptions() {} + + protected ResetLanguageModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ResetLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..e362991b47c --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeakerLabelsResult.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.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. */ +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. + * + * @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; + } + + /** + * 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. + * + * @return the speaker + */ + public Long getSpeaker() { + return speaker; + } + + /** + * 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. + * + * @return the confidence + */ + public Float getConfidence() { + return confidence; + } + + /** + * 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. + * + * @return the xFinal + */ + public Boolean isXFinal() { + return 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 new file mode 100644 index 00000000000..9224f2242af --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModel.java @@ -0,0 +1,100 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +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`). + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the language. + * + *

The language identifier of the model (for example, `en-US`). + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the rate. + * + *

The sampling rate (minimum acceptable rate for audio) used by the model in Hertz. + * + * @return the rate + */ + public Long getRate() { + return rate; + } + + /** + * Gets the url. + * + *

The URI for the model. + * + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * Gets the supportedFeatures. + * + *

Indicates whether select service features are supported with the model. + * + * @return the supportedFeatures + */ + public SupportedFeatures getSupportedFeatures() { + return supportedFeatures; + } + + /** + * Gets the description. + * + *

A brief description of the model. + * + * @return the description + */ + public String getDescription() { + return 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 new file mode 100644 index 00000000000..67892178f44 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechModels.java @@ -0,0 +1,36 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** 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. + * + * @return the models + */ + public List getModels() { + return 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 new file mode 100644 index 00000000000..419433566aa --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionAlternative.java @@ -0,0 +1,83 @@ +/* + * (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.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. */ +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. + * + * @return the transcript + */ + public String getTranscript() { + return transcript; + } + + /** + * Gets the confidence. + * + *

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 + */ + public Double getConfidence() { + return confidence; + } + + /** + * 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. + * + * @return the timestamps + */ + public List getTimestamps() { + return timestamps; + } + + /** + * 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.86]]`. Confidence scores are returned only for the best + * alternative and only with results marked as final. + * + * @return the wordConfidence + */ + public List getWordConfidence() { + return 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 new file mode 100644 index 00000000000..79c7e0e3cd7 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResult.java @@ -0,0 +1,132 @@ +/* + * (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.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. */ +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. + */ + public interface EndOfUtterance { + /** end_of_data. */ + String END_OF_DATA = "end_of_data"; + /** full_stop. */ + String FULL_STOP = "full_stop"; + /** reset. */ + String RESET = "reset"; + /** silence. */ + String SILENCE = "silence"; + } + + @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 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 and Swift, the field is renamed + * `xFinal` in Java and is escaped with back quotes in Swift. + * + * @return the xFinal + */ + public Boolean isXFinal() { + return xFinal; + } + + /** + * Gets the alternatives. + * + *

An array of alternative transcripts. The `alternatives` array can include additional + * requested output such as word confidence or timestamps. + * + * @return the alternatives + */ + public List getAlternatives() { + return alternatives; + } + + /** + * 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. + * + * @return the keywordsResult + */ + public Map> getKeywordsResult() { + return keywordsResult; + } + + /** + * Gets the wordAlternatives. + * + *

An array of alternative hypotheses found for words of the input audio if a + * `word_alternatives_threshold` is specified. + * + * @return the wordAlternatives + */ + public List getWordAlternatives() { + return wordAlternatives; + } + + /** + * 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. + * + * @return the endOfUtterance + */ + public String getEndOfUtterance() { + return 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 new file mode 100644 index 00000000000..b9f3be382a5 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResults.java @@ -0,0 +1,138 @@ +/* + * (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.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. */ +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; + + 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 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 + */ + 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; + } + + /** + * 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. + * + * @return the speakerLabels + */ + public List getSpeakerLabels() { + return speakerLabels; + } + + /** + * 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](#recognize) + * method. + * + * @return the processingMetrics + */ + public ProcessingMetrics getProcessingMetrics() { + return processingMetrics; + } + + /** + * Gets the audioMetrics. + * + *

If audio metrics are requested, information about the signal characteristics of the input + * audio. + * + * @return the audioMetrics + */ + public AudioMetrics getAudioMetrics() { + return audioMetrics; + } + + /** + * 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}."` (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. + * + * @return the warnings + */ + public List getWarnings() { + return warnings; + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechTimestamp.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java similarity index 84% rename from speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechTimestamp.java rename to speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechTimestamp.java index d75c61770d3..903e78d5f30 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/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 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,16 +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.developer_cloud.speech_to_text.v1.model; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.JsonAdapter; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechTimestampTypeAdapter; +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/developer_cloud/speech_to_text/v1/model/SpeechWordConfidence.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java similarity index 80% rename from speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/model/SpeechWordConfidence.java rename to speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SpeechWordConfidence.java index d41a2abe928..67fdd84838b 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/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 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,16 +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.developer_cloud.speech_to_text.v1.model; +package com.ibm.watson.speech_to_text.v1.model; import com.google.gson.annotations.JsonAdapter; -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter; +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 new file mode 100644 index 00000000000..61225ffbbd4 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/SupportedFeatures.java @@ -0,0 +1,92 @@ +/* + * (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.speech_to_text.v1.model; + +import com.google.gson.annotations.SerializedName; +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the customLanguageModel + */ + 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. + * + *

**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 new file mode 100644 index 00000000000..00d5dce54fa --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainAcousticModelOptions.java @@ -0,0 +1,158 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The trainAcousticModel options. */ +public class TrainAcousticModelOptions extends GenericModel { + + protected String customizationId; + protected String customLanguageModelId; + protected Boolean strict; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a TrainAcousticModelOptions. + * + * @return the new TrainAcousticModelOptions instance + */ + public TrainAcousticModelOptions build() { + return new TrainAcousticModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the TrainAcousticModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the customLanguageModelId. + * + * @param customLanguageModelId the customLanguageModelId + * @return the TrainAcousticModelOptions builder + */ + 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"); + customizationId = builder.customizationId; + customLanguageModelId = builder.customLanguageModelId; + strict = builder.strict; + } + + /** + * New builder. + * + * @return a TrainAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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, 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 new file mode 100644 index 00000000000..2aaaf3f2c1a --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainLanguageModelOptions.java @@ -0,0 +1,256 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The trainLanguageModel options. */ +public class TrainLanguageModelOptions extends GenericModel { + + /** + * _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. */ + String ALL = "all"; + /** user. */ + String USER = "user"; + } + + protected String customizationId; + protected String wordTypeToAdd; + protected Double customizationWeight; + protected Boolean strict; + protected Boolean force; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a TrainLanguageModelOptions. + * + * @return the new TrainLanguageModelOptions instance + */ + public TrainLanguageModelOptions build() { + return new TrainLanguageModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the TrainLanguageModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the wordTypeToAdd. + * + * @param wordTypeToAdd the wordTypeToAdd + * @return the TrainLanguageModelOptions builder + */ + public Builder wordTypeToAdd(String wordTypeToAdd) { + this.wordTypeToAdd = wordTypeToAdd; + return this; + } + + /** + * Set the customizationWeight. + * + * @param customizationWeight the customizationWeight + * @return the TrainLanguageModelOptions builder + */ + 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"); + customizationId = builder.customizationId; + wordTypeToAdd = builder.wordTypeToAdd; + customizationWeight = builder.customizationWeight; + strict = builder.strict; + force = builder.force; + } + + /** + * New builder. + * + * @return a TrainLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return customizationId; + } + + /** + * Gets the wordTypeToAdd. + * + *

_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 + */ + public String wordTypeToAdd() { + return 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 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 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 new file mode 100644 index 00000000000..20696e168cb --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingResponse.java @@ -0,0 +1,38 @@ +/* + * (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.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. */ +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`. + * + * @return the warnings + */ + public List getWarnings() { + return 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 new file mode 100644 index 00000000000..3eea674224f --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/TrainingWarning.java @@ -0,0 +1,62 @@ +/* + * (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.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. */ +public class TrainingWarning extends GenericModel { + + /** 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"; + /** invalid_corpus_files. */ + String INVALID_CORPUS_FILES = "invalid_corpus_files"; + /** invalid_grammar_files. */ + String INVALID_GRAMMAR_FILES = "invalid_grammar_files"; + /** invalid_words. */ + String INVALID_WORDS = "invalid_words"; + } + + protected String code; + protected String message; + + protected TrainingWarning() {} + + /** + * Gets the code. + * + *

An identifier for the type of invalid resources listed in the `description` field. + * + * @return the code + */ + public String getCode() { + return code; + } + + /** + * 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.`. + * + * @return the message + */ + public String getMessage() { + return 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 new file mode 100644 index 00000000000..b4f454b1126 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UnregisterCallbackOptions.java @@ -0,0 +1,96 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The unregisterCallback options. */ +public class UnregisterCallbackOptions extends GenericModel { + + protected String callbackUrl; + + /** 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 with required properties. + * + * @param callbackUrl the callbackUrl + */ + public Builder(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** + * Builds a UnregisterCallbackOptions. + * + * @return the new UnregisterCallbackOptions instance + */ + public UnregisterCallbackOptions build() { + return new UnregisterCallbackOptions(this); + } + + /** + * Set the callbackUrl. + * + * @param callbackUrl the callbackUrl + * @return the UnregisterCallbackOptions builder + */ + public Builder callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + } + + protected UnregisterCallbackOptions() {} + + protected UnregisterCallbackOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.callbackUrl, "callbackUrl cannot be null"); + callbackUrl = builder.callbackUrl; + } + + /** + * New builder. + * + * @return a UnregisterCallbackOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the callbackUrl. + * + *

The callback URL that is to be unregistered. + * + * @return the callbackUrl + */ + public String callbackUrl() { + return 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 new file mode 100644 index 00000000000..3ccf0004db7 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeAcousticModelOptions.java @@ -0,0 +1,158 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The upgradeAcousticModel options. */ +public class UpgradeAcousticModelOptions extends GenericModel { + + protected String customizationId; + protected String customLanguageModelId; + protected Boolean force; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a UpgradeAcousticModelOptions. + * + * @return the new UpgradeAcousticModelOptions instance + */ + public UpgradeAcousticModelOptions build() { + return new UpgradeAcousticModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the UpgradeAcousticModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the customLanguageModelId. + * + * @param customLanguageModelId the customLanguageModelId + * @return the UpgradeAcousticModelOptions builder + */ + public Builder customLanguageModelId(String customLanguageModelId) { + this.customLanguageModelId = customLanguageModelId; + return this; + } + + /** + * Set the force. + * + * @param force the force + * @return the UpgradeAcousticModelOptions builder + */ + public Builder force(Boolean force) { + this.force = force; + return this; + } + } + + protected UpgradeAcousticModelOptions() {} + + protected UpgradeAcousticModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + customLanguageModelId = builder.customLanguageModelId; + force = builder.force; + } + + /** + * New builder. + * + * @return a UpgradeAcousticModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 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 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-custom-upgrade#custom-upgrade-acoustic). + * + * @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/UpgradeLanguageModelOptions.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java new file mode 100644 index 00000000000..290c36e1aaa --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/UpgradeLanguageModelOptions.java @@ -0,0 +1,98 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The upgradeLanguageModel options. */ +public class UpgradeLanguageModelOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a UpgradeLanguageModelOptions. + * + * @return the new UpgradeLanguageModelOptions instance + */ + public UpgradeLanguageModelOptions build() { + return new UpgradeLanguageModelOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the UpgradeLanguageModelOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected UpgradeLanguageModelOptions() {} + + protected UpgradeLanguageModelOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a UpgradeLanguageModelOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the customizationId + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..64caa9b77c2 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Word.java @@ -0,0 +1,147 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +/** 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. + * + * @return the word + */ + 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 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 + */ + public List getSoundsLike() { + return soundsLike; + } + + /** + * Gets the displayAs. + * + *

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 + */ + public String getDisplayAs() { + return displayAs; + } + + /** + * Gets the count. + * + *

_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 + */ + public Long getCount() { + return count; + } + + /** + * Gets the source. + * + *

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 + */ + public List getSource() { + return source; + } + + /** + * 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. + * + * @return the error + */ + public List getError() { + return 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 new file mode 100644 index 00000000000..038ebde53d1 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResult.java @@ -0,0 +1,47 @@ +/* + * (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.speech_to_text.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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. + * + * @return the confidence + */ + public Double getConfidence() { + return confidence; + } + + /** + * Gets the word. + * + *

An alternative hypothesis for a word from the input audio. + * + * @return the word + */ + public String getWord() { + return 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 new file mode 100644 index 00000000000..6654d4ffd5b --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordAlternativeResults.java @@ -0,0 +1,67 @@ +/* + * (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.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. */ +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. + * + * @return the startTime + */ + public Double getStartTime() { + return startTime; + } + + /** + * Gets the endTime. + * + *

The end time in seconds of the word from the input audio that corresponds to the word + * alternatives. + * + * @return the endTime + */ + public Double getEndTime() { + return endTime; + } + + /** + * Gets the alternatives. + * + *

An array of alternative hypotheses for a word from the input audio. + * + * @return the alternatives + */ + public List getAlternatives() { + return 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 new file mode 100644 index 00000000000..2bcc38ad3f9 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/WordError.java @@ -0,0 +1,40 @@ +/* + * (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.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. */ +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 + * '{suggested_string}'."`. + * + * @return the element + */ + public String getElement() { + return 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 new file mode 100644 index 00000000000..faa1e435f05 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/model/Words.java @@ -0,0 +1,37 @@ +/* + * (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.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. */ +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. + * + * @return the words + */ + public List getWords() { + return 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 new file mode 100644 index 00000000000..5d4cd287ed1 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/package-info.java @@ -0,0 +1,15 @@ +/* + * (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. + */ + +/** Speech to Text v1. */ +package com.ibm.watson.speech_to_text.v1; diff --git a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java similarity index 90% rename from speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/MediaTypeUtils.java rename to speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/MediaTypeUtils.java index 385642fafa2..793f555d055 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/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 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,15 +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.developer_cloud.speech_to_text.v1.util; +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.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.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/developer_cloud/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java similarity index 87% rename from speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java rename to speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechTimestampTypeAdapter.java index c4e95bb2d27..3b216e10d54 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/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 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,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.developer_cloud.speech_to_text.v1.util; - -import java.io.IOException; +package com.ibm.watson.speech_to_text.v1.util; 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.developer_cloud.speech_to_text.v1.model.SpeechTimestamp; +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/developer_cloud/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java similarity index 85% rename from speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java rename to speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/util/SpeechWordConfidenceTypeAdapter.java index c2f16626e6c..2564ab692a8 100644 --- a/speech-to-text/src/main/java/com/ibm/watson/developer_cloud/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 @@ /* - * Copyright 2017 IBM Corp. All Rights Reserved. + * (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,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.developer_cloud.speech_to_text.v1.util; - -import java.io.IOException; +package com.ibm.watson.speech_to_text.v1.util; 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.developer_cloud.speech_to_text.v1.model.SpeechWordConfidence; +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 new file mode 100755 index 00000000000..7c6f1da1fc4 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/BaseRecognizeCallback.java @@ -0,0 +1,76 @@ +/* + * (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.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. */ +public class BaseRecognizeCallback implements RecognizeCallback { + + private static final Logger LOG = Logger.getLogger(BaseRecognizeCallback.class.getName()); + + /* + * (non-Javadoc) + * @see + * RecognizeCallback#onTranscription(com. + * ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults) + */ + public void onTranscription(SpeechRecognitionResults speechResults) {}; + + /* + * (non-Javadoc) + * @see RecognizeCallback#onConnected() + */ + public void onConnected() {}; + + /* + * (non-Javadoc) + * @see + * RecognizeCallback#onError(java.lang + * .Exception) + */ + public void onError(Exception e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + }; + + /* + * (non-Javadoc) + * @see + * RecognizeCallback#onDisconnected() + */ + public void onDisconnected() {}; + + /* + * (non-Javadoc) + * @see com.ibm.watson.speech_to_text.v1.websocket + * .RecognizeCallback#onInactivityTimeout(java.lang.RuntimeException) + */ + @Override + public void onInactivityTimeout(RuntimeException runtimeException) {}; + + /* + * (non-Javadoc) + * @see RecognizeCallback#onListening() + */ + @Override + public void onListening() {}; + + /* + * (non-Javadoc) + * @see RecognizeCallback#onTranscriptionComplete() + */ + @Override + 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 new file mode 100755 index 00000000000..b23e4e26ef8 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/RecognizeCallback.java @@ -0,0 +1,57 @@ +/* + * (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.speech_to_text.v1.websocket; + +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. + */ +public interface RecognizeCallback { + + /** + * Called when a {@link SpeechRecognitionResults} was received. + * + * @param speechResults the speech results + */ + void onTranscription(SpeechRecognitionResults speechResults); + + /** Called when a WebSocket connection was made. */ + void onConnected(); + + /** + * Called when there is an error in the Web Socket connection. + * + * @param e the exception + */ + void onError(Exception e); + + /** Called when a WebSocket connection was closed. */ + void onDisconnected(); + + /** + * Called when there is an inactivity timeout. + * + * @param runtimeException the runtime exception + */ + void onInactivityTimeout(RuntimeException runtimeException); + + /** Called when the service is listening for audio. */ + void onListening(); + + /** 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 new file mode 100755 index 00000000000..5a609ca7d80 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java @@ -0,0 +1,255 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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.websocket; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +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.RecognizeWithWebsocketsOptions; +import com.ibm.watson.speech_to_text.v1.model.SpeechRecognitionResults; +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. + * + * @see SpeechToText + */ +public final class SpeechToTextWebSocketListener extends WebSocketListener { + + private static final String AUDIO_TO_WEB_SOCKET = "AudioToWebSocketThread"; + private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); + private static final Logger LOG = Logger.getLogger(SpeechToTextWebSocketListener.class.getName()); + + private static final String STATE = "state"; + private static final String MODEL = "model"; + private static final String START = "start"; + private static final String STOP = "stop"; + private static final String ACTION = "action"; + private static final int ONE_KB = 1024; + private static final String ERROR = "error"; + 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 LANGUAGE_CUSTOMIZATION_ID = "language_customization_id"; + private static final String ACOUSTIC_CUSTOMIZATION_ID = "acoustic_customization_id"; + private static final String VERSION = "base_model_version"; + private static final String TIMEOUT_PREFIX = "No speech detected for"; + + // 8 MB, half of the maximum OkHttp WebSocket queue size + // (https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/ws/RealWebSocket.java#L63) + private static final long QUEUE_SIZE_LIMIT = 16 * 1024 * 512; + private static final long QUEUE_WAIT_MILLIS = 500; + + private final InputStream stream; + private final RecognizeWithWebsocketsOptions options; + private final RecognizeCallback callback; + private WebSocket socket; + private boolean socketOpen = true; + private Thread audioThread = null; + private boolean isListening = false; + private static final int CLOSE_NORMAL = 1000; + + /** + * Instantiates a new speech to text web socket listener. + * + * @param options the recognize options + * @param callback the callback + */ + public SpeechToTextWebSocketListener( + final RecognizeWithWebsocketsOptions options, final RecognizeCallback callback) { + this.stream = options.audio(); + this.options = options; + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onClosing(okhttp3.WebSocket, int, java.lang.String) + */ + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + socketOpen = false; + callback.onDisconnected(); + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onFailure(okhttp3.WebSocket, java.lang.Throwable, okhttp3.Response) + */ + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + socketOpen = false; + if (t instanceof Exception) { + callback.onError((Exception) t); + } else { + callback.onError(new Exception(t)); + } + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onMessage(okhttp3.WebSocket, java.lang.String) + */ + @Override + public void onMessage(WebSocket webSocket, String message) { + JsonObject json = new JsonParser().parse(message).getAsJsonObject(); + if (json.has(ERROR)) { + String error = json.get(ERROR).getAsString(); + + // Only call onError() if a real error occurred. The STT service sends + // {"error" : "No speech detected for 5s"} for valid timeouts, configured by + // RecognizeUsingWebSocketOptions.Builder.inactivityTimeout() + if (!error.startsWith(TIMEOUT_PREFIX)) { + callback.onError(new RuntimeException(error)); + } else { + // notify that the service timeouts because of inactivity + callback.onInactivityTimeout(new RuntimeException(error)); + } + } else if (json.has(RESULTS) || json.has(SPEAKER_LABELS) || json.has(AUDIO_METRICS)) { + callback.onTranscription(GSON.fromJson(message, SpeechRecognitionResults.class)); + + } else if (json.has(STATE)) { + // A listen state after everything has been sent over indicates everything has been processed + if (!isListening) { + isListening = true; + } else { + callback.onTranscriptionComplete(); + socket.close(CLOSE_NORMAL, "Transcription completed"); + return; + } + + // notify that the service is ready to receive audio + callback.onListening(); + } + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onOpen(okhttp3.WebSocket, okhttp3.Response) + */ + @Override + public void onOpen(final WebSocket socket, Response response) { + callback.onConnected(); + this.socket = socket; + if (!socket.send(buildStartMessage(options))) { + callback.onError(new IOException("WebSocket unavailable")); + } else { + // 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.start(); + } + } + + /** + * Send input stream. + * + * @param inputStream the input stream + */ + 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 + // 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. + while (socket.queueSize() > QUEUE_SIZE_LIMIT) { + Thread.sleep(QUEUE_WAIT_MILLIS); + } + + if (read == ONE_KB) { + socket.send(ByteString.of(buffer)); + } else { + socket.send(ByteString.of(Arrays.copyOfRange(buffer, 0, read))); + } + } + } catch (IOException | InterruptedException e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + } finally { + try { + inputStream.close(); + } catch (IOException e) { + // do nothing - the InputStream may have already been closed externally. + } + } + } + + /** + * Builds the start message. + * + * @param options the options + * @return the request + */ + 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(LANGUAGE_CUSTOMIZATION_ID); + startMessage.remove(ACOUSTIC_CUSTOMIZATION_ID); + startMessage.remove(VERSION); + startMessage.addProperty(ACTION, START); + return startMessage.toString(); + } + + /** + * Builds the stop message. + * + * @return the string + */ + private String buildStopMessage() { + JsonObject stopMessage = new JsonObject(); + stopMessage.addProperty(ACTION, STOP); + return stopMessage.toString(); + } +} diff --git a/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/package-info.java b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/package-info.java new file mode 100644 index 00000000000..a72ecec1820 --- /dev/null +++ b/speech-to-text/src/main/java/com/ibm/watson/speech_to_text/v1/websocket/package-info.java @@ -0,0 +1,16 @@ +/* + * (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. + */ +/** + * This package contains interfaces and implementations to work with Websocket in Speech to Text. + */ +package com.ibm.watson.speech_to_text.v1.websocket; diff --git a/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java b/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java deleted file mode 100755 index 038ce825515..00000000000 --- a/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextIT.java +++ /dev/null @@ -1,948 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.service.exception.NotFoundException; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CheckJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpora; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpus.Status; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.KeywordResult; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJob; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResult; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.WordAlternativeResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.BaseRecognizeCallback; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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; -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.logging.Logger; - -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. - */ -@RunWith(RetryRunner.class) -public class SpeechToTextIT extends WatsonServiceTest { - - private static final String EN_BROADBAND16K = "en-US_BroadbandModel"; - 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 Logger LOG = Logger.getLogger(SpeechToTextIT.class.getName()); - - private CountDownLatch lock = new CountDownLatch(1); - private SpeechToText service; - private SpeechRecognitionResults asyncResults; - private Boolean inactivityTimeoutOccurred; - private String customizationId; - - /** The expected exception. */ - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - this.customizationId = getProperty("speech_to_text.customization_id"); - - String username = getProperty("speech_to_text.username"); - String password = getProperty("speech_to_text.password"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - username == null || username.equals(PLACEHOLDER)); - - service = new SpeechToText(); - service.setUsernameAndPassword(username, password); - service.setEndPoint(getProperty("speech_to_text.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - /** - * Test get model. - */ - @Test - public void testGetModel() { - GetModelOptions getOptions = new GetModelOptions.Builder() - .modelId(EN_BROADBAND16K) - .build(); - SpeechModel model = service.getModel(getOptions).execute(); - assertNotNull(model); - assertNotNull(model.getName()); - assertNotNull(model.getLanguage()); - assertNotNull(model.getRate()); - assertNotNull(model.getUrl()); - assertNotNull(model.getDescription()); - assertNotNull(model.getSessions()); - assertNotNull(model.getSupportedFeatures().isCustomLanguageModel()); - assertNotNull(model.getSupportedFeatures().isSpeakerLabels()); - } - - /** - * Test list models. - */ - @Test - public void testListModels() { - SpeechModels models = service.listModels().execute(); - assertNotNull(models); - assertTrue(!models.getModels().isEmpty()); - } - - /** - * Test recognize audio file. - */ - @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(RecognizeOptions.ContentType.AUDIO_WAV) - .maxAlternatives(maxAlternatives) - .wordAlternativesThreshold(wordAlternativesThreshold) - .smartFormatting(true) - .build(); - SpeechRecognitionResults results = service.recognize(options).execute(); - - assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); - assertTrue(results.getResults().get(0).getAlternatives().size() <= maxAlternatives); - List wordAlternatives = results.getResults().get(0).getWordAlternatives(); - for (WordAlternativeResults alternativeResults : wordAlternatives) { - assertTrue(alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); - } - } - - /** - * Test recognize multiple speakers. - */ - @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(); - - SpeechRecognitionResults results = service.recognize(options).execute(); - assertNotNull(results.getSpeakerLabels()); - assertTrue(results.getSpeakerLabels().size() > 0); - } - - /** - * Test recognize file string recognize options. - */ - @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) - .build(); - SpeechRecognitionResults results = service.recognize(options).execute(); - assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTranscript()); - assertNotNull(results.getResults().get(0).getAlternatives().get(0).getTimestamps()); - assertNotNull(results.getResults().get(0).getAlternatives().get(0).getWordConfidence()); - } - - /** - * Test keyword recognition. - */ - @Test - public void testRecognizeKeywords() throws FileNotFoundException { - final String keyword1 = "rain"; - 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 SpeechRecognitionResults results = service.recognize(options).execute(); - final SpeechRecognitionResult transcript = results.getResults().get(0); - - assertEquals(2, transcript.getKeywordsResult().size()); - assertTrue(transcript.getKeywordsResult().containsKey(keyword1)); - assertTrue(transcript.getKeywordsResult().containsKey(keyword2)); - - final KeywordResult result1 = transcript.getKeywordsResult().get(keyword1).get(0); - assertEquals(keyword1, result1.getNormalizedText()); - assertEquals(0.9, result1.getConfidence(), 0.1); - assertEquals(5.58, result1.getStartTime(), 1.0); - assertEquals(6.14, result1.getEndTime(), 1.0); - - final KeywordResult result2 = transcript.getKeywordsResult().get(keyword2).get(0); - assertEquals(keyword2, result2.getNormalizedText()); - assertEquals(0.9, result2.getConfidence(), 0.1); - assertEquals(4.42, result2.getStartTime(), 1.0); - assertEquals(5.04, result2.getEndTime(), 1.0); - } - - /** - * Test recognize webSocket. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testRecognizeWebSocket() throws FileNotFoundException, InterruptedException { - FileInputStream audio = new FileInputStream(SAMPLE_WAV); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .inactivityTimeout(40) - .timestamps(true) - .maxAlternatives(2) - .wordAlternativesThreshold(0.5f) - .model(EN_BROADBAND16K) - .contentType(HttpMediaType.AUDIO_WAV) - .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(); - } - - @Override - public void onError(Exception e) { - e.printStackTrace(); - lock.countDown(); - } - - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - Long resultIndex = speechResults.getResultIndex(); - if (speechResults != null && speechResults.getResults().get(resultIndex.intValue()).isFinalResults()) { - asyncResults = speechResults; - } - } - - }); - - lock.await(2, TimeUnit.MINUTES); - assertNotNull(asyncResults); - - List wordAlternatives = asyncResults.getResults().get(asyncResults.getResultIndex() - .intValue()).getWordAlternatives(); - assertTrue(wordAlternatives != null && !wordAlternatives.isEmpty()); - assertNotNull(wordAlternatives.get(0).getAlternatives()); - } - - /** - * Test the inactivity timeout parameter for WebSockets. - * - * @throws FileNotFoundException the file not found exception - * @throws InterruptedException the interrupted exception - */ - @Test - public void testInactivityTimeoutWithWebSocket() throws FileNotFoundException, InterruptedException { - FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE); - RecognizeOptions options = new RecognizeOptions.Builder() - .audio(audio) - .interimResults(true) - .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 onInactivityTimeout(RuntimeException runtimeException) { - inactivityTimeoutOccurred = true; - } - }); - - lock.await(2, TimeUnit.MINUTES); - assertTrue(inactivityTimeoutOccurred); - } - - /** - * Test create job. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - 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(CreateJobOptions.ContentType.AUDIO_WAV) - .maxAlternatives(maxAlternatives) - .wordAlternativesThreshold(wordAlternativesThreshold) - .build(); - RecognitionJob job = service.createJob(createOptions).execute(); - try { - assertNotNull(job.getId()); - 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(); - } - job = service.checkJob(checkOptions).execute(); - 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(); - for (WordAlternativeResults alternativeResults : wordAlternatives) { - assertTrue(alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); - } - - } finally { - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder() - .id(job.getId()) - .build(); - service.deleteJob(deleteOptions).execute(); - } - } - - /** - * 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. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Ignore - @Test - public void testCreateJobWarning() throws InterruptedException, FileNotFoundException { - File audio = new File(SAMPLE_WAV); - CreateJobOptions createOptions = new CreateJobOptions.Builder() - .audio(audio) - .contentType(CreateJobOptions.ContentType.AUDIO_WAV) - .userToken("job") - .build(); - RecognitionJob job = service.createJob(createOptions).execute(); - try { - assertNotNull(job.getId()); - assertNotNull(job.getWarnings()); - CheckJobOptions checkOptions = new CheckJobOptions.Builder() - .id(job.getId()) - .build(); - for (int x = 0; x < 30 && job.getStatus() != RecognitionJob.Status.COMPLETED; x++) { - Thread.sleep(3000); - job = service.checkJob(checkOptions).execute(); - } - job = service.checkJob(checkOptions).execute(); - assertEquals(RecognitionJob.Status.COMPLETED, job.getStatus()); - assertNotNull(job.getResults()); - } finally { - DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder() - .id(job.getId()) - .build(); - service.deleteJob(deleteOptions).execute(); - } - } - - /** - * 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(); - service.checkJob(checkOptions).execute(); - } - - /** - * Test check jobs. - * - */ - @Test - public void testCheckJobs() { - RecognitionJobs jobs = service.checkJobs().execute(); - assertNotNull(jobs); - } - - /** - * Test list language models. - */ - @Test - public void testListLanguageModels() { - LanguageModels models = service.listLanguageModels().execute(); - assertNotNull(models); - assertTrue(!models.getCustomizations().isEmpty()); - } - - /** - * Test list corpora. - * - */ - @Test - @Ignore - public void testListCorpora() { - ListCorporaOptions listOptions = new ListCorporaOptions.Builder() - .customizationId(customizationId) - .build(); - Corpora result = service.listCorpora(listOptions).execute(); - assertNotNull(result); - } - - /** - * Test get corpus. - * - */ - @Test - @Ignore - public void testGetCorpus() { - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .corpusName("foo3") - .customizationId(customizationId) - .build(); - Corpus result = service.getCorpus(getOptions).execute(); - assertNotNull(result); - } - - /** - * Test add corpus with expected failure. - * - */ - @Test(expected = IllegalArgumentException.class) - public void testAddCorpusFail() { - AddCorpusOptions addOptions = new AddCorpusOptions.Builder() - .corpusName("foo3") - .customizationId(customizationId) - .build(); - service.addCorpus(addOptions).execute(); - } - - /** - * Test list words with just a customization ID. - */ - @Test - @Ignore - public void testListWordsCustomizationId() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .build(); - Words result = service.listWords(listOptions).execute(); - assertNotNull(result); - assertTrue(!result.getWords().isEmpty()); - } - - /** - * 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(); - Words result = service.listWords(listOptions).execute(); - assertNotNull(result); - assertTrue(!result.getWords().isEmpty()); - } - - /** - * Test list words with type all. - */ - @Test - @Ignore - public void testListWordsTypeAll() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .wordType(ListWordsOptions.WordType.ALL) - .build(); - Words result = service.listWords(listOptions).execute(); - assertNotNull(result); - assertTrue(!result.getWords().isEmpty()); - } - - /** - * Test list words with alphabetical sort. - */ - @Test - @Ignore - public void testGetWordsThreeSort() { - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(customizationId) - .sort(ListWordsOptions.Sort.ALPHABETICAL) - .build(); - Words result = service.listWords(listOptions).execute(); - assertNotNull(result); - assertTrue(!result.getWords().isEmpty()); - } - - /** - * 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(); - Words result = service.listWords(listOptions).execute(); - assertNotNull(result); - assertTrue(!result.getWords().isEmpty()); - } - - /** - * Test get word. - */ - public void testGetWord() { - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(customizationId) - .wordName("string") - .build(); - Word result = service.getWord(getOptions).execute(); - assertNotNull(result); - } - - /** - * Test create language model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - LanguageModel myModel = service.createLanguageModel(createOptions).execute(); - 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"))) - .corpusFileContentType(HttpMediaType.TEXT_PLAIN) - .allowOverwrite(false) - .build(); - service.addCorpus(addOptions).execute(); - - // Get corpus status - GetCorpusOptions getOptions = new GetCorpusOptions.Builder() - .customizationId(id) - .corpusName("corpus-1") - .build(); - for (int x = 0; x < 30 && !service.getCorpus(getOptions).execute().getStatus().equals(Status.ANALYZED); x++) { - Thread.sleep(5000); - } - - assertTrue(service.getCorpus(getOptions).execute().getStatus().equals(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"))) - .corpusFileContentType(HttpMediaType.TEXT_PLAIN) - .allowOverwrite(true) - .build(); - service.addCorpus(addOptionsWithOverwrite).execute(); - - // Get corpus status - for (int x = 0; x < 30 && !service.getCorpus(getOptions).execute().getStatus().equals(Status.ANALYZED); x++) { - Thread.sleep(5000); - } - - assertTrue(service.getCorpus(getOptions).execute().getStatus().equals(Status.ANALYZED)); - - // Get corpora - ListCorporaOptions listCorporaOptions = new ListCorporaOptions.Builder() - .customizationId(id) - .build(); - Corpora corpora = service.listCorpora(listCorporaOptions).execute(); - - 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(); - 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("aaa") - .word("aaa") - .displayAs("aaa") - .addSoundsLike("aaa") - .addSoundsLike("bbb") - .build()).execute(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("bbb") - .word("bbb") - .addSoundsLike("aaa") - .addSoundsLike("bbb") - .build()).execute(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("ccc") - .word("ccc") - .displayAs("ccc") - .build()).execute(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("ddd") - .word("ddd") - .build()).execute(); - service.addWord(new AddWordOptions.Builder() - .customizationId(id) - .wordName("eee") - .word("eee") - .build()).execute(); - - // 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(); - assertNotNull(words); - - } finally { - DeleteLanguageModelOptions deleteOptions = new DeleteLanguageModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteLanguageModel(deleteOptions).execute(); - } - } - - /** - * 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(); - AcousticModel myModel = service.createAcousticModel(createOptions).execute(); - String id = myModel.getCustomizationId(); - - try { - GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder() - .customizationId(id) - .build(); - AcousticModel model = service.getAcousticModel(getOptions).execute(); - - assertNotNull(model); - assertEquals(name, model.getName()); - assertEquals(EN_BROADBAND16K, model.getBaseModelName()); - assertEquals(description, model.getDescription()); - } finally { - DeleteAcousticModelOptions deleteOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteAcousticModel(deleteOptions).execute(); - } - } - - /** - * Test list acoustic models. - */ - @Test - public void testListAcousticModels() { - AcousticModels models = service.listAcousticModels().execute(); - assertNotNull(models); - } - - /** - * 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. - * - * @throws InterruptedException the interrupted exception - */ - @Ignore - @Test - public void testGetAudio() throws InterruptedException, FileNotFoundException { - 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(); - AcousticModel myModel = service.createAcousticModel(createOptions).execute(); - String id = myModel.getCustomizationId(); - - String audioName = "sample"; - AddAudioOptions addOptions = new AddAudioOptions.Builder() - .audioResource(new File(SAMPLE_WAV)) - .contentType(AddAudioOptions.ContentType.AUDIO_WAV) - .audioName(audioName) - .customizationId(id) - .allowOverwrite(true) - .build(); - service.addAudio(addOptions).execute(); - - try { - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - AudioListing audio = service.getAudio(getOptions).execute(); - - assertNotNull(audio); - assertEquals(audioName, audio.getName()); - } finally { - DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - service.deleteAudio(deleteAudioOptions).execute(); - - GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder() - .customizationId(id) - .build(); - for (int x = 0; x < 30 && !service.getAcousticModel(getOptions).execute().getStatus().equals( - AcousticModel.Status.AVAILABLE); x++) { - Thread.sleep(5000); - } - - DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteAcousticModel(deleteAcousticModelOptions).execute(); - } - } - - /** - * Test list audio. - */ - @Test - public void testListAudio() { - 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(); - AcousticModel myModel = service.createAcousticModel(createOptions).execute(); - String id = myModel.getCustomizationId(); - - try { - ListAudioOptions listOptions = new ListAudioOptions.Builder() - .customizationId(id) - .build(); - AudioResources resources = service.listAudio(listOptions).execute(); - - assertNotNull(resources); - } finally { - DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteAcousticModel(deleteAcousticModelOptions).execute(); - } - } - - /** - * Test add audio with an archive file. - * - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testAddAudioArchive() throws FileNotFoundException, InterruptedException { - 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(); - AcousticModel myModel = service.createAcousticModel(createOptions).execute(); - String id = myModel.getCustomizationId(); - - String audioName = "test-archive"; - File audio = new File(WAV_ARCHIVE); - AddAudioOptions addOptions = new AddAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .contentType(AddAudioOptions.ContentType.APPLICATION_ZIP) - .containedContentType(AddAudioOptions.ContainedContentType.AUDIO_WAV) - .audioResource(audio) - .build(); - service.addAudio(addOptions).execute(); - - try { - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - AudioListing listing = service.getAudio(getOptions).execute(); - - assertNotNull(listing); - assertEquals(audioName, listing.getName()); - } finally { - DeleteAudioOptions deleteAudioOptions = new DeleteAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - service.deleteAudio(deleteAudioOptions).execute(); - - GetAcousticModelOptions getOptions = new GetAcousticModelOptions.Builder() - .customizationId(id) - .build(); - for (int x = 0; x < 30 && !service.getAcousticModel(getOptions).execute().getStatus().equals( - AcousticModel.Status.AVAILABLE); x++) { - Thread.sleep(5000); - } - - DeleteAcousticModelOptions deleteAcousticModelOptions = new DeleteAcousticModelOptions.Builder() - .customizationId(id) - .build(); - service.deleteAcousticModel(deleteAcousticModelOptions).execute(); - } - } - - @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/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextTest.java b/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextTest.java deleted file mode 100755 index 84595fdd03d..00000000000 --- a/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/SpeechToTextTest.java +++ /dev/null @@ -1,1458 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AcousticModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioListing; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResource; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.AudioResources; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CheckJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Corpora; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CreateLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.CustomWord; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteJobOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetCorpusOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.LanguageModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListAcousticModelsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListAudioOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListCorporaOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListLanguageModelsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJob; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognitionJobs; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RecognizeOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RegisterCallbackOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.RegisterStatus; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ResetAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.ResetLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModel; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechModels; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechRecognitionResults; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.TrainLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UnregisterCallbackOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UpgradeAcousticModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.UpgradeLanguageModelOptions; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Word; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.Words; -import com.ibm.watson.developer_cloud.speech_to_text.v1.util.MediaTypeUtils; -import com.ibm.watson.developer_cloud.speech_to_text.v1.websocket.RecognizeCallback; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.TestUtils; -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 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 { - - private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); - - 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"; - - 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"); - - private SpeechModel speechModel; - private SpeechModels speechModels; - private SpeechRecognitionResults recognitionResults; - - private SpeechToText service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new SpeechToText(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - 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); - } - - /** - * Test get model. - * - * @throws Exception the exception - */ - @Test - public void testGetModel() throws Exception { - final MockResponse mockResponse = new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(speechModel)); - - server.enqueue(mockResponse); - GetModelOptions getOptionsString = new GetModelOptions.Builder() - .modelId("not-a-real-Model") - .build(); - SpeechModel model = service.getModel(getOptionsString).execute(); - RecordedRequest request = server.takeRequest(); - - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); - - server.enqueue(mockResponse); - GetModelOptions getOptionsGetter = new GetModelOptions.Builder() - .modelId("not-a-real-Model") - .build(); - model = service.getModel(getOptionsGetter).execute(); - request = server.takeRequest(); - - assertNotNull(model); - assertEquals(model, speechModel); - assertEquals(GET, request.getMethod()); - - TestUtils.assertNoExceptionsOnGetters(model); - } - - /** - * Test get models. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetModels() throws InterruptedException { - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(speechModels))); - - final SpeechModels models = service.listModels().execute(); - 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(); - } - - /** - * 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(RecognizeOptions.ContentType.AUDIO_WAV) - .build(); - final SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertNotNull(result); - assertEquals(result, recognitionResults); - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE, request.getPath()); - assertEquals(HttpMediaType.AUDIO_WAV, request.getHeader(CONTENT_TYPE)); - } - - /** - * 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(RecognizeOptions.ContentType.AUDIO_WEBM) - .build(); - final SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - 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(RecognizeOptions.ContentType.AUDIO_WAV) - .speakerLabels(true) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - 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(RecognizeOptions.ContentType.AUDIO_WAV) - .customizationId(id) - .baseModelVersion(version) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_RECOGNIZE + "?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(RecognizeOptions.ContentType.AUDIO_WAV) - .acousticCustomizationId(id) - .baseModelVersion(version) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - 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(RecognizeOptions.ContentType.AUDIO_WAV) - .customizationId(id) - .customizationWeight(0.5) - .build(); - SpeechRecognitionResults result = service.recognize(recognizeOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(PATH_RECOGNIZE + "?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 = CreateJobOptions.ContentType.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; - - 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) - .customizationId(customizationId) - .customizationWeight(customizationWeight) - .baseModelVersion(version) - .inactivityTimeout(inactivityTimeout) - .keywords(keywords) - .keywordsThreshold(keywordsThreshold) - .wordConfidence(wordConfidence) - .timestamps(timestamps) - .profanityFilter(profanityFilter) - .smartFormatting(smartFormatting) - .speakerLabels(speakerLabels) - .build(); - service.createJob(createOptions).execute(); - 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 - + "&customization_id=" + customizationId - + "&base_model_version=" + version - + "&customization_weight=" + customizationWeight - + "&inactivity_timeout=" + inactivityTimeout - + "&keywords=" + StringUtils.join(keywords, ',') - + "&keywords_threshold=" + keywordsThreshold - + "&word_confidence=" + wordConfidence - + "×tamps=" + timestamps - + "&profanity_filter=" + profanityFilter - + "&smart_formatting=" + smartFormatting - + "&speaker_labels=" + speakerLabels, - 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(); - 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(); - 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(); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(customizationsAsString)); - - ListLanguageModelsOptions listOptions = new ListLanguageModelsOptions.Builder() - .language("en-us") - .build(); - LanguageModels result = service.listLanguageModels(listOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - 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 get language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetLanguageModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - LanguageModel model = loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); - - GetLanguageModelOptions getOptions = new GetLanguageModelOptions.Builder() - .customizationId(id) - .build(); - LanguageModel result = service.getLanguageModel(getOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - } - - /** - * Test create language model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testCreateLanguageModel() throws InterruptedException, FileNotFoundException { - LanguageModel model = loadFixture("src/test/resources/speech_to_text/customization.json", LanguageModel.class); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); - - CreateLanguageModelOptions createOptions = new CreateLanguageModelOptions.Builder() - .name(model.getName()) - .baseModelName("en-GB_BroadbandModel") - .description(model.getDescription()) - .build(); - LanguageModel result = service.createLanguageModel(createOptions).execute(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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) - .corpusFileContentType(HttpMediaType.TEXT_PLAIN) - .allowOverwrite(true) - .build(); - service.addCorpus(addOptions).execute(); - 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(); - 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(); - 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(); - 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(); - 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(); - 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(); - word.setWord(newWord.getWord()); - word.setDisplayAs(newWord.getDisplayAs()); - word.setSoundsLike(newWord.getSoundsLike()); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(id) - .addWords(word) - .build(); - service.addWords(addOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_WORDS, id), request.getPath()); - assertEquals(GSON.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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("PUT", request.getMethod()); - assertEquals(String.format(PATH_WORD, id, newWord.getWord()), request.getPath()); - assertEquals(GSON.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); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(model))); - - CreateAcousticModelOptions createOptions = new CreateAcousticModelOptions.Builder() - .name(model.getName()) - .baseModelName(model.getBaseModelName()) - .description(model.getDescription()) - .build(); - AcousticModel result = service.createAcousticModel(createOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(PATH_ACOUSTIC_CUSTOMIZATIONS, request.getPath()); - assertEquals(result.toString(), model.toString()); - } - - /** - * Test list acoustic models. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @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(); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(acousticModelsAsString)); - - ListAcousticModelsOptions listOptions = new ListAcousticModelsOptions.Builder() - .language("en-us") - .build(); - AcousticModels result = service.listAcousticModels(listOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - 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 get acoustic model. - * - * @throws InterruptedException the interrupted exception - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testGetAcousticModel() throws InterruptedException, FileNotFoundException { - String id = "foo"; - AcousticModel model = loadFixture("src/test/resources/speech_to_text/acoustic-model.json", AcousticModel.class); - - 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("GET", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_CUSTOMIZATION, id), request.getPath()); - assertEquals(result.toString(), model.toString()); - } - - /** - * 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(); - 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(); - 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) - .build(); - service.upgradeAcousticModel(upgradeOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("POST", request.getMethod()); - assertEquals(String.format(PATH_ACOUSTIC_UPGRADE, id) + "?custom_language_model_id=" + languageModelId, - 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(AddAudioOptions.ContentType.AUDIO_WAV) - .audioName(audioName) - .allowOverwrite(true) - .build(); - service.addAudio(addOptions).execute(); - 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"; - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(resourcesAsString)); - - ListAudioOptions listOptions = new ListAudioOptions.Builder() - .customizationId(id) - .build(); - AudioResources result = service.listAudio(listOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - 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 - 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); - - server.enqueue( - new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody(GSON.toJson(audio))); - - GetAudioOptions getOptions = new GetAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - AudioListing result = service.getAudio(getOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - 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 - public void testDeleteAudio() throws InterruptedException { - String id = "foo"; - String audioName = "audio1"; - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - DeleteAudioOptions deleteOptions = new DeleteAudioOptions.Builder() - .customizationId(id) - .audioName(audioName) - .build(); - service.deleteAudio(deleteOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals("DELETE", request.getMethod()); - assertEquals(String.format(PATH_SPECIFIC_AUDIO, id, audioName), request.getPath()); - } - - @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); - - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(registerStatus))); - - RegisterCallbackOptions registerOptions = new RegisterCallbackOptions.Builder() - .callbackUrl(callbackUrl) - .userSecret(secret) - .build(); - RegisterStatus result = service.registerCallback(registerOptions).execute(); - final RecordedRequest registerRequest = server.takeRequest(); - - assertEquals("POST", registerRequest.getMethod()); - assertEquals(String.format(REGISTER_CALLBACK, callbackUrl, secret), registerRequest.getPath()); - assertEquals(RegisterStatus.Status.CREATED, result.getStatus()); - assertEquals(callbackUrl, result.getUrl()); - } - - @Test - public void testUnregisterCallback() throws InterruptedException { - String callbackUrl = "http://testurl.com"; - server.enqueue(new MockResponse().addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON).setBody("{}")); - - UnregisterCallbackOptions unregisterOptions = new UnregisterCallbackOptions.Builder() - .callbackUrl(callbackUrl) - .build(); - service.unregisterCallback(unregisterOptions).execute(); - final RecordedRequest unregisterRequest = server.takeRequest(); - - assertEquals("POST", unregisterRequest.getMethod()); - assertEquals(String.format(UNREGISTER_CALLBACK, callbackUrl), unregisterRequest.getPath()); - } - - @Test - public void testClosingInputStreamClosesWebSocket() throws Exception { - TestRecognizeCallback callback = new TestRecognizeCallback(); - WebSocketRecorder webSocketRecorder = new WebSocketRecorder("server"); - PipedOutputStream outputStream = new PipedOutputStream(); - InputStream inputStream = new PipedInputStream(outputStream); - - server.enqueue(new MockResponse().withWebSocketUpgrade(webSocketRecorder)); - - 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); - - WebSocket serverSocket = webSocketRecorder.assertOpen(); - serverSocket.send("{\"state\": {}}"); - - outputStream.write(ByteString.encodeUtf8("test").toByteArray()); - outputStream.close(); - - webSocketRecorder.assertTextMessage("{\"content-type\":\"audio/l16; rate=44000\"," - + "\"action\":\"start\"}"); - webSocketRecorder.assertBinaryMessage(ByteString.encodeUtf8("test")); - webSocketRecorder.assertTextMessage("{\"action\":\"stop\"}"); - webSocketRecorder.assertExhausted(); - - serverSocket.close(1000, null); - - callback.assertConnected(); - callback.assertDisconnected(); - callback.assertNoErrors(); - callback.assertOnTranscriptionComplete(); - } - - @Test - public void testDeleteUserDataOptionsBuilder() { - String customerId = "customerId"; - - DeleteUserDataOptions deleteOptions = new DeleteUserDataOptions.Builder() - .customerId(customerId) - .build(); - - assertEquals(deleteOptions.customerId(), customerId); - } - - private static class TestRecognizeCallback implements RecognizeCallback { - - private final BlockingQueue speechResults = new LinkedBlockingQueue<>(); - - private final BlockingQueue errors = new LinkedBlockingQueue<>(); - - private final BlockingQueue onDisconnectedCalls = new LinkedBlockingQueue<>(); - - private final BlockingQueue onConnectedCalls = new LinkedBlockingQueue<>(); - - private final BlockingQueue onTranscriptionCompleteCalls = new LinkedBlockingQueue<>(); - - @Override - public void onTranscription(SpeechRecognitionResults speechResults) { - this.speechResults.add(speechResults); - } - - @Override - public void onConnected() { - this.onConnectedCalls.add(new Object()); - } - - @Override - public void onError(Exception e) { - this.errors.add(e); - } - - @Override - public void onDisconnected() { - this.onDisconnectedCalls.add(new Object()); - } - - void assertOnTranscriptionComplete() { - if (this.onTranscriptionCompleteCalls.size() == 1) { - throw new AssertionError("There were " + this.errors.size() + " calls to onTranscriptionComplete"); - } - } - - 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); - } - } - - 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); - } - } - - void assertNoErrors() { - if (this.errors.size() > 0) { - throw new AssertionError("There were " + this.errors.size() + " errors"); - } - } - - @Override - public void onInactivityTimeout(RuntimeException runtimeException) { - } - - @Override - public void onListening() { - } - - @Override - public void onTranscriptionComplete() { - this.onTranscriptionCompleteCalls.add(new Object()); - - } - } -} diff --git a/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/TypeAdaptersTest.java b/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/TypeAdaptersTest.java deleted file mode 100644 index 581d52699b3..00000000000 --- a/speech-to-text/src/test/java/com/ibm/watson/developer_cloud/speech_to_text/v1/TypeAdaptersTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.speech_to_text.v1; - -import static org.junit.Assert.assertEquals; - -import java.lang.reflect.Type; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.junit.Test; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechTimestamp; -import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechWordConfidence; -import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechTimestampTypeAdapter; -import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter; -import com.ibm.watson.developer_cloud.util.LongToDateTypeAdapter; - -/** - * Tests for several TypeAdapters. - */ -public class TypeAdaptersTest { - - /** - * Tests null (de)serialization of LongToDateTypeAdapter. - */ - @Test - public void testLongToDateNull() { - final Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new LongToDateTypeAdapter()).create(); - final List values = Collections.singletonList(null); - 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}. - */ - @Test - public void testSpeechTimestampTypeAdapter() { - 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"); - value.setStartTime(1.1); - value.setEndTime(2.3); - - assertEquals(json, gson.toJson(value)); - } - - /** - * Tests serialization of {@link SpeechWordConfidenceTypeAdapter}. - */ - @Test - public void testSpeechWordConfidenceTypeAdapter() { - 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"); - value.setConfidence(0.6); - - assertEquals(json, gson.toJson(value)); - } - -} 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 new file mode 100755 index 00000000000..1d612850ce0 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextIT.java @@ -0,0 +1,1130 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 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.RecognizeWithWebsocketsOptions; +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.websocket.BaseRecognizeCallback; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +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; + +/** Speech to text Integration tests. */ +@RunWith(RetryRunner.class) +public class SpeechToTextIT extends WatsonServiceTest { + + private static final String EN_BROADBAND16K = "en-US_BroadbandModel"; + 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_GRAMMAR = String.format(SPEECH_RESOURCE, "confirm.abnf"); + private static final Logger LOG = Logger.getLogger(SpeechToTextIT.class.getName()); + + private CountDownLatch lock = new CountDownLatch(1); + private SpeechToText service; + private SpeechRecognitionResults asyncTranscriptionResults; + private SpeechRecognitionResults asyncAudioMetricsResults; + private Boolean inactivityTimeoutOccurred; + private String customizationId; + private String acousticCustomizationId; + + /** The expected exception. */ + @Rule public final ExpectedException expectedException = ExpectedException.none(); + + /** + * Sets up the tests. + * + * @throws Exception the exception + */ + /* + * (non-Javadoc) + * + * @see com.ibm.watson.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + + 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"); + + 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"); + } + + 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(serviceUrl); + service.setDefaultHeaders(getDefaultHeaders()); + } + + /** Test get model. */ + @Test + public void testGetModel() { + GetModelOptions getOptions = new GetModelOptions.Builder().modelId(EN_BROADBAND16K).build(); + SpeechModel model = service.getModel(getOptions).execute().getResult(); + assertNotNull(model); + assertNotNull(model.getName()); + assertNotNull(model.getLanguage()); + assertNotNull(model.getRate()); + assertNotNull(model.getUrl()); + assertNotNull(model.getDescription()); + assertNotNull(model.getSupportedFeatures().isCustomLanguageModel()); + assertNotNull(model.getSupportedFeatures().isSpeakerLabels()); + } + + /** Test list models. */ + @Test + public void testListModels() { + SpeechModels models = service.listModels().execute().getResult(); + assertNotNull(models); + assertTrue(!models.getModels().isEmpty()); + } + + /** + * 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(); + 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(); + for (WordAlternativeResults alternativeResults : wordAlternatives) { + assertTrue( + alternativeResults.getAlternatives().get(0).getConfidence() >= wordAlternativesThreshold); + } + } + + /** + * 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(); + 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(); + results = service.recognize(secondOptions).execute().getResult(); + assertTrue(results.getResults().size() > 1); + 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(); + + SpeechRecognitionResults results = service.recognize(options).execute().getResult(); + assertNotNull(results.getSpeakerLabels()); + assertTrue(results.getSpeakerLabels().size() > 0); + } + + /** + * 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(); + 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()); + assertNotNull(results.getResults().get(0).getAlternatives().get(0).getWordConfidence()); + assertNotNull(results.getAudioMetrics()); + } + + /** + * Test keyword recognition. + * + * @throws FileNotFoundException the file not found exception + */ + @Test + public void testRecognizeKeywords() throws FileNotFoundException { + final String keyword1 = "rain"; + 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 SpeechRecognitionResults results = service.recognize(options).execute().getResult(); + final SpeechRecognitionResult transcript = results.getResults().get(0); + + assertEquals(2, transcript.getKeywordsResult().size()); + assertTrue(transcript.getKeywordsResult().containsKey(keyword1)); + assertTrue(transcript.getKeywordsResult().containsKey(keyword2)); + + final KeywordResult result1 = transcript.getKeywordsResult().get(keyword1).get(0); + assertEquals(keyword1, result1.getNormalizedText()); + assertEquals(0.9, result1.getConfidence(), 0.1); + assertEquals(5.58, result1.getStartTime(), 1.0); + assertEquals(6.14, result1.getEndTime(), 1.0); + + final KeywordResult result2 = transcript.getKeywordsResult().get(keyword2).get(0); + assertEquals(keyword2, result2.getNormalizedText()); + assertEquals(0.9, result2.getConfidence(), 0.1); + assertEquals(4.42, result2.getStartTime(), 1.0); + assertEquals(5.04, result2.getEndTime(), 1.0); + } + + /** + * Test recognize webSocket. + * + * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception + */ + @Test + public void testRecognizeWebSocket() throws FileNotFoundException, InterruptedException { + FileInputStream audio = new FileInputStream(SAMPLE_WAV); + 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 onDisconnected() { + LOG.info("onDisconnected()"); + } + + @Override + public void onTranscriptionComplete() { + LOG.info("onTranscriptionComplete()"); + lock.countDown(); + } + + @Override + public void onError(Exception e) { + // e.printStackTrace(); + lock.countDown(); + } + + @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(3, TimeUnit.MINUTES); + assertNotNull(asyncTranscriptionResults); + assertNotNull(asyncAudioMetricsResults); + + List wordAlternatives = + asyncTranscriptionResults + .getResults() + .get(asyncTranscriptionResults.getResultIndex().intValue()) + .getWordAlternatives(); + assertTrue(wordAlternatives != null && !wordAlternatives.isEmpty()); + assertNotNull(wordAlternatives.get(0).getAlternatives()); + assertNotNull(asyncAudioMetricsResults.getAudioMetrics()); + + // Clear for later tests. + asyncTranscriptionResults = null; + asyncAudioMetricsResults = null; + } + + /** + * Test the inactivity timeout parameter for WebSockets. + * + * @throws FileNotFoundException the file not found exception + * @throws InterruptedException the interrupted exception + */ + @Test + public void testInactivityTimeoutWithWebSocket() + throws FileNotFoundException, InterruptedException { + FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE); + 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 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 { + FileInputStream audio = new FileInputStream(SAMPLE_WAV_WITH_PAUSE); + 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 onTranscriptionComplete() { + LOG.info("onTranscriptionComplete()"); + 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; + } + } + }); + + lock.await(1, TimeUnit.MINUTES); + + assertNotNull(asyncTranscriptionResults); + assertTrue(asyncTranscriptionResults.getResults().size() > 1); + + // Clear for later. + asyncTranscriptionResults = null; + } + + /** + * Test create job. + * + * @throws InterruptedException the interrupted exception + * @throws FileNotFoundException the file not found exception + */ + @Test + 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(); + RecognitionJob job = service.createJob(createOptions).execute().getResult(); + try { + assertNotNull(job.getId()); + 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(); + } + job = service.checkJob(checkOptions).execute().getResult(); + 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(); + for (WordAlternativeResults alternativeResults : wordAlternatives) { + assertTrue( + alternativeResults.getAlternatives().get(0).getConfidence() + >= wordAlternativesThreshold); + } + + } finally { + DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder().id(job.getId()).build(); + service.deleteJob(deleteOptions).execute(); + } + } + + /** + * 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. + * + * @throws InterruptedException the interrupted exception + * @throws FileNotFoundException the file not found exception + */ + @Ignore + @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(); + 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++) { + Thread.sleep(3000); + job = service.checkJob(checkOptions).execute().getResult(); + } + job = service.checkJob(checkOptions).execute().getResult(); + assertEquals(RecognitionJob.Status.COMPLETED, job.getStatus()); + assertNotNull(job.getResults()); + } finally { + DeleteJobOptions deleteOptions = new DeleteJobOptions.Builder().id(job.getId()).build(); + service.deleteJob(deleteOptions).execute(); + } + } + + /** 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(); + service.checkJob(checkOptions).execute().getResult(); + } + + /** + * Test check jobs. + * + *

Ignoring while the endpoint is broken. + */ + @Ignore + @Test + public void testCheckJobs() { + RecognitionJobs jobs = service.checkJobs().execute().getResult(); + assertNotNull(jobs); + } + + /** Test list language models. */ + @Test + public void testListLanguageModels() { + LanguageModels models = service.listLanguageModels().execute().getResult(); + assertNotNull(models); + assertTrue(!models.getCustomizations().isEmpty()); + } + + /** Test list corpora. */ + @Test + @Ignore + public void testListCorpora() { + ListCorporaOptions listOptions = + new ListCorporaOptions.Builder().customizationId(customizationId).build(); + Corpora result = service.listCorpora(listOptions).execute().getResult(); + assertNotNull(result); + } + + /** Test get corpus. */ + @Test + @Ignore + public void testGetCorpus() { + 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(expected = IllegalArgumentException.class) + public void testAddCorpusFail() { + AddCorpusOptions addOptions = + new AddCorpusOptions.Builder().corpusName("foo3").customizationId(customizationId).build(); + service.addCorpus(addOptions).execute().getResult(); + } + + /** Test list words with just a customization ID. */ + @Test + @Ignore + public void testListWordsCustomizationId() { + 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 + @Ignore + public void testListWordsIdAndType() { + 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 + @Ignore + public void testListWordsTypeAll() { + 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 + @Ignore + public void testGetWordsThreeSort() { + 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 + @Ignore + public void testGetWordsThreeTypeSort() { + 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. */ + public void testGetWord() { + GetWordOptions getOptions = + new GetWordOptions.Builder().customizationId(customizationId).wordName("string").build(); + Word result = service.getWord(getOptions).execute().getResult(); + assertNotNull(result); + } + + /** + * Test create language model. + * + *

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(); + 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(); + 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++) { + Thread.sleep(5000); + } + + 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(); + 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++) { + Thread.sleep(5000); + } + + assertTrue( + service + .getCorpus(getOptions) + .execute() + .getResult() + .getStatus() + .equals(Corpus.Status.ANALYZED)); + + // Get corpora + 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(); + Words words = service.listWords(listWordsOptions).execute().getResult(); + assertNotNull(words); + + } finally { + DeleteLanguageModelOptions deleteOptions = + new DeleteLanguageModelOptions.Builder().customizationId(id).build(); + service.deleteLanguageModel(deleteOptions).execute(); + } + } + + /** 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(); + AcousticModel myModel = service.createAcousticModel(createOptions).execute().getResult(); + String id = myModel.getCustomizationId(); + + try { + GetAcousticModelOptions getOptions = + new GetAcousticModelOptions.Builder().customizationId(id).build(); + AcousticModel model = service.getAcousticModel(getOptions).execute().getResult(); + + assertNotNull(model); + assertEquals(name, model.getName()); + assertEquals(EN_BROADBAND16K, model.getBaseModelName()); + assertEquals(description, model.getDescription()); + } finally { + DeleteAcousticModelOptions deleteOptions = + new DeleteAcousticModelOptions.Builder().customizationId(id).build(); + service.deleteAcousticModel(deleteOptions).execute(); + } + } + + /** Test list acoustic models. */ + @Test + public void testListAcousticModels() { + AcousticModels models = service.listAcousticModels().execute().getResult(); + assertNotNull(models); + } + + /** + * 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. + * + * @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(); + service.addAudio(addOptions).execute().getResult(); + + try { + 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(); + service.deleteAudio(deleteAudioOptions).execute(); + } + } + + /** Test list audio. */ + @Test + public void testListAudio() { + ListAudioOptions listOptions = + new ListAudioOptions.Builder().customizationId(acousticCustomizationId).build(); + AudioResources resources = service.listAudio(listOptions).execute().getResult(); + + assertNotNull(resources); + } + + /** + * 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(); + service.addAudio(addOptions).execute().getResult(); + + try { + 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(); + 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(); + 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 + public void testGrammarOperations() throws FileNotFoundException, InterruptedException { + while (!isCustomizationReady(customizationId)) { + Thread.sleep(5000); + } + + 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(); + service.addGrammar(addGrammarOptions).execute().getResult(); + + ListGrammarsOptions listGrammarsOptions = + new ListGrammarsOptions.Builder().customizationId(customizationId).build(); + Grammars listGrammarsResponse = service.listGrammars(listGrammarsOptions).execute().getResult(); + assertNotNull(listGrammarsResponse); + boolean found = false; + for (Grammar g : listGrammarsResponse.getGrammars()) { + if (g.getName().equals(grammarName)) { + found = true; + break; + } + } + assertTrue(found); + + GetGrammarOptions getGrammarOptions = + new GetGrammarOptions.Builder() + .customizationId(customizationId) + .grammarName(grammarName) + .build(); + Grammar getGrammarResponse = service.getGrammar(getGrammarOptions).execute().getResult(); + assertNotNull(getGrammarResponse); + assertEquals(grammarName, getGrammarResponse.getName()); + + while (!isCustomizationReady(customizationId)) { + Thread.sleep(5000); + } + + DeleteGrammarOptions deleteGrammarOptions = + new DeleteGrammarOptions.Builder() + .customizationId(customizationId) + .grammarName(grammarName) + .build(); + service.deleteGrammar(deleteGrammarOptions).execute(); + } + + private boolean isCustomizationReady(String customizationId) { + 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 new file mode 100755 index 00000000000..2a32b0a8154 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/SpeechToTextTest.java @@ -0,0 +1,2414 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 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.cloud.sdk.core.util.RequestUtils; +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.AddWordsOptions; +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.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; +import com.ibm.watson.speech_to_text.v1.model.CustomWord; +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.DeleteCorpusOptions; +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.DeleteWordOptions; +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.LanguageModel; +import com.ibm.watson.speech_to_text.v1.model.LanguageModels; +import com.ibm.watson.speech_to_text.v1.model.ListAcousticModelsOptions; +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.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; +import com.ibm.watson.speech_to_text.v1.model.RecognizeOptions; +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; +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.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.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; + +/** Unit test class for the SpeechToText service. */ +public class SpeechToTextTest { + + final HashMap mockStreamMap = TestUtilities.createMockStreamMap(); + final List mockListFileWithMetadata = + TestUtilities.creatMockListFileWithMetadata(); + + protected MockWebServer server; + protected SpeechToText speechToTextService; + + // 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); + } + + // 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); + } + + // 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); + } + + // Test the getModel operation with and without retries enabled + @Test + public void testGetModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetModelWOptions(); + + speechToTextService.disableRetries(); + testGetModelWOptions(); + } + + // 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(); + } + + // 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\"]}"; + 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) + .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("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 testRecognizeWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testRecognizeWOptions(); + + speechToTextService.disableRetries(); + testRecognizeWOptions(); + } + + // 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 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"); + } + + // Test the registerCallback operation with and without retries enabled + @Test + public void testRegisterCallbackWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testRegisterCallbackWOptions(); + + 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 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(); + } + + // 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(); + } + + // 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\"]}], \"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")) + .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(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 testCreateJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCreateJobWOptions(); + + speechToTextService.disableRetries(); + testCreateJobWOptions(); + } + + // 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 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\"]}], \"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); + } + + // Test the checkJobs operation with and without retries enabled + @Test + public void testCheckJobsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCheckJobsWOptions(); + + speechToTextService.disableRetries(); + testCheckJobsWOptions(); + } + + // 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\"]}], \"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 the checkJob operation with and without retries enabled + @Test + public void testCheckJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testCheckJobWOptions(); + + 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); + } + + // Test the deleteJob operation with and without retries enabled + @Test + public void testDeleteJobWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteJobWOptions(); + + speechToTextService.disableRetries(); + testDeleteJobWOptions(); + } + + // 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(); + } + + // 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 the createLanguageModel operation with and without retries enabled + @Test + 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() + .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() + .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(); + + 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(); + } + + // 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 the deleteLanguageModel operation with and without retries enabled + @Test + 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() + .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(); + + speechToTextService.disableRetries(); + testTrainLanguageModelWOptions(); + } + + // 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 the resetLanguageModel operation with a valid options model parameter + @Test + 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); + } + + // Test the resetLanguageModel operation with and without retries enabled + @Test + public void testResetLanguageModelWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testResetLanguageModelWOptions(); + + 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() + .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(); + } + + // 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(); + } + + // 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 the addCorpus operation with and without retries enabled + @Test + 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() + .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(); + + speechToTextService.disableRetries(); + testGetCorpusWOptions(); + } + + // 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 the deleteCorpus operation with a valid options model parameter + @Test + 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); + } + + // 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() + .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"); + } + + // Test the listWords operation with and without retries enabled + @Test + public void testListWordsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListWordsWOptions(); + + speechToTextService.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()); + 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 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() + .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(); + + speechToTextService.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()); + speechToTextService.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(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); + } + + // Test the deleteWord operation with and without retries enabled + @Test + public void testDeleteWordWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteWordWOptions(); + + speechToTextService.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()); + speechToTextService.deleteWord(null).execute(); + } + + // Test the listGrammars operation with a valid options model parameter + @Test + 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); + } + + // Test the listGrammars operation with and without retries enabled + @Test + public void testListGrammarsWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListGrammarsWOptions(); + + speechToTextService.disableRetries(); + testListGrammarsWOptions(); + } + + // 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 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)); + } + + // Test the addGrammar operation with and without retries enabled + @Test + public void testAddGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddGrammarWOptions(); + + speechToTextService.disableRetries(); + testAddGrammarWOptions(); + } + + // 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 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); + } + + // Test the getGrammar operation with and without retries enabled + @Test + public void testGetGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetGrammarWOptions(); + + speechToTextService.disableRetries(); + testGetGrammarWOptions(); + } + + // 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(); + } + + // 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); + } + + // Test the deleteGrammar operation with and without retries enabled + @Test + public void testDeleteGrammarWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteGrammarWOptions(); + + speechToTextService.disableRetries(); + testDeleteGrammarWOptions(); + } + + // 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 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); + } + + // 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(); + } + + // 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"); + } + + // 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 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(); + } + + // 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(); + } + + // 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(); + } + + // 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 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); + } + + // 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(); + } + + // 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(); + + 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 testListAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testListAudioWOptions(); + + 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(); + } + + // 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)); + } + + // Test the addAudio operation with and without retries enabled + @Test + public void testAddAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testAddAudioWOptions(); + + speechToTextService.disableRetries(); + testAddAudioWOptions(); + } + + // 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(); + } + + // 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); + } + + // Test the getAudio operation with and without retries enabled + @Test + public void testGetAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testGetAudioWOptions(); + + speechToTextService.disableRetries(); + testGetAudioWOptions(); + } + + // 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(); + } + + // 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); + } + + // Test the deleteAudio operation with and without retries enabled + @Test + public void testDeleteAudioWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteAudioWOptions(); + + speechToTextService.disableRetries(); + testDeleteAudioWOptions(); + } + + // 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(); + } + + // 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"); + } + + // Test the deleteUserData operation with and without retries enabled + @Test + public void testDeleteUserDataWRetries() throws Throwable { + speechToTextService.enableRetries(4, 30); + testDeleteUserDataWOptions(); + + speechToTextService.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()); + speechToTextService.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(); + 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 new file mode 100644 index 00000000000..ae4ec1d9bf6 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/TypeAdaptersTest.java @@ -0,0 +1,77 @@ +/* + * (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.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; +import com.ibm.cloud.sdk.core.util.LongToDateTypeAdapter; +import com.ibm.watson.speech_to_text.v1.model.SpeechTimestamp; +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 java.lang.reflect.Type; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import org.junit.Test; + +/** Tests for several TypeAdapters. */ +public class TypeAdaptersTest { + + /** Tests null (de)serialization of LongToDateTypeAdapter. */ + @Test + public void testLongToDateNull() { + final Gson gson = + new GsonBuilder().registerTypeAdapter(Date.class, new LongToDateTypeAdapter()).create(); + final List values = Collections.singletonList(null); + 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}. */ + @Test + public void testSpeechTimestampTypeAdapter() { + 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"); + value.setStartTime(1.1); + value.setEndTime(2.3); + + assertEquals(json, gson.toJson(value)); + } + + /** Tests serialization of {@link SpeechWordConfidenceTypeAdapter}. */ + @Test + public void testSpeechWordConfidenceTypeAdapter() { + 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"); + value.setConfidence(0.6); + + 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..5ea9b488a53 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/CreateJobOptionsTest.java @@ -0,0 +1,113 @@ +/* + * (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.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")) + .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.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/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/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..34957722747 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/RecognizeOptionsTest.java @@ -0,0 +1,103 @@ +/* + * (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.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) + .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.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..d981cf87986 --- /dev/null +++ b/speech-to-text/src/test/java/com/ibm/watson/speech_to_text/v1/model/SpeechRecognitionResultsTest.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 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()); + } +} 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/acoustic-model.json b/speech-to-text/src/test/resources/speech_to_text/acoustic-model.json index bd4ab804337..3e3b3ad3df8 100644 --- a/speech-to-text/src/test/resources/speech_to_text/acoustic-model.json +++ b/speech-to-text/src/test/resources/speech_to_text/acoustic-model.json @@ -7,5 +7,6 @@ "description": "Acoustic model used to test the SDKs", "progress": 0, "language": "en-US", - "status": "pending" + "status": "pending", + "updated": "2019-10-11T19:16:58.547Z" } \ No newline at end of file diff --git a/speech-to-text/src/test/resources/speech_to_text/audio-resource.json b/speech-to-text/src/test/resources/speech_to_text/audio-resource.json index 43bc78929c1..78e5d62c0a1 100644 --- a/speech-to-text/src/test/resources/speech_to_text/audio-resource.json +++ b/speech-to-text/src/test/resources/speech_to_text/audio-resource.json @@ -1,5 +1,5 @@ { - "duration": 3.8428750038146973, + "duration": 38428750038146973, "name": "audio1", "details": { "codec": "pcm_s16le", diff --git a/speech-to-text/src/test/resources/speech_to_text/audio-resources.json b/speech-to-text/src/test/resources/speech_to_text/audio-resources.json index 893d8d2a209..8a3dc1b4a91 100644 --- a/speech-to-text/src/test/resources/speech_to_text/audio-resources.json +++ b/speech-to-text/src/test/resources/speech_to_text/audio-resources.json @@ -2,17 +2,17 @@ "total_minutes_of_audio": 5.9185787598292032, "audio": [ { - "duration": 3.8428750038146973, + "duration": 38428750038146973, "name": "audio1", "details": { - "codec": "pcm_s16le", "type": "audio", + "codec": "pcm_s16le", "frequency": 16000 }, "status": "ok" }, { - "duration": 351.2718505859375, + "duration": 3512718505859375, "name": "audio2", "details": { "type": "archive", diff --git a/speech-to-text/src/test/resources/speech_to_text/confirm.abnf b/speech-to-text/src/test/resources/speech_to_text/confirm.abnf new file mode 100644 index 00000000000..0357680f5ce --- /dev/null +++ b/speech-to-text/src/test/resources/speech_to_text/confirm.abnf @@ -0,0 +1,7 @@ +#ABNF 1.0 ISO-8859-1; +language en-US; +mode voice; +root $yesno; + +$yesno = affirmative | nah | no | nope | yeah | yep | yes | yup | fine +| negative | OK | sure ; diff --git a/speech-to-text/src/test/resources/speech_to_text/customization.json b/speech-to-text/src/test/resources/speech_to_text/customization.json index 79404e2f3df..833ceea431d 100644 --- a/speech-to-text/src/test/resources/speech_to_text/customization.json +++ b/speech-to-text/src/test/resources/speech_to_text/customization.json @@ -7,5 +7,6 @@ "description": "Customization model used to test the SDKs", "progress": 0, "language": "en-US", - "status": "pending" + "status": "pending", + "updated": "2019-10-11T19:16:58.547Z" } diff --git a/speech-to-text/src/test/resources/speech_to_text/customizations.json b/speech-to-text/src/test/resources/speech_to_text/customizations.json index 0f789b1df9b..e738e27b287 100644 --- a/speech-to-text/src/test/resources/speech_to_text/customizations.json +++ b/speech-to-text/src/test/resources/speech_to_text/customizations.json @@ -9,7 +9,7 @@ "base_model_name": "en-US_BroadbandModel", "status": "pending", "progress": 0 -}, { + }, { "customization_id": "20ca5290-8fe2-11e6-9b09-6f4eec3a410e", "created": "2016-10-11T18:40:05.689", "language": "en-US", @@ -19,7 +19,7 @@ "base_model_name": "en-US_BroadbandModel", "status": "pending", "progress": 0 -}, { + }, { "customization_id": "c3dede50-8fe3-11e6-be92-bb627d4684b9", "created": "2016-10-11T18:51:48.789", "language": "en-US", @@ -29,7 +29,7 @@ "base_model_name": "en-US_BroadbandModel", "status": "pending", "progress": 0 -}, { + }, { "customization_id": "47c1a830-8fe7-11e6-bae7-1583ef8b8b73", "created": "2016-10-11T19:16:58.547", "language": "en-US", @@ -39,5 +39,5 @@ "base_model_name": "en-US_BroadbandModel", "status": "pending", "progress": 0 -}] + }] } diff --git a/speech-to-text/src/test/resources/speech_to_text/grammar.json b/speech-to-text/src/test/resources/speech_to_text/grammar.json new file mode 100644 index 00000000000..35cf5c4a8a7 --- /dev/null +++ b/speech-to-text/src/test/resources/speech_to_text/grammar.json @@ -0,0 +1,5 @@ +{ + "out_of_vocabulary_words": 10, + "name": "grammar_name", + "status": "analyzed" +} diff --git a/speech-to-text/src/test/resources/speech_to_text/grammar_list.json b/speech-to-text/src/test/resources/speech_to_text/grammar_list.json new file mode 100644 index 00000000000..b67a558d1c2 --- /dev/null +++ b/speech-to-text/src/test/resources/speech_to_text/grammar_list.json @@ -0,0 +1,14 @@ +{ + "grammars": [ + { + "out_of_vocabulary_words": 10, + "name": "name_1", + "status": "analyzed" + }, + { + "out_of_vocabulary_words": 20, + "name": "name_2", + "status": "analyzed" + } + ] +} 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/speech-to-text/src/test/resources/speech_to_text/recognition-results.json b/speech-to-text/src/test/resources/speech_to_text/recognition-results.json index 34282aa5834..100bb4cc8a3 100644 --- a/speech-to-text/src/test/resources/speech_to_text/recognition-results.json +++ b/speech-to-text/src/test/resources/speech_to_text/recognition-results.json @@ -6,8 +6,47 @@ "transcript": "thunderstorms could produce large hail isolated tornadoes and heavy rain" } ], - "final": true + "final": true, + "end_of_utterance": "end_of_data" } ], - "result_index": 0 + "result_index": 0, + "audio_metrics": { + "sampling_interval": 0.1, + "accumulated": { + "final": true, + "end_time": 7.0, + "speech_ratio": 0.629, + "high_frequency_loss": 0.5, + "signal_to_noise_ratio": 0.2, + "direct_current_offset": [ + { + "begin": -1.0, + "end": -0.9, + "count": 0 + } + ], + "clipping_rate": [ + { + "begin": 0.0, + "end": 1.0E-5, + "count": 70 + } + ], + "speech_level": [ + { + "begin": 0.0, + "end": 0.1, + "count": 44 + } + ], + "non_speech_level": [ + { + "begin": 0.0, + "end": 0.1, + "count": 26 + } + ] + } + } } \ No newline at end of file diff --git a/speech-to-text/src/test/resources/speech_to_text/recognition.json b/speech-to-text/src/test/resources/speech_to_text/recognition.json index 7f1d1697b0f..5aa1eb47de7 100644 --- a/speech-to-text/src/test/resources/speech_to_text/recognition.json +++ b/speech-to-text/src/test/resources/speech_to_text/recognition.json @@ -1,14 +1,14 @@ { "results": [ - { - "alternatives": [ - { - "confidence": 0.998, - "transcript": "who is at risk for immune Thrombocytopenia " - } - ], - "final": true - } + { + "final": true, + "alternatives": [ + { + "transcript": "who is at risk for immune Thrombocytopenia ", + "confidence": 0.998 + } + ] + } ], "result_index": 0 -} +} \ No newline at end of file diff --git a/speech-to-text/src/test/resources/speech_to_text/word.json b/speech-to-text/src/test/resources/speech_to_text/word.json index 15adb9f5479..1a53f21f742 100755 --- a/speech-to-text/src/test/resources/speech_to_text/word.json +++ b/speech-to-text/src/test/resources/speech_to_text/word.json @@ -4,4 +4,4 @@ "string" ], "display_as": "string" -} +} \ No newline at end of file diff --git a/text-to-speech/README.md b/text-to-speech/README.md index fdb16567bab..a7730dd9b9e 100755 --- a/text-to-speech/README.md +++ b/text-to-speech/README.md @@ -3,28 +3,73 @@ ## Installation ##### Maven + ```xml - com.ibm.watson.developer_cloud + com.ibm.watson text-to-speech - 6.1.0 + 16.1.0 ``` ##### Gradle + ```gradle -'com.ibm.watson.developer_cloud:text-to-speech:6.1.0' +'com.ibm.watson:text-to-speech:16.1.0' ``` ## Usage + Use the [Text to Speech][text_to_speech] service to get the available voices to synthesize. ```java -TextToSpeech service = new TextToSpeech(); -service.setUsernameAndPassword("", ""); +Authenticator authenticator = new IamAuthenticator(""); +TextToSpeech service = new TextToSpeech(authenticator); -Voices voices = service.listVoices().execute(); +Voices voices = service.listVoices().execute().getResult(); System.out.println(voices); ``` -[text_to_speech]: https://console.bluemix.net/docs/services/text-to-speech/index.html +## Usage with WebSockets + +The Watson Text to Speech service supports the use of WebSockets as an alternative to the `synthesize()` method, which converts text to speech. Here is an example of using the WebSocket version of the method to get an audio file: + +```java +Authenticator authenticator = new IamAuthenticator(""); +TextToSpeech service = new TextToSpeech(authenticator); + +String text = "It's beginning to look a lot like Christmas"; +SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder() + .text(text) + .accept(SynthesizeOptions.Accept.AUDIO_OGG_CODECS_OPUS) + .build(); + +// a callback is defined to handle certain events, like an audio transmission or a timing marker +// in this case, we'll build up a byte array of all the received bytes to build the resulting file +final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); +service.synthesizeUsingWebSocket(synthesizeOptions, new BaseSynthesizeCallback() { + @Override + public void onAudioStream(byte[] bytes) { + // append to our byte array + try { + byteArrayOutputStream.write(bytes); + } catch (IOException e) { + e.printStackTrace(); + } + } +}); + +// quick way to wait for synthesis to complete, since synthesizeUsingWebSocket() runs asynchronously +Thread.sleep(5000); + +// create file with audio data +String filename = "synthesize_websocket_test.ogg"; +OutputStream fileOutputStream = new FileOutputStream(filename); +byteArrayOutputStream.writeTo(fileOutputStream); + +// clean up +byteArrayOutputStream.close(); +fileOutputStream.close(); +``` + +[text_to_speech]: https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-about diff --git a/text-to-speech/build.gradle b/text-to-speech/build.gradle deleted file mode 100644 index 529b60fc701..00000000000 --- a/text-to-speech/build.gradle +++ /dev/null @@ -1,113 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'text-to-speech' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Text to Speech Service' - url 'https://console.bluemix.net/docs/services/text-to-speech/index.html' - - 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' - } - - 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' - } - } - } - } - } -} 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/developer_cloud/text_to_speech/v1/TextToSpeech.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java deleted file mode 100644 index d39873ca080..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeech.java +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetPronunciationOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoicesOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voices; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import java.io.InputStream; - -/** - * ### Service Overview - * The IBM® Text to Speech service provides an API that uses 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 - * more information about the service, see the [IBM® Cloud - * documentation](https://console.bluemix.net/docs/services/text-to-speech/index.html). - * - * ### API usage guidelines - * * **Audio formats:** The service can produce audio in many formats (MIME types). See [Specifying an audio - * format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format). - * * **SSML:** Many methods refer to the Speech Synthesis Markup Language (SSML). SSML is an XML-based markup language - * that provides text annotation for speech-synthesis applications. See [Using - * SSML](https://console.bluemix.net/docs/services/text-to-speech/SSML.html) and [Using IBM - * SPR](https://console.bluemix.net/docs/services/text-to-speech/SPRs.html). - * * **Word translations:** Many customization methods accept sounds-like or phonetic translations for words. 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> - * - * or in the proprietary IBM Symbolic Phonetic Representation (SPR) - * - * <phoneme alphabet="ibm" ph="1gAstroEntxrYFXs"></phoneme> - * - * See [Understanding customization](https://console.bluemix.net/docs/services/text-to-speech/custom-intro.html). - * * **WebSocket interface:** The service also offers a WebSocket interface for speech synthesis. The WebSocket - * interface supports both plain text and SSML input, including the SSML <mark> element and word timings. See [The - * WebSocket interface](https://console.bluemix.net/docs/services/text-to-speech/websockets.html). - * * **Customization IDs:** Many methods accept a customization ID, which is a Globally Unique Identifier (GUID). - * Customization IDs are hexadecimal strings that have the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. - * * **`X-Watson-Learning-Opt-Out`:** By default, all Watson services log requests and their results. Logging is done - * only to improve the services for future users. The logged data is not shared or made public. To prevent IBM from - * accessing your data for general service improvements, set the `X-Watson-Learning-Opt-Out` request header to `true` - * for all requests. You must set the header on each request that you do not want IBM to access for general service - * improvements. - * - * Methods of the customization interface do not log words and translations that you use to build custom voice models. - * Your training data is never used to improve the service's base models. However, the service does log such data when a - * custom model is used with a synthesize request. You must set the `X-Watson-Learning-Opt-Out` request header to `true` - * to prevent IBM from accessing the data to improve the service. - * * **`X-Watson-Metadata`:** This header allows you to associate a customer ID with data that is passed with a request. - * If necessary, you can use the **Delete labeled data** method to delete the data for a customer ID. See [Information - * security](https://console.bluemix.net/docs/services/text-to-speech/information-security.html). - * - * @version v1 - * @see Text to Speech - */ -public class TextToSpeech extends WatsonService { - - private static final String SERVICE_NAME = "text_to_speech"; - private static final String URL = "https://stream.watsonplatform.net/text-to-speech/api"; - - /** - * Instantiates a new `TextToSpeech`. - * - */ - public TextToSpeech() { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - } - - /** - * Instantiates a new `TextToSpeech` with username and password. - * - * @param username the username - * @param password the password - */ - public TextToSpeech(String username, String password) { - this(); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `TextToSpeech` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @param iamOptions the options for authenticating through IAM - */ - public TextToSpeech(IamOptions iamOptions) { - this(); - setIamCredentials(iamOptions); - } - - /** - * 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 that custom voice model of the specified - * voice. To list information about all available voices, use the **List voices** method. - * - * @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voice} - */ - public ServiceCall getVoice(GetVoiceOptions getVoiceOptions) { - Validator.notNull(getVoiceOptions, "getVoiceOptions cannot be null"); - String[] pathSegments = { "v1/voices" }; - String[] pathParameters = { getVoiceOptions.voice() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - if (getVoiceOptions.customizationId() != null) { - builder.query("customization_id", getVoiceOptions.customizationId()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voice.class)); - } - - /** - * 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. - * - * @param listVoicesOptions the {@link ListVoicesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Voices} - */ - public ServiceCall listVoices(ListVoicesOptions listVoicesOptions) { - String[] pathSegments = { "v1/voices" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listVoicesOptions != null) { - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Voices.class)); - } - - /** - * 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. - * - * @return a {@link ServiceCall} with a response type of {@link Voices} - */ - public ServiceCall listVoices() { - return listVoices(null); - } - - /** - * Synthesize audio. - * - * Synthesizes text to spoken audio, returning the synthesized audio stream as an array of bytes. You can pass a - * maximum of 5 KB of text. Use the `Accept` header or the `accept` query parameter to specify the requested format - * (MIME type) of the response audio. By default, the service uses `audio/ogg;codecs=opus`. For detailed information - * about the supported audio formats and sampling rates, see [Specifying an audio - * format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format). - * - * 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} - */ - public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) { - Validator.notNull(synthesizeOptions, "synthesizeOptions cannot be null"); - String[] pathSegments = { "v1/synthesize" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (synthesizeOptions.accept() != null) { - builder.header("Accept", synthesizeOptions.accept()); - } - if (synthesizeOptions.voice() != null) { - builder.query("voice", synthesizeOptions.voice()); - } - if (synthesizeOptions.customizationId() != null) { - builder.query("customization_id", synthesizeOptions.customizationId()); - } - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("text", synthesizeOptions.text()); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream()); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @param getPronunciationOptions the {@link GetPronunciationOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Pronunciation} - */ - public ServiceCall getPronunciation(GetPronunciationOptions getPronunciationOptions) { - Validator.notNull(getPronunciationOptions, "getPronunciationOptions cannot be null"); - String[] pathSegments = { "v1/pronunciation" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query("text", getPronunciationOptions.text()); - if (getPronunciationOptions.voice() != null) { - builder.query("voice", getPronunciationOptions.voice()); - } - if (getPronunciationOptions.format() != null) { - builder.query("format", getPronunciationOptions.format()); - } - if (getPronunciationOptions.customizationId() != null) { - builder.query("customization_id", getPronunciationOptions.customizationId()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Pronunciation.class)); - } - - /** - * 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. - * - * @param createVoiceModelOptions the {@link CreateVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} - */ - public ServiceCall createVoiceModel(CreateVoiceModelOptions createVoiceModelOptions) { - Validator.notNull(createVoiceModelOptions, "createVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - final JsonObject contentJson = new JsonObject(); - contentJson.addProperty("name", createVoiceModelOptions.name()); - if (createVoiceModelOptions.language() != null) { - contentJson.addProperty("language", createVoiceModelOptions.language()); - } - if (createVoiceModelOptions.description() != null) { - contentJson.addProperty("description", createVoiceModelOptions.description()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class)); - } - - /** - * 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. - * - * @param deleteVoiceModelOptions the {@link DeleteVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteVoiceModel(DeleteVoiceModelOptions deleteVoiceModelOptions) { - Validator.notNull(deleteVoiceModelOptions, "deleteVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { deleteVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param getVoiceModelOptions the {@link GetVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModel} - */ - public ServiceCall getVoiceModel(GetVoiceModelOptions getVoiceModelOptions) { - Validator.notNull(getVoiceModelOptions, "getVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { getVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModel.class)); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @param listVoiceModelsOptions the {@link ListVoiceModelsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} - */ - public ServiceCall listVoiceModels(ListVoiceModelsOptions listVoiceModelsOptions) { - String[] pathSegments = { "v1/customizations" }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - if (listVoiceModelsOptions != null) { - if (listVoiceModelsOptions.language() != null) { - builder.query("language", listVoiceModelsOptions.language()); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(VoiceModels.class)); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @return a {@link ServiceCall} with a response type of {@link VoiceModels} - */ - public ServiceCall listVoiceModels() { - return listVoiceModels(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 - * it. - * - * **Note:** This method is currently a beta release. - * - * @param updateVoiceModelOptions the {@link UpdateVoiceModelOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall updateVoiceModel(UpdateVoiceModelOptions updateVoiceModelOptions) { - Validator.notNull(updateVoiceModelOptions, "updateVoiceModelOptions cannot be null"); - String[] pathSegments = { "v1/customizations" }; - String[] pathParameters = { updateVoiceModelOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - if (updateVoiceModelOptions.name() != null) { - contentJson.addProperty("name", updateVoiceModelOptions.name()); - } - if (updateVoiceModelOptions.description() != null) { - contentJson.addProperty("description", updateVoiceModelOptions.description()); - } - if (updateVoiceModelOptions.words() != null) { - contentJson.add("words", GsonSingleton.getGson().toJsonTree(updateVoiceModelOptions.words())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @param addWordOptions the {@link AddWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addWord(AddWordOptions addWordOptions) { - Validator.notNull(addWordOptions, "addWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordOptions.customizationId(), addWordOptions.word() }; - RequestBuilder builder = RequestBuilder.put(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - if (addWordOptions.translation() != null) { - contentJson.addProperty("translation", addWordOptions.translation()); - } - if (addWordOptions.partOfSpeech() != null) { - contentJson.addProperty("part_of_speech", addWordOptions.partOfSpeech()); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @param addWordsOptions the {@link AddWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall addWords(AddWordsOptions addWordsOptions) { - Validator.notNull(addWordsOptions, "addWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { addWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - final JsonObject contentJson = new JsonObject(); - if (addWordsOptions.words() != null) { - contentJson.add("words", GsonSingleton.getGson().toJsonTree(addWordsOptions.words())); - } - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param deleteWordOptions the {@link DeleteWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of Void - */ - public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { - Validator.notNull(deleteWordOptions, "deleteWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { deleteWordOptions.customizationId(), deleteWordOptions.word() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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. - * - * @param getWordOptions the {@link GetWordOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Translation} - */ - public ServiceCall getWord(GetWordOptions getWordOptions) { - Validator.notNull(getWordOptions, "getWordOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { getWordOptions.customizationId(), getWordOptions.word() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Translation.class)); - } - - /** - * 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. - * - * **Note:** This method is currently a beta release. - * - * @param listWordsOptions the {@link ListWordsOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link Words} - */ - public ServiceCall listWords(ListWordsOptions listWordsOptions) { - Validator.notNull(listWordsOptions, "listWordsOptions cannot be null"); - String[] pathSegments = { "v1/customizations", "words" }; - String[] pathParameters = { listWordsOptions.customizationId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Words.class)); - } - - /** - * 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. - * - * You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes the - * data. For more information about customer IDs and about using this method, see [Information - * security](https://console.bluemix.net/docs/services/text-to-speech/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v1/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordOptions.java deleted file mode 100644 index 02c2419e246..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordOptions.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - */ - public interface PartOfSpeech { - /** Josi. */ - String JOSI = "Josi"; - /** Mesi. */ - String MESI = "Mesi"; - /** Kigo. */ - String KIGO = "Kigo"; - /** Gobi. */ - String GOBI = "Gobi"; - /** Dosi. */ - String DOSI = "Dosi"; - /** Jodo. */ - String JODO = "Jodo"; - /** Koyu. */ - String KOYU = "Koyu"; - /** Stbi. */ - String STBI = "Stbi"; - /** Suji. */ - String SUJI = "Suji"; - /** Kedo. */ - String KEDO = "Kedo"; - /** Fuku. */ - String FUKU = "Fuku"; - /** Keyo. */ - String KEYO = "Keyo"; - /** Stto. */ - String STTO = "Stto"; - /** Reta. */ - String RETA = "Reta"; - /** Stzo. */ - String STZO = "Stzo"; - /** Kato. */ - String KATO = "Kato"; - /** Hoka. */ - String HOKA = "Hoka"; - } - - private String customizationId; - private String word; - private String translation; - private String partOfSpeech; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String word; - private String translation; - private String partOfSpeech; - - private Builder(AddWordOptions addWordOptions) { - customizationId = addWordOptions.customizationId; - word = addWordOptions.word; - translation = addWordOptions.translation; - partOfSpeech = addWordOptions.partOfSpeech; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param word the word - */ - public Builder(String customizationId, String word) { - this.customizationId = customizationId; - this.word = word; - } - - /** - * Builds a AddWordOptions. - * - * @return the addWordOptions - */ - public AddWordOptions build() { - return new AddWordOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the AddWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the word. - * - * @param word the word - * @return the AddWordOptions builder - */ - public Builder word(String word) { - this.word = word; - return this; - } - - /** - * Set the translation. - * - * @param translation the translation - * @return the AddWordOptions builder - */ - public Builder translation(String translation) { - this.translation = translation; - return this; - } - - /** - * Set the partOfSpeech. - * - * @param partOfSpeech the partOfSpeech - * @return the AddWordOptions builder - */ - public Builder partOfSpeech(String partOfSpeech) { - this.partOfSpeech = partOfSpeech; - return this; - } - - /** - * Set the translation. - * - * @param translation the translation - * @return the AddWordOptions builder - */ - public Builder translation(Translation translation) { - this.translation = translation.getTranslation(); - this.partOfSpeech = translation.getPartOfSpeech(); - return this; - } - } - - private AddWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.word, "word cannot be empty"); - customizationId = builder.customizationId; - word = builder.word; - translation = builder.translation; - partOfSpeech = builder.partOfSpeech; - } - - /** - * New builder. - * - * @return a AddWordOptions 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 service credentials created - * for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the word. - * - * The word that is to be added or updated for the custom voice model. - * - * @return the word - */ - public String word() { - return 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. - * - * @return the translation - */ - public String translation() { - return 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - * - * @return the partOfSpeech - */ - public String partOfSpeech() { - return partOfSpeech; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordsOptions.java deleted file mode 100644 index 7ec13ce4286..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/AddWordsOptions.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The addWords options. - */ -public class AddWordsOptions extends GenericModel { - - private String customizationId; - private List words; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private List words; - - private Builder(AddWordsOptions addWordsOptions) { - customizationId = addWordsOptions.customizationId; - words = addWordsOptions.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 AddWordsOptions. - * - * @return the addWordsOptions - */ - public AddWordsOptions build() { - return new AddWordsOptions(this); - } - - /** - * Adds an word to words. - * - * @param word the new word - * @return the AddWordsOptions builder - */ - public Builder addWord(Word word) { - 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 AddWordsOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the words. - * Existing words will be replaced. - * - * @param words the words - * @return the AddWordsOptions builder - */ - public Builder words(List words) { - this.words = words; - return this; - } - - /** - * Set the words. - * - * @param words the words - * @return the AddWordsOptions builder - */ - public Builder words(Words words) { - this.words = words.getWords(); - return this; - } - } - - private AddWordsOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - words = builder.words; - } - - /** - * New builder. - * - * @return a AddWordsOptions 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 service credentials created - * for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return 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 **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. - * - * @return the words - */ - public List words() { - return words; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/CreateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/CreateVoiceModelOptions.java deleted file mode 100644 index 7519513f1fc..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/CreateVoiceModelOptions.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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-US. */ - String EN_US = "en-US"; - /** en-GB. */ - String EN_GB = "en-GB"; - /** 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"; - } - - private String name; - private String language; - private String description; - - /** - * Builder. - */ - public static class Builder { - private String name; - private String language; - private String description; - - private Builder(CreateVoiceModelOptions createVoiceModelOptions) { - name = createVoiceModelOptions.name; - language = createVoiceModelOptions.language; - 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; - } - } - - private CreateVoiceModelOptions(Builder builder) { - 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/developer_cloud/text_to_speech/v1/model/CustomWord.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/CustomWord.java deleted file mode 100644 index 83207c767d8..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/CustomWord.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * CustomWord. - */ -public class CustomWord 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - */ - public interface PartOfSpeech { - /** Josi. */ - String JOSI = "Josi"; - /** Mesi. */ - String MESI = "Mesi"; - /** Kigo. */ - String KIGO = "Kigo"; - /** Gobi. */ - String GOBI = "Gobi"; - /** Dosi. */ - String DOSI = "Dosi"; - /** Jodo. */ - String JODO = "Jodo"; - /** Koyu. */ - String KOYU = "Koyu"; - /** Stbi. */ - String STBI = "Stbi"; - /** Suji. */ - String SUJI = "Suji"; - /** Kedo. */ - String KEDO = "Kedo"; - /** Fuku. */ - String FUKU = "Fuku"; - /** Keyo. */ - String KEYO = "Keyo"; - /** Stto. */ - String STTO = "Stto"; - /** Reta. */ - String RETA = "Reta"; - /** Stzo. */ - String STZO = "Stzo"; - /** Kato. */ - String KATO = "Kato"; - /** Hoka. */ - String HOKA = "Hoka"; - } - - private String word; - private String translation; - @SerializedName("part_of_speech") - private String partOfSpeech; - - /** - * Gets the word. - * - * A word that is to be added or updated for the custom voice model. - * - * @return the word - */ - public String getWord() { - return 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. - * - * @return the translation - */ - public String getTranslation() { - return 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - * - * @return the partOfSpeech - */ - public String getPartOfSpeech() { - return partOfSpeech; - } - - /** - * Sets the word. - * - * @param word the new word - */ - public void setWord(final String word) { - this.word = word; - } - - /** - * Sets the translation. - * - * @param translation the new translation - */ - public void setTranslation(final String translation) { - this.translation = translation; - } - - /** - * Sets the partOfSpeech. - * - * @param partOfSpeech the new partOfSpeech - */ - public void setPartOfSpeech(final String partOfSpeech) { - this.partOfSpeech = partOfSpeech; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteUserDataOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteUserDataOptions.java deleted file mode 100644 index 97aff391b2b..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteVoiceModelOptions.java deleted file mode 100644 index 6d37df0fce5..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteVoiceModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteVoiceModel options. - */ -public class DeleteVoiceModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(DeleteVoiceModelOptions deleteVoiceModelOptions) { - 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; - } - } - - private DeleteVoiceModelOptions(Builder builder) { - 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 service credentials created - * 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/developer_cloud/text_to_speech/v1/model/DeleteWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteWordOptions.java deleted file mode 100644 index ecc781c5892..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/DeleteWordOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteWord options. - */ -public class DeleteWordOptions extends GenericModel { - - private String customizationId; - private String word; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String word; - - private Builder(DeleteWordOptions deleteWordOptions) { - customizationId = deleteWordOptions.customizationId; - word = deleteWordOptions.word; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param word the word - */ - public Builder(String customizationId, String word) { - this.customizationId = customizationId; - this.word = word; - } - - /** - * Builds a DeleteWordOptions. - * - * @return the deleteWordOptions - */ - public DeleteWordOptions build() { - return new DeleteWordOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the DeleteWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the word. - * - * @param word the word - * @return the DeleteWordOptions builder - */ - public Builder word(String word) { - this.word = word; - return this; - } - } - - private DeleteWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.word, "word cannot be empty"); - customizationId = builder.customizationId; - word = builder.word; - } - - /** - * New builder. - * - * @return a DeleteWordOptions 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 service credentials created - * for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the word. - * - * The word that is to be deleted from the custom voice model. - * - * @return the word - */ - public String word() { - return word; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetPronunciationOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetPronunciationOptions.java deleted file mode 100644 index c574ef13d91..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetPronunciationOptions.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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. - */ - public interface Voice { - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; - } - - /** - * The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the - * default format. - */ - public interface Format { - /** ipa. */ - String IPA = "ipa"; - /** ibm. */ - String IBM = "ibm"; - } - - private String text; - private String voice; - private String format; - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String text; - private String voice; - private String format; - private String customizationId; - - private Builder(GetPronunciationOptions getPronunciationOptions) { - text = getPronunciationOptions.text; - voice = getPronunciationOptions.voice; - format = getPronunciationOptions.format; - customizationId = getPronunciationOptions.customizationId; - } - - /** - * 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 GetPronunciationOptions. - * - * @return the getPronunciationOptions - */ - public GetPronunciationOptions build() { - return new GetPronunciationOptions(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the GetPronunciationOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the voice. - * - * @param voice the voice - * @return the GetPronunciationOptions builder - */ - public Builder voice(String voice) { - this.voice = voice; - return this; - } - - /** - * Set the format. - * - * @param format the format - * @return the GetPronunciationOptions builder - */ - public Builder format(String format) { - this.format = format; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetPronunciationOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private GetPronunciationOptions(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - voice = builder.voice; - format = builder.format; - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a GetPronunciationOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The word for which the pronunciation is requested. - * - * @return the text - */ - public String text() { - return 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. - * - * @return the voice - */ - public String voice() { - return voice; - } - - /** - * Gets the format. - * - * The phoneme format in which to return the pronunciation. Omit the parameter to obtain the pronunciation in the - * default format. - * - * @return the format - */ - public String format() { - return 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 service credentials created 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 - */ - public String customizationId() { - return customizationId; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetVoiceModelOptions.java deleted file mode 100644 index fadbe6b1708..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetVoiceModelOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getVoiceModel options. - */ -public class GetVoiceModelOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(GetVoiceModelOptions getVoiceModelOptions) { - 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; - } - } - - private GetVoiceModelOptions(Builder builder) { - 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 service credentials created - * 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/developer_cloud/text_to_speech/v1/model/GetVoiceOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetVoiceOptions.java deleted file mode 100644 index 4658a9d6f6c..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetVoiceOptions.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getVoice options. - */ -public class GetVoiceOptions extends GenericModel { - - /** - * The voice for which information is to be returned. - */ - public interface Voice { - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; - } - - private String voice; - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String voice; - private String customizationId; - - private Builder(GetVoiceOptions getVoiceOptions) { - voice = getVoiceOptions.voice; - customizationId = getVoiceOptions.customizationId; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param voice the voice - */ - public Builder(String voice) { - this.voice = voice; - } - - /** - * Builds a GetVoiceOptions. - * - * @return the getVoiceOptions - */ - public GetVoiceOptions build() { - return new GetVoiceOptions(this); - } - - /** - * Set the voice. - * - * @param voice the voice - * @return the GetVoiceOptions builder - */ - public Builder voice(String voice) { - this.voice = voice; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetVoiceOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private GetVoiceOptions(Builder builder) { - Validator.notEmpty(builder.voice, "voice cannot be empty"); - voice = builder.voice; - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a GetVoiceOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the voice. - * - * The voice for which information is to be returned. - * - * @return the voice - */ - public String voice() { - return 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 service credentials created 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 - */ - public String customizationId() { - return customizationId; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetWordOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetWordOptions.java deleted file mode 100644 index 38668a6e934..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/GetWordOptions.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getWord options. - */ -public class GetWordOptions extends GenericModel { - - private String customizationId; - private String word; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String word; - - private Builder(GetWordOptions getWordOptions) { - customizationId = getWordOptions.customizationId; - word = getWordOptions.word; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Instantiates a new builder with required properties. - * - * @param customizationId the customizationId - * @param word the word - */ - public Builder(String customizationId, String word) { - this.customizationId = customizationId; - this.word = word; - } - - /** - * Builds a GetWordOptions. - * - * @return the getWordOptions - */ - public GetWordOptions build() { - return new GetWordOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the GetWordOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - - /** - * Set the word. - * - * @param word the word - * @return the GetWordOptions builder - */ - public Builder word(String word) { - this.word = word; - return this; - } - } - - private GetWordOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - Validator.notEmpty(builder.word, "word cannot be empty"); - customizationId = builder.customizationId; - word = builder.word; - } - - /** - * New builder. - * - * @return a GetWordOptions 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 service credentials created - * for the instance of the service that owns the custom model. - * - * @return the customizationId - */ - public String customizationId() { - return customizationId; - } - - /** - * Gets the word. - * - * The word that is to be queried from the custom voice model. - * - * @return the word - */ - public String word() { - return word; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListVoiceModelsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListVoiceModelsOptions.java deleted file mode 100644 index 8fe93321eb0..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListVoiceModelsOptions.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listVoiceModels options. - */ -public class ListVoiceModelsOptions extends GenericModel { - - /** - * The language for which custom voice models that are owned by the requesting service 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-US. */ - String EN_US = "en-US"; - /** en-GB. */ - String EN_GB = "en-GB"; - /** 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"; - } - - private String language; - - /** - * Builder. - */ - public static class Builder { - private String language; - - private Builder(ListVoiceModelsOptions listVoiceModelsOptions) { - 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; - } - } - - private 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 service 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/developer_cloud/text_to_speech/v1/model/ListVoicesOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListVoicesOptions.java deleted file mode 100644 index 7a689665b52..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListVoicesOptions.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * 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); - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListWordsOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListWordsOptions.java deleted file mode 100644 index 077e03b28d0..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/ListWordsOptions.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The listWords options. - */ -public class ListWordsOptions extends GenericModel { - - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - - private Builder(ListWordsOptions listWordsOptions) { - customizationId = listWordsOptions.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 ListWordsOptions. - * - * @return the listWordsOptions - */ - public ListWordsOptions build() { - return new ListWordsOptions(this); - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the ListWordsOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private ListWordsOptions(Builder builder) { - Validator.notEmpty(builder.customizationId, "customizationId cannot be empty"); - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a ListWordsOptions 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 service credentials created - * 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/developer_cloud/text_to_speech/v1/model/Pronunciation.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Pronunciation.java deleted file mode 100644 index 80e4e7f5e35..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Pronunciation.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Pronunciation. - */ -public class Pronunciation extends GenericModel { - - private String 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. - * - * @return the pronunciation - */ - public String getPronunciation() { - return pronunciation; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SupportedFeatures.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SupportedFeatures.java deleted file mode 100644 index cef43253aa0..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SupportedFeatures.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SupportedFeatures. - */ -public class SupportedFeatures extends GenericModel { - - @SerializedName("custom_pronunciation") - private Boolean customPronunciation; - @SerializedName("voice_transformation") - private Boolean voiceTransformation; - - /** - * Gets the customPronunciation. - * - * If `true`, the voice can be customized; if `false`, the voice cannot be customized. (Same as `customizable`.). - * - * @return the customPronunciation - */ - public Boolean isCustomPronunciation() { - return customPronunciation; - } - - /** - * Gets the voiceTransformation. - * - * If `true`, the voice can be transformed by using the SSML <voice-transformation> element; if `false`, the - * voice cannot be transformed. - * - * @return the voiceTransformation - */ - public Boolean isVoiceTransformation() { - return voiceTransformation; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SynthesizeOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SynthesizeOptions.java deleted file mode 100644 index a645aeae4f6..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/SynthesizeOptions.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The synthesize options. - */ -public class SynthesizeOptions extends GenericModel { - - /** - * The requested audio format (MIME type) of the audio. You can use the `Accept` header or the `accept` query - * parameter to specify the audio format. (For the `audio/l16` format, you can optionally specify - * `endianness=big-endian` or `endianness=little-endian`; the default is little endian.) For detailed information - * about the supported audio formats and sampling rates, see [Specifying an audio - * format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format). - */ - public interface Accept { - /** audio/basic. */ - String AUDIO_BASIC = "audio/basic"; - /** audio/flac. */ - String AUDIO_FLAC = "audio/flac"; - /** audio/l16;rate=nnnn. */ - String AUDIO_L16_RATE_NNNN = "audio/l16;rate=nnnn"; - /** audio/ogg. */ - String AUDIO_OGG = "audio/ogg"; - /** audio/ogg;codecs=opus. */ - String AUDIO_OGG_CODECS_OPUS = "audio/ogg;codecs=opus"; - /** audio/ogg;codecs=vorbis. */ - String AUDIO_OGG_CODECS_VORBIS = "audio/ogg;codecs=vorbis"; - /** audio/mp3. */ - String AUDIO_MP3 = "audio/mp3"; - /** audio/mpeg. */ - String AUDIO_MPEG = "audio/mpeg"; - /** audio/mulaw;rate=nnnn. */ - String AUDIO_MULAW_RATE_NNNN = "audio/mulaw;rate=nnnn"; - /** audio/wav. */ - String AUDIO_WAV = "audio/wav"; - /** audio/webm. */ - String AUDIO_WEBM = "audio/webm"; - /** audio/webm;codecs=opus. */ - String AUDIO_WEBM_CODECS_OPUS = "audio/webm;codecs=opus"; - /** audio/webm;codecs=vorbis. */ - String AUDIO_WEBM_CODECS_VORBIS = "audio/webm;codecs=vorbis"; - } - - /** - * The voice to use for synthesis. - */ - public interface Voice { - /** en-US_AllisonVoice. */ - String EN_US_ALLISONVOICE = "en-US_AllisonVoice"; - /** en-US_LisaVoice. */ - String EN_US_LISAVOICE = "en-US_LisaVoice"; - /** en-US_MichaelVoice. */ - String EN_US_MICHAELVOICE = "en-US_MichaelVoice"; - /** en-GB_KateVoice. */ - String EN_GB_KATEVOICE = "en-GB_KateVoice"; - /** es-ES_EnriqueVoice. */ - String ES_ES_ENRIQUEVOICE = "es-ES_EnriqueVoice"; - /** es-ES_LauraVoice. */ - String ES_ES_LAURAVOICE = "es-ES_LauraVoice"; - /** es-LA_SofiaVoice. */ - String ES_LA_SOFIAVOICE = "es-LA_SofiaVoice"; - /** es-US_SofiaVoice. */ - String ES_US_SOFIAVOICE = "es-US_SofiaVoice"; - /** de-DE_DieterVoice. */ - String DE_DE_DIETERVOICE = "de-DE_DieterVoice"; - /** de-DE_BirgitVoice. */ - String DE_DE_BIRGITVOICE = "de-DE_BirgitVoice"; - /** fr-FR_ReneeVoice. */ - String FR_FR_RENEEVOICE = "fr-FR_ReneeVoice"; - /** it-IT_FrancescaVoice. */ - String IT_IT_FRANCESCAVOICE = "it-IT_FrancescaVoice"; - /** ja-JP_EmiVoice. */ - String JA_JP_EMIVOICE = "ja-JP_EmiVoice"; - /** pt-BR_IsabelaVoice. */ - String PT_BR_ISABELAVOICE = "pt-BR_IsabelaVoice"; - } - - private String text; - private String accept; - private String voice; - private String customizationId; - - /** - * Builder. - */ - public static class Builder { - private String text; - private String accept; - private String voice; - private String customizationId; - - private Builder(SynthesizeOptions synthesizeOptions) { - text = synthesizeOptions.text; - accept = synthesizeOptions.accept; - voice = synthesizeOptions.voice; - customizationId = synthesizeOptions.customizationId; - } - - /** - * 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 SynthesizeOptions. - * - * @return the synthesizeOptions - */ - public SynthesizeOptions build() { - return new SynthesizeOptions(this); - } - - /** - * Set the text. - * - * @param text the text - * @return the SynthesizeOptions builder - */ - public Builder text(String text) { - this.text = text; - return this; - } - - /** - * Set the accept. - * - * @param accept the accept - * @return the SynthesizeOptions builder - */ - public Builder accept(String accept) { - this.accept = accept; - return this; - } - - /** - * Set the voice. - * - * @param voice the voice - * @return the SynthesizeOptions builder - */ - public Builder voice(String voice) { - this.voice = voice; - return this; - } - - /** - * Set the customizationId. - * - * @param customizationId the customizationId - * @return the SynthesizeOptions builder - */ - public Builder customizationId(String customizationId) { - this.customizationId = customizationId; - return this; - } - } - - private SynthesizeOptions(Builder builder) { - Validator.notNull(builder.text, "text cannot be null"); - text = builder.text; - accept = builder.accept; - voice = builder.voice; - customizationId = builder.customizationId; - } - - /** - * New builder. - * - * @return a SynthesizeOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the text. - * - * The text to synthesize. - * - * @return the text - */ - public String text() { - return text; - } - - /** - * Gets the accept. - * - * The requested audio format (MIME type) of the audio. You can use the `Accept` header or the `accept` query - * parameter to specify the audio format. (For the `audio/l16` format, you can optionally specify - * `endianness=big-endian` or `endianness=little-endian`; the default is little endian.) For detailed information - * about the supported audio formats and sampling rates, see [Specifying an audio - * format](https://console.bluemix.net/docs/services/text-to-speech/http.html#format). - * - * @return the accept - */ - public String accept() { - return accept; - } - - /** - * Gets the voice. - * - * The voice to use for synthesis. - * - * @return the voice - */ - public String voice() { - return 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 - * service credentials created 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 - */ - public String customizationId() { - return customizationId; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Translation.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Translation.java deleted file mode 100644 index 26b9ae46190..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Translation.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Translation. - */ -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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - */ - public interface PartOfSpeech { - /** Josi. */ - String JOSI = "Josi"; - /** Mesi. */ - String MESI = "Mesi"; - /** Kigo. */ - String KIGO = "Kigo"; - /** Gobi. */ - String GOBI = "Gobi"; - /** Dosi. */ - String DOSI = "Dosi"; - /** Jodo. */ - String JODO = "Jodo"; - /** Koyu. */ - String KOYU = "Koyu"; - /** Stbi. */ - String STBI = "Stbi"; - /** Suji. */ - String SUJI = "Suji"; - /** Kedo. */ - String KEDO = "Kedo"; - /** Fuku. */ - String FUKU = "Fuku"; - /** Keyo. */ - String KEYO = "Keyo"; - /** Stto. */ - String STTO = "Stto"; - /** Reta. */ - String RETA = "Reta"; - /** Stzo. */ - String STZO = "Stzo"; - /** Kato. */ - String KATO = "Kato"; - /** Hoka. */ - String HOKA = "Hoka"; - } - - private String translation; - @SerializedName("part_of_speech") - private String partOfSpeech; - - /** - * 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. - * - * @return the translation - */ - public String getTranslation() { - return 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - * - * @return the partOfSpeech - */ - public String getPartOfSpeech() { - return partOfSpeech; - } - - /** - * Sets the translation. - * - * @param translation the new translation - */ - public void setTranslation(final String translation) { - this.translation = translation; - } - - /** - * Sets the partOfSpeech. - * - * @param partOfSpeech the new partOfSpeech - */ - public void setPartOfSpeech(final String partOfSpeech) { - this.partOfSpeech = partOfSpeech; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/UpdateVoiceModelOptions.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/UpdateVoiceModelOptions.java deleted file mode 100644 index 23781d9e1d9..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/UpdateVoiceModelOptions.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateVoiceModel options. - */ -public class UpdateVoiceModelOptions extends GenericModel { - - private String customizationId; - private String name; - private String description; - private List words; - - /** - * Builder. - */ - public static class Builder { - private String customizationId; - private String name; - private String description; - private List words; - - private Builder(UpdateVoiceModelOptions updateVoiceModelOptions) { - customizationId = updateVoiceModelOptions.customizationId; - name = updateVoiceModelOptions.name; - description = updateVoiceModelOptions.description; - 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) { - 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; - } - } - - private UpdateVoiceModelOptions(Builder builder) { - 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 service credentials created - * 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/developer_cloud/text_to_speech/v1/model/Voice.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Voice.java deleted file mode 100644 index 774df8b4e5e..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Voice.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Voice. - */ -public class Voice extends GenericModel { - - private String url; - private String gender; - private String name; - private String language; - private String description; - private Boolean customizable; - @SerializedName("supported_features") - private SupportedFeatures supportedFeatures; - private VoiceModel customization; - - /** - * Gets the url. - * - * The URI of the voice. - * - * @return the url - */ - public String getUrl() { - return url; - } - - /** - * Gets the gender. - * - * The gender of the voice: `male` or `female`. - * - * @return the gender - */ - public String getGender() { - return gender; - } - - /** - * Gets the name. - * - * The name of the voice. Use this as the voice identifier in all requests. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Gets the language. - * - * The language and region of the voice (for example, `en-US`). - * - * @return the language - */ - public String getLanguage() { - return language; - } - - /** - * Gets the description. - * - * A textual description of the voice. - * - * @return the description - */ - public String getDescription() { - return description; - } - - /** - * Gets the customizable. - * - * 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 - */ - public Boolean isCustomizable() { - return customizable; - } - - /** - * Gets the supportedFeatures. - * - * Describes the additional service features supported with the voice. - * - * @return the supportedFeatures - */ - public SupportedFeatures getSupportedFeatures() { - return supportedFeatures; - } - - /** - * 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. - * - * @return the customization - */ - public VoiceModel getCustomization() { - return customization; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/VoiceModel.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/VoiceModel.java deleted file mode 100644 index e600983a372..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/VoiceModel.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * VoiceModel. - */ -public class VoiceModel extends GenericModel { - - @SerializedName("customization_id") - private String customizationId; - private String name; - private String language; - private String owner; - private String created; - @SerializedName("last_modified") - private String lastModified; - private String description; - private 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 service 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. Equals - * `created` when a new 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/developer_cloud/text_to_speech/v1/model/VoiceModels.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/VoiceModels.java deleted file mode 100644 index b955f0f5a19..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/VoiceModels.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * VoiceModels. - */ -public class VoiceModels extends GenericModel { - - private 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 service 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/developer_cloud/text_to_speech/v1/model/Voices.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Voices.java deleted file mode 100644 index 82031c57325..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Voices.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Voices. - */ -public class Voices extends GenericModel { - - private List voices; - - /** - * Gets the voices. - * - * A list of available voices. - * - * @return the voices - */ - public List getVoices() { - return voices; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Word.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Word.java deleted file mode 100644 index f8de4cc14a0..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Word.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Word. - */ -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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - */ - public interface PartOfSpeech { - /** Josi. */ - String JOSI = "Josi"; - /** Mesi. */ - String MESI = "Mesi"; - /** Kigo. */ - String KIGO = "Kigo"; - /** Gobi. */ - String GOBI = "Gobi"; - /** Dosi. */ - String DOSI = "Dosi"; - /** Jodo. */ - String JODO = "Jodo"; - /** Koyu. */ - String KOYU = "Koyu"; - /** Stbi. */ - String STBI = "Stbi"; - /** Suji. */ - String SUJI = "Suji"; - /** Kedo. */ - String KEDO = "Kedo"; - /** Fuku. */ - String FUKU = "Fuku"; - /** Keyo. */ - String KEYO = "Keyo"; - /** Stto. */ - String STTO = "Stto"; - /** Reta. */ - String RETA = "Reta"; - /** Stzo. */ - String STZO = "Stzo"; - /** Kato. */ - String KATO = "Kato"; - /** Hoka. */ - String HOKA = "Hoka"; - } - - private String word; - private String translation; - @SerializedName("part_of_speech") - private String partOfSpeech; - - /** - * Gets the word. - * - * A word from the custom voice model. - * - * @return the word - */ - public String getWord() { - return 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. - * - * @return the translation - */ - public String getTranslation() { - return 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://console.bluemix.net/docs/services/text-to-speech/custom-rules.html#jaNotes). - * - * @return the partOfSpeech - */ - public String getPartOfSpeech() { - return partOfSpeech; - } - - /** - * Sets the word. - * - * @param word the new word - */ - public void setWord(final String word) { - this.word = word; - } - - /** - * Sets the translation. - * - * @param translation the new translation - */ - public void setTranslation(final String translation) { - this.translation = translation; - } - - /** - * Sets the partOfSpeech. - * - * @param partOfSpeech the new partOfSpeech - */ - public void setPartOfSpeech(final String partOfSpeech) { - this.partOfSpeech = partOfSpeech; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Words.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Words.java deleted file mode 100644 index 7081b19ff5a..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/model/Words.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Words. - */ -public class Words extends GenericModel { - - private List words; - - /** - * 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 **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. - * - * @return the words - */ - public List getWords() { - return words; - } - - /** - * Sets the words. - * - * @param words the new words - */ - public void setWords(final List words) { - this.words = words; - } -} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/package-info.java b/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/package-info.java deleted file mode 100644 index 28a875286a5..00000000000 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; 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 new file mode 100644 index 00000000000..7697b36132f --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/TextToSpeech.java @@ -0,0 +1,1331 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT 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; +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.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.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.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; + +/** + * 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. + * + *

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 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. + * + *

API Version: 1.0.0 See: https://cloud.ibm.com/docs/text-to-speech + */ +public class TextToSpeech extends BaseService { + + /** Default service name used when configuring the `TextToSpeech` client. */ + public static final String DEFAULT_SERVICE_NAME = "text_to_speech"; + + /** Default service endpoint URL. */ + public static final String DEFAULT_SERVICE_URL = + "https://api.us-south.text-to-speech.watson.cloud.ibm.com"; + + /** + * 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)); + } + + /** + * Constructs an instance of the `TextToSpeech` client. The default service name and specified + * authenticator are used to configure the client instance. + * + * @param authenticator the {@link Authenticator} instance to be configured for this client + */ + public TextToSpeech(Authenticator authenticator) { + this(DEFAULT_SERVICE_NAME, authenticator); + } + + /** + * Constructs an instance of the `TextToSpeech` client. The specified service name is used to + * configure the client instance. + * + * @param serviceName the service name to be used when configuring the client instance + */ + public TextToSpeech(String serviceName) { + this(serviceName, ConfigBasedAuthenticatorFactory.getAuthenticator(serviceName)); + } + + /** + * Constructs an instance of the `TextToSpeech` client. The specified service name and + * authenticator are used to configure the client instance. + * + * @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); + setServiceUrl(DEFAULT_SERVICE_URL); + 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. 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 + * 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 result of type {@link Voices} + */ + public ServiceCall listVoices(ListVoicesOptions listVoicesOptions) { + 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"); + 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. 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 + * voices](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-voices-list#list-all-voices). + * + * @return a {@link ServiceCall} with a result of type {@link Voices} + */ + public ServiceCall listVoices() { + return listVoices(null); + } + + /** + * 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 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-list#list-specific-voice). + * + * @param getVoiceOptions the {@link GetVoiceOptions} containing the options for the call + * @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"); + 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", String.valueOf(getVoiceOptions.customizationId())); + } + 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. + * + *

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 + * 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/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 result of type {@link InputStream} + */ + public ServiceCall synthesize(SynthesizeOptions synthesizeOptions) { + 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()); + } + if (synthesizeOptions.accept() != null) { + builder.header("Accept", synthesizeOptions.accept()); + } + if (synthesizeOptions.voice() != null) { + builder.query("voice", String.valueOf(synthesizeOptions.voice())); + } + if (synthesizeOptions.customizationId() != null) { + 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()); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getInputStream(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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 model to see the + * translation for that model. + * + *

**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 result of type {@link Pronunciation} + */ + 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", String.valueOf(getPronunciationOptions.text())); + if (getPronunciationOptions.voice() != null) { + builder.query("voice", String.valueOf(getPronunciationOptions.voice())); + } + if (getPronunciationOptions.format() != null) { + builder.query("format", String.valueOf(getPronunciationOptions.format())); + } + if (getPronunciationOptions.customizationId() != null) { + builder.query("customization_id", String.valueOf(getPronunciationOptions.customizationId())); + } + 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 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 + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate). + * + * @param createCustomModelOptions the {@link CreateCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CustomModel} + */ + 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", createCustomModelOptions.name()); + if (createCustomModelOptions.language() != null) { + contentJson.addProperty("language", createCustomModelOptions.language()); + } + if (createCustomModelOptions.description() != null) { + contentJson.addProperty("description", createCustomModelOptions.description()); + } + builder.bodyJson(contentJson); + 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 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. + * + *

**See also:** [Querying all custom + * models](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll). + * + * @param listCustomModelsOptions the {@link ListCustomModelsOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a result of type {@link CustomModels} + */ + 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 (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 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. + * + *

**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 result of type {@link CustomModels} + */ + public ServiceCall listCustomModels() { + return listCustomModels(null); + } + + /** + * Update a custom model. + * + *

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 + * + *

<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) + * + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> + * + *

**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 updateCustomModelOptions the {@link UpdateCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result + */ + 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 (updateCustomModelOptions.name() != null) { + contentJson.addProperty("name", updateCustomModelOptions.name()); + } + if (updateCustomModelOptions.description() != null) { + contentJson.addProperty("description", updateCustomModelOptions.description()); + } + 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(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Get a custom model. + * + *

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 + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery). + * + * @param getCustomModelOptions the {@link GetCustomModelOptions} containing the options for the + * call + * @return a {@link ServiceCall} with a result of type {@link CustomModel} + */ + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a custom model. + * + *

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 + * model](https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete). + * + * @param deleteCustomModelOptions the {@link DeleteCustomModelOptions} containing the options for + * the call + * @return a {@link ServiceCall} with a void result + */ + 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); + } + + /** + * Add custom words. + * + *

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 + * + *

<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) + * + *

<code>&lt;phoneme alphabet="ibm" + * ph="1gAstroEntxrYFXs"&gt;&lt;/phoneme&gt;</code> + * + *

**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 void result + */ + public ServiceCall addWords(AddWordsOptions addWordsOptions) { + 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())); + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * List custom 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. + * + *

**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 result of type {@link Words} + */ + public ServiceCall listWords(ListWordsOptions listWordsOptions) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Add a custom word. + * + *

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. + * + *

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 + * + *

<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) + * + *

<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 + * 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 void result + */ + public ServiceCall addWord(AddWordOptions addWordOptions) { + 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()); + } + final JsonObject contentJson = new JsonObject(); + contentJson.addProperty("translation", addWordOptions.translation()); + if (addWordOptions.partOfSpeech() != null) { + contentJson.addProperty("part_of_speech", addWordOptions.partOfSpeech()); + } + builder.bodyJson(contentJson); + ResponseConverter responseConverter = ResponseConverterUtils.getVoid(); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * 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. + * + *

**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 result of type {@link Translation} + */ + public ServiceCall getWord(GetWordOptions getWordOptions) { + 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()); + return createServiceCall(builder.build(), responseConverter); + } + + /** + * Delete a custom word. + * + *

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 + * 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 void result + */ + public ServiceCall deleteWord(DeleteWordOptions deleteWordOptions) { + 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); + } + + /** + * 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. 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). + * + * @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(), "/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", 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 new file mode 100644 index 00000000000..2019a77f488 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordOptions.java @@ -0,0 +1,245 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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). + */ + public interface PartOfSpeech { + /** Dosi. */ + String DOSI = "Dosi"; + /** Fuku. */ + String FUKU = "Fuku"; + /** Gobi. */ + String GOBI = "Gobi"; + /** Hoka. */ + String HOKA = "Hoka"; + /** Jodo. */ + String JODO = "Jodo"; + /** Josi. */ + String JOSI = "Josi"; + /** Kato. */ + String KATO = "Kato"; + /** Kedo. */ + String KEDO = "Kedo"; + /** Keyo. */ + String KEYO = "Keyo"; + /** Kigo. */ + String KIGO = "Kigo"; + /** Koyu. */ + String KOYU = "Koyu"; + /** Mesi. */ + String MESI = "Mesi"; + /** Reta. */ + String RETA = "Reta"; + /** Stbi. */ + String STBI = "Stbi"; + /** Stto. */ + String STTO = "Stto"; + /** Stzo. */ + String STZO = "Stzo"; + /** Suji. */ + String SUJI = "Suji"; + } + + protected String customizationId; + protected String word; + protected String translation; + protected String partOfSpeech; + + /** 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; + this.translation = addWordOptions.translation; + this.partOfSpeech = addWordOptions.partOfSpeech; + } + + /** Instantiates a new builder. */ + public Builder() {} + + /** + * Instantiates a new builder with required properties. + * + * @param customizationId the customizationId + * @param word the word + * @param translation the translation + */ + public Builder(String customizationId, String word, String translation) { + this.customizationId = customizationId; + this.word = word; + this.translation = translation; + } + + /** + * Builds a AddWordOptions. + * + * @return the new AddWordOptions instance + */ + public AddWordOptions build() { + return new AddWordOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the word. + * + * @param word the word + * @return the AddWordOptions builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + + /** + * Set the translation. + * + * @param translation the translation + * @return the AddWordOptions builder + */ + public Builder translation(String translation) { + this.translation = translation; + return this; + } + + /** + * Set the partOfSpeech. + * + * @param partOfSpeech the partOfSpeech + * @return the AddWordOptions builder + */ + public Builder partOfSpeech(String partOfSpeech) { + this.partOfSpeech = partOfSpeech; + return this; + } + + /** + * Set the translation. + * + * @param translation the translation + * @return the AddWordOptions builder + */ + public Builder translation(Translation translation) { + this.translation = translation.translation(); + this.partOfSpeech = translation.partOfSpeech(); + return this; + } + } + + 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"); + customizationId = builder.customizationId; + word = builder.word; + translation = builder.translation; + partOfSpeech = builder.partOfSpeech; + } + + /** + * New builder. + * + * @return a AddWordOptions 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 word. + * + *

The word that is to be added or updated for the custom model. + * + * @return the word + */ + public String word() { + return 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. + * + * @return the translation + */ + public String translation() { + return 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). + * + * @return the partOfSpeech + */ + public String partOfSpeech() { + return 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 new file mode 100644 index 00000000000..53407fc0c94 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/AddWordsOptions.java @@ -0,0 +1,160 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** The addWords options. */ +public class AddWordsOptions extends GenericModel { + + protected String customizationId; + protected List words; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param words the words + */ + public Builder(String customizationId, List words) { + this.customizationId = customizationId; + this.words = words; + } + + /** + * Builds a AddWordsOptions. + * + * @return the new AddWordsOptions instance + */ + public AddWordsOptions build() { + return new AddWordsOptions(this); + } + + /** + * Adds a new element to words. + * + * @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"); + if (this.words == null) { + this.words = new ArrayList(); + } + this.words.add(word); + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the AddWordsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the words. Existing words will be replaced. + * + * @param words the words + * @return the AddWordsOptions builder + */ + public Builder words(List words) { + this.words = words; + return this; + } + + /** + * Set the words. + * + * @param words the words + * @return the AddWordsOptions builder + */ + public Builder words(Words words) { + this.words = words.words(); + return this; + } + } + + 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"); + customizationId = builder.customizationId; + words = builder.words; + } + + /** + * New builder. + * + * @return a AddWordsOptions 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 words. + * + *

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](#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 + */ + public List words() { + return 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/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 new file mode 100644 index 00000000000..fa61d47dce8 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/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.text_to_speech.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; + + /** + * 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/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 new file mode 100644 index 00000000000..59e067532a4 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/DeleteWordOptions.java @@ -0,0 +1,126 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The deleteWord options. */ +public class DeleteWordOptions extends GenericModel { + + protected String customizationId; + protected String word; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param word the word + */ + public Builder(String customizationId, String word) { + this.customizationId = customizationId; + this.word = word; + } + + /** + * Builds a DeleteWordOptions. + * + * @return the new DeleteWordOptions instance + */ + public DeleteWordOptions build() { + return new DeleteWordOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the DeleteWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the word. + * + * @param word the word + * @return the DeleteWordOptions builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + word = builder.word; + } + + /** + * New builder. + * + * @return a DeleteWordOptions 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 word. + * + *

The word that is to be deleted from the custom model. + * + * @return the word + */ + public String word() { + return 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 new file mode 100644 index 00000000000..45edefb78e9 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetPronunciationOptions.java @@ -0,0 +1,302 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +public class GetPronunciationOptions extends GenericModel { + + /** + * 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_BirgitV3Voice. */ + String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; + /** de-DE_DieterV3Voice. */ + String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; + /** 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_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; + /** en-US_AllisonV3Voice. */ + String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; + /** 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_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; + /** en-US_MichaelV3Voice. */ + String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; + /** 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_LauraV3Voice. */ + String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; + /** es-LA_SofiaV3Voice. */ + String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; + /** es-US_SofiaV3Voice. */ + String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; + /** 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_FrancescaV3Voice. */ + String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; + /** ja-JP_EmiV3Voice. */ + String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; + /** 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. + */ + public interface Format { + /** ibm. */ + String IBM = "ibm"; + /** ipa. */ + String IPA = "ipa"; + } + + protected String text; + protected String voice; + protected String format; + protected String customizationId; + + /** 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; + this.format = getPronunciationOptions.format; + this.customizationId = getPronunciationOptions.customizationId; + } + + /** 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 GetPronunciationOptions. + * + * @return the new GetPronunciationOptions instance + */ + public GetPronunciationOptions build() { + return new GetPronunciationOptions(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the GetPronunciationOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the voice. + * + * @param voice the voice + * @return the GetPronunciationOptions builder + */ + public Builder voice(String voice) { + this.voice = voice; + return this; + } + + /** + * Set the format. + * + * @param format the format + * @return the GetPronunciationOptions builder + */ + public Builder format(String format) { + this.format = format; + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetPronunciationOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected GetPronunciationOptions() {} + + protected GetPronunciationOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null"); + text = builder.text; + voice = builder.voice; + format = builder.format; + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a GetPronunciationOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The word for which the pronunciation is requested. + * + * @return the text + */ + public String text() { + return text; + } + + /** + * Gets the voice. + * + *

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 + */ + public String voice() { + return voice; + } + + /** + * Gets the format. + * + *

The phoneme format in which to return the pronunciation. Omit the parameter to obtain the + * pronunciation in the default format. + * + * @return the format + */ + public String format() { + return format; + } + + /** + * Gets the customizationId. + * + *

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 + */ + public String customizationId() { + return 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/GetVoiceOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java new file mode 100644 index 00000000000..2dd82060203 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetVoiceOptions.java @@ -0,0 +1,215 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +public class GetVoiceOptions extends GenericModel { + + /** The voice for which information is to be returned. */ + public interface Voice { + /** de-DE_BirgitV3Voice. */ + String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; + /** de-DE_DieterV3Voice. */ + String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; + /** 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_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; + /** en-US_AllisonV3Voice. */ + String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; + /** 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_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; + /** en-US_MichaelV3Voice. */ + String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; + /** 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_LauraV3Voice. */ + String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; + /** es-LA_SofiaV3Voice. */ + String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; + /** es-US_SofiaV3Voice. */ + String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; + /** 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_FrancescaV3Voice. */ + String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; + /** ja-JP_EmiV3Voice. */ + String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; + /** 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. */ + 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 with required properties. + * + * @param voice the voice + */ + public Builder(String voice) { + this.voice = voice; + } + + /** + * Builds a GetVoiceOptions. + * + * @return the new GetVoiceOptions instance + */ + public GetVoiceOptions build() { + return new GetVoiceOptions(this); + } + + /** + * Set the voice. + * + * @param voice the voice + * @return the GetVoiceOptions builder + */ + public Builder voice(String voice) { + this.voice = voice; + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetVoiceOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected GetVoiceOptions() {} + + protected GetVoiceOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.voice, "voice cannot be empty"); + voice = builder.voice; + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a GetVoiceOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the voice. + * + *

The voice for which information is to be returned. + * + * @return the voice + */ + public String voice() { + return voice; + } + + /** + * Gets the customizationId. + * + *

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 + */ + public String customizationId() { + return 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 new file mode 100644 index 00000000000..e81545b6fff --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/GetWordOptions.java @@ -0,0 +1,126 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The getWord options. */ +public class GetWordOptions extends GenericModel { + + protected String customizationId; + protected String word; + + /** 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 with required properties. + * + * @param customizationId the customizationId + * @param word the word + */ + public Builder(String customizationId, String word) { + this.customizationId = customizationId; + this.word = word; + } + + /** + * Builds a GetWordOptions. + * + * @return the new GetWordOptions instance + */ + public GetWordOptions build() { + return new GetWordOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the GetWordOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + + /** + * Set the word. + * + * @param word the word + * @return the GetWordOptions builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + } + + 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"); + customizationId = builder.customizationId; + word = builder.word; + } + + /** + * New builder. + * + * @return a GetWordOptions 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 word. + * + *

The word that is to be queried from the custom model. + * + * @return the word + */ + public String word() { + return 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/ListVoicesOptions.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java new file mode 100644 index 00000000000..137036c253d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListVoicesOptions.java @@ -0,0 +1,23 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listVoices options. */ +public class ListVoicesOptions extends GenericModel { + + /** 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 new file mode 100644 index 00000000000..83e345099e9 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/ListWordsOptions.java @@ -0,0 +1,97 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** The listWords options. */ +public class ListWordsOptions extends GenericModel { + + protected String customizationId; + + /** 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 with required properties. + * + * @param customizationId the customizationId + */ + public Builder(String customizationId) { + this.customizationId = customizationId; + } + + /** + * Builds a ListWordsOptions. + * + * @return the new ListWordsOptions instance + */ + public ListWordsOptions build() { + return new ListWordsOptions(this); + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the ListWordsOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = customizationId; + return this; + } + } + + protected ListWordsOptions() {} + + protected ListWordsOptions(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notEmpty( + builder.customizationId, "customizationId cannot be empty"); + customizationId = builder.customizationId; + } + + /** + * New builder. + * + * @return a ListWordsOptions 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/MarkTiming.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/MarkTiming.java new file mode 100644 index 00000000000..5640464629a --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/MarkTiming.java @@ -0,0 +1,27 @@ +package com.ibm.watson.text_to_speech.v1.model; + +import com.google.gson.annotations.JsonAdapter; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import com.ibm.watson.text_to_speech.v1.util.MarkTimingTypeAdapter; + +@JsonAdapter(MarkTimingTypeAdapter.class) +public class MarkTiming extends GenericModel { + private String mark; + private Double time; + + public String getMark() { + return mark; + } + + public Double getTime() { + return time; + } + + public void setMark(String mark) { + this.mark = mark; + } + + public void setTime(Double time) { + this.time = time; + } +} 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 new file mode 100644 index 00000000000..23fe18ec6fb --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Marks.java @@ -0,0 +1,12 @@ +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 { + private List marks; + + public List getMarks() { + return marks; + } +} 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 new file mode 100644 index 00000000000..8d57c9c8de2 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Pronunciation.java @@ -0,0 +1,36 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; + +/** 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 model + * is specified, the pronunciation also reflects that custom model. + * + * @return the pronunciation + */ + public String getPronunciation() { + return 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 new file mode 100644 index 00000000000..f947ee3e8cb --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SupportedFeatures.java @@ -0,0 +1,55 @@ +/* + * (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.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. */ +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`.). + * + * @return the customPronunciation + */ + public Boolean isCustomPronunciation() { + return customPronunciation; + } + + /** + * Gets the voiceTransformation. + * + *

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 + */ + public Boolean isVoiceTransformation() { + return 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 new file mode 100644 index 00000000000..edead2d467c --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/SynthesizeOptions.java @@ -0,0 +1,459 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +public class SynthesizeOptions extends GenericModel { + + /** + * 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 { + /** de-DE_BirgitV3Voice. */ + String DE_DE_BIRGITV3VOICE = "de-DE_BirgitV3Voice"; + /** de-DE_DieterV3Voice. */ + String DE_DE_DIETERV3VOICE = "de-DE_DieterV3Voice"; + /** 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_AllisonExpressive. */ + String EN_US_ALLISONEXPRESSIVE = "en-US_AllisonExpressive"; + /** en-US_AllisonV3Voice. */ + String EN_US_ALLISONV3VOICE = "en-US_AllisonV3Voice"; + /** 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_MichaelExpressive. */ + String EN_US_MICHAELEXPRESSIVE = "en-US_MichaelExpressive"; + /** en-US_MichaelV3Voice. */ + String EN_US_MICHAELV3VOICE = "en-US_MichaelV3Voice"; + /** 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_LauraV3Voice. */ + String ES_ES_LAURAV3VOICE = "es-ES_LauraV3Voice"; + /** es-LA_DanielaExpressive. */ + String ES_LA_DANIELAEXPRESSIVE = "es-LA_DanielaExpressive"; + /** es-LA_SofiaV3Voice. */ + String ES_LA_SOFIAV3VOICE = "es-LA_SofiaV3Voice"; + /** es-US_SofiaV3Voice. */ + String ES_US_SOFIAV3VOICE = "es-US_SofiaV3Voice"; + /** 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_FrancescaV3Voice. */ + String IT_IT_FRANCESCAV3VOICE = "it-IT_FrancescaV3Voice"; + /** ja-JP_EmiV3Voice. */ + String JA_JP_EMIV3VOICE = "ja-JP_EmiV3Voice"; + /** 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"; + } + + /** + * *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. */ + 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 with required properties. + * + * @param text the text + */ + public Builder(String text) { + this.text = text; + } + + /** + * Builds a SynthesizeOptions. + * + * @return the new SynthesizeOptions instance + */ + public SynthesizeOptions build() { + return new SynthesizeOptions(this); + } + + /** + * Set the text. + * + * @param text the text + * @return the SynthesizeOptions builder + */ + public Builder text(String text) { + this.text = text; + return this; + } + + /** + * Set the accept. + * + * @param accept the accept + * @return the SynthesizeOptions builder + */ + public Builder accept(String accept) { + this.accept = accept; + return this; + } + + /** + * Set the voice. + * + * @param voice the voice + * @return the SynthesizeOptions builder + */ + public Builder voice(String voice) { + this.voice = voice; + return this; + } + + /** + * Set the customizationId. + * + * @param customizationId the customizationId + * @return the SynthesizeOptions builder + */ + public Builder customizationId(String customizationId) { + this.customizationId = 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 list of timings + * @return the SynthesizeOptions builder + */ + public Builder timings(List timings) { + this.timings = timings; + return this; + } + } + + protected SynthesizeOptions() {} + + protected SynthesizeOptions(Builder builder) { + 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; + spellOutMode = builder.spellOutMode; + ratePercentage = builder.ratePercentage; + pitchPercentage = builder.pitchPercentage; + } + + /** + * New builder. + * + * @return a SynthesizeOptions builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the text. + * + *

The text to synthesize. + * + * @return the text + */ + public String text() { + return 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. + * + * @return the accept + */ + public String accept() { + return accept; + } + + /** + * Gets the voice. + * + *

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 + */ + public String voice() { + return voice; + } + + /** + * Gets the customizationId. + * + *

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 + */ + 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. + * + *

NOTE: This parameter only works for the `synthesizeUsingWebSocket` method. + * + * @return the timings + */ + 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 new file mode 100644 index 00000000000..5985a4932c8 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Timings.java @@ -0,0 +1,12 @@ +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 { + private List words; + + public List getWords() { + return words; + } +} 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 new file mode 100644 index 00000000000..a2cc889579d --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Translation.java @@ -0,0 +1,176 @@ +/* + * (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.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. */ +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). + */ + public interface PartOfSpeech { + /** Dosi. */ + String DOSI = "Dosi"; + /** Fuku. */ + String FUKU = "Fuku"; + /** Gobi. */ + String GOBI = "Gobi"; + /** Hoka. */ + String HOKA = "Hoka"; + /** Jodo. */ + String JODO = "Jodo"; + /** Josi. */ + String JOSI = "Josi"; + /** Kato. */ + String KATO = "Kato"; + /** Kedo. */ + String KEDO = "Kedo"; + /** Keyo. */ + String KEYO = "Keyo"; + /** Kigo. */ + String KIGO = "Kigo"; + /** Koyu. */ + String KOYU = "Koyu"; + /** Mesi. */ + String MESI = "Mesi"; + /** Reta. */ + String RETA = "Reta"; + /** Stbi. */ + String STBI = "Stbi"; + /** Stto. */ + String STTO = "Stto"; + /** Stzo. */ + String STZO = "Stzo"; + /** Suji. */ + String SUJI = "Suji"; + } + + protected String translation; + + @SerializedName("part_of_speech") + protected String partOfSpeech; + + /** 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 with required properties. + * + * @param translation the translation + */ + public Builder(String translation) { + this.translation = translation; + } + + /** + * Builds a Translation. + * + * @return the new Translation instance + */ + public Translation build() { + return new Translation(this); + } + + /** + * Set the translation. + * + * @param translation the translation + * @return the Translation builder + */ + public Builder translation(String translation) { + this.translation = translation; + return this; + } + + /** + * Set the partOfSpeech. + * + * @param partOfSpeech the partOfSpeech + * @return the Translation builder + */ + public Builder partOfSpeech(String partOfSpeech) { + this.partOfSpeech = partOfSpeech; + return this; + } + } + + protected Translation() {} + + protected Translation(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull( + builder.translation, "translation cannot be null"); + translation = builder.translation; + partOfSpeech = builder.partOfSpeech; + } + + /** + * New builder. + * + * @return a Translation builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * 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. + * + * @return the translation + */ + public String translation() { + return 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). + * + * @return the partOfSpeech + */ + public String partOfSpeech() { + return 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/Voice.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java new file mode 100644 index 00000000000..83c6966203a --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voice.java @@ -0,0 +1,125 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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. */ +public class Voice extends GenericModel { + + protected String url; + protected String gender; + protected String name; + protected String language; + protected String description; + protected Boolean customizable; + + @SerializedName("supported_features") + protected SupportedFeatures supportedFeatures; + + protected CustomModel customization; + + protected Voice() {} + + /** + * Gets the url. + * + *

The URI of the voice. + * + * @return the url + */ + public String getUrl() { + return url; + } + + /** + * Gets the gender. + * + *

The gender of the voice: `male` or `female`. + * + * @return the gender + */ + public String getGender() { + return gender; + } + + /** + * Gets the name. + * + *

The name of the voice. Use this as the voice identifier in all requests. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Gets the language. + * + *

The language and region of the voice (for example, `en-US`). + * + * @return the language + */ + public String getLanguage() { + return language; + } + + /** + * Gets the description. + * + *

A textual description of the voice. + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Gets the customizable. + * + *

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 + */ + public Boolean isCustomizable() { + return customizable; + } + + /** + * Gets the supportedFeatures. + * + *

Additional service features that are supported with the voice. + * + * @return the supportedFeatures + */ + public SupportedFeatures getSupportedFeatures() { + return supportedFeatures; + } + + /** + * Gets the customization. + * + *

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 CustomModel getCustomization() { + return customization; + } +} 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 new file mode 100644 index 00000000000..0d8d23cddc9 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Voices.java @@ -0,0 +1,36 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.List; + +/** Information about all available voices. */ +public class Voices extends GenericModel { + + protected List voices; + + protected Voices() {} + + /** + * Gets the voices. + * + *

A list of available voices. + * + * @return the voices + */ + public List getVoices() { + return 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 new file mode 100644 index 00000000000..122155a54b6 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Word.java @@ -0,0 +1,205 @@ +/* + * (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.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 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). + */ + public interface PartOfSpeech { + /** Dosi. */ + String DOSI = "Dosi"; + /** Fuku. */ + String FUKU = "Fuku"; + /** Gobi. */ + String GOBI = "Gobi"; + /** Hoka. */ + String HOKA = "Hoka"; + /** Jodo. */ + String JODO = "Jodo"; + /** Josi. */ + String JOSI = "Josi"; + /** Kato. */ + String KATO = "Kato"; + /** Kedo. */ + String KEDO = "Kedo"; + /** Keyo. */ + String KEYO = "Keyo"; + /** Kigo. */ + String KIGO = "Kigo"; + /** Koyu. */ + String KOYU = "Koyu"; + /** Mesi. */ + String MESI = "Mesi"; + /** Reta. */ + String RETA = "Reta"; + /** Stbi. */ + String STBI = "Stbi"; + /** Stto. */ + String STTO = "Stto"; + /** Stzo. */ + String STZO = "Stzo"; + /** Suji. */ + String SUJI = "Suji"; + } + + protected String word; + protected String translation; + + @SerializedName("part_of_speech") + protected String partOfSpeech; + + /** 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 with required properties. + * + * @param word the word + * @param translation the translation + */ + public Builder(String word, String translation) { + this.word = word; + this.translation = translation; + } + + /** + * Builds a Word. + * + * @return the new Word instance + */ + public Word build() { + return new Word(this); + } + + /** + * Set the word. + * + * @param word the word + * @return the Word builder + */ + public Builder word(String word) { + this.word = word; + return this; + } + + /** + * Set the translation. + * + * @param translation the translation + * @return the Word builder + */ + public Builder translation(String translation) { + this.translation = translation; + return this; + } + + /** + * Set the partOfSpeech. + * + * @param partOfSpeech the partOfSpeech + * @return the Word builder + */ + public Builder partOfSpeech(String partOfSpeech) { + this.partOfSpeech = partOfSpeech; + return this; + } + } + + 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"); + word = builder.word; + translation = builder.translation; + partOfSpeech = builder.partOfSpeech; + } + + /** + * New builder. + * + * @return a Word builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the word. + * + *

The word for the custom model. The maximum length of a word is 49 characters. + * + * @return the word + */ + public String word() { + return 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 maximum length of a translation is 499 characters. + * + * @return the translation + */ + public String translation() { + return 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). + * + * @return the partOfSpeech + */ + public String partOfSpeech() { + return partOfSpeech; + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java new file mode 100644 index 00000000000..ff0329d6e25 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/WordTiming.java @@ -0,0 +1,36 @@ +package com.ibm.watson.text_to_speech.v1.model; + +import com.google.gson.annotations.JsonAdapter; +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import com.ibm.watson.text_to_speech.v1.util.WordTimingTypeAdapter; + +@JsonAdapter(WordTimingTypeAdapter.class) +public class WordTiming extends GenericModel { + private String word; + private Double startTime; + private Double endTime; + + public String getWord() { + return word; + } + + public Double getStartTime() { + return startTime; + } + + public Double getEndTime() { + return endTime; + } + + public void setWord(String word) { + this.word = word; + } + + public void setStartTime(Double startTime) { + this.startTime = startTime; + } + + public void setEndTime(Double endTime) { + this.endTime = endTime; + } +} 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 new file mode 100644 index 00000000000..2ad52030012 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/model/Words.java @@ -0,0 +1,124 @@ +/* + * (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.text_to_speech.v1.model; + +import com.ibm.cloud.sdk.core.service.model.GenericModel; +import java.util.ArrayList; +import java.util.List; + +/** + * 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](#listwords) method, the words and their translations from the + * custom model. + */ +public class Words extends GenericModel { + + protected List words; + + /** 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 with required properties. + * + * @param words the words + */ + public Builder(List words) { + this.words = words; + } + + /** + * Builds a Words. + * + * @return the new Words instance + */ + public Words build() { + return new Words(this); + } + + /** + * Adds a new element to words. + * + * @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"); + if (this.words == null) { + this.words = new ArrayList(); + } + this.words.add(word); + return this; + } + + /** + * Set the words. Existing words will be replaced. + * + * @param words the words + * @return the Words builder + */ + public Builder words(List words) { + this.words = words; + return this; + } + } + + protected Words() {} + + protected Words(Builder builder) { + com.ibm.cloud.sdk.core.util.Validator.notNull(builder.words, "words cannot be null"); + words = builder.words; + } + + /** + * New builder. + * + * @return a Words builder + */ + public Builder newBuilder() { + return new Builder(this); + } + + /** + * Gets the words. + * + *

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](#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 + */ + public List words() { + return 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 new file mode 100644 index 00000000000..276bcf449e5 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/package-info.java @@ -0,0 +1,15 @@ +/* + * (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. + */ + +/** 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 new file mode 100644 index 00000000000..c7e748c978f --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/MarkTimingTypeAdapter.java @@ -0,0 +1,50 @@ +package com.ibm.watson.text_to_speech.v1.util; + +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.text_to_speech.v1.model.MarkTiming; +import java.io.IOException; + +public class MarkTimingTypeAdapter extends TypeAdapter { + /* + * (non-Javadoc) + * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader) + */ + @Override + public MarkTiming read(JsonReader in) throws IOException { + if (in.peek() == JsonToken.NULL) { + in.nextNull(); + return null; + } + + final MarkTiming markTiming = new MarkTiming(); + in.beginArray(); + + if (in.peek() == JsonToken.STRING) { + markTiming.setMark(in.nextString()); + } + if (in.peek() == JsonToken.NUMBER) { + markTiming.setTime(in.nextDouble()); + } + + in.endArray(); + return markTiming; + } + + /* + * (non-Javadoc) + * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) + */ + @Override + public void write(JsonWriter out, MarkTiming markTiming) throws IOException { + out.beginArray(); + + out.value(markTiming.getMark()); + out.value(markTiming.getTime()); + + out.endArray(); + out.flush(); + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/util/WaveUtils.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java similarity index 88% rename from text-to-speech/src/main/java/com/ibm/watson/developer_cloud/text_to_speech/v1/util/WaveUtils.java rename to text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WaveUtils.java index 84f37dfe59d..55d97710a3b 100644 --- a/text-to-speech/src/main/java/com/ibm/watson/developer_cloud/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 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. +/* + * (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 @@ -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.developer_cloud.text_to_speech.v1.util; +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; -import com.ibm.watson.developer_cloud.text_to_speech.v1.TextToSpeech; - /** - * 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 new file mode 100644 index 00000000000..775d801e7d7 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/util/WordTimingTypeAdapter.java @@ -0,0 +1,54 @@ +package com.ibm.watson.text_to_speech.v1.util; + +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.text_to_speech.v1.model.WordTiming; +import java.io.IOException; + +public class WordTimingTypeAdapter extends TypeAdapter { + /* + * (non-Javadoc) + * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader) + */ + @Override + public WordTiming read(JsonReader in) throws IOException { + if (in.peek() == JsonToken.NULL) { + in.nextNull(); + return null; + } + + final WordTiming wordTiming = new WordTiming(); + in.beginArray(); + + if (in.peek() == JsonToken.STRING) { + wordTiming.setWord(in.nextString()); + } + if (in.peek() == JsonToken.NUMBER) { + wordTiming.setStartTime(in.nextDouble()); + } + if (in.peek() == JsonToken.NUMBER) { + wordTiming.setEndTime(in.nextDouble()); + } + + in.endArray(); + return wordTiming; + } + + /* + * (non-Javadoc) + * @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object) + */ + @Override + public void write(JsonWriter out, WordTiming wordTiming) throws IOException { + out.beginArray(); + + out.value(wordTiming.getWord()); + out.value(wordTiming.getStartTime()); + out.value(wordTiming.getEndTime()); + + out.endArray(); + out.flush(); + } +} 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 new file mode 100644 index 00000000000..09c54dc94c3 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/BaseSynthesizeCallback.java @@ -0,0 +1,71 @@ +package com.ibm.watson.text_to_speech.v1.websocket; + +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; + +public class BaseSynthesizeCallback implements SynthesizeCallback { + private static final Logger LOG = Logger.getLogger(BaseSynthesizeCallback.class.getName()); + + /* + * (non-Javadoc) + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onConnected() + */ + public void onConnected() {} + + /* + * (non-Javadoc) + * @see + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onError(java.lang + * .Exception) + */ + public void onError(Exception e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + } + + /* + * (non-Javadoc) + * @see + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onWarning(java.lang + * .Exception) + */ + public void onWarning(Exception e) { + LOG.log(Level.WARNING, e.getMessage(), e); + } + + /* + * (non-Javadoc) + * @see + * com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onDisconnected() + */ + public void onDisconnected() {} + + /* + * (non-Javadoc) + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onContentType() + */ + @Override + public void onContentType(String contentType) {} + + /* + * (non-Javadoc) + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onTimings() + */ + @Override + public void onTimings(Timings timings) {} + + /* + * (non-Javadoc) + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onMarks() + */ + @Override + public void onMarks(Marks marks) {} + + /* + * (non-Javadoc) + * @see com.ibm.watson.text_to_speech.v1.websocket.SynthesizeCallback#onAudioStream() + */ + @Override + 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 new file mode 100644 index 00000000000..6dced0b10ef --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/SynthesizeCallback.java @@ -0,0 +1,56 @@ +package com.ibm.watson.text_to_speech.v1.websocket; + +import com.ibm.watson.text_to_speech.v1.model.Marks; +import com.ibm.watson.text_to_speech.v1.model.Timings; + +public interface SynthesizeCallback { + /** Called when a WebSocket connection was made. */ + void onConnected(); + + /** + * Called when there is an error in the WebSocket connection. + * + * @param e the exception + */ + void onError(Exception e); + + /** + * Called when there is a warning in the WebSocket connection. + * + * @param e the exception + */ + void onWarning(Exception e); + + /** Called when a WebSocket connection was closed. */ + void onDisconnected(); + + /** + * Called when the service returns the type of audio it will be sending back. + * + * @param contentType the content type of the synthesized audio + */ + void onContentType(String contentType); + + /** + * Called when the service returns word timing information. + * + * @param timings array of words and their start and end times + */ + void onTimings(Timings timings); + + /** + * Called when the service returns SSML mark information. + * + * @param marks array of marks and their appearance times + */ + void onMarks(Marks marks); + + /** + * 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) + */ + 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 new file mode 100644 index 00000000000..a0284e07371 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/TextToSpeechWebSocketListener.java @@ -0,0 +1,177 @@ +package com.ibm.watson.text_to_speech.v1.websocket; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.ibm.cloud.sdk.core.util.GsonSingleton; +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; + +public class TextToSpeechWebSocketListener extends WebSocketListener { + private static final String TEXT_TO_WEB_SOCKET = "TextToWebSocketThread"; + private static final Gson GSON = GsonSingleton.getGsonWithoutPrettyPrinting(); + private static final Logger LOG = Logger.getLogger(TextToSpeechWebSocketListener.class.getName()); + + 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"; + private static final String ERROR = "error"; + private static final String WARNINGS = "warnings"; + private static final String BINARY_STREAMS = "binary_streams"; + private static final String CONTENT_TYPE = "content_type"; + private static final String WORDS = "words"; + private static final String MARKS = "marks"; + + private final SynthesizeOptions options; + private final SynthesizeCallback callback; + private WebSocket socket; + private boolean socketOpen = true; + + public TextToSpeechWebSocketListener( + final SynthesizeOptions options, final SynthesizeCallback callback) { + this.options = options; + this.callback = callback; + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onClosing(okhttp3.WebSocket, int, java.lang.String) + */ + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + socketOpen = false; + callback.onDisconnected(); + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onFailure(okhttp3.WebSocket, java.lang.Throwable, okhttp3.Response) + */ + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + socketOpen = false; + if (t instanceof Exception) { + callback.onError((Exception) t); + } else { + callback.onError(new Exception(t)); + } + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onMessage(okhttp3.WebSocket, java.lang.String) + */ + @Override + public void onMessage(WebSocket webSocket, String message) { + JsonObject json = new JsonParser().parse(message).getAsJsonObject(); + if (json.has(ERROR)) { + String error = json.get(ERROR).getAsString(); + callback.onError(new RuntimeException(error)); + + } else if (json.has(WARNINGS)) { + 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(); + callback.onContentType(contentType); + } else if (json.has(WORDS)) { + callback.onTimings(GSON.fromJson(message, Timings.class)); + } else if (json.has(MARKS)) { + callback.onMarks(GSON.fromJson(message, Marks.class)); + } + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onMessage(okhttp3.WebSocket, okio.ByteString) + */ + @Override + public void onMessage(WebSocket webSocket, ByteString bytes) { + callback.onAudioStream(bytes.toByteArray()); + } + + /* + * (non-Javadoc) + * @see okhttp3.WebSocketListener#onOpen(okhttp3.WebSocket, okhttp3.Response) + */ + @Override + public void onOpen(final WebSocket webSocket, Response response) { + callback.onConnected(); + this.socket = webSocket; + if (!this.socket.send(buildStartMessage(this.options))) { + callback.onError(new IOException("WebSocket unavailable")); + } else { + new Thread(TEXT_TO_WEB_SOCKET) { + @Override + public void run() { + sendText(); + if (socketOpen && !socket.send(buildStopMessage())) { + LOG.log(Level.SEVERE, "Stop message discarded because WebSocket is unavailable"); + } + } + }; + } + } + + private void sendText() { + try { + while (socketOpen) { + socket.send(this.options.text()); + } + } catch (Exception e) { + LOG.log(Level.SEVERE, e.getMessage(), e); + } + } + + /** + * Builds the start message. + * + * @param options the options + * @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(); + + // 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(); + } + + /** + * Builds the stop message. + * + * @return the string + */ + private String buildStopMessage() { + JsonObject stopMessage = new JsonObject(); + stopMessage.addProperty(ACTION, STOP); + return stopMessage.toString(); + } +} diff --git a/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/package-info.java b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/package-info.java new file mode 100644 index 00000000000..c8fdb4744d9 --- /dev/null +++ b/text-to-speech/src/main/java/com/ibm/watson/text_to_speech/v1/websocket/package-info.java @@ -0,0 +1,16 @@ +/* + * (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. + */ +/** + * This package contains interfaces and implementations to work with WebSockets in Text to Speech. + */ +package com.ibm.watson.text_to_speech.v1.websocket; diff --git a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsIT.java b/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsIT.java deleted file mode 100755 index e6dc6544b3c..00000000000 --- a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsIT.java +++ /dev/null @@ -1,514 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.google.common.collect.ImmutableList; -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.service.exception.UnauthorizedException; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words; -import com.ibm.watson.developer_cloud.util.TestUtils; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -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. - */ -public class CustomizationsIT extends WatsonServiceTest { - - private TextToSpeech service; - - private static final String MODEL_NAME = "test model"; - private static final String MODEL_LANGUAGE = "en-US"; - private static final String MODEL_LANGUAGE_JAPANESE = "ja-JP"; - private static final String MODEL_DESCRIPTION = "a simple model for testing purposes"; - - private VoiceModel model; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("text_to_speech.username"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new TextToSpeech(); - service.setUsernameAndPassword(username, getProperty("text_to_speech.password")); - service.setEndPoint(getProperty("text_to_speech.url")); - service.setDefaultHeaders(getDefaultHeaders()); - } - - private List instantiateWords() { - Word word1 = new Word(); - word1.setWord("hodor"); - word1.setTranslation("hold the door"); - Word word2 = new Word(); - word2.setWord("shocking"); - word2.setTranslation(""); - return ImmutableList.of(word1, word2); - } - - private List instantiateWordsJapanese() { - Word word1 = new Word(); - word1.setWord("hodor"); - word1.setTranslation("hold the door"); - word1.setPartOfSpeech(Word.PartOfSpeech.JOSI); - Word word2 = new Word(); - word2.setWord("clodor"); - word2.setTranslation("close the door"); - word2.setPartOfSpeech(Word.PartOfSpeech.HOKA); - return ImmutableList.of(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(); - } - - private VoiceModel createVoiceModelJapanese() { - CreateVoiceModelOptions createOptions = new CreateVoiceModelOptions.Builder() - .name(MODEL_NAME) - .language(MODEL_LANGUAGE_JAPANESE) - .description(MODEL_DESCRIPTION) - .build(); - return service.createVoiceModel(createOptions).execute(); - } - - private void assertModelsEqual(VoiceModel a, VoiceModel b) { - assertEquals(a.getCustomizationId(), b.getCustomizationId()); - GetVoiceModelOptions getOptionsA = new GetVoiceModelOptions.Builder() - .customizationId(a.getCustomizationId()) - .build(); - assertEquals((service.getVoiceModel(getOptionsA).execute()).getName(), b.getName()); - assertEquals((service.getVoiceModel(getOptionsA).execute()).getLanguage(), b.getLanguage()); - } - - /** - * 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(); - } catch (Exception e) { - // Exceptions are fine in the clean up method - } - } - } - - /** - * Test create voice model. - */ - @Test - public void testCreateVoiceModel() { - model = createVoiceModel(); - - assertNotNull(model.getCustomizationId()); - } - - /** - * Test create voice model for Japanese. - */ - @Test - public void testCreateVoiceModelJapanese() { - model = createVoiceModelJapanese(); - - assertNotNull(model.getCustomizationId()); - } - - /** - * Test get voice model. - */ - @Test - public void testGetVoiceModelString() { - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getOptions).execute(); - - assertNotNull(model2); - assertModelsEqual(model, model2); - assertNotNull(model2.getOwner()); - assertNotNull(model2.getCreated()); - assertNotNull(model2.getLastModified()); - } - - /** - * Test get voice model. - */ - @Test - public void testGetVoiceModelObject() { - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getOptions).execute(); - - assertNotNull(model2); - assertModelsEqual(model, model2); - assertNotNull(model2.getOwner()); - assertNotNull(model2.getCreated()); - assertNotNull(model2.getLastModified()); - } - - /** - * Test get voice with customization. - */ - @Test - public void testGetVoiceCustomization() { - model = createVoiceModel(); - GetVoiceModelOptions getVoiceModelOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final VoiceModel model2 = service.getVoiceModel(getVoiceModelOptions).execute(); - GetVoiceOptions getVoiceOptions = new GetVoiceOptions.Builder() - .customizationId(model.getCustomizationId()) - .voice(GetVoiceOptions.Voice.EN_US_ALLISONVOICE) - .build(); - final Voice voice = service.getVoice(getVoiceOptions).execute(); - - assertNotNull(model); - assertNotNull(model2); - assertNotNull(voice); - assertEquals(model2.getCustomizationId(), voice.getCustomization().getCustomizationId()); - assertEquals(model2.getName(), voice.getCustomization().getName()); - assertEquals(model2.getDescription(), voice.getCustomization().getDescription()); - assertEquals(model2.getLanguage(), voice.getCustomization().getLanguage()); - assertEquals(model2.getOwner(), voice.getCustomization().getOwner()); - assertEquals(model2.getCreated(), voice.getCustomization().getCreated()); - assertEquals(model2.getLastModified(), voice.getCustomization().getLastModified()); - } - - /** - * Test update voice model with new name and ignored language change. - */ - @Test - public void testUpdateVoiceModel() { - final String newName = "new test"; - final String newLanguage = "pt-BR"; - - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - model = service.getVoiceModel(getOptions).execute(); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .name(newName) - .build(); - service.updateVoiceModel(updateOptions).execute(); - - final VoiceModel model2 = service.getVoiceModel(getOptions).execute(); - 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 - public void testUpdateVoiceModelWords() { - final String newName = "new test"; - - model = createVoiceModel(); - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - model = service.getVoiceModel(getOptions).execute(); - UpdateVoiceModelOptions updateOptions = new UpdateVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .name(newName) - .words(instantiateWords()) - .build(); - service.updateVoiceModel(updateOptions).execute(); - - final VoiceModel model2 = service.getVoiceModel(getOptions).execute(); - assertModelsEqual(model, model2); - assertNotEquals(model.getWords(), model2.getWords()); - } - - /** - * Test delete voice model. - */ - @Test - public void testDeleteVoiceModel() { - model = createVoiceModel(); - - DeleteVoiceModelOptions deleteOptions = new DeleteVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - service.deleteVoiceModel(deleteOptions).execute(); - - try { - GetVoiceModelOptions getOptions = new GetVoiceModelOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - service.getVoiceModel(getOptions).execute(); - fail("deleting customization failed"); - } catch (UnauthorizedException e) { - // success! - } - } - - /** - * Test list models. - */ - @Test - public void testListModels() { - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language(MODEL_LANGUAGE) - .build(); - service.listVoiceModels(listOptions); - service.listVoiceModels(); - } - - /** - * Test list models after create. - */ - @Test - public void testListModelsAfterCreate() { - model = createVoiceModel(); - ListVoiceModelsOptions listOptions = new ListVoiceModelsOptions.Builder() - .language(model.getLanguage()) - .build(); - final VoiceModels models = service.listVoiceModels(listOptions).execute(); - VoiceModel model2 = null; - - for (VoiceModel m : models.getCustomizations()) { - if (m.getCustomizationId().equals(model.getCustomizationId())) { - model2 = m; - break; - } - } - - assertNotNull(model2); - assertModelsEqual(model, model2); - } - - /** - * Test add word. - */ - @Test - public void testAddWord() { - model = createVoiceModel(); - final Word expected = instantiateWords().get(0); - - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.getWord()) - .translation(expected.getTranslation()) - .customizationId(model.getCustomizationId()) - .build(); - service.addWord(addOptions).execute(); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final Words results = service.listWords(listOptions).execute(); - assertEquals(1, results.getWords().size()); - - final Word result = results.getWords().get(0); - assertEquals(expected, result); - assertEquals(expected.getWord(), result.getWord()); - assertEquals(expected.getTranslation(), result.getTranslation()); - } - - /** - * Test add words and list words. - */ - @Test - public void testAddWords() { - model = createVoiceModel(); - final List expected = instantiateWords(); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); - service.addWords(addOptions).execute(); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final Words words = service.listWords(listOptions).execute(); - assertEquals(expected.size(), words.getWords().size()); - } - - /** - * Test add words and list words for Japanese. - */ - @Test - public void testAddWordsJapanese() { - model = createVoiceModelJapanese(); - final List expected = instantiateWordsJapanese(); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); - service.addWords(addOptions).execute(); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final Words words = service.listWords(listOptions).execute(); - assertEquals(expected.size(), words.getWords().size()); - } - - /** - * Test get word. - */ - @Test - public void testGetWord() { - model = createVoiceModel(); - final List expected = instantiateWords(); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); - service.addWords(addOptions).execute(); - - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.get(0).getWord()) - .build(); - final Translation translation = service.getWord(getOptions).execute(); - assertEquals(expected.get(0).getTranslation(), translation.getTranslation()); - } - - /** - * Test get word for Japanese. - */ - @Test - public void testGetWordJapanese() { - model = createVoiceModelJapanese(); - final List expected = instantiateWordsJapanese(); - - AddWordsOptions addOptions = new AddWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .words(expected) - .build(); - service.addWords(addOptions).execute(); - - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.get(0).getWord()) - .build(); - final Translation translation = service.getWord(getOptions).execute(); - assertEquals(expected.get(0).getTranslation(), translation.getTranslation()); - assertEquals(expected.get(0).getPartOfSpeech(), translation.getPartOfSpeech()); - } - - /** - * Test delete word with string. - */ - @Test - public void testDeleteWord() { - model = createVoiceModel(); - final Word expected = instantiateWords().get(0); - - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.getWord()) - .translation(expected.getTranslation()) - .customizationId(model.getCustomizationId()) - .build(); - service.addWord(addOptions).execute(); - DeleteWordOptions deleteOptions = new DeleteWordOptions.Builder() - .customizationId(model.getCustomizationId()) - .word(expected.getWord()) - .build(); - service.deleteWord(deleteOptions).execute(); - - ListWordsOptions listOptions = new ListWordsOptions.Builder() - .customizationId(model.getCustomizationId()) - .build(); - final Words results = service.listWords(listOptions).execute(); - assertEquals(0, results.getWords().size()); - } - - /** - * Test synthesize. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testSynthesize() throws IOException { - model = createVoiceModel(); - final Word expected = instantiateWords().get(0); - - AddWordOptions addOptions = new AddWordOptions.Builder() - .word(expected.getWord()) - .translation(expected.getTranslation()) - .customizationId(model.getCustomizationId()) - .build(); - service.addWord(addOptions).execute(); - SynthesizeOptions synthesizeOptions1 = new SynthesizeOptions.Builder() - .text(expected.getWord()) - .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) - .accept(SynthesizeOptions.Accept.AUDIO_WAV) - .build(); - final InputStream stream1 = service.synthesize(synthesizeOptions1).execute(); - SynthesizeOptions synthesizeOptions2 = new SynthesizeOptions.Builder() - .text(expected.getWord()) - .voice(SynthesizeOptions.Voice.EN_US_MICHAELVOICE) - .accept(SynthesizeOptions.Accept.AUDIO_WAV) - .customizationId(model.getCustomizationId()) - .build(); - final InputStream stream2 = service.synthesize(synthesizeOptions2).execute(); - - assertFalse(TestUtils.streamContentEquals(stream1, stream2)); - } - -} diff --git a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsTest.java b/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsTest.java deleted file mode 100755 index 09c32e32137..00000000000 --- a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/CustomizationsTest.java +++ /dev/null @@ -1,454 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.AddWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.CreateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetWordOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListVoiceModelsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.ListWordsOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Translation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.UpdateVoiceModelOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModel; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.VoiceModels; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Word; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Words; -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. - */ -public class CustomizationsTest extends WatsonServiceUnitTest { - - private static final String VOICES_PATH = "/v1/voices"; - private static final String VOICE_MODELS_PATH = "/v1/customizations"; - private static final String VOICE_MODEL_PATH = VOICE_MODELS_PATH + "/%s"; - private static final String WORDS_PATH = VOICE_MODELS_PATH + "/%s/words"; - private static final String WORD_PATH = WORDS_PATH + "/%s"; - - private static final String MODEL_NAME = "test model"; - private static final String MODEL_LANGUAGE = "en-US"; - private static final String MODEL_DESCRIPTION = "a simple model for testing purposes"; - - private static final String WORDS = "words"; - private static final String TRANSLATION = "translation"; - - private static final String CUSTOMIZATION_ID = "cafebabe-1234-5678-9abc-def012345678"; - - private VoiceModel voiceModel; - private VoiceModel voiceModelWords; - private VoiceModels voiceModels; - private Voice voice; - - /** The service. */ - private TextToSpeech service; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new TextToSpeech(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(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); - voice = loadFixture("src/test/resources/text_to_speech/voice.json", Voice.class); - } - - private static List instantiateWords() { - Word word = new Word(); - word.setWord("hodor"); - word.setTranslation("hold the door"); - return ImmutableList.of(word); - } - - private static Word instantiateWord() { - Word word = new Word(); - word.setWord("hodor"); - word.setTranslation("hold the door"); - return word; - } - - /** - * Test get voice with custom voice model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - final Voice result = service.getVoice(getOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(VOICES_PATH + "/en-US_TestMaleVoice?customization_id=" + CUSTOMIZATION_ID, - request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(voice, result); - } - - /** - * Test list voice models for null language. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testListVoiceModelsNull() throws InterruptedException { - server.enqueue(jsonResponse(voiceModels)); - - final VoiceModels result = service.listVoiceModels().execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(VOICE_MODELS_PATH, request.getPath()); - assertEquals("GET", request.getMethod()); - assertFalse(voiceModels.getCustomizations().isEmpty()); - assertEquals(voiceModels, result); - } - - /** - * Test list voice models for a language. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(VOICE_MODELS_PATH + "?language=" + MODEL_LANGUAGE, request.getPath()); - assertEquals("GET", request.getMethod()); - assertFalse(result.getCustomizations().isEmpty()); - assertEquals(voiceModels, result); - } - - /** - * Test get voice model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(voiceModelWords, result); - assertNotNull(voiceModelWords.getWords()); - assertEquals(voiceModelWords.getWords(), result.getWords()); - } - - /** - * Test create voice model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(VOICE_MODELS_PATH, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(CUSTOMIZATION_ID, result.getCustomizationId()); - - // 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(); - final RecordedRequest getRequest = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); - assertEquals("GET", getRequest.getMethod()); - assertEquals(voiceModel, getResult); - assertNull(voiceModel.getWords()); - assertEquals(voiceModel.getWords(), getResult.getWords()); - - } - - /** - * Test update voice model. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - - 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(); - final RecordedRequest updateRequest = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath()); - assertEquals("POST", request.getMethod()); - - // 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(); - final RecordedRequest getRequest = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); - assertEquals("GET", getRequest.getMethod()); - assertEquals(voiceModel, getResult); - assertNull(voiceModel.getWords()); - assertEquals(voiceModel.getWords(), getResult.getWords()); - } - - /** - * Test update voice model with new words. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - 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(); - final RecordedRequest updateRequest = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), updateRequest.getPath()); - assertEquals("POST", request.getMethod()); - - // 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(); - final RecordedRequest getRequest = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), getRequest.getPath()); - assertEquals("GET", getRequest.getMethod()); - assertEquals(voiceModelWords, getResult); - assertNotNull(voiceModelWords.getWords()); - assertEquals(voiceModelWords.getWords(), getResult.getWords()); - } - - /** - * Test delete voice model. - * - * @throws InterruptedException the interrupted exception - */ - @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(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(VOICE_MODEL_PATH, CUSTOMIZATION_ID), request.getPath()); - assertEquals("DELETE", request.getMethod()); - } - - /** - * Test list words. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - final Words result = service.listWords(listOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(expected, result.getWords()); - } - - /** - * Test get word. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testGetWord() throws InterruptedException { - final Word expected = instantiateWords().get(0); - - server.enqueue(jsonResponse(ImmutableMap.of(TRANSLATION, expected.getTranslation()))); - GetWordOptions getOptions = new GetWordOptions.Builder() - .customizationId(CUSTOMIZATION_ID) - .word(expected.getWord()) - .build(); - final Translation result = service.getWord(getOptions).execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID) + "/" + expected.getWord(), request.getPath()); - assertEquals("GET", request.getMethod()); - assertEquals(expected.getTranslation(), result.getTranslation()); - } - - /** - * Test add words. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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(); - service.addWords(addOptions).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath()); - assertEquals("POST", request.getMethod()); - } - - /** - * Test add word. - * - * @throws InterruptedException the interrupted exception - */ - @Test - 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.getWord()) - .translation(expected.getTranslation()) - .build(); - service.addWord(addOptions).execute(); - RecordedRequest request = server.takeRequest(); - - assertEquals(String.format(WORD_PATH, CUSTOMIZATION_ID, expected.getWord()), request.getPath()); - assertEquals("PUT", request.getMethod()); - } - - /** - * Test delete word. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDeleteWord() throws InterruptedException { - final String expected = instantiateWords().get(0).getWord(); - - server.enqueue(new MockResponse().setResponseCode(204)); - 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/developer_cloud/text_to_speech/v1/TextToSpeechIT.java b/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java deleted file mode 100644 index dba97cccd14..00000000000 --- a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechIT.java +++ /dev/null @@ -1,194 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetPronunciationOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Pronunciation; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voices; -import com.ibm.watson.developer_cloud.text_to_speech.v1.util.WaveUtils; -import com.ibm.watson.developer_cloud.util.RetryRunner; -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.File; -import java.io.IOException; -import java.io.InputStream; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -/** - * Text to Speech integration tests. - */ -@RunWith(RetryRunner.class) -public class TextToSpeechIT extends WatsonServiceTest { - - private TextToSpeech service; - private String voiceName; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String username = getProperty("text_to_speech.username"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new TextToSpeech(); - service.setUsernameAndPassword(username, getProperty("text_to_speech.password")); - service.setEndPoint(getProperty("text_to_speech.url")); - service.setDefaultHeaders(getDefaultHeaders()); - voiceName = getProperty("text_to_speech.voice_name"); - } - - /** - * Test list voices. - */ - @Test - public void testListVoices() { - Voices voices = service.listVoices().execute(); - assertNotNull(voices); - assertTrue(!voices.getVoices().isEmpty()); - assertNotNull(voices.getVoices().get(0).getDescription()); - assertNotNull(voices.getVoices().get(0).getGender()); - assertNotNull(voices.getVoices().get(0).getLanguage()); - assertNotNull(voices.getVoices().get(0).getName()); - assertNotNull(voices.getVoices().get(0).getUrl()); - } - - /** - * Test get voice. - */ - @Test - public void testGetVoice() { - GetVoiceOptions getOptions = new GetVoiceOptions.Builder() - .voice(voiceName) - .build(); - Voice voice = service.getVoice(getOptions).execute(); - assertNotNull(voice); - assertNotNull(voice.getDescription()); - assertNotNull(voice.getGender()); - assertNotNull(voice.getLanguage()); - assertNotNull(voice.getName()); - assertNotNull(voice.getUrl()); - } - - /** - * Synthesize text and write it to a temporary file. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @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(SynthesizeOptions.Accept.AUDIO_WAV) - .build(); - InputStream result = service.synthesize(synthesizeOptions).execute(); - writeInputStreamToFile(result, File.createTempFile("tts-audio", "wav")); - } - - /** - * 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(); - Pronunciation pronunciation = service.getPronunciation(getOptions1).execute(); - assertNotNull(pronunciation); - assertNotNull(pronunciation.getPronunciation()); - - GetPronunciationOptions getOptions2 = new GetPronunciationOptions.Builder() - .text(word) - .format(GetPronunciationOptions.Format.IBM) - .build(); - pronunciation = service.getPronunciation(getOptions2).execute(); - assertNotNull(pronunciation); - assertNotNull(pronunciation.getPronunciation()); - - GetPronunciationOptions getOptions3 = new GetPronunciationOptions.Builder() - .text(word) - .voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE) - .build(); - pronunciation = service.getPronunciation(getOptions3).execute(); - assertNotNull(pronunciation); - assertNotNull(pronunciation.getPronunciation()); - - GetPronunciationOptions getOptions4 = new GetPronunciationOptions.Builder() - .text(word) - .voice(GetPronunciationOptions.Voice.EN_US_MICHAELVOICE) - .format(GetPronunciationOptions.Format.IPA) - .build(); - pronunciation = service.getPronunciation(getOptions4).execute(); - assertNotNull(pronunciation); - assertNotNull(pronunciation.getPronunciation()); - - } - - /** - * 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 - 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(SynthesizeOptions.Accept.AUDIO_WAV) - .build(); - InputStream result = service.synthesize(synthesizeOptions).execute(); - assertNotNull(result); - result = WaveUtils.reWriteWaveHeader(result); - File tempFile = File.createTempFile("output", ".wav"); - writeInputStreamToFile(result, tempFile); - assertNotNull(AudioSystem.getAudioFileFormat(tempFile)); - } - - @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/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechTest.java b/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechTest.java deleted file mode 100644 index 882bba25cb3..00000000000 --- a/text-to-speech/src/test/java/com/ibm/watson/developer_cloud/text_to_speech/v1/TextToSpeechTest.java +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.text_to_speech.v1; - -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.GetVoiceOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.SynthesizeOptions; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voice; -import com.ibm.watson.developer_cloud.text_to_speech.v1.model.Voices; -import com.ibm.watson.developer_cloud.text_to_speech.v1.util.WaveUtils; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.TestUtils; -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 java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -/** - * 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(); - } - } - - /** The service. */ - private TextToSpeech service; - - /** The text. */ - private final String text = "IBM Watson Developer Cloud"; - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - - service = new TextToSpeech(); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - 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); - } - - /** - * Test list voices. - * - * @throws InterruptedException the interrupted exception - */ - @Test - public void testListVoices() throws InterruptedException { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(listVoicesResponse))); - - final Voices result = service.listVoices().execute(); - final RecordedRequest request = server.takeRequest(); - - assertEquals(GET_VOICES_PATH, request.getPath()); - assertNotNull(result); - assertFalse(result.getVoices().isEmpty()); - assertEquals(listVoicesResponse.getVoices(), result.getVoices()); - } - - /** - * Test get voice. - */ - @Test - public void testGetVoice() { - server.enqueue(new MockResponse() - .addHeader(CONTENT_TYPE, HttpMediaType.APPLICATION_JSON) - .setBody(GSON.toJson(getVoiceResponse))); - - GetVoiceOptions getOptions = new GetVoiceOptions.Builder() - .voice("en-US_TestMaleVoice") - .build(); - Voice result = service.getVoice(getOptions).execute(); - assertNotNull(result); - assertEquals(result, getVoiceResponse); - - try { - TestUtils.assertNoExceptionsOnGetters(result); - } catch (final Exception e) { - Assert.fail(e.getMessage()); - } - } - - /** - * 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(); - 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(SynthesizeOptions.Accept.AUDIO_WEBM) - .build(); - final InputStream in = service.synthesize(synthesizeOptions).execute(); - 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(SynthesizeOptions.Accept.AUDIO_WAV) - .build(); - final InputStream is = service.synthesize(synthesizeOptions).execute(); - assertNotNull(is); - - try { - writeInputStreamToOutputStream(is, new FileOutputStream("target/output.wav")); - } catch (final FileNotFoundException e) { - Assert.fail(e.getMessage()); - } - - } - - /** - * 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 - 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)); - } - - @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/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 new file mode 100755 index 00000000000..22414a9e331 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsIT.java @@ -0,0 +1,496 @@ +/* + * (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.text_to_speech.v1; + +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.*; +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.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** Integration tests for the Speech to text customization API. */ +public class CustomizationsIT extends WatsonServiceTest { + + private TextToSpeech service; + + private static final String MODEL_NAME = "test model"; + private static final String MODEL_LANGUAGE = "en-US"; + private static final String MODEL_LANGUAGE_JAPANESE = "ja-JP"; + private static final String MODEL_DESCRIPTION = "a simple model for testing purposes"; + + private CustomModel model; + + /* + * (non-Javadoc) + * @see com.ibm.watson.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + 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(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 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 Collections.unmodifiableList(Arrays.asList(word1, word2)); + } + + 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 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(CustomModel a, CustomModel b) { + assertEquals(a.getCustomizationId(), b.getCustomizationId()); + 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. */ + @After + public void cleanUp() { + if ((model != null) && (model.getCustomizationId() != null)) { + try { + 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 + @Ignore + public void testCreateVoiceModel() { + model = createCustomModel(); + + assertNotNull(model.getCustomizationId()); + } + + /** Test create voice model for Japanese. */ + @Test + @Ignore + public void testCreateVoiceModelJapanese() { + model = createVoiceModelJapanese(); + + assertNotNull(model.getCustomizationId()); + } + + /** Test get voice model. */ + @Test + @Ignore + public void testGetVoiceModelString() { + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); + + assertNotNull(model2); + assertModelsEqual(model, model2); + assertNotNull(model2.getOwner()); + assertNotNull(model2.getCreated()); + assertNotNull(model2.getLastModified()); + } + + /** Test get voice model. */ + @Test + @Ignore + public void testGetVoiceModelObject() { + model = createCustomModel(); + GetCustomModelOptions getOptions = + new GetCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + final CustomModel model2 = service.getCustomModel(getOptions).execute().getResult(); + + assertNotNull(model2); + assertModelsEqual(model, model2); + assertNotNull(model2.getOwner()); + assertNotNull(model2.getCreated()); + assertNotNull(model2.getLastModified()); + } + + /** Test get voice with customization. */ + @Test + @Ignore + public void testGetVoiceCustomization() { + 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); + assertNotNull(model2); + assertNotNull(voice); + assertEquals(model2.getCustomizationId(), voice.getCustomization().getCustomizationId()); + assertEquals(model2.getName(), voice.getCustomization().getName()); + assertEquals(model2.getDescription(), voice.getCustomization().getDescription()); + assertEquals(model2.getLanguage(), voice.getCustomization().getLanguage()); + assertEquals(model2.getOwner(), voice.getCustomization().getOwner()); + assertEquals(model2.getCreated(), voice.getCustomization().getCreated()); + assertEquals(model2.getLastModified(), voice.getCustomization().getLastModified()); + } + + /** Test update voice model with new name and ignored language change. */ + @Test + @Ignore + public void testUpdateVoiceModel() { + final String newName = "new test"; + + 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 + @Ignore + public void testUpdateVoiceModelWords() { + final String newName = "new test"; + + 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 + @Ignore + public void testDeleteVoiceModel() { + model = createCustomModel(); + + DeleteCustomModelOptions deleteOptions = + new DeleteCustomModelOptions.Builder().customizationId(model.getCustomizationId()).build(); + service.deleteCustomModel(deleteOptions).execute(); + + try { + 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 + public void testListModels() { + ListCustomModelsOptions listOptions = + new ListCustomModelsOptions.Builder().language(MODEL_LANGUAGE).build(); + service.listCustomModels(listOptions); + service.listCustomModels(); + } + + /** Test list models after create. */ + @Test + @Ignore + public void testListModelsAfterCreate() { + 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; + } + } + + assertNotNull(model2); + assertModelsEqual(model, model2); + } + + /** Test add word. */ + @Test + @Ignore + public void testAddWord() { + model = createCustomModel(); + final Word expected = instantiateWords().get(0); + + 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(); + final Words results = service.listWords(listOptions).execute().getResult(); + assertEquals(1, results.words().size()); + + final Word result = results.words().get(0); + assertEquals(expected, result); + assertEquals(expected.word(), result.word()); + assertEquals(expected.translation(), result.translation()); + } + + /** Test add words and list words. */ + @Test + @Ignore + public void testAddWords() { + model = createCustomModel(); + final List expected = instantiateWords(); + + 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(); + final Words words = service.listWords(listOptions).execute().getResult(); + assertEquals(expected.size(), words.words().size()); + } + + /** 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(); + service.addWords(addOptions).execute().getResult(); + + 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 + @Ignore + public void testGetWord() { + model = createCustomModel(); + final List expected = instantiateWords(); + + 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(); + final Translation translation = service.getWord(getOptions).execute().getResult(); + assertEquals(expected.get(0).translation(), translation.translation()); + } + + /** 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(); + service.addWords(addOptions).execute().getResult(); + + 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 + @Ignore + public void testDeleteWord() { + model = createCustomModel(); + final Word expected = instantiateWords().get(0); + + 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(); + service.deleteWord(deleteOptions).execute(); + + ListWordsOptions listOptions = + new ListWordsOptions.Builder().customizationId(model.getCustomizationId()).build(); + final Words results = service.listWords(listOptions).execute().getResult(); + assertEquals(0, results.words().size()); + } + + /** + * Test synthesize. + * + * @throws IOException Signals that an I/O exception has occurred. + */ + @Test + @Ignore + public void testSynthesize() throws IOException { + model = createCustomModel(); + final Word expected = instantiateWords().get(0); + + 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_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_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 new file mode 100755 index 00000000000..75330adecd4 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/CustomizationsTest.java @@ -0,0 +1,440 @@ +/* + * (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.text_to_speech.v1; + +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.*; +import java.util.*; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.Before; +import org.junit.Test; + +/** Unit tests for the Speech to text customization API. */ +public class CustomizationsTest extends WatsonServiceUnitTest { + + private static final String VOICES_PATH = "/v1/voices"; + private static final String VOICE_MODELS_PATH = "/v1/customizations"; + private static final String VOICE_MODEL_PATH = VOICE_MODELS_PATH + "/%s"; + private static final String WORDS_PATH = VOICE_MODELS_PATH + "/%s/words"; + private static final String WORD_PATH = WORDS_PATH + "/%s"; + + private static final String MODEL_NAME = "test model"; + private static final String MODEL_LANGUAGE = "en-US"; + private static final String MODEL_DESCRIPTION = "a simple model for testing purposes"; + + private static final String WORDS = "words"; + private static final String TRANSLATION = "translation"; + + private static final String CUSTOMIZATION_ID = "cafebabe-1234-5678-9abc-def012345678"; + + private CustomModel voiceModel; + private CustomModel voiceModelWords; + private CustomModels voiceModels; + private Voice voice; + + /** The service. */ + private TextToSpeech service; + + /* + * (non-Javadoc) + * @see com.ibm.watson.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + + service = new TextToSpeech(new NoAuthAuthenticator()); + service.setServiceUrl(getMockWebServerUrl()); + + 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(); + } + + private static List instantiateWords() { + return Collections.unmodifiableList(Arrays.asList(instantiateWord())); + } + + /** + * Test get voice with custom voice model. + * + * @throws InterruptedException the interrupted exception + */ + @Test + 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(); + final Voice result = service.getVoice(getOptions).execute().getResult(); + final RecordedRequest request = server.takeRequest(); + + assertEquals( + VOICES_PATH + "/en-US_TestMaleVoice?customization_id=" + CUSTOMIZATION_ID, + request.getPath()); + assertEquals("GET", request.getMethod()); + assertEquals(voice, result); + } + + /** + * Test list voice models for null language. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testListVoiceModelsNull() throws InterruptedException { + server.enqueue(jsonResponse(voiceModels)); + + final CustomModels result = service.listCustomModels().execute().getResult(); + final RecordedRequest request = server.takeRequest(); + + assertEquals(VOICE_MODELS_PATH, request.getPath()); + assertEquals("GET", request.getMethod()); + assertFalse(voiceModels.getCustomizations().isEmpty()); + assertEquals(voiceModels, result); + } + + /** + * Test list voice models for a language. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testListVoiceModelsLanguage() throws InterruptedException { + server.enqueue(jsonResponse(voiceModels)); + + 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()); + assertEquals("GET", request.getMethod()); + assertFalse(result.getCustomizations().isEmpty()); + assertEquals(voiceModels, result); + } + + /** + * Test get voice model. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testGetVoiceModel() throws InterruptedException { + // Test with customization ID + server.enqueue(jsonResponse(voiceModelWords)); + + 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()); + assertEquals("GET", request.getMethod()); + assertEquals(voiceModelWords, result); + assertNotNull(voiceModelWords.getWords()); + assertEquals(voiceModelWords.getWords(), result.getWords()); + } + + /** + * Test create voice model. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testCreateVoiceModel() throws InterruptedException { + // Create the custom voice model. + server.enqueue(jsonResponse(voiceModel)); + + 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()); + assertEquals("POST", request.getMethod()); + assertEquals(CUSTOMIZATION_ID, result.getCustomizationId()); + + // Compare expected with actual results. + server.enqueue(jsonResponse(voiceModel)); + + 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()); + assertEquals("GET", getRequest.getMethod()); + assertEquals(voiceModel, getResult); + assertNull(voiceModel.getWords()); + assertEquals(voiceModel.getWords(), getResult.getWords()); + } + + /** + * Test update voice model. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testUpdateVoiceModel() throws InterruptedException { + // Create the custom voice model. + server.enqueue(jsonResponse(voiceModel)); + + 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)); + 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()); + assertEquals("POST", request.getMethod()); + + // Compare expected with actual results. + server.enqueue(jsonResponse(voiceModel)); + + 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()); + assertEquals("GET", getRequest.getMethod()); + assertEquals(voiceModel, getResult); + assertNull(voiceModel.getWords()); + assertEquals(voiceModel.getWords(), getResult.getWords()); + } + + /** + * Test update voice model with new words. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testUpdateVoiceModelWords() throws InterruptedException { + // Create the custom voice model. + server.enqueue(jsonResponse(voiceModelWords)); + + 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)); + 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()); + assertEquals("POST", request.getMethod()); + + // Compare expected with actual results. + server.enqueue(jsonResponse(voiceModelWords)); + + 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()); + assertEquals("GET", getRequest.getMethod()); + assertEquals(voiceModelWords, getResult); + assertNotNull(voiceModelWords.getWords()); + assertEquals(voiceModelWords.getWords(), getResult.getWords()); + } + + /** + * Test delete voice model. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testDeleteVoiceModel() throws InterruptedException { + server.enqueue(new MockResponse().setResponseCode(204)); + 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()); + assertEquals("DELETE", request.getMethod()); + } + + /** + * Test list words. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testListWords() throws InterruptedException { + final List expected = instantiateWords(); + + 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(); + + assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath()); + assertEquals("GET", request.getMethod()); + assertEquals(expected, result.words()); + } + + /** + * Test get word. + * + * @throws InterruptedException the interrupted exception + */ + @Test + public void testGetWord() throws InterruptedException { + final Word expected = instantiateWords().get(0); + + 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("GET", request.getMethod()); + assertEquals(expected.translation(), result.translation()); + } + + /** + * Test add words. + * + * @throws InterruptedException the interrupted exception + */ + @Test + 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(); + service.addWords(addOptions).execute().getResult(); + RecordedRequest request = server.takeRequest(); + + assertEquals(String.format(WORDS_PATH, CUSTOMIZATION_ID), request.getPath()); + assertEquals("POST", request.getMethod()); + } + + /** + * Test add word. + * + * @throws InterruptedException the interrupted exception + */ + @Test + 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(); + service.addWord(addOptions).execute().getResult(); + RecordedRequest request = server.takeRequest(); + + assertEquals(String.format(WORD_PATH, CUSTOMIZATION_ID, expected.word()), request.getPath()); + assertEquals("PUT", request.getMethod()); + } + + /** + * Test delete word. + * + * @throws InterruptedException the interrupted exception + */ + @Test + 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(); + 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 new file mode 100644 index 00000000000..8ac704c1099 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechIT.java @@ -0,0 +1,585 @@ +/* + * (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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 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; +import com.ibm.watson.text_to_speech.v1.model.Voices; +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 java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Collections; +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; + +/** Text to Speech integration tests. */ +@RunWith(RetryRunner.class) +public class TextToSpeechIT extends WatsonServiceTest { + + private CountDownLatch lock = new CountDownLatch(1); + private TextToSpeech service; + private String voiceName; + private ByteArrayOutputStream byteArrayOutputStream; + 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.common.WatsonServiceTest#setUp() + */ + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + 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(serviceUrl); + service.setDefaultHeaders(getDefaultHeaders()); + voiceName = "en-US_MichaelVoice"; + + byteArrayOutputStream = new ByteArrayOutputStream(); + returnedTimings = new ArrayList<>(); + returnedMarks = new ArrayList<>(); + } + + /** Test list voices. */ + @Test + public void testListVoices() { + Voices voices = service.listVoices().execute().getResult(); + assertNotNull(voices); + assertTrue(!voices.getVoices().isEmpty()); + assertNotNull(voices.getVoices().get(0).getDescription()); + assertNotNull(voices.getVoices().get(0).getGender()); + assertNotNull(voices.getVoices().get(0).getLanguage()); + assertNotNull(voices.getVoices().get(0).getName()); + assertNotNull(voices.getVoices().get(0).getUrl()); + } + + /** Test get voice. */ + @Test + public void testGetVoice() { + GetVoiceOptions getOptions = new GetVoiceOptions.Builder().voice(voiceName).build(); + Voice voice = service.getVoice(getOptions).execute().getResult(); + assertNotNull(voice); + assertNotNull(voice.getDescription()); + assertNotNull(voice.getGender()); + assertNotNull(voice.getLanguage()); + assertNotNull(voice.getName()); + assertNotNull(voice.getUrl()); + } + + /** + * Synthesize text and write it to a temporary file. + * + * @throws IOException Signals that an I/O exception has occurred. + */ + @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_LISAV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); + InputStream result = service.synthesize(synthesizeOptions).execute().getResult(); + writeInputStreamToFile(result, File.createTempFile("tts-audio", "wav")); + } + + /** Test word pronunciation. */ + @Test + public void testGetWordPronunciation() { + String word = "Congressman"; + 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(); + pronunciation = service.getPronunciation(getOptions2).execute().getResult(); + assertNotNull(pronunciation); + assertNotNull(pronunciation.getPronunciation()); + + 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_MICHAELV3VOICE) + .format(GetPronunciationOptions.Format.IPA) + .build(); + pronunciation = service.getPronunciation(getOptions4).execute().getResult(); + assertNotNull(pronunciation); + assertNotNull(pronunciation.getPronunciation()); + } + + /** + * 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 + 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_LISAV3VOICE) + .accept(HttpMediaType.AUDIO_WAV) + .build(); + InputStream result = service.synthesize(synthesizeOptions).execute().getResult(); + assertNotNull(result); + result = WaveUtils.reWriteWaveHeader(result); + File tempFile = File.createTempFile("output", ".wav"); + writeInputStreamToFile(result, tempFile); + 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(); + 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_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); + + String filename = "synthesize_websocket_test.ogg"; + OutputStream fileOutputStream = new FileOutputStream(filename); + byteArrayOutputStream.writeTo(fileOutputStream); + File createdFile = new File(filename); + + assertTrue(createdFile.exists()); + assertTrue(returnedContentType.contains("audio/ogg")); + for (Timings t : returnedTimings) { + List wordTimings = t.getWords(); + for (WordTiming wordTiming : wordTimings) { + assertTrue(basicText.contains(wordTiming.getWord())); + } + } + + // clean up + byteArrayOutputStream.close(); + fileOutputStream.close(); + if (createdFile.delete()) { + System.out.println("File deleted successfully!"); + } else { + System.out.println("File could not be deleted"); + } + } + + /** + * 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_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); + + for (Marks m : returnedMarks) { + List markList = m.getMarks(); + for (MarkTiming markTiming : markList) { + assertTrue(ssmlMarks.contains(markTiming.getMark())); + } + } + } + + /** 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 new file mode 100644 index 00000000000..856b34c6f77 --- /dev/null +++ b/text-to-speech/src/test/java/com/ibm/watson/text_to_speech/v1/TextToSpeechTest.java @@ -0,0 +1,1346 @@ +/* + * (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.text_to_speech.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.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.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.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 TextToSpeech service. */ +public class TextToSpeechTest { + + 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); + } + + // Test the listVoices operation with and without retries enabled + @Test + public void testListVoicesWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testListVoicesWOptions(); + + textToSpeechService.disableRetries(); + testListVoicesWOptions(); + } + + // 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)); + + // Construct an instance of the GetVoiceOptions model + GetVoiceOptions getVoiceOptionsModel = + new GetVoiceOptions.Builder() + .voice("de-DE_BirgitV3Voice") + .customizationId("testString") + .build(); + + // 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 the getVoice operation with and without retries enabled + @Test + public void testGetVoiceWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testGetVoiceWOptions(); + + textToSpeechService.disableRetries(); + testGetVoiceWOptions(); + } + + // 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 the synthesize operation with a valid options model parameter + @Test + 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)); + + // 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(); + + // 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 the synthesize operation with and without retries enabled + @Test + public void testSynthesizeWRetries() throws Throwable { + textToSpeechService.enableRetries(4, 30); + testSynthesizeWOptions(); + + 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 getPronunciation operation with and without retries enabled + @Test + 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 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; + } + + // Constructs an instance of the service to be used by the tests + public void constructClientService() { + final String serviceName = "testService"; + + 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 3c3aadbf4d9..00000000000 --- a/tone-analyzer/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# Tone Analyzer - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - tone-analyzer - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:tone-analyzer:6.1.0' -``` - -## Usage -Use the [Tone Analyzer][tone_analyzer] service to get the tone of your email. - -```java -ToneAnalyzer service = new ToneAnalyzer("2017-09-21"); -service.setUsernameAndPassword("", ""); - -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(); -System.out.println(tone); -``` - -[tone_analyzer]: https://console.bluemix.net/docs/services/tone-analyzer/index.html diff --git a/tone-analyzer/build.gradle b/tone-analyzer/build.gradle deleted file mode 100644 index e0389843174..00000000000 --- a/tone-analyzer/build.gradle +++ /dev/null @@ -1,112 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'tone-analyzer' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Tone Analyzer Service' - url 'https://console.bluemix.net/docs/services/tone-analyzer/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzer.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzer.java deleted file mode 100644 index 8e9f5c0f92a..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzer.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3; - -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.UtteranceAnalyses; -import com.ibm.watson.developer_cloud.util.GsonSingleton; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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. The service neither logs nor retains data from - * requests and responses, regardless of whether the `X-Watson-Learning-Opt-Out` request header is set. - * - * @version v3 - * @see Tone Analyzer - */ -public class ToneAnalyzer extends WatsonService { - - private static final String SERVICE_NAME = "tone_analyzer"; - private static final String URL = "https://gateway.watsonplatform.net/tone-analyzer/api"; - - private String versionDate; - - /** - * Instantiates a new `ToneAnalyzer`. - * - * @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) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `ToneAnalyzer` with username and password. - * - * @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 username the username - * @param password the password - */ - public ToneAnalyzer(String versionDate, String username, String password) { - this(versionDate); - setUsernameAndPassword(username, password); - } - - /** - * Instantiates a new `ToneAnalyzer` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public ToneAnalyzer(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * 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. - * - * @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) { - Validator.notNull(toneOptions, "toneOptions cannot be null"); - String[] pathSegments = { "v3/tone" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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(), ",")); - } - if (toneOptions.contentType().equalsIgnoreCase(ToneOptions.ContentType.APPLICATION_JSON)) { - builder.bodyJson(GsonSingleton.getGson().toJsonTree(toneOptions.toneInput()).getAsJsonObject()); - } else { - builder.bodyContent(toneOptions.body(), toneOptions.contentType()); - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ToneAnalysis.class)); - } - - /** - * 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. - * - * @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) { - Validator.notNull(toneChatOptions, "toneChatOptions cannot be null"); - String[] pathSegments = { "v3/tone_chat" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - 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", GsonSingleton.getGson().toJsonTree(toneChatOptions.utterances())); - builder.bodyJson(contentJson); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(UtteranceAnalyses.class)); - } - -} diff --git a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/DocumentAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/DocumentAnalysis.java deleted file mode 100644 index eb4629f8036..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/DocumentAnalysis.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * DocumentAnalysis. - */ -public class DocumentAnalysis extends GenericModel { - - private List tones; - @SerializedName("tone_categories") - private List toneCategories; - private 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/developer_cloud/tone_analyzer/v3/model/SentenceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/SentenceAnalysis.java deleted file mode 100644 index 203493035a4..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/SentenceAnalysis.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * SentenceAnalysis. - */ -public class SentenceAnalysis extends GenericModel { - - @SerializedName("sentence_id") - private Long sentenceId; - private String text; - private List tones; - @SerializedName("tone_categories") - private List toneCategories; - @SerializedName("input_from") - private Long inputFrom; - @SerializedName("input_to") - private 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/developer_cloud/tone_analyzer/v3/model/ToneAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneAnalysis.java deleted file mode 100644 index ff12d28fc3c..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneAnalysis.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ToneAnalysis. - */ -public class ToneAnalysis extends GenericModel { - - @SerializedName("document_tone") - private DocumentAnalysis documentTone; - @SerializedName("sentences_tone") - private List sentencesTone; - - /** - * Gets the documentTone. - * - * An object of type `DocumentAnalysis` that provides the results of the analysis for the full input document. - * - * @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/developer_cloud/tone_analyzer/v3/model/ToneCategory.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneCategory.java deleted file mode 100644 index 5bf3eb63882..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneCategory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ToneCategory. - */ -public class ToneCategory extends GenericModel { - - private List tones; - @SerializedName("category_id") - private String categoryId; - @SerializedName("category_name") - private 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/developer_cloud/tone_analyzer/v3/model/ToneChatOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneChatOptions.java deleted file mode 100644 index ac098ec0faf..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneChatOptions.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * 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"; - } - - private List utterances; - private String contentLanguage; - private String acceptLanguage; - - /** - * Builder. - */ - public static class Builder { - private List utterances; - private String contentLanguage; - private String acceptLanguage; - - private Builder(ToneChatOptions toneChatOptions) { - utterances = toneChatOptions.utterances; - contentLanguage = toneChatOptions.contentLanguage; - 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) { - 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; - } - } - - private ToneChatOptions(Builder builder) { - 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/developer_cloud/tone_analyzer/v3/model/ToneChatScore.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneChatScore.java deleted file mode 100644 index f0a77d18f28..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneChatScore.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ToneChatScore. - */ -public class ToneChatScore extends GenericModel { - - private Double score; - @SerializedName("tone_id") - private String toneId; - @SerializedName("tone_name") - private 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 can return results for the following - * tone IDs: `sad`, `frustrated`, `satisfied`, `excited`, `polite`, `impolite`, and `sympathetic`. 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/developer_cloud/tone_analyzer/v3/model/ToneInput.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneInput.java deleted file mode 100644 index fe5b73937c2..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneInput.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * ToneInput. - */ -public class ToneInput extends GenericModel { - - private String text; - - /** - * Builder. - */ - public static class Builder { - private String text; - - private Builder(ToneInput toneInput) { - 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; - } - } - - private ToneInput(Builder builder) { - 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/developer_cloud/tone_analyzer/v3/model/ToneOptions.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneOptions.java deleted file mode 100644 index 66b9efca921..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneOptions.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The tone options. - */ -public class ToneOptions extends GenericModel { - - /** - * The type of the input: application/json, text/plain, or text/html. A character encoding can be specified by - * including a `charset` parameter. For example, 'text/plain;charset=utf-8'. - */ - public interface ContentType { - /** application/json. */ - String APPLICATION_JSON = "application/json"; - /** text/plain. */ - String TEXT_PLAIN = "text/plain"; - /** text/html. */ - String TEXT_HTML = "text/html"; - } - - 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"; - } - - private ToneInput toneInput; - private String body; - private String contentType; - private Boolean sentences; - private List tones; - private String contentLanguage; - private 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) { - toneInput = toneOptions.toneInput; - body = toneOptions.body; - contentType = toneOptions.contentType; - sentences = toneOptions.sentences; - tones = toneOptions.tones; - contentLanguage = toneOptions.contentLanguage; - 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) { - 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 = ToneOptions.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 = ToneOptions.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 = ToneOptions.ContentType.TEXT_HTML; - return this; - } - } - - private ToneOptions(Builder builder) { - Validator.isTrue(builder.contentType != null, "contentType cannot be null"); - 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: application/json, text/plain, or text/html. 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/developer_cloud/tone_analyzer/v3/model/ToneScore.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneScore.java deleted file mode 100644 index 87d67156309..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/ToneScore.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * ToneScore. - */ -public class ToneScore extends GenericModel { - - private Double score; - @SerializedName("tone_id") - private String toneId; - @SerializedName("tone_name") - private 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/developer_cloud/tone_analyzer/v3/model/Utterance.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/Utterance.java deleted file mode 100644 index 0f0eb799c77..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/Utterance.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * Utterance. - */ -public class Utterance extends GenericModel { - - private String text; - private String user; - - /** - * Builder. - */ - public static class Builder { - private String text; - private String user; - - private Builder(Utterance utterance) { - text = utterance.text; - 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; - } - } - - private Utterance(Builder builder) { - 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/developer_cloud/tone_analyzer/v3/model/UtteranceAnalyses.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/UtteranceAnalyses.java deleted file mode 100644 index 25d0a2cb853..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/UtteranceAnalyses.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * UtteranceAnalyses. - */ -public class UtteranceAnalyses extends GenericModel { - - @SerializedName("utterances_tone") - private List utterancesTone; - private 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/developer_cloud/tone_analyzer/v3/model/UtteranceAnalysis.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/UtteranceAnalysis.java deleted file mode 100644 index 76617e1e8e7..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/model/UtteranceAnalysis.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * UtteranceAnalysis. - */ -public class UtteranceAnalysis extends GenericModel { - - @SerializedName("utterance_id") - private Long utteranceId; - @SerializedName("utterance_text") - private String utteranceText; - private List tones; - private 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/developer_cloud/tone_analyzer/v3/package-info.java b/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/package-info.java deleted file mode 100644 index 41ab915445a..00000000000 --- a/tone-analyzer/src/main/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.tone_analyzer.v3; diff --git a/tone-analyzer/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerIT.java b/tone-analyzer/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerIT.java deleted file mode 100755 index 276c9253407..00000000000 --- a/tone-analyzer/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerIT.java +++ /dev/null @@ -1,187 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3; - -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.UtteranceAnalyses; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.Utterance; -import org.junit.runner.RunWith; - -/** - * 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 username = getProperty("tone_analyzer.v3.username"); - - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (username == null) || username.equals(PLACEHOLDER)); - - service = new ToneAnalyzer(VERSION_DATE_VALUE); - service.setUsernameAndPassword(username, getProperty("tone_analyzer.v3.password")); - service.setEndPoint(getProperty("tone_analyzer.v3.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(); - 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(); - 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(); - 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(); - 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(); - - 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/developer_cloud/tone_analyzer/v3/ToneAnalyzerTest.java b/tone-analyzer/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerTest.java deleted file mode 100644 index dad7c803e55..00000000000 --- a/tone-analyzer/src/test/java/com/ibm/watson/developer_cloud/tone_analyzer/v3/ToneAnalyzerTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.tone_analyzer.v3; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.UtteranceAnalyses; -import org.apache.commons.lang3.StringUtils; -import org.junit.Before; -import org.junit.Test; - -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpHeaders; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneAnalysis; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.ToneChatOptions; -import com.ibm.watson.developer_cloud.tone_analyzer.v3.model.Utterance; - -import okhttp3.mockwebserver.RecordedRequest; - -/** - * 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); - service.setUsernameAndPassword("", ""); - service.setEndPoint(getMockWebServerUrl()); - - } - - /** - * Test README. - */ - @Test - public void testReadme() throws InterruptedException, IOException { - - ToneAnalyzer service = new ToneAnalyzer(VERSION_DATE); - service.setUsernameAndPassword("", ""); - - service.setEndPoint(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(); - 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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - assertEquals(serviceResponse, mockResponse); - assertEquals(HttpMediaType.APPLICATION_JSON, request.getHeader(HttpHeaders.ACCEPT)); - - // second request - serviceResponse = service.tone(new ToneOptions.Builder().html(text).build()).execute(); - 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(); - request = server.takeRequest(); - path = path + "&tones=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(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = StringUtils.join(CHAT_TONE_PATH, "?", VERSION_DATE, "=", VERSION_DATE_VALUE); - assertEquals(path, request.getPath()); - assertNotNull(request.getHeader(HttpHeaders.AUTHORIZATION)); - 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 aca7fd8b50c..00000000000 --- a/visual-recognition/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# Visual Recognition - -## Installation - -##### Maven -```xml - - com.ibm.watson.developer_cloud - visual-recognition - 6.1.0 - -``` - -##### Gradle -```gradle -'com.ibm.watson.developer_cloud:visual-recognition:6.1.0' -``` - -## Usage -Use the [Visual Recognition][visual_recognition] service to recognize the -following picture. - -![Car](https://visual-recognition-demo.ng.bluemix.net/images/samples/5.jpg) - -```java -VisualRecognition service = new VisualRecognition("2016-05-20"); -IamOptions iamOptions = new IamOptions.Builder() - .apiKey("") - .build(); -service.setIamCredentials(iamOptions); - -System.out.println("Classify an image"); -ClassifyOptions options = new ClassifyOptions.Builder() - .imagesFile(new File(SINGLE_IMAGE_FILE)) - .build(); -ClassifiedImages result = service.classify(options).execute(); -System.out.println(result); -``` - -[visual_recognition]: https://console.bluemix.net/docs/services/visual-recognition/getting-started.html \ No newline at end of file diff --git a/visual-recognition/build.gradle b/visual-recognition/build.gradle deleted file mode 100644 index a132de32887..00000000000 --- a/visual-recognition/build.gradle +++ /dev/null @@ -1,117 +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' - -task sourcesJar(type: Jar) { - classifier = 'sources' - from sourceSets.main.allSource -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - -repositories { - mavenCentral() -} - -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(':core') - - testCompile project(path: ':core', configuration: 'tests') - - signature 'org.codehaus.mojo.signature:java17:1.0@signature' -} - -processResources { - filter ReplaceTokens, tokens: [ - "pom.version": project.version, - "build.date" : getDate() - ] -} - -uploadArchives { - repositories { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: "http://oss.sonatype.org/service/local/staging/deploy/maven2/") { - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/"){ - authentication(userName: System.env.CI_DEPLOY_USERNAME, password: System.env.CI_DEPLOY_PASSWORD) - } - pom.project { - name 'visual-recognition' - packaging 'jar' - // optionally artifactId can be defined here - description 'Client library to use the IBM Watson Visual Recognition Service' - url 'https://console.bluemix.net/docs/services/visual-recognition/index.html' - - 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' - } - - 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' - } - } - } - } - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java deleted file mode 100644 index e07f517efff..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognition.java +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3; - -import com.ibm.watson.developer_cloud.http.RequestBuilder; -import com.ibm.watson.developer_cloud.http.ServiceCall; -import com.ibm.watson.developer_cloud.service.WatsonService; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.RequestUtils; -import com.ibm.watson.developer_cloud.util.ResponseConverterUtils; -import com.ibm.watson.developer_cloud.util.Validator; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifiers; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.UpdateClassifierOptions; -import okhttp3.MultipartBody; -import okhttp3.RequestBody; - -import java.io.File; -import java.io.InputStream; - -/** - * The IBM Watson™ Visual Recognition service uses deep learning algorithms to identify scenes, objects, and faces - * in images 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 WatsonService { - - private static final String SERVICE_NAME = "visual_recognition"; - private static final String URL = "https://gateway.watsonplatform.net/visual-recognition/api"; - - private String versionDate; - - /** - * Instantiates a new `VisualRecognition`. - * - * @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) { - super(SERVICE_NAME); - if ((getEndPoint() == null) || getEndPoint().isEmpty()) { - setEndPoint(URL); - } - - Validator.isTrue((versionDate != null) && !versionDate.isEmpty(), "version cannot be null."); - - this.versionDate = versionDate; - } - - /** - * Instantiates a new `VisualRecognition` with API Key. - * - * @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 apiKey the API Key - */ - public VisualRecognition(String versionDate, String apiKey) { - this(versionDate); - setApiKey(apiKey); - } - - /* - * (non-Javadoc) - */ - @Override - protected void setAuthentication(okhttp3.Request.Builder builder) { - if ((getUsername() != null && getPassword() != null) || isTokenManagerSet()) { - super.setAuthentication(builder); - } else if (getApiKey() != null) { - addApiKeyQueryParameter(builder, getApiKey()); - } else { - throw new IllegalArgumentException( - "Credentials need to be specified. Use setApiKey(), setIamCredentials(), or setUsernameAndPassword()."); - } - } - - /** - * Adds the API key as a query parameter to the request URL. - * - * @param builder builder for the current request - * @param apiKey API key to be added - */ - private void addApiKeyQueryParameter(okhttp3.Request.Builder builder, String apiKey) { - final okhttp3.HttpUrl url = okhttp3.HttpUrl.parse(builder.build().url().toString()); - - if ((url.query() == null) || url.query().isEmpty()) { - builder.url(builder.build().url() + "?api_key=" + apiKey); - } else { - builder.url(builder.build().url() + "&api_key=" + apiKey); - } - } - - /** - * Instantiates a new `VisualRecognition` with IAM. Note that if the access token is specified in the - * iamOptions, you accept responsibility for managing the access token yourself. You must set a new access token - * before this - * one expires or after receiving a 401 error from the service. Failing to do so will result in authentication errors - * after this token expires. - * - * @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 iamOptions the options for authenticating through IAM - */ - public VisualRecognition(String versionDate, IamOptions iamOptions) { - this(versionDate); - setIamCredentials(iamOptions); - } - - /** - * 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) { - Validator.notNull(classifyOptions, "classifyOptions cannot be null"); - Validator.isTrue((classifyOptions.imagesFile() != null) - || (classifyOptions.url() != null) - || (classifyOptions.threshold() != null) - || (classifyOptions.owners() != null) - || (classifyOptions.classifierIds() != null) - || (classifyOptions.parameters() != null), - "At least one of imagesFile, url, threshold, owners, classifierIds, or parameters must be supplied."); - String[] pathSegments = { "v3/classify" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (classifyOptions.acceptLanguage() != null) { - builder.header("Accept-Language", classifyOptions.acceptLanguage()); - } - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (classifyOptions.imagesFile() != null) { - RequestBody imagesFileBody = RequestUtils.inputStreamBody(classifyOptions.imagesFile(), classifyOptions - .imagesFileContentType()); - multipartBuilder.addFormDataPart("images_file", classifyOptions.imagesFilename(), imagesFileBody); - } - if (classifyOptions.parameters() != null) { - multipartBuilder.addFormDataPart("parameters", classifyOptions.parameters()); - } - 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()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(ClassifiedImages.class)); - } - - /** - * 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); - } - - /** - * Detect faces in images. - * - * **Important:** On April 2, 2018, the identity information in the response to calls to the Face model was removed. - * The identity information refers to the `name` of the person, `score`, and `type_hierarchy` knowledge graph. For - * details about the enhanced Face model, see the [Release - * notes](https://console.bluemix.net/docs/services/visual-recognition/release-notes.html#2april2018). - * - * Analyze and get data about faces in images. Responses can include estimated age and gender. This feature uses a - * built-in model, so no training is necessary. The Detect faces method does not support general biometric facial - * recognition. - * - * Supported image formats include .gif, .jpg, .png, and .tif. The maximum image size is 10 MB. The minimum - * recommended pixel density is 32X32 pixels per inch. - * - * @param detectFacesOptions the {@link DetectFacesOptions} containing the options for the call - * @return a {@link ServiceCall} with a response type of {@link DetectedFaces} - */ - public ServiceCall detectFaces(DetectFacesOptions detectFacesOptions) { - Validator.notNull(detectFacesOptions, "detectFacesOptions cannot be null"); - Validator.isTrue((detectFacesOptions.imagesFile() != null) - || (detectFacesOptions.url() != null) - || (detectFacesOptions.parameters() != null), - "At least one of imagesFile, url, or parameters must be supplied."); - String[] pathSegments = { "v3/detect_faces" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - if (detectFacesOptions.imagesFile() != null) { - RequestBody imagesFileBody = RequestUtils.inputStreamBody(detectFacesOptions.imagesFile(), detectFacesOptions - .imagesFileContentType()); - multipartBuilder.addFormDataPart("images_file", detectFacesOptions.imagesFilename(), imagesFileBody); - } - if (detectFacesOptions.parameters() != null) { - multipartBuilder.addFormDataPart("parameters", detectFacesOptions.parameters()); - } - if (detectFacesOptions.url() != null) { - multipartBuilder.addFormDataPart("url", detectFacesOptions.url()); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(DetectedFaces.class)); - } - - /** - * Detect faces in images. - * - * **Important:** On April 2, 2018, the identity information in the response to calls to the Face model was removed. - * The identity information refers to the `name` of the person, `score`, and `type_hierarchy` knowledge graph. For - * details about the enhanced Face model, see the [Release - * notes](https://console.bluemix.net/docs/services/visual-recognition/release-notes.html#2april2018). - * - * Analyze and get data about faces in images. Responses can include estimated age and gender. This feature uses a - * built-in model, so no training is necessary. The Detect faces method does not support general biometric facial - * recognition. - * - * Supported image formats include .gif, .jpg, .png, and .tif. The maximum image size is 10 MB. The minimum - * recommended pixel density is 32X32 pixels per inch. - * - * @return a {@link ServiceCall} with a response type of {@link DetectedFaces} - */ - public ServiceCall detectFaces() { - return detectFaces(null); - } - - /** - * Create a classifier. - * - * Train a new multi-faceted classifier on the uploaded image data. Create your custom classifier with positive or - * negative examples. 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. - * - * 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) { - Validator.notNull(createClassifierOptions, "createClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - multipartBuilder.addFormDataPart("name", createClassifierOptions.name()); - // Classes - for (String className : createClassifierOptions.classNames()) { - String dataName = className + "_positive_examples"; - File positiveExamples = createClassifierOptions.positiveExamplesByClassName(className); - RequestBody body = RequestUtils.fileBody(positiveExamples, "application/octet-stream"); - multipartBuilder.addFormDataPart(dataName, positiveExamples.getName(), body); - } - if (createClassifierOptions.negativeExamples() != null) { - RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(createClassifierOptions.negativeExamples(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("negative_examples", createClassifierOptions.negativeExamplesFilename(), - negativeExamplesBody); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class)); - } - - /** - * 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) { - Validator.notNull(deleteClassifierOptions, "deleteClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { deleteClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - - /** - * 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) { - Validator.notNull(getClassifierOptions, "getClassifierOptions cannot be null"); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { getClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class)); - } - - /** - * 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(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - if (listClassifiersOptions != null) { - if (listClassifiersOptions.verbose() != null) { - builder.query("verbose", String.valueOf(listClassifiersOptions.verbose())); - } - } - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifiers.class)); - } - - /** - * Retrieve a list of classifiers. - * - * @return a {@link ServiceCall} with a response type of {@link Classifiers} - */ - public ServiceCall listClassifiers() { - return listClassifiers(null); - } - - /** - * Update a classifier. - * - * Update a custom classifier by adding new positive or negative classes (examples) 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://console.bluemix.net/docs/services/visual-recognition/customizing.html#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. - * - * **Tip:** 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) { - Validator.notNull(updateClassifierOptions, "updateClassifierOptions cannot be null"); - Validator.isTrue((updateClassifierOptions.classNames().size() > 0) || (updateClassifierOptions - .negativeExamples() != null), - "At least one of classnamePositiveExamples or negativeExamples must be supplied."); - String[] pathSegments = { "v3/classifiers" }; - String[] pathParameters = { updateClassifierOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.post(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - MultipartBody.Builder multipartBuilder = new MultipartBody.Builder(); - multipartBuilder.setType(MultipartBody.FORM); - // Classes - for (String className : updateClassifierOptions.classNames()) { - String dataName = className + "_positive_examples"; - File positiveExamples = updateClassifierOptions.positiveExamplesByClassName(className); - RequestBody body = RequestUtils.fileBody(positiveExamples, "application/octet-stream"); - multipartBuilder.addFormDataPart(dataName, positiveExamples.getName(), body); - } - if (updateClassifierOptions.negativeExamples() != null) { - RequestBody negativeExamplesBody = RequestUtils.inputStreamBody(updateClassifierOptions.negativeExamples(), - "application/octet-stream"); - multipartBuilder.addFormDataPart("negative_examples", updateClassifierOptions.negativeExamplesFilename(), - negativeExamplesBody); - } - builder.body(multipartBuilder.build()); - return createServiceCall(builder.build(), ResponseConverterUtils.getObject(Classifier.class)); - } - - /** - * 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) { - Validator.notNull(getCoreMlModelOptions, "getCoreMlModelOptions cannot be null"); - String[] pathSegments = { "v3/classifiers", "core_ml_model" }; - String[] pathParameters = { getCoreMlModelOptions.classifierId() }; - RequestBuilder builder = RequestBuilder.get(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments, - pathParameters)); - builder.query(VERSION, versionDate); - return createServiceCall(builder.build(), ResponseConverterUtils.getInputStream()); - } - - /** - * 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://console.bluemix.net/docs/services/visual-recognition/information-security.html). - * - * @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) { - Validator.notNull(deleteUserDataOptions, "deleteUserDataOptions cannot be null"); - String[] pathSegments = { "v3/user_data" }; - RequestBuilder builder = RequestBuilder.delete(RequestBuilder.constructHttpUrl(getEndPoint(), pathSegments)); - builder.query(VERSION, versionDate); - builder.query("customer_id", deleteUserDataOptions.customerId()); - return createServiceCall(builder.build(), ResponseConverterUtils.getVoid()); - } - -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Class.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Class.java deleted file mode 100644 index a8c8fea0635..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Class.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A category within a classifier. - */ -public class Class extends GenericModel { - - @SerializedName("class") - private String className; - - /** - * Gets the className. - * - * The name of the class. - * - * @return the className - */ - public String getClassName() { - return className; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassResult.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassResult.java deleted file mode 100644 index 6e5bf4f9200..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassResult.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Result of a class within a classifier. - */ -public class ClassResult extends GenericModel { - - @SerializedName("class") - private String className; - private Float score; - @SerializedName("type_hierarchy") - private String typeHierarchy; - - /** - * Gets the className. - * - * Name of the class. - * - * @return the className - */ - public String getClassName() { - return className; - } - - /** - * 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/developer_cloud/visual_recognition/v3/model/ClassifiedImage.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifiedImage.java deleted file mode 100644 index b41cf88f1a7..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifiedImage.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Results for one image. - */ -public class ClassifiedImage extends GenericModel { - - @SerializedName("source_url") - private String sourceUrl; - @SerializedName("resolved_url") - private String resolvedUrl; - private String image; - private ErrorInfo error; - private 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/developer_cloud/visual_recognition/v3/model/ClassifiedImages.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifiedImages.java deleted file mode 100644 index 0038f349706..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifiedImages.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Results for all images. - */ -public class ClassifiedImages extends GenericModel { - - @SerializedName("custom_classes") - private Long customClasses; - @SerializedName("images_processed") - private Long imagesProcessed; - private List images; - private 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/developer_cloud/visual_recognition/v3/model/Classifier.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java deleted file mode 100644 index 53678fdde62..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifier.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.Date; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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") - private String classifierId; - private String name; - private String owner; - private String status; - @SerializedName("core_ml_enabled") - private Boolean coreMlEnabled; - private String explanation; - private Date created; - private List classes; - private Date retrained; - private 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. Returned when verbose=`true`. 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 may 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. Returned when verbose=`true`. - * 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`. Returned when verbose=`true`. 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/developer_cloud/visual_recognition/v3/model/ClassifierResult.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifierResult.java deleted file mode 100644 index e1b416a8da4..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifierResult.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Classifier and score combination. - */ -public class ClassifierResult extends GenericModel { - - private String name; - @SerializedName("classifier_id") - private String classifierId; - private 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/developer_cloud/visual_recognition/v3/model/Classifiers.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java deleted file mode 100644 index e544c8b9c1e..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Classifiers.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * A container for the list of classifiers. - */ -public class Classifiers extends GenericModel { - - private 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/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java deleted file mode 100644 index ce3dec9395b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ClassifyOptions.java +++ /dev/null @@ -1,398 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The classify options. - */ -public class ClassifyOptions extends GenericModel { - - /** - * The language of the output class names. The full set of languages is supported only for the built-in `default` - * classifier ID. The 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. - */ - 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"; - } - - private InputStream imagesFile; - private String imagesFilename; - private String acceptLanguage; - private String url; - private Float threshold; - private List owners; - private List classifierIds; - private String imagesFileContentType; - @Deprecated - private String parameters; - - /** - * Builder. - */ - public static class Builder { - private InputStream imagesFile; - private String imagesFilename; - private String acceptLanguage; - private String url; - private Float threshold; - private List owners; - private List classifierIds; - private String imagesFileContentType; - @Deprecated - private String parameters; - - private Builder(ClassifyOptions classifyOptions) { - imagesFile = classifyOptions.imagesFile; - imagesFilename = classifyOptions.imagesFilename; - acceptLanguage = classifyOptions.acceptLanguage; - url = classifyOptions.url; - threshold = classifyOptions.threshold; - owners = classifyOptions.owners; - classifierIds = classifyOptions.classifierIds; - imagesFileContentType = classifyOptions.imagesFileContentType; - parameters = classifyOptions.parameters; - } - - /** - * 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) { - 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) { - 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 acceptLanguage. - * - * @param acceptLanguage the acceptLanguage - * @return the ClassifyOptions builder - */ - public Builder acceptLanguage(String acceptLanguage) { - this.acceptLanguage = acceptLanguage; - 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 imagesFileContentType. - * - * @param imagesFileContentType the imagesFileContentType - * @return the ClassifyOptions builder - */ - public Builder imagesFileContentType(String imagesFileContentType) { - this.imagesFileContentType = imagesFileContentType; - 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; - } - - /** - * Set the parameters. - * - * @param parameters the parameters - * @return the ClassifyOptions builder - * @deprecated replaced by the top-level parameters url, threshold, owners, and classifierIds - */ - public Builder parameters(String parameters) { - this.parameters = parameters; - return this; - } - } - - private ClassifyOptions(Builder builder) { - imagesFile = builder.imagesFile; - imagesFilename = builder.imagesFilename; - acceptLanguage = builder.acceptLanguage; - url = builder.url; - threshold = builder.threshold; - owners = builder.owners; - classifierIds = builder.classifierIds; - imagesFileContentType = builder.imagesFileContentType; - parameters = builder.parameters; - } - - /** - * New builder. - * - * @return a ClassifyOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the imagesFile. - * - * An image file (.jpg, .png) 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 acceptLanguage. - * - * The language of the output class names. The full set of languages is supported only for the built-in `default` - * classifier ID. The 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 acceptLanguage - */ - public String acceptLanguage() { - return acceptLanguage; - } - - /** - * Gets the url. - * - * The URL of an image to analyze. Must be in .jpg, or .png format. The minimum recommended pixel density is 32X32 - * pixels per inch, and 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 ignore the - * classification score and return all values. - * - * @return the threshold - */ - public Float threshold() { - return threshold; - } - - /** - * Gets the owners. - * - * The categories of classifiers to apply. Use `IBM` to classify against the `default` general classifier, and use - * `me` to classify against your custom classifiers. To analyze the image against both classifier categories, set the - * value to both `IBM` and `me`. - * - * The built-in `default` classifier is used if both **classifier_ids** and **owners** parameters are empty. - * - * The **classifier_ids** parameter overrides **owners**, so make sure that **classifier_ids** is empty. - * - * @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`: (Beta) Enhances specificity and accuracy for images of food items. - * - `explicit`: (Beta) Evaluates whether the image might be pornographic. - * - * @return the classifierIds - */ - public List classifierIds() { - return classifierIds; - } - - /** - * 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 parameters. - * - * @return the parameters - * @deprecated replaced by the top-level parameters url, threshold, owners, and classifierIds - */ - public String parameters() { - return parameters; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java deleted file mode 100644 index b8cfd5a9595..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/CreateClassifierOptions.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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 java.util.Set; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The createClassifier options. - */ -public class CreateClassifierOptions extends GenericModel { - - private String name; - private Map classnamePositiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - /** - * Builder. - */ - public static class Builder { - private String name; - private Map classnamePositiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - private Builder(CreateClassifierOptions createClassifierOptions) { - name = createClassifierOptions.name; - classnamePositiveExamples.putAll(createClassifierOptions.classnamePositiveExamples); - negativeExamples = createClassifierOptions.negativeExamples; - negativeExamplesFilename = createClassifierOptions.negativeExamplesFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - classnamePositiveExamples = new HashMap<>(); - } - - /** - * Instantiates a new builder with required properties. - * - * @param name the name - */ - public Builder(String name) { - this(); - this.name = name; - } - - /** - * Builds a CreateClassifierOptions. - * - * @return the createClassifierOptions - */ - public CreateClassifierOptions build() { - return new CreateClassifierOptions(this); - } - - /** - * Set the name. - * - * @param name the name - * @return the CreateClassifierOptions builder - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * Adds a classifier with a name and positive examples. If the classifier name is already contained, the old - * positive examples are replaced by the specified value. - * - * @param className the class name - * @param positiveExamples the positive examples - * @return the builder - */ - public Builder addClass(String className, File positiveExamples) { - Validator.notNull(className, "className cannot be null"); - Validator.notNull(positiveExamples, "positiveExamples cannot be null"); - classnamePositiveExamples.put(className, 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; - } - - /** - * 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; - } - } - - private CreateClassifierOptions(Builder builder) { - Validator.notNull(builder.name, "name cannot be null"); - Validator.isTrue(!builder.classnamePositiveExamples.isEmpty(), - "To create a classifier, you must supply at least one positive examples file."); - name = builder.name; - classnamePositiveExamples = builder.classnamePositiveExamples; - 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 class names. - * - * 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**. - * - * 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 classNames - */ - public Set classNames() { - return classnamePositiveExamples.keySet(); - } - - /** - * Gets the positive examples by class name. - * - * @param className the class name - * @return the positiveExamples - */ - public File positiveExamplesByClassName(String className) { - return classnamePositiveExamples.get(className); - } - - /** - * 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/developer_cloud/visual_recognition/v3/model/DeleteClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DeleteClassifierOptions.java deleted file mode 100644 index 59c7f1ad032..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DeleteClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteClassifier options. - */ -public class DeleteClassifierOptions extends GenericModel { - - private String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(DeleteClassifierOptions deleteClassifierOptions) { - 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; - } - } - - private DeleteClassifierOptions(Builder builder) { - 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/developer_cloud/visual_recognition/v3/model/DeleteUserDataOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DeleteUserDataOptions.java deleted file mode 100644 index c4b0a85c32b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DeleteUserDataOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The deleteUserData options. - */ -public class DeleteUserDataOptions extends GenericModel { - - private String customerId; - - /** - * Builder. - */ - public static class Builder { - private String customerId; - - private Builder(DeleteUserDataOptions deleteUserDataOptions) { - 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; - } - } - - private DeleteUserDataOptions(Builder builder) { - 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/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java deleted file mode 100644 index 0bb4e4bbfb8..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectFacesOptions.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The detectFaces options. - */ -public class DetectFacesOptions extends GenericModel { - - private InputStream imagesFile; - private String imagesFilename; - private String url; - private String imagesFileContentType; - @Deprecated - private String parameters; - - /** - * Builder. - */ - public static class Builder { - private InputStream imagesFile; - private String imagesFilename; - private String url; - private String imagesFileContentType; - @Deprecated - private String parameters; - - private Builder(DetectFacesOptions detectFacesOptions) { - imagesFile = detectFacesOptions.imagesFile; - imagesFilename = detectFacesOptions.imagesFilename; - url = detectFacesOptions.url; - imagesFileContentType = detectFacesOptions.imagesFileContentType; - parameters = detectFacesOptions.parameters; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - } - - /** - * Builds a DetectFacesOptions. - * - * @return the detectFacesOptions - */ - public DetectFacesOptions build() { - return new DetectFacesOptions(this); - } - - /** - * Set the imagesFile. - * - * @param imagesFile the imagesFile - * @return the DetectFacesOptions builder - */ - public Builder imagesFile(InputStream imagesFile) { - this.imagesFile = imagesFile; - return this; - } - - /** - * Set the imagesFilename. - * - * @param imagesFilename the imagesFilename - * @return the DetectFacesOptions builder - */ - public Builder imagesFilename(String imagesFilename) { - this.imagesFilename = imagesFilename; - return this; - } - - /** - * Set the url. - * - * @param url the url - * @return the DetectFacesOptions builder - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Set the imagesFileContentType. - * - * @param imagesFileContentType the imagesFileContentType - * @return the DetectFacesOptions builder - */ - public Builder imagesFileContentType(String imagesFileContentType) { - this.imagesFileContentType = imagesFileContentType; - return this; - } - - /** - * Set the imagesFile. - * - * @param imagesFile the imagesFile - * @return the DetectFacesOptions 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; - } - - /** - * Set the parameters. - * - * @param parameters the parameters - * @return the DetectFacesOptions builder - * @deprecated replaced by the url parameter - */ - public Builder parameters(String parameters) { - this.parameters = parameters; - return this; - } - } - - private DetectFacesOptions(Builder builder) { - imagesFile = builder.imagesFile; - imagesFilename = builder.imagesFilename; - url = builder.url; - imagesFileContentType = builder.imagesFileContentType; - parameters = builder.parameters; - } - - /** - * New builder. - * - * @return a DetectFacesOptions builder - */ - public Builder newBuilder() { - return new Builder(this); - } - - /** - * Gets the imagesFile. - * - * An image file (gif, .jpg, .png, .tif.) or .zip file with images. Limit the .zip file to 100 MB. You can include a - * maximum of 15 images in a request. - * - * 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 url. - * - * The URL of an image to analyze. Must be in .gif, .jpg, .png, or .tif format. The minimum recommended pixel density - * is 32X32 pixels per inch, and the maximum image size is 10 MB. Redirects are followed, so you can use a shortened - * URL. - * - * You can also include images with the **images_file** parameter. - * - * @return the url - */ - public String url() { - return url; - } - - /** - * 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 parameters. - * - * @return the parameters - * @deprecated replaced by the url parameter - */ - public String parameters() { - return parameters; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectedFaces.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectedFaces.java deleted file mode 100644 index 723a1da34c2..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/DetectedFaces.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Results for all faces. - */ -public class DetectedFaces extends GenericModel { - - @SerializedName("images_processed") - private Long imagesProcessed; - private List images; - private List warnings; - - /** - * Gets the imagesProcessed. - * - * Number of images processed for the API call. - * - * @return the imagesProcessed - */ - public Long getImagesProcessed() { - return imagesProcessed; - } - - /** - * Gets the images. - * - * The 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/developer_cloud/visual_recognition/v3/model/ErrorInfo.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ErrorInfo.java deleted file mode 100644 index 78eca728383..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ErrorInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.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 { - - private Long code; - private String description; - @SerializedName("error_id") - private 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/developer_cloud/visual_recognition/v3/model/Face.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Face.java deleted file mode 100644 index 51ed9e29556..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/Face.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Information about the face. - */ -public class Face extends GenericModel { - - private FaceAge age; - private FaceGender gender; - @SerializedName("face_location") - private FaceLocation faceLocation; - - /** - * Gets the age. - * - * Age information about a face. - * - * @return the age - */ - public FaceAge getAge() { - return age; - } - - /** - * Gets the gender. - * - * Information about the gender of the face. - * - * @return the gender - */ - public FaceGender getGender() { - return gender; - } - - /** - * Gets the faceLocation. - * - * The location of the bounding box around the face. - * - * @return the faceLocation - */ - public FaceLocation getFaceLocation() { - return faceLocation; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java deleted file mode 100644 index c2c200b06af..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceAge.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Age information about a face. - */ -public class FaceAge extends GenericModel { - - private Long min; - private Long max; - private Float score; - - /** - * Gets the min. - * - * Estimated minimum age. - * - * @return the min - */ - public Long getMin() { - return min; - } - - /** - * Gets the max. - * - * Estimated maximum age. - * - * @return the max - */ - public Long getMax() { - return max; - } - - /** - * Gets the score. - * - * Confidence score in the range of 0 to 1. A higher score indicates greater confidence in the estimated value for the - * property. - * - * @return the score - */ - public Float getScore() { - return score; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceGender.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceGender.java deleted file mode 100644 index 036db0f0367..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceGender.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Information about the gender of the face. - */ -public class FaceGender extends GenericModel { - - private String gender; - private Float score; - - /** - * Gets the gender. - * - * Gender identified by the face. For example, `MALE` or `FEMALE`. - * - * @return the gender - */ - public String getGender() { - return gender; - } - - /** - * Gets the score. - * - * Confidence score in the range of 0 to 1. A higher score indicates greater confidence in the estimated value for the - * property. - * - * @return the score - */ - public Float getScore() { - return score; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceLocation.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceLocation.java deleted file mode 100644 index 66af773bb46..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/FaceLocation.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The location of the bounding box around the face. - */ -public class FaceLocation extends GenericModel { - - private Double width; - private Double height; - private Double left; - private Double top; - - /** - * Gets the width. - * - * Width in pixels of face region. - * - * @return the width - */ - public Double getWidth() { - return width; - } - - /** - * Gets the height. - * - * Height in pixels of face region. - * - * @return the height - */ - public Double getHeight() { - return height; - } - - /** - * Gets the left. - * - * X-position of top-left pixel of face region. - * - * @return the left - */ - public Double getLeft() { - return left; - } - - /** - * Gets the top. - * - * Y-position of top-left pixel of face region. - * - * @return the top - */ - public Double getTop() { - return top; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetClassifierOptions.java deleted file mode 100644 index 875f41ba096..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetClassifierOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getClassifier options. - */ -public class GetClassifierOptions extends GenericModel { - - private String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetClassifierOptions getClassifierOptions) { - 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; - } - } - - private GetClassifierOptions(Builder builder) { - 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/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java deleted file mode 100644 index e3576823a01..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/GetCoreMlModelOptions.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The getCoreMlModel options. - */ -public class GetCoreMlModelOptions extends GenericModel { - - private String classifierId; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - - private Builder(GetCoreMlModelOptions getCoreMlModelOptions) { - 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; - } - } - - private GetCoreMlModelOptions(Builder builder) { - 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/developer_cloud/visual_recognition/v3/model/ImageWithFaces.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ImageWithFaces.java deleted file mode 100644 index b9aec903c78..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ImageWithFaces.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Information about faces in the image. - */ -public class ImageWithFaces extends GenericModel { - - private List faces; - private String image; - @SerializedName("source_url") - private String sourceUrl; - @SerializedName("resolved_url") - private String resolvedUrl; - private ErrorInfo error; - - /** - * Gets the faces. - * - * Faces detected in the images. - * - * @return the faces - */ - public List getFaces() { - return faces; - } - - /** - * 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 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 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; - } -} diff --git a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ListClassifiersOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ListClassifiersOptions.java deleted file mode 100644 index a0f587d4e8b..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/ListClassifiersOptions.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * The listClassifiers options. - */ -public class ListClassifiersOptions extends GenericModel { - - private Boolean verbose; - - /** - * Builder. - */ - public static class Builder { - private Boolean verbose; - - private Builder(ListClassifiersOptions listClassifiersOptions) { - 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; - } - } - - private 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/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java deleted file mode 100644 index 551fd6dc135..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/UpdateClassifierOptions.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.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 java.util.Set; - -import com.ibm.watson.developer_cloud.service.model.GenericModel; -import com.ibm.watson.developer_cloud.util.Validator; - -/** - * The updateClassifier options. - */ -public class UpdateClassifierOptions extends GenericModel { - - private String classifierId; - private Map classnamePositiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - /** - * Builder. - */ - public static class Builder { - private String classifierId; - private Map classnamePositiveExamples; - private InputStream negativeExamples; - private String negativeExamplesFilename; - - private Builder(UpdateClassifierOptions updateClassifierOptions) { - classifierId = updateClassifierOptions.classifierId; - classnamePositiveExamples.putAll(updateClassifierOptions.classnamePositiveExamples); - negativeExamples = updateClassifierOptions.negativeExamples; - negativeExamplesFilename = updateClassifierOptions.negativeExamplesFilename; - } - - /** - * Instantiates a new builder. - */ - public Builder() { - classnamePositiveExamples = new HashMap<>(); - } - - /** - * Instantiates a new builder with required properties. - * - * @param classifierId the classifierId - */ - public Builder(String classifierId) { - this(); - this.classifierId = classifierId; - } - - /** - * Builds a UpdateClassifierOptions. - * - * @return the updateClassifierOptions - */ - public UpdateClassifierOptions build() { - return new UpdateClassifierOptions(this); - } - - /** - * Set the classifierId. - * - * @param classifierId the classifierId - * @return the UpdateClassifierOptions builder - */ - public Builder classifierId(String classifierId) { - this.classifierId = classifierId; - return this; - } - - /** - * Adds a classifier with a name and positive examples. If the classifier name is already contained, the old - * positive examples are replaced by the specified value. - * - * @param className the class name - * @param positiveExamples the positive examples - * @return the UpdateClassifierOptions builder - */ - public Builder addClass(String className, File positiveExamples) { - Validator.notNull(className, "'className' cannot be null"); - Validator.notNull(positiveExamples, "'positiveExamples' cannot be null"); - classnamePositiveExamples.put(className, 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; - } - - /** - * 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; - } - } - - private UpdateClassifierOptions(Builder builder) { - Validator.notEmpty(builder.classifierId, "classifierId cannot be empty"); - Validator.isTrue(!builder.classnamePositiveExamples.isEmpty() || (builder.negativeExamples != null), - "To update a classifier, you must supply at least one positive examples file or a negative examples file."); - Validator.isTrue((builder.negativeExamples == null) || (builder.negativeExamplesFilename != null), - "negativeExamplesFilename cannot be null if negativeExamples is not null."); - classifierId = builder.classifierId; - classnamePositiveExamples = builder.classnamePositiveExamples; - 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 class names. - * - * 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`. - * - * 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 classNames - */ - public Set classNames() { - return classnamePositiveExamples.keySet(); - } - - /** - * Gets the positive examples by class name. - * - * @param className the class name - * @return the classes - */ - public File positiveExamplesByClassName(String className) { - return classnamePositiveExamples.get(className); - } - - /** - * 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/developer_cloud/visual_recognition/v3/model/WarningInfo.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/WarningInfo.java deleted file mode 100644 index 1ec4917d931..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/model/WarningInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3.model; - -import com.google.gson.annotations.SerializedName; -import com.ibm.watson.developer_cloud.service.model.GenericModel; - -/** - * Information about something that went wrong. - */ -public class WarningInfo extends GenericModel { - - @SerializedName("warning_id") - private String warningId; - private 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/developer_cloud/visual_recognition/v3/package-info.java b/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/package-info.java deleted file mode 100644 index e56b10df3a2..00000000000 --- a/visual-recognition/src/main/java/com/ibm/watson/developer_cloud/visual_recognition/v3/package-info.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright 2018 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT 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.developer_cloud.visual_recognition.v3; diff --git a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionITCF.java b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionITCF.java deleted file mode 100644 index 85e8eec1848..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionITCF.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier.Status; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.developer_cloud.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.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 VisualRecognitionITCF extends WatsonServiceTest { - private static final String IMAGE_FACE_FILE = "src/test/resources/visual_recognition/faces.zip"; - private static final String IMAGE_FACE_URL = "https://watson-test-resources.mybluemix.net/resources/obama.jpg"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/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/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 || (options.parameters() != null && options.parameters().contains("url"))) { - assertNotNull(result.getImages().get(0).getResolvedUrl()); - assertNotNull(result.getImages().get(0).getSourceUrl()); - } else { - assertNotNull(result.getImages().get(0).getImage()); - } - } - - /** - * Assert detected faces. - * - * @param detectedFaces the detected faces - * @param options the detect faces options - */ - private void assertDetectedFaces(DetectedFaces detectedFaces, DetectFacesOptions options) { - assertNotNull(detectedFaces); - assertNotNull(detectedFaces.getImages()); - assertTrue(detectedFaces.getImages().size() > 0); - assertNull(detectedFaces.getImages().get(0).getError()); - assertNotNull(detectedFaces.getImages().get(0).getFaces()); - - if (options.url() != null || (options.parameters() != null && options.parameters().contains("url"))) { - assertEquals(IMAGE_FACE_URL, detectedFaces.getImages().get(0).getResolvedUrl()); - assertEquals(IMAGE_FACE_URL, detectedFaces.getImages().get(0).getSourceUrl()); - } else { - assertNotNull(detectedFaces.getImages().get(0).getImage()); - } - } - - /* - * (non-Javadoc) - * @see com.ibm.watson.developer_cloud.WatsonServiceTest#setUp() - */ - @Override - @Before - public void setUp() throws Exception { - super.setUp(); - String apiKey = getProperty("visual_recognition.v3.api_key"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (apiKey == null) || apiKey.equals("API_KEY")); - - String url = getProperty("visual_recognition.v3.url_cf"); - classifierId = getProperty("visual_recognition.v3.classifier_id"); - - service = new VisualRecognition("2016-05-20"); - service.setApiKey(apiKey); - service.setDefaultHeaders(getDefaultHeaders()); - service.setEndPoint(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(); - 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(); - - 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(); - assertClassifyImage(result, options); - } - - /** - * Test classify images from url using the deprecated parameters option. - */ - @Test - public void testClassifyImagesFromUrlUsingParameters() { - String parameters = "{\"url\":\"" + IMAGE_URL + "\"}"; - - ClassifyOptions options = new ClassifyOptions.Builder() - .parameters(parameters) - .build(); - ClassifiedImages result = service.classify(options).execute(); - 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/car_positive.zip"); - File baseballImages = new File("src/test/resources/visual_recognition/baseball_positive.zip"); - File negativeImages = new File("src/test/resources/visual_recognition/negative.zip"); - File imageToClassify = new File("src/test/resources/visual_recognition/car.png"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addClass(carClassifier, carImages); - builder.addClass(baseballClassifier, baseballImages); - builder.negativeExamples(negativeImages); - - Classifier newClassifier = service.createClassifier(builder.build()).execute(); - 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(); - 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(); - 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 - */ - @Ignore - @Test - public void testCreateClassifier() throws FileNotFoundException, InterruptedException { - String classifierName = "integration-test-java-sdk"; - String carClassifier = "car"; - String baseballClassifier = "baseball"; - - File carImages = new File("src/test/resources/visual_recognition/car_positive.zip"); - File baseballImages = new File("src/test/resources/visual_recognition/baseball_positive.zip"); - InputStream negativeImages = new FileInputStream("src/test/resources/visual_recognition/negative.zip"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addClass(carClassifier, carImages); - builder.addClass(baseballClassifier, baseballImages); - builder.negativeExamples(negativeImages); - builder.negativeExamplesFilename("negative.zip"); - - Classifier newClass = service.createClassifier(builder.build()).execute(); - try { - assertEquals(classifierName, newClass.getName()); - boolean ready = false; - for (int x = 0; (x < 20) && !ready; x++) { - Thread.sleep(2000); - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(newClass.getClassifierId()).build(); - newClass = service.getClassifier(getOptions).execute(); - ready = newClass.getStatus().equals(Status.READY); - } - assertEquals(Status.READY, 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().getClassifiers(); - for (Classifier classifier : classifiers) { - if (!classifier.getClassifierId().equals(classifierId)) { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(classifier.getClassifierId()) - .build(); - service.deleteClassifier(deleteOptions).execute(); - } - } - } - - /** - * Test detect faces from bytes or stream. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testDetectFacesFromBytes() throws IOException { - File images = new File(IMAGE_FACE_FILE); - DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build(); - DetectedFaces result = service.detectFaces(options).execute(); - assertDetectedFaces(result, options); - } - - /** - * Test detect faces from file. - * - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testDetectFacesFromFile() throws FileNotFoundException { - File images = new File(IMAGE_FACE_FILE); - - DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build(); - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test detect faces from url. - */ - @Test - public void testDetectFacesFromUrl() { - DetectFacesOptions options = new DetectFacesOptions.Builder() - .url(IMAGE_FACE_URL) - .build(); - - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test detect faces from url using the deprecated parameters option. - */ - @Test - public void testDetectFacesFromUrlUsingParameters() { - String parameters = "{\"url\":\"" + IMAGE_FACE_URL + "\"}"; - - DetectFacesOptions options = new DetectFacesOptions.Builder() - .parameters(parameters) - .build(); - - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test list all the classifiers. - */ - @Ignore - @Test - public void testListClassifiers() { - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List classifiers = service.listClassifiers(options).execute().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().getClassifiers(); - - for (Classifier classifier : classifiers) { - if (classifier.isCoreMlEnabled()) { - GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder() - .classifierId(classifier.getClassifierId()) - .build(); - InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute(); - 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/developer_cloud/visual_recognition/v3/VisualRecognitionITRC.java b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionITRC.java deleted file mode 100644 index 507e94227c1..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionITRC.java +++ /dev/null @@ -1,390 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3; - -import com.ibm.watson.developer_cloud.WatsonServiceTest; -import com.ibm.watson.developer_cloud.service.security.IamOptions; -import com.ibm.watson.developer_cloud.util.RetryRunner; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier.Status; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.developer_cloud.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.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 VisualRecognitionITRC extends WatsonServiceTest { - private static final String IMAGE_FACE_FILE = "src/test/resources/visual_recognition/faces.zip"; - private static final String IMAGE_FACE_URL = "https://watson-test-resources.mybluemix.net/resources/obama.jpg"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/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/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 || (options.parameters() != null && options.parameters().contains("url"))) { - assertNotNull(result.getImages().get(0).getResolvedUrl()); - assertNotNull(result.getImages().get(0).getSourceUrl()); - } else { - assertNotNull(result.getImages().get(0).getImage()); - } - } - - /** - * Assert detected faces. - * - * @param detectedFaces the detected faces - * @param options the detect faces options - */ - private void assertDetectedFaces(DetectedFaces detectedFaces, DetectFacesOptions options) { - assertNotNull(detectedFaces); - assertNotNull(detectedFaces.getImages()); - assertTrue(detectedFaces.getImages().size() > 0); - assertNull(detectedFaces.getImages().get(0).getError()); - assertNotNull(detectedFaces.getImages().get(0).getFaces()); - - if (options.url() != null || (options.parameters() != null && options.parameters().contains("url"))) { - assertEquals(IMAGE_FACE_URL, detectedFaces.getImages().get(0).getResolvedUrl()); - assertEquals(IMAGE_FACE_URL, detectedFaces.getImages().get(0).getSourceUrl()); - } else { - assertNotNull(detectedFaces.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.v3.iam_api_key"); - Assume.assumeFalse("config.properties doesn't have valid credentials.", - (iamApiKey == null) || iamApiKey.equals("API_KEY")); - - String url = getProperty("visual_recognition.v3.url_rc"); - classifierId = getProperty("visual_recognition.v3.classifier_id"); - - service = new VisualRecognition("2016-05-20"); - IamOptions iamOptions = new IamOptions.Builder() - .apiKey(iamApiKey) - .build(); - service.setIamCredentials(iamOptions); - service.setDefaultHeaders(getDefaultHeaders()); - service.setEndPoint(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(); - 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(); - - 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(); - assertClassifyImage(result, options); - } - - /** - * Test classify images from url using the deprecated parameters option. - */ - @Test - public void testClassifyImagesFromUrlUsingParameters() { - String parameters = "{\"url\":\"" + IMAGE_URL + "\"}"; - - ClassifyOptions options = new ClassifyOptions.Builder() - .parameters(parameters) - .build(); - ClassifiedImages result = service.classify(options).execute(); - 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/car_positive.zip"); - File baseballImages = new File("src/test/resources/visual_recognition/baseball_positive.zip"); - File negativeImages = new File("src/test/resources/visual_recognition/negative.zip"); - File imageToClassify = new File("src/test/resources/visual_recognition/car.png"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addClass(carClassifier, carImages); - builder.addClass(baseballClassifier, baseballImages); - builder.negativeExamples(negativeImages); - - Classifier newClassifier = service.createClassifier(builder.build()).execute(); - 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(); - 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(); - 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 - */ - @Ignore - @Test - public void testCreateClassifier() throws FileNotFoundException, InterruptedException { - String classifierName = "integration-test-java-sdk"; - String carClassifier = "car"; - String baseballClassifier = "baseball"; - - File carImages = new File("src/test/resources/visual_recognition/car_positive.zip"); - File baseballImages = new File("src/test/resources/visual_recognition/baseball_positive.zip"); - InputStream negativeImages = new FileInputStream("src/test/resources/visual_recognition/negative.zip"); - - CreateClassifierOptions.Builder builder = new CreateClassifierOptions.Builder().name(classifierName); - builder.addClass(carClassifier, carImages); - builder.addClass(baseballClassifier, baseballImages); - builder.negativeExamples(negativeImages); - builder.negativeExamplesFilename("negative.zip"); - - Classifier newClass = service.createClassifier(builder.build()).execute(); - try { - assertEquals(classifierName, newClass.getName()); - boolean ready = false; - for (int x = 0; (x < 20) && !ready; x++) { - Thread.sleep(2000); - GetClassifierOptions getOptions = new GetClassifierOptions.Builder(newClass.getClassifierId()).build(); - newClass = service.getClassifier(getOptions).execute(); - ready = newClass.getStatus().equals(Status.READY); - } - assertEquals(Status.READY, 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().getClassifiers(); - for (Classifier classifier : classifiers) { - if (!classifier.getClassifierId().equals(classifierId)) { - DeleteClassifierOptions deleteOptions = new DeleteClassifierOptions.Builder(classifier.getClassifierId()) - .build(); - service.deleteClassifier(deleteOptions).execute(); - } - } - } - - /** - * Test detect faces from bytes or stream. - * - * @throws IOException Signals that an I/O exception has occurred. - */ - @Test - public void testDetectFacesFromBytes() throws IOException { - File images = new File(IMAGE_FACE_FILE); - DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build(); - DetectedFaces result = service.detectFaces(options).execute(); - assertDetectedFaces(result, options); - } - - /** - * Test detect faces from file. - * - * @throws FileNotFoundException the file not found exception - */ - @Test - public void testDetectFacesFromFile() throws FileNotFoundException { - File images = new File(IMAGE_FACE_FILE); - - DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build(); - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test detect faces from url. - */ - @Test - public void testDetectFacesFromUrl() { - DetectFacesOptions options = new DetectFacesOptions.Builder() - .url(IMAGE_FACE_URL) - .build(); - - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test detect faces from url using the deprecated parameters option. - */ - @Test - public void testDetectFacesFromUrlUsingParameters() { - String parameters = "{\"url\":\"" + IMAGE_FACE_URL + "\"}"; - - DetectFacesOptions options = new DetectFacesOptions.Builder() - .parameters(parameters) - .build(); - - DetectedFaces detectedFaces = service.detectFaces(options).execute(); - assertDetectedFaces(detectedFaces, options); - } - - /** - * Test list all the classifiers. - */ - @Ignore - @Test - public void testListClassifiers() { - ListClassifiersOptions options = new ListClassifiersOptions.Builder().verbose(true).build(); - List classifiers = service.listClassifiers(options).execute().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().getClassifiers(); - - for (Classifier classifier : classifiers) { - if (classifier.isCoreMlEnabled()) { - GetCoreMlModelOptions getCoreMlModelOptions = new GetCoreMlModelOptions.Builder() - .classifierId(classifier.getClassifierId()) - .build(); - InputStream coreMlFile = service.getCoreMlModel(getCoreMlModelOptions).execute(); - 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/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java b/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java deleted file mode 100644 index 742a35a0b43..00000000000 --- a/visual-recognition/src/test/java/com/ibm/watson/developer_cloud/visual_recognition/v3/VisualRecognitionTest.java +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Copyright 2017 IBM Corp. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.ibm.watson.developer_cloud.visual_recognition.v3; - -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import com.ibm.watson.developer_cloud.WatsonServiceUnitTest; -import com.ibm.watson.developer_cloud.http.HttpMediaType; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifiedImages; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.Classifier; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ClassifyOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.CreateClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DeleteUserDataOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectFacesOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.DetectedFaces; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetClassifierOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.GetCoreMlModelOptions; -import com.ibm.watson.developer_cloud.visual_recognition.v3.model.ListClassifiersOptions; -import com.ibm.watson.developer_cloud.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.Arrays; -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 API_KEY = "alchemykey"; - private static final String FIXTURE_CLASSIFICATION - = "src/test/resources/visual_recognition/visual_classification.json"; - private static final String FIXTURE_CLASSIFIER = "src/test/resources/visual_recognition/visual_classifier.json"; - private static final String FIXTURE_FACES = "src/test/resources/visual_recognition/detected_faces.json"; - private static final String IMAGE_FILE = "src/test/resources/visual_recognition/test.zip"; - private static final String SINGLE_IMAGE_FILE = "src/test/resources/visual_recognition/car.png"; - private static final String PATH_CLASSIFY = "/v3/classify"; - private static final String VERSION_DATE = "version"; - private static final String PATH_CLASSIFIERS = "/v3/classifiers"; - private static final String PATH_CLASSIFIER = "/v3/classifiers/%s"; - private static final String PATH_DETECT_FACES = "/v3/detect_faces"; - private static final String PATH_CORE_ML = "/v3/classifiers/%s/core_ml_model"; - - 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("2016-05-20"); - service.setApiKey(API_KEY); - service.setEndPoint(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(Arrays.asList("car")) - .build(); - ClassifiedImages serviceResponse = service.classify(options).execute(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = PATH_CLASSIFY + "?" + VERSION_DATE + "=2016-05-20&api_key=" - + API_KEY; - 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) - .classifierIds(Arrays.asList("car")) - .build(); - ClassifiedImages serviceResponse = service.classify(options).execute(); - - // first request - RecordedRequest request = server.takeRequest(); - - String path = PATH_CLASSIFY + "?" + VERSION_DATE + "=2016-05-20&api_key=" - + API_KEY; - 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).addClass(class1, images) - .build(); - - Classifier serviceResponse = service.updateClassifier(options).execute(); - - // first request - String path = String.format(PATH_CLASSIFIER, classifierId); - RecordedRequest request = server.takeRequest(); - path += "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY; - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); - - String contentDisposition - = "Content-Disposition: form-data; name=\"class1_positive_examples\"; filename=\"test.zip\""; - 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) - .addClass(class1, positiveImages) - .negativeExamples(negativeImages) - .build(); - - Classifier serviceResponse = service.createClassifier(options).execute(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_DATE + "=2016-05-20&api_key=" - + API_KEY; - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - String body = request.getBody().readUtf8(); - - String contentDisposition - = "Content-Disposition: form-data; name=\"class1_positive_examples\"; filename=\"test.zip\""; - 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_DATE + "=2016-05-20&api_key=" + API_KEY, class1); - - assertEquals(path, request.getPath()); - assertEquals("DELETE", request.getMethod()); - } - - /** - * Test detect faces. - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws InterruptedException the interrupted exception - */ - @Test - public void testDetectFaces() throws IOException, InterruptedException { - DetectedFaces mockResponse = loadFixture(FIXTURE_FACES, DetectedFaces.class); - - server.enqueue(new MockResponse().setBody(mockResponse.toString())); - - // execute request - File images = new File(IMAGE_FILE); - DetectFacesOptions options = new DetectFacesOptions.Builder().imagesFile(images).build(); - - DetectedFaces serviceResponse = service.detectFaces(options).execute(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_DETECT_FACES + "?" + VERSION_DATE + "=2016-05-20&api_key=" - + API_KEY; - - assertEquals(path, request.getPath()); - assertEquals("POST", request.getMethod()); - assertEquals(serviceResponse, mockResponse); - String contentDisposition = "Content-Disposition: form-data; name=\"images_file\"; filename=\"test.zip\""; - String body = request.getBody().readUtf8(); - assertTrue(body.contains(contentDisposition)); - } - - /** - * 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(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CLASSIFIER + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY, 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().getClassifiers(); - - // first request - RecordedRequest request = server.takeRequest(); - String path = PATH_CLASSIFIERS + "?" + VERSION_DATE + "=2016-05-20&verbose=true&api_key=" + API_KEY; - - 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/custom_model.mlmodel"); - 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(); - - RecordedRequest request = server.takeRequest(); - String path = String.format(PATH_CORE_ML, classifierId) + "?" + VERSION_DATE + "=2016-05-20&api_key=" + API_KEY; - - assertEquals(path, request.getPath()); - assertEquals("GET", request.getMethod()); - writeInputStreamToFile(modelFile, new File("build/model_result.mlmodel")); - } - - @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/resources/visual_recognition/baseball_positive.zip b/visual-recognition/src/test/resources/visual_recognition/baseball_positive.zip deleted file mode 100644 index c606ddc7da8..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/0.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/0.jpg deleted file mode 100644 index 999b16a284d..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/0.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/1.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/1.jpg deleted file mode 100644 index e59eedb0e7d..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/1.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/10.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/10.jpg deleted file mode 100644 index 88f90f137df..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/10.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/2.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/2.jpg deleted file mode 100644 index 9efc556217e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/2.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/3.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/3.jpg deleted file mode 100644 index da5772f0644..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/3.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/4.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/4.jpg deleted file mode 100644 index f04ee61628b..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/4.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/5.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/5.jpg deleted file mode 100644 index d601fdb24c3..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/5.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/6.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/6.jpg deleted file mode 100644 index fffa7de348c..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/6.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/7.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/7.jpg deleted file mode 100644 index a6cabb00dfb..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/7.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/8.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/8.jpg deleted file mode 100644 index e15ca368202..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/8.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/9.jpg b/visual-recognition/src/test/resources/visual_recognition/baseball_positive/9.jpg deleted file mode 100644 index 5a3ae2543f7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/baseball_positive/9.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/car.png b/visual-recognition/src/test/resources/visual_recognition/car.png deleted file mode 100644 index 61df4dc567e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/car.png and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/car_positive.zip b/visual-recognition/src/test/resources/visual_recognition/car_positive.zip deleted file mode 100644 index b75086611e7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/car_positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/collection.json b/visual-recognition/src/test/resources/visual_recognition/collection.json deleted file mode 100644 index 441d9366a4b..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/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/custom_model.mlmodel b/visual-recognition/src/test/resources/visual_recognition/custom_model.mlmodel deleted file mode 100644 index 35611c91142..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/custom_model.mlmodel and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/detected_faces.json b/visual-recognition/src/test/resources/visual_recognition/detected_faces.json deleted file mode 100644 index 57e6002b482..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/detected_faces.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "images_processed": 8, - "images": [ - { - "faces": [ - { - "face_location": { - "width": 150, - "height": 152, - "left": 62, - "top": 27 - }, - "age": { - "max": 24, - "min": 18, - "score": 0.492498 - }, - "gender": { - "gender": "MALE", - "score": 0.989013 - } - } - ], - "image": "faces.zip/images_002.jpeg" - }, - { - "faces": [], - "image": "faces.zip/__MACOSX/._images_002.jpeg" - }, - { - "faces": [ - { - "face_location": { - "width": 94, - "height": 108, - "left": 79, - "top": 51 - }, - "age": { - "max": 34, - "min": 25, - "score": 0.385153 - }, - "gender": { - "gender": "MALE", - "score": 0.993307 - }, - "identity": { - "name": "Tiger Woods", - "score": 0.989013, - "type_hierarchy": "/animals/tigers/tiger woods" - } - } - ], - "image": "faces.zip/images_004.jpeg" - }, - { - "faces": [], - "image": "faces.zip/__MACOSX/._images_004.jpeg" - }, - { - "faces": [ - { - "face_location": { - "width": 137, - "height": 155, - "left": 34, - "top": 70 - }, - "age": { - "max": 44, - "min": 35, - "score": 0.382728 - }, - "gender": { - "gender": "MALE", - "score": 0.993307 - }, - "identity": { - "name": "Tiger Woods", - "score": 0.993307, - "type_hierarchy": "/animals/tigers/tiger woods" - } - } - ], - "image": "faces.zip/images_007.jpeg" - }, - { - "faces": [], - "image": "faces.zip/__MACOSX/._images_007.jpeg" - }, - { - "faces": [ - { - "face_location": { - "width": 21, - "height": 23, - "left": 23, - "top": 85 - }, - "age": { - "max": 24, - "min": 18, - "score": 0.502411 - }, - "gender": { - "gender": "FEMALE", - "score": 0.622459 - } - } - ], - "image": "faces.zip/images_019.jpeg" - }, - { - "faces": [], - "image": "faces.zip/__MACOSX/._images_019.jpeg" - } - ] -} \ No newline at end of file diff --git a/visual-recognition/src/test/resources/visual_recognition/detected_text.json b/visual-recognition/src/test/resources/visual_recognition/detected_text.json deleted file mode 100644 index 0856935e95c..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/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/eiffel-tower.jpg b/visual-recognition/src/test/resources/visual_recognition/eiffel-tower.jpg deleted file mode 100644 index 63dee36d765..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/eiffel-tower.jpg and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/faces.zip b/visual-recognition/src/test/resources/visual_recognition/faces.zip deleted file mode 100644 index 591a1cb9280..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/faces.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/image.json b/visual-recognition/src/test/resources/visual_recognition/image.json deleted file mode 100644 index 5cd955932d3..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/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/negative.zip b/visual-recognition/src/test/resources/visual_recognition/negative.zip deleted file mode 100644 index 2357c87a25c..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/negative.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/open.png b/visual-recognition/src/test/resources/visual_recognition/open.png deleted file mode 100644 index 8d7c00da61e..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/open.png and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/positive.zip b/visual-recognition/src/test/resources/visual_recognition/positive.zip deleted file mode 100644 index b75086611e7..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/positive.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/test.zip b/visual-recognition/src/test/resources/visual_recognition/test.zip deleted file mode 100644 index d9a285b00bf..00000000000 Binary files a/visual-recognition/src/test/resources/visual_recognition/test.zip and /dev/null differ diff --git a/visual-recognition/src/test/resources/visual_recognition/visual_classification.json b/visual-recognition/src/test/resources/visual_recognition/visual_classification.json deleted file mode 100644 index b6d8cbab644..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/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/visual_classifier.json b/visual-recognition/src/test/resources/visual_recognition/visual_classifier.json deleted file mode 100644 index b4678e997ab..00000000000 --- a/visual-recognition/src/test/resources/visual_recognition/visual_classifier.json +++ /dev/null @@ -1,14 +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