From f9b9ecbd8b29c53a2ba139913990be2f30c0412a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20R=C3=B6hrig?= <54274238+jridfe@users.noreply.github.com> Date: Mon, 10 Feb 2020 22:09:39 +0100 Subject: [PATCH] Release 0.2.0 (#1) * Release 0.2.0 common parts. * Release 0.2.0 common parts (not changed in abap-sdk-nwas release 0.2.0). * Release 0.2.0 platform specific parts. * Update README.md --- .abapgit.xml | 19 + LICENSE | 28 +- README.md | 335 +- src/package.devc.xml | 10 + src/zcl_ibmc_assistant_v1.clas.abap | 7326 +++++++++++++++ src/zcl_ibmc_assistant_v1.clas.xml | 16 + src/zcl_ibmc_assistant_v2.clas.abap | 1251 +++ src/zcl_ibmc_assistant_v2.clas.xml | 16 + src/zcl_ibmc_compare_comply_v1.clas.abap | 2851 ++++++ src/zcl_ibmc_compare_comply_v1.clas.xml | 16 + src/zcl_ibmc_discovery_v1.clas.abap | 8442 ++++++++++++++++++ src/zcl_ibmc_discovery_v1.clas.xml | 16 + src/zcl_ibmc_lang_translator_v3.clas.abap | 1463 +++ src/zcl_ibmc_lang_translator_v3.clas.xml | 16 + src/zcl_ibmc_nat_lang_class_v1.clas.abap | 792 ++ src/zcl_ibmc_nat_lang_class_v1.clas.xml | 16 + src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap | 1320 +++ src/zcl_ibmc_nat_lang_undrstnd_v1.clas.xml | 16 + src/zcl_ibmc_personal_insights_v3.clas.abap | 825 ++ src/zcl_ibmc_personal_insights_v3.clas.xml | 16 + src/zcl_ibmc_service.clas.abap | 1539 ++++ src/zcl_ibmc_service.clas.xml | 168 + src/zcl_ibmc_service_arch.clas.abap | 368 + src/zcl_ibmc_service_arch.clas.xml | 126 + src/zcl_ibmc_service_ext.clas.abap | 1023 +++ src/zcl_ibmc_service_ext.clas.xml | 120 + src/zcl_ibmc_speech_to_text_v1.clas.abap | 5465 ++++++++++++ src/zcl_ibmc_speech_to_text_v1.clas.xml | 16 + src/zcl_ibmc_text_to_speech_v1.clas.abap | 1627 ++++ src/zcl_ibmc_text_to_speech_v1.clas.xml | 16 + src/zcl_ibmc_tone_analyzer_v3.clas.abap | 696 ++ src/zcl_ibmc_tone_analyzer_v3.clas.xml | 16 + src/zcl_ibmc_util.clas.abap | 560 ++ src/zcl_ibmc_util.clas.xml | 60 + src/zcl_ibmc_visual_recognition_v3.clas.abap | 1281 +++ src/zcl_ibmc_visual_recognition_v3.clas.xml | 16 + src/zcl_ibmc_visual_recognition_v4.clas.abap | 2239 +++++ src/zcl_ibmc_visual_recognition_v4.clas.xml | 16 + src/zcx_ibmc_service_exception.clas.abap | 68 + src/zcx_ibmc_service_exception.clas.xml | 25 + src/zibmc.msag.xml | 416 + src/zibmc_config.tabl.xml | 87 + src/zibmc_dom_stringvalue.doma.xml | 14 + src/zibmc_token.tabl.xml | 140 + src/zibmc_ty_instance_uid.dtel.xml | 24 + src/zibmc_ty_stringvalue.dtel.xml | 23 + src/zif_ibmc_service_arch.intf.abap | 151 + src/zif_ibmc_service_arch.intf.xml | 15 + 48 files changed, 41074 insertions(+), 31 deletions(-) create mode 100644 .abapgit.xml create mode 100644 src/package.devc.xml create mode 100644 src/zcl_ibmc_assistant_v1.clas.abap create mode 100644 src/zcl_ibmc_assistant_v1.clas.xml create mode 100644 src/zcl_ibmc_assistant_v2.clas.abap create mode 100644 src/zcl_ibmc_assistant_v2.clas.xml create mode 100644 src/zcl_ibmc_compare_comply_v1.clas.abap create mode 100644 src/zcl_ibmc_compare_comply_v1.clas.xml create mode 100644 src/zcl_ibmc_discovery_v1.clas.abap create mode 100644 src/zcl_ibmc_discovery_v1.clas.xml create mode 100644 src/zcl_ibmc_lang_translator_v3.clas.abap create mode 100644 src/zcl_ibmc_lang_translator_v3.clas.xml create mode 100644 src/zcl_ibmc_nat_lang_class_v1.clas.abap create mode 100644 src/zcl_ibmc_nat_lang_class_v1.clas.xml create mode 100644 src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap create mode 100644 src/zcl_ibmc_nat_lang_undrstnd_v1.clas.xml create mode 100644 src/zcl_ibmc_personal_insights_v3.clas.abap create mode 100644 src/zcl_ibmc_personal_insights_v3.clas.xml create mode 100644 src/zcl_ibmc_service.clas.abap create mode 100644 src/zcl_ibmc_service.clas.xml create mode 100644 src/zcl_ibmc_service_arch.clas.abap create mode 100644 src/zcl_ibmc_service_arch.clas.xml create mode 100644 src/zcl_ibmc_service_ext.clas.abap create mode 100644 src/zcl_ibmc_service_ext.clas.xml create mode 100644 src/zcl_ibmc_speech_to_text_v1.clas.abap create mode 100644 src/zcl_ibmc_speech_to_text_v1.clas.xml create mode 100644 src/zcl_ibmc_text_to_speech_v1.clas.abap create mode 100644 src/zcl_ibmc_text_to_speech_v1.clas.xml create mode 100644 src/zcl_ibmc_tone_analyzer_v3.clas.abap create mode 100644 src/zcl_ibmc_tone_analyzer_v3.clas.xml create mode 100644 src/zcl_ibmc_util.clas.abap create mode 100644 src/zcl_ibmc_util.clas.xml create mode 100644 src/zcl_ibmc_visual_recognition_v3.clas.abap create mode 100644 src/zcl_ibmc_visual_recognition_v3.clas.xml create mode 100644 src/zcl_ibmc_visual_recognition_v4.clas.abap create mode 100644 src/zcl_ibmc_visual_recognition_v4.clas.xml create mode 100644 src/zcx_ibmc_service_exception.clas.abap create mode 100644 src/zcx_ibmc_service_exception.clas.xml create mode 100644 src/zibmc.msag.xml create mode 100644 src/zibmc_config.tabl.xml create mode 100644 src/zibmc_dom_stringvalue.doma.xml create mode 100644 src/zibmc_token.tabl.xml create mode 100644 src/zibmc_ty_instance_uid.dtel.xml create mode 100644 src/zibmc_ty_stringvalue.dtel.xml create mode 100644 src/zif_ibmc_service_arch.intf.abap create mode 100644 src/zif_ibmc_service_arch.intf.xml diff --git a/.abapgit.xml b/.abapgit.xml new file mode 100644 index 0000000..9727f9c --- /dev/null +++ b/.abapgit.xml @@ -0,0 +1,19 @@ + + + + + E + /src/ + PREFIX + + /.gitignore + /LICENSE + /README.md + /package.json + /.travis.yml + /.gitlab-ci.yml + /abaplint.json + + + + diff --git a/LICENSE b/LICENSE index 261eeb9..4947287 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -173,29 +174,4 @@ incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index baf9e30..5f08e2a 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,344 @@ # ABAP SDK for IBM Watson, using SAP Cloud Platform ABAP Environment -ABAP client library to use the [IBM Watson APIs][wdc]. This is a Community SDK written by ABAPers for the ABAPers in the Open Source community, to provide easy usage of IBM Watson Developer Services in innovation initiatives using SA{ Cloud Platform ABAP Environment combined with any SAP Application which is run on SAP NetWeaver 7.50 and above, such as SAP ECC or SAP S/4HANA. It is the choice and responsibility of application developers how this Community SDK is used. +ABAP client library to use the [Watson APIs][wdc]. This is a Community SDK written by ABAPers for the ABAPers in the Open Source community, to provide easy usage of IBM Watson Developer Services in innovation initatives using the SAP Cloud Platform ABAP Environment. It is the choice and responsibility of application developers how this Community SDK is used. -Additionally, as the ABAP SDK is a community release it is not updated with the same schedule as IBM-supported SDKs. Please see more information in [Questions](#questions). +Additionally, as the ABAP SDK is a community release it is not updated with the same schedule as IBM-supported SDKs. Please see more information in [Questions](#Questions). # Choose ABAP SDK release for the applicable ABAP Runtime | [abap-sdk-nwas](https://github.com/watson-developer-cloud/abap-sdk-nwas) | **abap-sdk-scp** | |---|---| -| for SAP NetWeaver AS ABAP 7.50+ | for SAP Cloud Platform ABAP Environment 1911+ | +| for SAP NetWeaver AS ABAP 7.50+ | for SAP Cloud Platform ABAP Environment 2002+ | | tested on SAP ECC and SAP S/4HANA | | | | `this repository` | -| | **coming soon, to be released in conjunction with SCP ABAP 1911 release** | + +**Note:** The ABAP SDK is available and will run in the SAP Cloud Platform ABAP Environment. However, at time of release, the SCP ABAP Env Trial has not been upgraded, therefore will not work at this time. The documentation will be updated, when the SCP ABAP Env Trial has been upgraded. --- +
+ Table of Contents + + * [Before you begin](#before-you-begin) + * [Installation](#installation) + * [SSL Certificates](#ssl-certificates) + * [Credentials](#credentials) + * [Configuration table](#configuration-table) + * [IAM Authentication](#iam-authentication) + * [Usage](#usage) + * [API Reference](#api-reference) + * [Questions](#questions) + * [License](#license) + * [Contributors](#contributors) + * [Acknowledgements](#acknowledgements) +
+ +## Before you begin +* You need an [IBM Cloud][ibm_cloud_onboarding] account. + +## Installation + +The client library is provided as ABAP Git Repository. Proceed as follows to clone the ABAP SDK code to your SAP system. +1. Install the [abapGit Plug-In][abapgit_plugin] for ADT. +2. Use abapGit to clone the ABAP SDK Git repository into your SAP system. +3. Assign the ABAP SDK to the package `ZIBMC` when performing setup of the abapGit repository. + +## SSL Certificates +Communication between SAP and the IBM Cloud is secured by the Transport Layer Security (TLS) protocol, also known as Secure Sockets Layer (SSL). SSL requires certificates that must be stored in the SCP Certificate Trust List, which can be maintained through the SCP ABAP environment dashboard. Ensure that the *DigiCert Global Root CA* certificate is installed. + +## Credentials + +Before you can access a specific service from your SAP system, you must create a service instance in the IBM Cloud and obtain credentials. The credentials can be shared among multiple end users of the SAP system, but you must ensure that the selected plan is sufficient to support the expected number of calls or the expected data volume. Please note that some plans may have restrictions on the allowed methods, so make sure to select the right plan for your purpose. + +All currently supported services support IAM authentication (see below). Service credentials consist of an API Key and a URL. Both the API Key and the URL are character values that can be viewed through the IBM Cloud dashboard and need to be provided as parameters `i_apikey` and `i_url` to method `zcl_ibmc_service_ext=>get_instance`. + +You can store the values with your application, but it is suggested to do that in an encrypted format. Using cloud services usually creates costs based on usage for the owner of the service instance, and anyone with the credentials can use the service instance at the owner's expenses. If you want to distribute the costs over multiple cost centers, you need to create a service instance and provide service credentials for each cost center separately. + + +## Configuration table + +Service credentials and other parameters that must be specified at Watson service wrapper ABAP class instantiation can also be provided in table `ZIBMC_CONFIG`. This table has three keys: + +| Table Key | Description | +|:------------ |:-------------------------------------------------------------------------------------------------------------------------------------- | +| SERVICE | The ABAP class name without prefix ZCL_IBMC_ | +| INSTANCE_UID | ID chosen by application developer that must be provided by application as parameter to method `zcl_ibmc_service_ext=>get_instance()` | +| PARAM | The parameter name | + +
+ List of configuration parameters in table ZIBMC_CONFIG + +| Parameter Name | Default Value | Description | +|:----------------- |:----------------- |:--------------------------------------------------------------------------- | +| URL | service-dependent | Watson service url | +| APIKEY | | Watson service API keys | +| AUTH_NAME | service-dependent | Authorization, `IAM` or `basicAuth` | + +
+ + +## IAM Authentication + +Identity and Access Management (IAM) is a bearer-token based authentication method. Token management is either performed by the ABAP SDK or must be implemented by the SDK user.
+If a value for apikey is provided by the caller in method `zcl_ibmc_service_ext=>get_instance()`, the ABAP SDK generates a bearer-token under the cover when needed and refreshes it when it is about to expire.
+If apikey is not provided for method `zcl_ibmc_service_ext=>get_instance()`, the ABAP SDK user must implement an individual token management. Before a service method is called the first time, a valid bearer-token must be provided to the Watson service wrapper ABAP class instance as follows: +```abap + lo_service_class->set_bearer_token( i_bearer_token = '...' ). +``` +Afterwards, service methods can be called as long as the provided token is valid. When the token has expired, the method above must be called again with a new (refreshed) bearer-token as parameter. + + +## Usage + +The client library is delivered as package *ZIBMC*. Once the Git Repository has been cloned to the SAP system, a Watson service instance is wrapped by an ABAP class instance.
+The following Watson services are currently supported: + +| Service | ABAP Class Name | +|:------------------------------ |:------------------------------ | +| Compare and Comply | ZCL_IBMC_COMPARE_COMPLY_V1 | +| Discovery | ZCL_IBMC_DISCOVERY_V1 | +| Language Translator | ZCL_IBMC_LANG_TRANSLATOR_V3 | +| Natural Language Classifier | ZCL_IBMC_NAT_LANG_CLASS_V1 | +| Natural Language Understanding | ZCL_IBMC_NAT_LANG_UNDRSTND_V1 | +| Personality Insights | ZCL_IBMC_PERSONAL_INSIGHTS_V3 | +| Speech to Text | ZCL_IBMC_SPEECH_TO_TEXT_V1 | +| Text to Speech | ZCL_IBMC_TEXT_TO_SPEECH_V1 | +| Tone Analyzer | ZCL_IBMC_TONE_ANALYZER_V3 | +| Visual Recognition | ZCL_IBMC_VISUAL_RECOGNITION_V3 | +| | ZCL_IBMC_VISUAL_RECOGNITION_V4 | +| Watson Assistant | ZCL_IBMC_ASSISTANT_V1 | +| | ZCL_IBMC_ASSISTANT_V2 | + +Using the client library requires two steps: + +1. Create an instance of the Watson service wrapper ABAP class by calling method `zcl_ibmc_service_ext=>get_instance`. +```abap + data: + lo_service_class type . + + zcl_ibmc_service_ext=>get_instance( + exporting + i_url = + i_apikey = +... + importing + eo_instance = lo_service_class ). +``` + +2. Call the Watson service API endpoint by invoking the corresponding class method. +```abap + try. + lo_service_class->method( + exporting + is_input = ... + importing + es_output = ... ). + catch zcx_ibmc_service_exception into data(lo_service_exception). + ... + endtry. +``` + +
+ Text to Speech Example + +```abap +* List all voices provided by Watson Text to Speech + + " declare variables + data: + lv_apikey type string value '...', + lo_text_to_speech type ref to zcl_ibmc_text_to_speech_v1, + lo_service_exception type ref to zcx_ibmc_service_exception, + ls_voice type zcl_ibmc_text_to_speech=>t_voice, + lt_voices type zcl_ibmc_text_to_speech=>t_voices. + + " get Watson Text-to-Speech service instance + zcl_ibmc_service_ext=>get_instance( + exporting + i_url = 'https://api.kr-seo.text-to-speech.watson.cloud.ibm.com/instances/' + i_apikey = lv_apikey + importing + eo_instance = lo_text_to_speech ). + + " call Watson Text-to-Speech service to retrieve available voices + try. + lo_text_to_speech->list_voices( + importing + e_response = lt_voices ). + + catch zcx_ibmc_service_exception into lo_service_exception. + message lo_service_exception type 'E'. + endtry. + + " evaluate voices + loop at lt_voices-voices into ls_voice. + ... + endloop. +``` + +
+ +
+ Natural Language Understanding Example + +```abap +* Analyze www.ibm.com using Watson Natural Language Understanding + + " declare variables + data: + lv_apikey type string value '...', + lo_instance type ref to zcl_ibmc_nat_lang_undrstnd_v1, + lo_service_exception type ref to zcx_ibmc_service_exception, + ls_parameter type zcl_ibmc_nat_lang_undrstnd_v1=>t_parameters, + ls_analysis_results type zcl_ibmc_nat_lang_undrstnd_v1=>t_analysis_results. + + " get Watson Natural Language Understanding service instance + zcl_ibmc_service_ext=>get_instance( + exporting + i_url = 'https://api.eu-de.natural-language-understanding.watson.cloud.ibm.com/instances/' + i_apikey = lv_apikey + i_version = '2019-07-12' + importing + eo_instance = lo_instance ). + + " set the input parameters + ls_parameters-url = 'www.ibm.com'. + ls_parameters-return_analyzed_text = zcl_ibmc_service=>c_boolean_true. + ls_parameters-features-entities-emotion = zcl_ibmc_service=>c_boolean_true. + ls_parameters-features-entities-sentiment = zcl_ibmc_service=>c_boolean_true. + ls_parameters-features-keywords-emotion = zcl_ibmc_service=>c_boolean_true. + ls_parameters-features-keywords-sentiment = zcl_ibmc_service=>c_boolean_true. + + " call Watson Natural Language Understanding service to analyze URL www.ibm.com + try. + lo_instance->analyze( + exporting + i_parameters = ls_parameters + importing + e_response = ls_analysis_results ). + + catch zcx_ibmc_service_exception into lo_service_exception. + message lo_service_exception type 'E'. + endtry. + + " retreive analysis results from ls_analysis_results + +``` + +
+ +
+ Personality Insights Example + +```abap +* Analyze profile using example text using Watson Personality Insights + + " declare variables + data: + lv_apikey type string value '...', + lo_personality_insights type ref to zcl_ibmc_personal_insights_v3, + lo_service_exception type ref to zcx_ibmc_service_exception, + ls_content_item type zcl_ibmc_personal_insights_v3=>t_content_item, + ls_response type zcl_ibmc_personal_insights_v3=>t_profile, + ls_content type zcl_ibmc_personal_insights_v3=>t_content, + lv_content_language type string value 'en', + lv_accept_language type string value 'en', + lv_raw_scores type boolean value 'C_BOOLEAN_FALSE', + lv_csv_headers type boolean valiue 'C_BOOLEAN_FALSE', + lv_consumption_preferences type boolean value 'C_BOOLEAN_FALSE', + lv_accept type string value 'text/csv'. + + " get Watson Personality Insights service instance + zcl_ibmc_service_ext=>get_instance( + exporting + i_url = 'https://api.eu-gb.personality-insights.watson.cloud.ibm.com/instances/' + i_apikey = lv_apikey + i_version = '2018-05-01' + importing + eo_instance = lo_personality_insights ). + + " store text to be analyzed into ls_content + " concatenate ... into ls_content_item-content + " append ls_content_item to ls_content-contentitems + + " call Watson Personality Insights service to analyze text in ls_content + try. + lo_personality_insights->profile( + exporting + i_content = ls_content + i_content_language = lv_content_language + i_accept_language = lv_accept_language + i_raw_scores = lv_raw_scores + i_csv_headers = lv_csv_headers + i_consumption_preferences = lv_consumption_preferences + importing + e_response = ls_response ). + + catch zcx_ibmc_service_exception into lo_service_exception. + message lo_service_exception type 'E'. + endtry. + + " retreive profile analysis results from ls_response + +``` + +
+ +
+ Language Translator Example + +```abap +* Translate text from English to German using Watson Language Translator + + " declare variables + data: + lv_apikey type string value '...', + lo_lang_translator type ref to zcl_ibmc_lang_translator_v3, + lo_service_exception type ref to zcx_ibmc_service_exception, + ls_request type zcl_ibmc_lang_translator_v3=>t_translate_request, + lv_text type string, + ls_trans type zcl_ibmc_lang_translator_v3=>t_translation_result. + + " get Watson Language Translator service instance + zcl_ibmc_service_ext=>get_instance( + exporting + i_url = 'https://api.us-south.language-translator.watson.cloud.ibm.com/instances/' + i_apikey = lv_apikey + i_version = '2018-05-01' + importing + eo_instance = lo_lang_translator ). + + " store text to be translated into ls_request and set the languages + lv_text = 'Welcome'. + append lv_text to ls_request-text. + ls_request-model_id = 'en-de'. + ls_request-source = 'EN'. + ls_request-target = 'DE'. + + " call Watson Language Translator service to translate the text in ls_request + try. + lo_lang_translator->translate( + exporting + i_request = ls_request + i_contenttype = 'application/json' + i_accept = 'application/json' + importing + e_response = ls_trans ). + + catch zcx_ibmc_service_exception into lo_service_exception. + message lo_service_exception type 'E'. + endtry. + + " retreive translation results from ls_trans + +``` + +
+ +## API Reference + +GitHub Pages contain the [ABAP Client Library for Watson API Reference](https://watson-developer-cloud.github.io/abap-sdk-nwas/). + ## Questions The ABAP SDK is a Community SDK for IBM Watson, created by the IBM Watson development community and SAP's ABAP development community - written by ABAPers from IBM Cloud, IBM Services and IBM Systems. Therefore as a community release it is not updated with the same schedule as IBM-supported SDKs, and does not include support by IBM. For more information on IBM-supported SDKs and the update policy, please see https://cloud.ibm.com/docs/watson?topic=watson-using-sdks @@ -46,5 +370,6 @@ In addition, we would like to thank the [abapGit][abapgit] contributors and the [ibm_cloud]: https://cloud.ibm.com/ [ibm_cloud_onboarding]: https://cloud.ibm.com/registration?target=/developer/watson&cm_sp=WatsonPlatform-WatsonServices-_-OnPageNavLink-IBMWatson_SDKs-_-ABAP [license]: http://www.apache.org/licenses/LICENSE-2.0 -[abapgit]: https://github.com/larshp/abapGit +[abapgit_plugin]: https://eclipse.abapgit.org/updatesite/ [abapgit_docs]: https://docs.abapgit.org/ +[abapgit]: https://github.com/larshp/abapGit diff --git a/src/package.devc.xml b/src/package.devc.xml new file mode 100644 index 0000000..ef268e4 --- /dev/null +++ b/src/package.devc.xml @@ -0,0 +1,10 @@ + + + + + + ABAP SDK for IBM Watson + + + + diff --git a/src/zcl_ibmc_assistant_v1.clas.abap b/src/zcl_ibmc_assistant_v1.clas.abap new file mode 100644 index 0000000..12fa523 --- /dev/null +++ b/src/zcl_ibmc_assistant_v1.clas.abap @@ -0,0 +1,7326 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM Watson™ Assistant service combines machine learning, natural +"! language understanding, and an integrated dialog editor to create conversation +"! flows between your apps and your users.
+"!
+"! The Assistant v1 API provides authoring methods your application can use to +"! create or update a workspace.
+class ZCL_IBMC_ASSISTANT_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Workspace settings related to detection of irrelevant input. + begin of T_WS_SYSTEM_SETTINGS_OFF_TOPIC, + "! Whether enhanced irrelevance detection is enabled for the workspace. + ENABLED type BOOLEAN, + end of T_WS_SYSTEM_SETTINGS_OFF_TOPIC. + types: + "! No documentation available. + begin of T_RT_ENTITY_INTERPRETATION, + "! The calendar used to represent a recognized date (for example, `Gregorian`). + CALENDAR_TYPE type STRING, + "! 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). + DATETIME_LINK type STRING, + "! 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. + FESTIVAL type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RANGE_MODIFIER type STRING, + "! 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`). + RELATIVE_DAY type NUMBER, + "! 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`). + RELATIVE_MONTH type NUMBER, + "! 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). + RELATIVE_WEEK type NUMBER, + "! 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`). + RELATIVE_WEEKEND type NUMBER, + "! 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`). + RELATIVE_YEAR type NUMBER, + "! A recognized mention of a specific date, represented numerically as the date + "! within the month (for example, `30` for `June 30`.). + SPECIFIC_DAY type NUMBER, + "! A recognized mention of a specific day of the week as a lowercase string (for + "! example, `monday`). + SPECIFIC_DAY_OF_WEEK type STRING, + "! A recognized mention of a specific month, represented numerically (for example, + "! `7` for `July`). + SPECIFIC_MONTH type NUMBER, + "! A recognized mention of a specific quarter, represented numerically (for + "! example, `3` for `the third quarter`). + SPECIFIC_QUARTER type NUMBER, + "! A recognized mention of a specific year (for example, `2016`). + SPECIFIC_YEAR type NUMBER, + "! A recognized numeric value, represented as an integer or double. + NUMERIC_VALUE type NUMBER, + "! The type of numeric value recognized in the user input (`integer` or + "! `rational`). + SUBTYPE type STRING, + "! 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`). + PART_OF_DAY type STRING, + "! 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`). + RELATIVE_HOUR type NUMBER, + "! 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`). + RELATIVE_MINUTE type NUMBER, + "! 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`). + RELATIVE_SECOND type NUMBER, + "! A recognized specific hour mentioned as part of a time value (for example, `10` + "! for `10:15 AM`.). + SPECIFIC_HOUR type NUMBER, + "! A recognized specific minute mentioned as part of a time value (for example, + "! `15` for `10:15 AM`.). + SPECIFIC_MINUTE type NUMBER, + "! A recognized specific second mentioned as part of a time value (for example, + "! `30` for `10:15:30 AM`.). + SPECIFIC_SECOND type NUMBER, + "! A recognized time zone mentioned as part of a time value (for example, `EST`). + TIMEZONE type STRING, + end of T_RT_ENTITY_INTERPRETATION. + types: + "! A key/value pair defining an HTTP header and a value. + begin of T_WEBHOOK_HEADER, + "! The name of an HTTP header (for example, `Authorization`). + NAME type STRING, + "! The value of an HTTP header. + VALUE type STRING, + end of T_WEBHOOK_HEADER. + types: + "! No documentation available. + begin of T_DIALOG_NODE_ACTION, + "! The name of the action. + NAME type STRING, + "! The type of action to invoke. + TYPE type STRING, + "! A map of key/value pairs to be provided to the action. + PARAMETERS type MAP, + "! The location in the dialog context where the result of the action is stored. + RESULT_VARIABLE type STRING, + "! The name of the context variable that the client application will use to pass in + "! credentials for the action. + CREDENTIALS type STRING, + end of T_DIALOG_NODE_ACTION. + types: + "! Workspace settings related to the disambiguation feature.
+ "!
+ "! **Note:** This feature is available only to Plus and Premium users. + begin of T_WS_SYSTM_STTNGS_DSMBGTN, + "! The text of the introductory prompt that accompanies disambiguation options + "! presented to the user. + PROMPT type STRING, + "! 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. + NONE_OF_THE_ABOVE_PROMPT type STRING, + "! Whether the disambiguation feature is enabled for the workspace. + ENABLED type BOOLEAN, + "! The sensitivity of the disambiguation feature to intent detection conflicts. Set + "! to **high** if you want the disambiguation feature to be triggered more often. + "! This can be useful for testing or demonstration purposes. + SENSITIVITY type STRING, + "! Whether the order in which disambiguation suggestions are presented should be + "! randomized (but still influenced by relative confidence). + RANDOMIZE type BOOLEAN, + "! The maximum number of disambigation suggestions that can be included in a + "! `suggestion` response. + MAX_SUGGESTIONS type INTEGER, + "! For internal use only. + SUGGESTION_TEXT_POLICY type STRING, + end of T_WS_SYSTM_STTNGS_DSMBGTN. + types: + "! Options that modify how specified output is handled. + begin of T_DIALOG_NODE_OUTPUT_MODIFIERS, + "! 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. + OVERWRITE type BOOLEAN, + end of T_DIALOG_NODE_OUTPUT_MODIFIERS. + types: + "! The next step to execute following this dialog node. + begin of T_DIALOG_NODE_NEXT_STEP, + "! 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. + BEHAVIOR type STRING, + "! The ID of the dialog node to process next. This parameter is required if + "! **behavior**=`jump_to`. + DIALOG_NODE type STRING, + "! Which part of the dialog node to process next. + SELECTOR type STRING, + end of T_DIALOG_NODE_NEXT_STEP. + types: + "! An input object that includes the input text. + begin of T_MESSAGE_INPUT, + "! The text of the user input. This string cannot contain carriage return, newline, + "! or tab characters. + TEXT type STRING, + end of T_MESSAGE_INPUT. + types: + "! A recognized capture group for a pattern-based entity. + begin of T_CAPTURE_GROUP, + "! A recognized capture group for the entity. + GROUP type STRING, + "! Zero-based character offsets that indicate where the entity value begins and + "! ends in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_CAPTURE_GROUP. + types: + "! 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. + begin of T_RUNTIME_ENTITY_ROLE, + "! The relationship of the entity to the range. + TYPE type STRING, + end of T_RUNTIME_ENTITY_ROLE. + types: + "! A term from the request that was identified as an entity. + begin of T_RUNTIME_ENTITY, + "! An entity detected in the input. + ENTITY type STRING, + "! An array of zero-based character offsets that indicate where the detected entity + "! values begin and end in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + "! The entity value that was recognized in the user input. + VALUE type STRING, + "! A decimal percentage that represents Watson's confidence in the recognized + "! entity. + CONFIDENCE type NUMBER, + "! Any metadata for the entity. + METADATA type MAP, + "! The recognized capture groups for the entity, as defined by the entity pattern. + GROUPS type STANDARD TABLE OF T_CAPTURE_GROUP WITH NON-UNIQUE DEFAULT KEY, + "! An object containing detailed information about the entity recognized in the + "! user input. This property is included only if the new system entities are + "! enabled for the workspace.
+ "!
+ "! For more information about how the new system entities are interpreted, see the + "! [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-beta-syste + "! m-entities). + INTERPRETATION type T_RT_ENTITY_INTERPRETATION, + "! 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. + ROLE type T_RUNTIME_ENTITY_ROLE, + end of T_RUNTIME_ENTITY. + types: + "! An intent identified in the user input. + begin of T_RUNTIME_INTENT, + "! The name of the recognized intent. + INTENT type STRING, + "! A decimal percentage that represents Watson's confidence in the intent. + CONFIDENCE type DOUBLE, + end of T_RUNTIME_INTENT. + types: + "! An object defining the message input to be sent to the Watson Assistant service + "! if the user selects the corresponding option. + begin of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! An array of intents to be used while processing the input.
+ "!
+ "! **Note:** This property is supported for backward compatibility with + "! applications that use the v1 **Get response to user input** method. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! 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. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + end of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE. + types: + "! No documentation available. + begin of T_DIA_NODE_OUTPUT_OPT_ELEMENT, + "! The user-facing label for the option. + LABEL type STRING, + "! An object defining the message input to be sent to the Watson Assistant service + "! if the user selects the corresponding option. + VALUE type T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + end of T_DIA_NODE_OUTPUT_OPT_ELEMENT. + types: + "! No documentation available. + begin of T_DIA_ND_OTPT_TEXT_VALUES_ELEM, + "! The text of a response. This string can include newline characters (`\n`), + "! Markdown tagging, or other special characters, if supported by the channel. + TEXT type STRING, + end of T_DIA_ND_OTPT_TEXT_VALUES_ELEM. + types: + "! No documentation available. + begin of T_DIALOG_NODE_OUTPUT_GENERIC, + "! The type of response returned by the dialog node. The specified response type + "! must be supported by the client application or channel.
+ "!
+ "! **Note:** The **search_skill** response type is available only for Plus and + "! Premium users, and is used only by the v2 runtime API. + RESPONSE_TYPE type STRING, + "! A list of one or more objects defining text responses. Required when + "! **response_type**=`text`. + VALUES type STANDARD TABLE OF T_DIA_ND_OTPT_TEXT_VALUES_ELEM WITH NON-UNIQUE DEFAULT KEY, + "! How a response is selected from the list, if more than one response is + "! specified. Valid only when **response_type**=`text`. + SELECTION_POLICY type STRING, + "! The delimiter to use as a separator between responses when + "! `selection_policy`=`multiline`. + DELIMITER type STRING, + "! How long to pause, in milliseconds. The valid values are from 0 to 10000. Valid + "! only when **response_type**=`pause`. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. Ignored if the + "! channel does not support this event. Valid only when **response_type**=`pause`. + "! + TYPING type BOOLEAN, + "! The URL of the image. Required when **response_type**=`image`. + SOURCE type STRING, + "! An optional title to show before the response. Valid only when + "! **response_type**=`image` or `option`. + TITLE type STRING, + "! An optional description to show with the response. Valid only when + "! **response_type**=`image` or `option`. + DESCRIPTION type STRING, + "! The preferred type of control to display, if supported by the channel. Valid + "! only when **response_type**=`option`. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. You + "! can include up to 20 options. Required when **response_type**=`option`. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! An optional message to be sent to the human agent who will be taking over the + "! conversation. Valid only when **reponse_type**=`connect_to_agent`. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! 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/services/discovery/query-operators.ht + "! ml#query-operators). Required when **response_type**=`search_skill`. + QUERY type STRING, + "! The type of the search query. Required when **response_type**=`search_skill`. + QUERY_TYPE type STRING, + "! 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/services/discovery/query-parameters.h + "! tml#filter). + FILTER type STRING, + "! The version of the Discovery service API to use for the query. + DISCOVERY_VERSION type STRING, + end of T_DIALOG_NODE_OUTPUT_GENERIC. + types: + "! 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-ove + "! rview#dialog-overview-responses). + begin of T_DIALOG_NODE_OUTPUT, + "! An array of objects describing the output defined for the dialog node. + GENERIC type STANDARD TABLE OF T_DIALOG_NODE_OUTPUT_GENERIC WITH NON-UNIQUE DEFAULT KEY, + "! Options that modify how specified output is handled. + MODIFIERS type T_DIALOG_NODE_OUTPUT_MODIFIERS, + end of T_DIALOG_NODE_OUTPUT. + types: + "! No documentation available. + begin of T_DIALOG_NODE, + "! The dialog node ID. This string must conform to the following restrictions:
+ "! - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + "! characters. + DIALOG_NODE type STRING, + "! The description of the dialog node. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The condition that will trigger the dialog node. This string cannot contain + "! carriage return, newline, or tab characters. + CONDITIONS type STRING, + "! The ID of the parent dialog node. This property is omitted if the dialog node + "! has no parent. + PARENT type STRING, + "! The ID of the previous sibling dialog node. This property is omitted if the + "! dialog node has no previous sibling. + PREVIOUS_SIBLING type STRING, + "! 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-ove + "! rview#dialog-overview-responses). + OUTPUT type T_DIALOG_NODE_OUTPUT, + "! The context for the dialog node. + CONTEXT type MAP, + "! The metadata for the dialog node. + METADATA type MAP, + "! The next step to execute following this dialog node. + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + "! 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. + TITLE type STRING, + "! How the dialog node is processed. + TYPE type STRING, + "! How an `event_handler` node is processed. + EVENT_NAME type STRING, + "! The location in the dialog context where output is stored. + VARIABLE type STRING, + "! An array of objects describing any actions to be invoked by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + "! Whether this top-level dialog node can be digressed into. + DIGRESS_IN type STRING, + "! Whether this dialog node can be returned to after a digression. + DIGRESS_OUT type STRING, + "! Whether the user can digress to top-level nodes while filling out slots. + DIGRESS_OUT_SLOTS type STRING, + "! A label that can be displayed externally to describe the purpose of the node to + "! users. + USER_LABEL type STRING, + "! Whether the dialog node should be excluded from disambiguation suggestions. + DISAMBIGUATION_OPT_OUT type BOOLEAN, + "! For internal use only. + DISABLED type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_DIALOG_NODE. + types: + "! No documentation available. + begin of T_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. + VALUE type STRING, + "! Any metadata related to the entity value. + METADATA type MAP, + "! Specifies the type of entity value. + TYPE type STRING, + "! 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. + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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#e + "! ntities-create-dictionary-based). + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_VALUE. + types: + "! 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. + begin of T_WEBHOOK, + "! The URL for the external service or application to which you want to send HTTP + "! POST requests. + URL type STRING, + "! The name of the webhook. Currently, `main_webhook` is the only supported value. + NAME type STRING, + "! An optional array of HTTP headers to pass with the HTTP request. + HEADERS type STANDARD TABLE OF T_WEBHOOK_HEADER WITH NON-UNIQUE DEFAULT KEY, + end of T_WEBHOOK. + types: + "! Workspace settings related to the behavior of system entities. + begin of T_WS_SYSTM_STTNGS_SYSTM_ENTTS, + "! Whether the new system entities are enabled for the workspace. + ENABLED type BOOLEAN, + end of T_WS_SYSTM_STTNGS_SYSTM_ENTTS. + types: + "! A mention of a contextual entity. + begin of T_MENTION, + "! The name of the entity. + ENTITY type STRING, + "! An array of zero-based character offsets that indicate where the entity mentions + "! begin and end in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_MENTION. + types: + "! No documentation available. + begin of T_EXAMPLE, + "! 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. + TEXT type STRING, + "! An array of contextual entity mentions. + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_EXAMPLE. + types: + "! No documentation available. + begin of T_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-`. + INTENT type STRING, + "! The description of the intent. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of user input examples for the intent. + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_INTENT. + types: + "! Workspace settings related to the Watson Assistant user interface. + begin of T_WS_SYSTEM_SETTINGS_TOOLING, + "! Whether the dialog JSON editor displays text responses within the + "! `output.generic` object. + STORE_GENERIC_RESPONSES type BOOLEAN, + end of T_WS_SYSTEM_SETTINGS_TOOLING. + types: + "! Global settings for the workspace. + begin of T_WORKSPACE_SYSTEM_SETTINGS, + "! Workspace settings related to the Watson Assistant user interface. + TOOLING type T_WS_SYSTEM_SETTINGS_TOOLING, + "! Workspace settings related to the disambiguation feature.
+ "!
+ "! **Note:** This feature is available only to Plus and Premium users. + DISAMBIGUATION type T_WS_SYSTM_STTNGS_DSMBGTN, + "! For internal use only. + HUMAN_AGENT_ASSIST type MAP, + "! Workspace settings related to the behavior of system entities. + SYSTEM_ENTITIES type T_WS_SYSTM_STTNGS_SYSTM_ENTTS, + "! Workspace settings related to detection of irrelevant input. + OFF_TOPIC type T_WS_SYSTEM_SETTINGS_OFF_TOPIC, + end of T_WORKSPACE_SYSTEM_SETTINGS. + types: + "! No documentation available. + begin of T_COUNTEREXAMPLE, + "! 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. + TEXT type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_COUNTEREXAMPLE. + types: + "! No documentation available. + begin of T_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.). + ENTITY type STRING, + "! The description of the entity. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! Any metadata related to the entity. + METADATA type MAP, + "! Whether to use fuzzy matching for the entity. + FUZZY_MATCH type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of objects describing the entity values. + VALUES type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_ENTITY. + types: + "! No documentation available. + begin of T_WORKSPACE, + "! The name of the workspace. This string cannot contain carriage return, newline, + "! or tab characters. + NAME type STRING, + "! The description of the workspace. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The language of the workspace. + LANGUAGE type STRING, + "! Any metadata related to the workspace. + METADATA type MAP, + "! 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. + LEARNING_OPT_OUT type BOOLEAN, + "! Global settings for the workspace. + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + "! The workspace ID of the workspace. + WORKSPACE_ID type STRING, + "! The current status of the workspace. + STATUS type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of intents. + INTENTS type STANDARD TABLE OF T_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the entities for the workspace. + ENTITIES type STANDARD TABLE OF T_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the dialog nodes in the workspace. + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + "! An array of counterexamples. + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + "! No documentation available. + WEBHOOKS type STANDARD TABLE OF T_WEBHOOK WITH NON-UNIQUE DEFAULT KEY, + end of T_WORKSPACE. + types: + "! No documentation available. + begin of T_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. + SYNONYM type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_SYNONYM. + types: + "! The pagination data for the returned objects. + begin of T_PAGINATION, + "! The URL that will return the same page of results. + REFRESH_URL type STRING, + "! The URL that will return the next page of results. + NEXT_URL type STRING, + "! Reserved for future use. + TOTAL type INTEGER, + "! Reserved for future use. + MATCHED type INTEGER, + "! A token identifying the current page of results. + REFRESH_CURSOR type STRING, + "! A token identifying the next page of results. + NEXT_CURSOR type STRING, + end of T_PAGINATION. + types: + "! No documentation available. + begin of T_SYNONYM_COLLECTION, + "! An array of synonyms. + SYNONYMS type STANDARD TABLE OF T_SYNONYM WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_SYNONYM_COLLECTION. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_OPTION, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + "! The preferred type of control to display. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_OPTION. + types: + "! No documentation available. + begin of T_DIA_ND_OUTPUT_RESP_TYPE_TEXT, + "! A list of one or more objects defining text responses. Required when + "! **response_type**=`text`. + VALUES type STANDARD TABLE OF T_DIA_ND_OTPT_TEXT_VALUES_ELEM WITH NON-UNIQUE DEFAULT KEY, + "! How a response is selected from the list, if more than one response is + "! specified. Valid only when **response_type**=`text`. + SELECTION_POLICY type STRING, + "! The delimiter to use as a separator between responses when + "! `selection_policy`=`multiline`. + DELIMITER type STRING, + end of T_DIA_ND_OUTPUT_RESP_TYPE_TEXT. + types: + "! No documentation available. + begin of T_BASE_WORKSPACE, + "! The name of the workspace. This string cannot contain carriage return, newline, + "! or tab characters. + NAME type STRING, + "! The description of the workspace. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The language of the workspace. + LANGUAGE type STRING, + "! Any metadata related to the workspace. + METADATA type MAP, + "! 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. + LEARNING_OPT_OUT type BOOLEAN, + "! Global settings for the workspace. + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + "! The workspace ID of the workspace. + WORKSPACE_ID type STRING, + "! The current status of the workspace. + STATUS type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_WORKSPACE. + types: + "! No documentation available. + begin of T_BASE_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-`. + ENTITY type STRING, + "! The description of the entity. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! Any metadata related to the entity. + METADATA type MAP, + "! Whether to use fuzzy matching for the entity. + FUZZY_MATCH type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_ENTITY. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_TEXT, + "! The text of the response. + TEXT type STRING, + end of T_RUNTIME_RESPONSE_TYPE_TEXT. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_TIME, + "! 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). + DATETIME_LINK type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + PART_OF_DAY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RELATIVE_HOUR type NUMBER, + "! 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`). + RELATIVE_MINUTE type NUMBER, + "! 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`). + RELATIVE_SECOND type NUMBER, + "! A recognized specific hour mentioned as part of a time value (for example, `10` + "! for `10:15 AM`.). + SPECIFIC_HOUR type NUMBER, + "! A recognized specific minute mentioned as part of a time value (for example, + "! `15` for `10:15 AM`.). + SPECIFIC_MINUTE type NUMBER, + "! A recognized specific second mentioned as part of a time value (for example, + "! `30` for `10:15:30 AM`.). + SPECIFIC_SECOND type NUMBER, + "! A recognized time zone mentioned as part of a time value (for example, `EST`). + TIMEZONE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_TIME. + types: + "! No documentation available. + begin of T_UPDATE_EXAMPLE, + "! 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. + TEXT type STRING, + "! An array of contextual entity mentions. + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_UPDATE_EXAMPLE. + types: + "! An object describing a contextual entity mention. + begin of T_ENTITY_MENTION, + "! The text of the user input example. + TEXT type STRING, + "! The name of the intent. + INTENT type STRING, + "! An array of zero-based character offsets that indicate where the entity mentions + "! begin and end in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_ENTITY_MENTION. + types: + "! No documentation available. + begin of T_DIA_ND_OTPT_RESP_TYP_SRCH_S1, + "! 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/services/discovery/query-operators.ht + "! ml#query-operators). Required when **response_type**=`search_skill`. + QUERY type STRING, + "! The type of the search query. Required when **response_type**=`search_skill`. + QUERY_TYPE type STRING, + "! 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/services/discovery/query-parameters.h + "! tml#filter). + FILTER type STRING, + "! The version of the Discovery service API to use for the query. + DISCOVERY_VERSION type STRING, + end of T_DIA_ND_OTPT_RESP_TYP_SRCH_S1. + types: + "! No documentation available. + begin of T_EXAMPLE_COLLECTION, + "! An array of objects describing the examples defined for the intent. + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_EXAMPLE_COLLECTION. + types: + "! The pagination data for the returned objects. + begin of T_LOG_PAGINATION, + "! The URL that will return the next page of results, if any. + NEXT_URL type STRING, + "! Reserved for future use. + MATCHED type INTEGER, + "! A token identifying the next page of results. + NEXT_CURSOR type STRING, + end of T_LOG_PAGINATION. + types: + "! No documentation available. + begin of T_RT_RESP_TYP_CONNECT_TO_AGENT, + "! A message to be sent to the human agent who will be taking over the + "! conversation. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! A label identifying the topic of the conversation, derived from the + "! **user_label** property of the relevant node. + TOPIC type STRING, + "! The ID of the dialog node that the **topic** property is taken from. The + "! **topic** property is populated using the value of the dialog node's + "! **user_label** property. + DIALOG_NODE type STRING, + end of T_RT_RESP_TYP_CONNECT_TO_AGENT. + types: + "! No documentation available. + begin of T_CREATE_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. + VALUE type STRING, + "! Any metadata related to the entity value. + METADATA type MAP, + "! Specifies the type of entity value. + TYPE type STRING, + "! 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. + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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#e + "! ntities-create-dictionary-based). + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_CREATE_VALUE. + types: + "! No documentation available. + begin of T_DIALOG_NODE_VISITED_DETAILS, + "! A dialog node that was triggered during processing of the input message. + DIALOG_NODE type STRING, + "! The title of the dialog node. + TITLE type STRING, + "! The conditions that trigger the dialog node. + CONDITIONS type STRING, + end of T_DIALOG_NODE_VISITED_DETAILS. + types: + "! No documentation available. + begin of T_DIA_SUGGESTION_RESP_GENERIC, + "! The type of response returned by the dialog node. The specified response type + "! must be supported by the client application or channel.
+ "!
+ "! **Note:** The **suggestion** response type is part of the disambiguation + "! feature, which is only available for Plus and Premium users. The + "! **search_skill** response type is available only for Plus and Premium users, + "! and is used only by the v2 runtime API. + RESPONSE_TYPE type STRING, + "! The text of the response. + TEXT type STRING, + "! How long to pause, in milliseconds. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. + TYPING type BOOLEAN, + "! The URL of the image. + SOURCE type STRING, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + "! The preferred type of control to display. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! A message to be sent to the human agent who will be taking over the + "! conversation. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! A label identifying the topic of the conversation, derived from the + "! **user_label** property of the relevant node. + TOPIC type STRING, + "! The ID of the dialog node that the **topic** property is taken from. The + "! **topic** property is populated using the value of the dialog node's + "! **user_label** property. + DIALOG_NODE type STRING, + end of T_DIA_SUGGESTION_RESP_GENERIC. + types: + "! 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. + begin of T_DIALOG_SUGGESTION_VALUE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! An array of intents to be sent along with the user input. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of entities to be sent along with the user input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + end of T_DIALOG_SUGGESTION_VALUE. + types: + "! The dialog output that will be returned from the Watson Assistant service if the + "! user selects the corresponding option. + begin of T_DIALOG_SUGGESTION_OUTPUT, + "! 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. + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + "! An array of responses to the user. + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Output intended for any channel. It is the responsibility of the client + "! application to implement the supported response types. + GENERIC type STANDARD TABLE OF T_DIA_SUGGESTION_RESP_GENERIC WITH NON-UNIQUE DEFAULT KEY, + end of T_DIALOG_SUGGESTION_OUTPUT. + types: + "! No documentation available. + begin of T_DIALOG_SUGGESTION, + "! The user-facing label for the disambiguation option. This label is taken from + "! the **title** or **user_label** property of the corresponding dialog node, + "! depending on the disambiguation options. + LABEL type STRING, + "! 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. + VALUE type T_DIALOG_SUGGESTION_VALUE, + "! The dialog output that will be returned from the Watson Assistant service if the + "! user selects the corresponding option. + OUTPUT type T_DIALOG_SUGGESTION_OUTPUT, + "! The ID of the dialog node that the **label** property is taken from. The + "! **label** property is populated using the value of the dialog node's + "! **user_label** property. + DIALOG_NODE type STRING, + end of T_DIALOG_SUGGESTION. + types: + "! No documentation available. + T_EMPTY_RESPONSE type JSONOBJECT. + types: + "! No documentation available. + begin of T_UPDATE_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. + VALUE type STRING, + "! Any metadata related to the entity value. + METADATA type MAP, + "! Specifies the type of entity value. + TYPE type STRING, + "! 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. + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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#e + "! ntities-create-dictionary-based). + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_UPDATE_VALUE. + types: + "! An alternative value for the recognized entity. + begin of T_RUNTIME_ENTITY_ALTERNATIVE, + "! The entity value that was recognized in the user input. + VALUE type STRING, + "! A decimal percentage that represents Watson's confidence in the recognized + "! entity. + CONFIDENCE type NUMBER, + end of T_RUNTIME_ENTITY_ALTERNATIVE. + types: + "! No documentation available. + begin of T_UPDATE_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-`. + INTENT type STRING, + "! The description of the intent. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of user input examples for the intent. + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_INTENT. + types: + "! No documentation available. + begin of T_VALUE_COLLECTION, + "! An array of entity values. + VALUES type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_VALUE_COLLECTION. + types: + "! Log message details. + begin of T_LOG_MESSAGE, + "! The severity of the log message. + LEVEL type STRING, + "! The text of the log message. + MSG type STRING, + end of T_LOG_MESSAGE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_GENERIC, + "! The type of response returned by the dialog node. The specified response type + "! must be supported by the client application or channel.
+ "!
+ "! **Note:** The **suggestion** response type is part of the disambiguation + "! feature, which is only available for Plus and Premium users. + RESPONSE_TYPE type STRING, + "! The text of the response. + TEXT type STRING, + "! How long to pause, in milliseconds. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. + TYPING type BOOLEAN, + "! The URL of the image. + SOURCE type STRING, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + "! The preferred type of control to display. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! A message to be sent to the human agent who will be taking over the + "! conversation. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! A label identifying the topic of the conversation, derived from the + "! **user_label** property of the relevant node. + TOPIC type STRING, + "! The ID of the dialog node that the **topic** property is taken from. The + "! **topic** property is populated using the value of the dialog node's + "! **user_label** property. + DIALOG_NODE type STRING, + "! An array of objects describing the possible matching dialog nodes from which the + "! user can choose.
+ "!
+ "! **Note:** The **suggestions** property is part of the disambiguation feature, + "! which is only available for Plus and Premium users. + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_GENERIC. + types: + "! An output object that includes the response to the user, the dialog nodes that + "! were triggered, and messages from the log. + begin of T_OUTPUT_DATA, + "! 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. + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + "! An array of up to 50 messages logged with the request. + LOG_MESSAGES type STANDARD TABLE OF T_LOG_MESSAGE WITH NON-UNIQUE DEFAULT KEY, + "! An array of responses to the user. + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Output intended for any channel. It is the responsibility of the client + "! application to implement the supported response types. + GENERIC type STANDARD TABLE OF T_RUNTIME_RESPONSE_GENERIC WITH NON-UNIQUE DEFAULT KEY, + end of T_OUTPUT_DATA. + types: + "! An array of dialog nodes. + begin of T_DIALOG_NODE_COLLECTION, + "! An array of objects describing the dialog nodes defined for the workspace. + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_DIALOG_NODE_COLLECTION. + types: + "! For internal use only. + T_SYSTEM_RESPONSE type MAP. + types: + "! Metadata related to the message. + begin of T_MESSAGE_CONTEXT_METADATA, + "! A label identifying the deployment environment, used for filtering log data. + "! This string cannot contain carriage return, newline, or tab characters. + DEPLOYMENT type STRING, + "! A string value that identifies the user who is interacting with the workspace. + "! The client must provide a unique identifier for each individual end user who + "! accesses the application. For Plus and Premium plans, this user ID is used to + "! identify unique users for billing purposes. This string cannot contain carriage + "! return, newline, or tab characters. + USER_ID type STRING, + end of T_MESSAGE_CONTEXT_METADATA. + types: + "! State information for the conversation. To maintain state, include the context + "! from the previous response. + begin of T_CONTEXT, + "! The unique identifier of the conversation. + CONVERSATION_ID type STRING, + "! For internal use only. + SYSTEM type T_SYSTEM_RESPONSE, + "! Metadata related to the message. + METADATA type T_MESSAGE_CONTEXT_METADATA, + end of T_CONTEXT. + types: + "! The response sent by the workspace, including the output text, detected intents + "! and entities, and context. + begin of T_MESSAGE_RESPONSE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! An array of intents recognized in the user input, sorted in descending order of + "! confidence. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of entities identified in the user input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! Whether to return more than one intent. A value of `true` indicates that all + "! matching intents are returned. + ALTERNATE_INTENTS type BOOLEAN, + "! State information for the conversation. To maintain state, include the context + "! from the previous response. + CONTEXT type T_CONTEXT, + "! An output object that includes the response to the user, the dialog nodes that + "! were triggered, and messages from the log. + OUTPUT type T_OUTPUT_DATA, + "! An array of objects describing any actions requested by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_MESSAGE_RESPONSE. + types: + "! No documentation available. + begin of T_BASE_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. + VALUE type STRING, + "! Any metadata related to the entity value. + METADATA type MAP, + "! Specifies the type of entity value. + TYPE type STRING, + "! 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. + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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#e + "! ntities-create-dictionary-based). + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_VALUE. + types: + "! No documentation available. + begin of T_UPDATE_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-`. + ENTITY type STRING, + "! The description of the entity. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! Any metadata related to the entity. + METADATA type MAP, + "! Whether to use fuzzy matching for the entity. + FUZZY_MATCH type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of objects describing the entity values. + VALUES type STANDARD TABLE OF T_CREATE_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_ENTITY. + types: + "! No documentation available. + begin of T_UPDATE_DIALOG_NODE, + "! The dialog node ID. This string must conform to the following restrictions:
+ "! - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + "! characters. + DIALOG_NODE type STRING, + "! The description of the dialog node. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The condition that will trigger the dialog node. This string cannot contain + "! carriage return, newline, or tab characters. + CONDITIONS type STRING, + "! The ID of the parent dialog node. This property is omitted if the dialog node + "! has no parent. + PARENT type STRING, + "! The ID of the previous sibling dialog node. This property is omitted if the + "! dialog node has no previous sibling. + PREVIOUS_SIBLING type STRING, + "! 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-ove + "! rview#dialog-overview-responses). + OUTPUT type T_DIALOG_NODE_OUTPUT, + "! The context for the dialog node. + CONTEXT type MAP, + "! The metadata for the dialog node. + METADATA type MAP, + "! The next step to execute following this dialog node. + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + "! 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. + TITLE type STRING, + "! How the dialog node is processed. + TYPE type STRING, + "! How an `event_handler` node is processed. + EVENT_NAME type STRING, + "! The location in the dialog context where output is stored. + VARIABLE type STRING, + "! An array of objects describing any actions to be invoked by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + "! Whether this top-level dialog node can be digressed into. + DIGRESS_IN type STRING, + "! Whether this dialog node can be returned to after a digression. + DIGRESS_OUT type STRING, + "! Whether the user can digress to top-level nodes while filling out slots. + DIGRESS_OUT_SLOTS type STRING, + "! A label that can be displayed externally to describe the purpose of the node to + "! users. + USER_LABEL type STRING, + "! Whether the dialog node should be excluded from disambiguation suggestions. + DISAMBIGUATION_OPT_OUT type BOOLEAN, + "! For internal use only. + DISABLED type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_UPDATE_DIALOG_NODE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_PAUSE, + "! How long to pause, in milliseconds. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. + TYPING type BOOLEAN, + end of T_RUNTIME_RESPONSE_TYPE_PAUSE. + types: + "! No documentation available. + begin of T_DIA_ND_OTPT_RESP_TYP_CNNCT_1, + "! An optional message to be sent to the human agent who will be taking over the + "! conversation. Valid only when **reponse_type**=`connect_to_agent`. + MESSAGE_TO_HUMAN_AGENT type STRING, + end of T_DIA_ND_OTPT_RESP_TYP_CNNCT_1. + types: + "! No documentation available. + begin of T_ERROR_DETAIL, + "! Description of a specific constraint violation. + MESSAGE type STRING, + "! The location of the constraint violation. + PATH type STRING, + end of T_ERROR_DETAIL. + types: + "! No documentation available. + begin of T_CREATE_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-`. + INTENT type STRING, + "! The description of the intent. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of user input examples for the intent. + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_INTENT. + types: + "! No documentation available. + begin of T_CREATE_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.). + ENTITY type STRING, + "! The description of the entity. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! Any metadata related to the entity. + METADATA type MAP, + "! Whether to use fuzzy matching for the entity. + FUZZY_MATCH type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of objects describing the entity values. + VALUES type STANDARD TABLE OF T_CREATE_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_ENTITY. + types: + "! No documentation available. + begin of T_CREATE_WORKSPACE, + "! The name of the workspace. This string cannot contain carriage return, newline, + "! or tab characters. + NAME type STRING, + "! The description of the workspace. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The language of the workspace. + LANGUAGE type STRING, + "! Any metadata related to the workspace. + METADATA type MAP, + "! 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. + LEARNING_OPT_OUT type BOOLEAN, + "! Global settings for the workspace. + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + "! The workspace ID of the workspace. + WORKSPACE_ID type STRING, + "! The current status of the workspace. + STATUS type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of objects defining the intents for the workspace. + INTENTS type STANDARD TABLE OF T_CREATE_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the entities for the workspace. + ENTITIES type STANDARD TABLE OF T_CREATE_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the dialog nodes in the workspace. + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects defining input examples that have been marked as irrelevant + "! input. + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + "! No documentation available. + WEBHOOKS type STANDARD TABLE OF T_WEBHOOK WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_WORKSPACE. + types: + "! No documentation available. + begin of T_COUNTEREXAMPLE_COLLECTION, + "! An array of objects describing the examples marked as irrelevant input. + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_COUNTEREXAMPLE_COLLECTION. + types: + "! No documentation available. + begin of T_BASE_EXAMPLE, + "! 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. + TEXT type STRING, + "! An array of contextual entity mentions. + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_EXAMPLE. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_NUM, + "! A recognized numeric value, represented as an integer or double. + NUMERIC_VALUE type NUMBER, + "! 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`). + RANGE_LINK type STRING, + "! The type of numeric value recognized in the user input (`integer` or + "! `rational`). + SUBTYPE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_NUM. + types: + "! No documentation available. + begin of T_UPDATE_COUNTEREXAMPLE, + "! 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. + TEXT type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_UPDATE_COUNTEREXAMPLE. + types: + "! An array of objects describing the entities for the workspace. + begin of T_ENTITY_COLLECTION, + "! An array of objects describing the entities defined for the workspace. + ENTITIES type STANDARD TABLE OF T_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_ENTITY_COLLECTION. + types: + "! No documentation available. + begin of T_INTENT_COLLECTION, + "! An array of objects describing the intents defined for the workspace. + INTENTS type STANDARD TABLE OF T_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_INTENT_COLLECTION. + types: + "! No documentation available. + begin of T_DIA_ND_OTPT_RESP_TYPE_PAUSE, + "! How long to pause, in milliseconds. The valid values are from 0 to 10000. Valid + "! only when **response_type**=`pause`. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. Ignored if the + "! channel does not support this event. Valid only when **response_type**=`pause`. + "! + TYPING type BOOLEAN, + end of T_DIA_ND_OTPT_RESP_TYPE_PAUSE. + types: + "! No documentation available. + begin of T_DIA_ND_OUTPUT_RESP_TYPE_IMG, + "! The URL of the image. Required when **response_type**=`image`. + SOURCE type STRING, + "! An optional title to show before the response. Valid only when + "! **response_type**=`image` or `option`. + TITLE type STRING, + "! An optional description to show with the response. Valid only when + "! **response_type**=`image` or `option`. + DESCRIPTION type STRING, + end of T_DIA_ND_OUTPUT_RESP_TYPE_IMG. + types: + "! No documentation available. + begin of T_ERROR_RESPONSE, + "! General description of an error. + ERROR type STRING, + "! Collection of specific constraint violations associated with the error. + ERRORS type STANDARD TABLE OF T_ERROR_DETAIL WITH NON-UNIQUE DEFAULT KEY, + "! HTTP status code for the error response. + CODE type INTEGER, + end of T_ERROR_RESPONSE. + types: + "! No documentation available. + begin of T_BASE_MESSAGE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! An array of intents recognized in the user input, sorted in descending order of + "! confidence. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of entities identified in the user input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! Whether to return more than one intent. A value of `true` indicates that all + "! matching intents are returned. + ALTERNATE_INTENTS type BOOLEAN, + "! State information for the conversation. To maintain state, include the context + "! from the previous response. + CONTEXT type T_CONTEXT, + "! An output object that includes the response to the user, the dialog nodes that + "! were triggered, and messages from the log. + OUTPUT type T_OUTPUT_DATA, + "! An array of objects describing any actions requested by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_MESSAGE. + types: + "! No documentation available. + begin of T_RT_RESPONSE_TYPE_SUGGESTION, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! An array of objects describing the possible matching dialog nodes from which the + "! user can choose.
+ "!
+ "! **Note:** The **suggestions** property is part of the disambiguation feature, + "! which is only available for Plus and Premium users. + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + end of T_RT_RESPONSE_TYPE_SUGGESTION. + types: + "! No documentation available. + begin of T_ENTITY_MENTION_COLLECTION, + "! An array of objects describing the entity mentions defined for an entity. + EXAMPLES type STANDARD TABLE OF T_ENTITY_MENTION WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_ENTITY_MENTION_COLLECTION. + types: + "! No documentation available. + begin of T_UPDATE_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. + SYNONYM type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_UPDATE_SYNONYM. + types: + "! No documentation available. + begin of T_BASE_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-`. + INTENT type STRING, + "! The description of the intent. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_INTENT. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_DATE, + "! The calendar used to represent a recognized date (for example, `Gregorian`). + CALENDAR_TYPE type STRING, + "! A unique identifier used to associate a 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). + DATETIME_LINK type STRING, + "! 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. + FESTIVAL type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RANGE_MODIFIER type STRING, + "! 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`). + RELATIVE_DAY type NUMBER, + "! 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`). + RELATIVE_MONTH type NUMBER, + "! 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). + RELATIVE_WEEK type NUMBER, + "! 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`). + RELATIVE_WEEKEND type NUMBER, + "! 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`). + RELATIVE_YEAR type NUMBER, + "! A recognized mention of a specific date, represented numerically as the date + "! within the month (for example, `30` for `June 30`.). + SPECIFIC_DAY type NUMBER, + "! A recognized mention of a specific day of the week as a lowercase string (for + "! example, `monday`). + SPECIFIC_DAY_OF_WEEK type STRING, + "! A recognized mention of a specific month, represented numerically (for example, + "! `7` for `July`). + SPECIFIC_MONTH type NUMBER, + "! A recognized mention of a specific quarter, represented numerically (for + "! example, `3` for `the third quarter`). + SPECIFIC_QUARTER type NUMBER, + "! A recognized mention of a specific year (for example, `2016`). + SPECIFIC_YEAR type NUMBER, + end of T_RT_ENTTY_INTRPRTTN_SYS_DATE. + types: + "! No documentation available. + begin of T_DIA_ND_OUTPUT_RESP_TYPE_OPT, + "! An optional title to show before the response. Valid only when + "! **response_type**=`image` or `option`. + TITLE type STRING, + "! An optional description to show with the response. Valid only when + "! **response_type**=`image` or `option`. + DESCRIPTION type STRING, + "! The preferred type of control to display, if supported by the channel. Valid + "! only when **response_type**=`option`. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. You + "! can include up to 20 options. Required when **response_type**=`option`. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_DIA_ND_OUTPUT_RESP_TYPE_OPT. + types: + "! No documentation available. + begin of T_BASE_COUNTEREXAMPLE, + "! 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. + TEXT type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_COUNTEREXAMPLE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_IMAGE, + "! The URL of the image. + SOURCE type STRING, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + end of T_RUNTIME_RESPONSE_TYPE_IMAGE. + types: + "! No documentation available. + begin of T_UPDATE_WORKSPACE, + "! The name of the workspace. This string cannot contain carriage return, newline, + "! or tab characters. + NAME type STRING, + "! The description of the workspace. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The language of the workspace. + LANGUAGE type STRING, + "! Any metadata related to the workspace. + METADATA type MAP, + "! 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. + LEARNING_OPT_OUT type BOOLEAN, + "! Global settings for the workspace. + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + "! The workspace ID of the workspace. + WORKSPACE_ID type STRING, + "! The current status of the workspace. + STATUS type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + "! An array of objects defining the intents for the workspace. + INTENTS type STANDARD TABLE OF T_CREATE_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the entities for the workspace. + ENTITIES type STANDARD TABLE OF T_CREATE_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing the dialog nodes in the workspace. + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects defining input examples that have been marked as irrelevant + "! input. + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + "! No documentation available. + WEBHOOKS type STANDARD TABLE OF T_WEBHOOK WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_WORKSPACE. + types: + "! No documentation available. + begin of T_BASE_DIALOG_NODE, + "! The dialog node ID. This string must conform to the following restrictions:
+ "! - It can contain only Unicode alphanumeric, space, underscore, hyphen, and dot + "! characters. + DIALOG_NODE type STRING, + "! The description of the dialog node. This string cannot contain carriage return, + "! newline, or tab characters. + DESCRIPTION type STRING, + "! The condition that will trigger the dialog node. This string cannot contain + "! carriage return, newline, or tab characters. + CONDITIONS type STRING, + "! The ID of the parent dialog node. This property is omitted if the dialog node + "! has no parent. + PARENT type STRING, + "! The ID of the previous sibling dialog node. This property is omitted if the + "! dialog node has no previous sibling. + PREVIOUS_SIBLING type STRING, + "! 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-ove + "! rview#dialog-overview-responses). + OUTPUT type T_DIALOG_NODE_OUTPUT, + "! The context for the dialog node. + CONTEXT type MAP, + "! The metadata for the dialog node. + METADATA type MAP, + "! The next step to execute following this dialog node. + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + "! 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. + TITLE type STRING, + "! How the dialog node is processed. + TYPE type STRING, + "! How an `event_handler` node is processed. + EVENT_NAME type STRING, + "! The location in the dialog context where output is stored. + VARIABLE type STRING, + "! An array of objects describing any actions to be invoked by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + "! Whether this top-level dialog node can be digressed into. + DIGRESS_IN type STRING, + "! Whether this dialog node can be returned to after a digression. + DIGRESS_OUT type STRING, + "! Whether the user can digress to top-level nodes while filling out slots. + DIGRESS_OUT_SLOTS type STRING, + "! A label that can be displayed externally to describe the purpose of the node to + "! users. + USER_LABEL type STRING, + "! Whether the dialog node should be excluded from disambiguation suggestions. + DISAMBIGUATION_OPT_OUT type BOOLEAN, + "! For internal use only. + DISABLED type BOOLEAN, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_DIALOG_NODE. + types: + "! A request sent to the workspace, including the user input and context. + begin of T_MESSAGE_REQUEST, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! Intents to use when evaluating the user input. Include intents from the previous + "! response to continue using those intents rather than trying to recognize + "! intents in the new input. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! Entities to use when evaluating the message. Include entities from the previous + "! response to continue using those entities rather than detecting entities in the + "! new input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! Whether to return more than one intent. A value of `true` indicates that all + "! matching intents are returned. + ALTERNATE_INTENTS type BOOLEAN, + "! State information for the conversation. To maintain state, include the context + "! from the previous response. + CONTEXT type T_CONTEXT, + "! An output object that includes the response to the user, the dialog nodes that + "! were triggered, and messages from the log. + OUTPUT type T_OUTPUT_DATA, + "! An array of objects describing any actions requested by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_MESSAGE_REQUEST. + types: + "! No documentation available. + begin of T_LOG, + "! A request sent to the workspace, including the user input and context. + REQUEST type T_MESSAGE_REQUEST, + "! The response sent by the workspace, including the output text, detected intents + "! and entities, and context. + RESPONSE type T_MESSAGE_RESPONSE, + "! A unique identifier for the logged event. + LOG_ID type STRING, + "! The timestamp for receipt of the message. + REQUEST_TIMESTAMP type STRING, + "! The timestamp for the system response to the message. + RESPONSE_TIMESTAMP type STRING, + "! The unique identifier of the workspace where the request was made. + WORKSPACE_ID type STRING, + "! The language of the workspace where the message request was made. + LANGUAGE type STRING, + end of T_LOG. + types: + "! An output object that includes the response to the user, the dialog nodes that + "! were triggered, and messages from the log. + begin of T_BASE_OUTPUT, + "! 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. + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_OUTPUT. + types: + "! No documentation available. + begin of T_LOG_COLLECTION, + "! An array of objects describing log events. + LOGS type STANDARD TABLE OF T_LOG WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_LOG_PAGINATION, + end of T_LOG_COLLECTION. + types: + "! No documentation available. + begin of T_AUDIT_PROPERTIES, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_AUDIT_PROPERTIES. + types: + "! No documentation available. + begin of T_WORKSPACE_COLLECTION, + "! An array of objects describing the workspaces associated with the service + "! instance. + WORKSPACES type STANDARD TABLE OF T_WORKSPACE WITH NON-UNIQUE DEFAULT KEY, + "! The pagination data for the returned objects. + PAGINATION type T_PAGINATION, + end of T_WORKSPACE_COLLECTION. + types: + "! No documentation available. + begin of T_BASE_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. + SYNONYM type STRING, + "! The timestamp for creation of the object. + CREATED type DATETIME, + "! The timestamp for the most recent update to the object. + UPDATED type DATETIME, + end of T_BASE_SYNONYM. + +constants: + begin of C_REQUIRED_FIELDS, + T_WS_SYSTEM_SETTINGS_OFF_TOPIC type string value '|', + T_RT_ENTITY_INTERPRETATION type string value '|', + T_WEBHOOK_HEADER type string value '|NAME|VALUE|', + T_DIALOG_NODE_ACTION type string value '|NAME|RESULT_VARIABLE|', + T_WS_SYSTM_STTNGS_DSMBGTN type string value '|', + T_DIALOG_NODE_OUTPUT_MODIFIERS type string value '|', + T_DIALOG_NODE_NEXT_STEP type string value '|BEHAVIOR|', + T_MESSAGE_INPUT type string value '|', + T_CAPTURE_GROUP type string value '|GROUP|', + T_RUNTIME_ENTITY_ROLE type string value '|', + T_RUNTIME_ENTITY type string value '|ENTITY|LOCATION|VALUE|', + T_RUNTIME_INTENT type string value '|INTENT|CONFIDENCE|', + T_DIA_ND_OUTPUT_OPT_ELEM_VALUE type string value '|', + T_DIA_NODE_OUTPUT_OPT_ELEMENT type string value '|LABEL|VALUE|', + T_DIA_ND_OTPT_TEXT_VALUES_ELEM type string value '|', + T_DIALOG_NODE_OUTPUT_GENERIC type string value '|RESPONSE_TYPE|', + T_DIALOG_NODE_OUTPUT type string value '|', + T_DIALOG_NODE type string value '|DIALOG_NODE|', + T_VALUE type string value '|VALUE|TYPE|', + T_WEBHOOK type string value '|URL|NAME|', + T_WS_SYSTM_STTNGS_SYSTM_ENTTS type string value '|', + T_MENTION type string value '|ENTITY|LOCATION|', + T_EXAMPLE type string value '|TEXT|', + T_INTENT type string value '|INTENT|', + T_WS_SYSTEM_SETTINGS_TOOLING type string value '|', + T_WORKSPACE_SYSTEM_SETTINGS type string value '|', + T_COUNTEREXAMPLE type string value '|TEXT|', + T_ENTITY type string value '|ENTITY|', + T_WORKSPACE type string value '|NAME|LANGUAGE|LEARNING_OPT_OUT|WORKSPACE_ID|', + T_SYNONYM type string value '|SYNONYM|', + T_PAGINATION type string value '|REFRESH_URL|', + T_SYNONYM_COLLECTION type string value '|SYNONYMS|PAGINATION|', + T_RUNTIME_RESPONSE_TYPE_OPTION type string value '|', + T_DIA_ND_OUTPUT_RESP_TYPE_TEXT type string value '|', + T_BASE_WORKSPACE type string value '|', + T_BASE_ENTITY type string value '|', + T_RUNTIME_RESPONSE_TYPE_TEXT type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_TIME type string value '|', + T_UPDATE_EXAMPLE type string value '|', + T_ENTITY_MENTION type string value '|TEXT|INTENT|LOCATION|', + T_DIA_ND_OTPT_RESP_TYP_SRCH_S1 type string value '|', + T_EXAMPLE_COLLECTION type string value '|EXAMPLES|PAGINATION|', + T_LOG_PAGINATION type string value '|', + T_RT_RESP_TYP_CONNECT_TO_AGENT type string value '|', + T_CREATE_VALUE type string value '|VALUE|', + T_DIALOG_NODE_VISITED_DETAILS type string value '|', + T_DIA_SUGGESTION_RESP_GENERIC type string value '|RESPONSE_TYPE|', + T_DIALOG_SUGGESTION_VALUE type string value '|', + T_DIALOG_SUGGESTION_OUTPUT type string value '|TEXT|', + T_DIALOG_SUGGESTION type string value '|LABEL|VALUE|', + T_UPDATE_VALUE type string value '|', + T_RUNTIME_ENTITY_ALTERNATIVE type string value '|', + T_UPDATE_INTENT type string value '|', + T_VALUE_COLLECTION type string value '|VALUES|PAGINATION|', + T_LOG_MESSAGE type string value '|LEVEL|MSG|', + T_RUNTIME_RESPONSE_GENERIC type string value '|RESPONSE_TYPE|', + T_OUTPUT_DATA type string value '|LOG_MESSAGES|TEXT|', + T_DIALOG_NODE_COLLECTION type string value '|DIALOG_NODES|PAGINATION|', + T_MESSAGE_CONTEXT_METADATA type string value '|', + T_CONTEXT type string value '|', + T_MESSAGE_RESPONSE type string value '|INPUT|INTENTS|ENTITIES|CONTEXT|OUTPUT|', + T_BASE_VALUE type string value '|', + T_UPDATE_ENTITY type string value '|', + T_UPDATE_DIALOG_NODE type string value '|', + T_RUNTIME_RESPONSE_TYPE_PAUSE type string value '|', + T_DIA_ND_OTPT_RESP_TYP_CNNCT_1 type string value '|', + T_ERROR_DETAIL type string value '|MESSAGE|', + T_CREATE_INTENT type string value '|INTENT|', + T_CREATE_ENTITY type string value '|ENTITY|', + T_CREATE_WORKSPACE type string value '|', + T_COUNTEREXAMPLE_COLLECTION type string value '|COUNTEREXAMPLES|PAGINATION|', + T_BASE_EXAMPLE type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_NUM type string value '|', + T_UPDATE_COUNTEREXAMPLE type string value '|', + T_ENTITY_COLLECTION type string value '|ENTITIES|PAGINATION|', + T_INTENT_COLLECTION type string value '|INTENTS|PAGINATION|', + T_DIA_ND_OTPT_RESP_TYPE_PAUSE type string value '|', + T_DIA_ND_OUTPUT_RESP_TYPE_IMG type string value '|', + T_ERROR_RESPONSE type string value '|ERROR|CODE|', + T_BASE_MESSAGE type string value '|', + T_RT_RESPONSE_TYPE_SUGGESTION type string value '|', + T_ENTITY_MENTION_COLLECTION type string value '|EXAMPLES|PAGINATION|', + T_UPDATE_SYNONYM type string value '|', + T_BASE_INTENT type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_DATE type string value '|', + T_DIA_ND_OUTPUT_RESP_TYPE_OPT type string value '|', + T_BASE_COUNTEREXAMPLE type string value '|', + T_RUNTIME_RESPONSE_TYPE_IMAGE type string value '|', + T_UPDATE_WORKSPACE type string value '|', + T_BASE_DIALOG_NODE type string value '|', + T_MESSAGE_REQUEST type string value '|', + T_LOG type string value '|REQUEST|RESPONSE|LOG_ID|REQUEST_TIMESTAMP|RESPONSE_TIMESTAMP|WORKSPACE_ID|LANGUAGE|', + T_BASE_OUTPUT type string value '|', + T_LOG_COLLECTION type string value '|LOGS|PAGINATION|', + T_AUDIT_PROPERTIES type string value '|', + T_WORKSPACE_COLLECTION type string value '|WORKSPACES|PAGINATION|', + T_BASE_SYNONYM type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + CREATED type string value 'created', + UPDATED type string value 'updated', + TEXT type string value 'text', + DIALOG_NODE type string value 'dialog_node', + DESCRIPTION type string value 'description', + CONDITIONS type string value 'conditions', + PARENT type string value 'parent', + PREVIOUS_SIBLING type string value 'previous_sibling', + OUTPUT type string value 'output', + CONTEXT type string value 'context', + INNER type string value 'inner', + METADATA type string value 'metadata', + NEXT_STEP type string value 'next_step', + TITLE type string value 'title', + TYPE type string value 'type', + EVENT_NAME type string value 'event_name', + VARIABLE type string value 'variable', + ACTIONS type string value 'actions', + DIGRESS_IN type string value 'digress_in', + DIGRESS_OUT type string value 'digress_out', + DIGRESS_OUT_SLOTS type string value 'digress_out_slots', + USER_LABEL type string value 'user_label', + DISAMBIGUATION_OPT_OUT type string value 'disambiguation_opt_out', + DISABLED type string value 'disabled', + ENTITY type string value 'entity', + FUZZY_MATCH type string value 'fuzzy_match', + MENTIONS type string value 'mentions', + INTENT type string value 'intent', + INPUT type string value 'input', + INTENTS type string value 'intents', + ENTITIES type string value 'entities', + ALTERNATE_INTENTS type string value 'alternate_intents', + NODES_VISITED type string value 'nodes_visited', + NODESVISITED type string value 'nodesVisited', + NODES_VISITED_DETAILS type string value 'nodes_visited_details', + NODESVISITEDDETAILS type string value 'nodesVisitedDetails', + SYNONYM type string value 'synonym', + VALUE type string value 'value', + SYNONYMS type string value 'synonyms', + PATTERNS type string value 'patterns', + PATTERN type string value 'pattern', + NAME type string value 'name', + LANGUAGE type string value 'language', + LEARNING_OPT_OUT type string value 'learning_opt_out', + SYSTEM_SETTINGS type string value 'system_settings', + WORKSPACE_ID type string value 'workspace_id', + STATUS type string value 'status', + GROUP type string value 'group', + LOCATION type string value 'location', + CONVERSATION_ID type string value 'conversation_id', + SYSTEM type string value 'system', + COUNTEREXAMPLES type string value 'counterexamples', + PAGINATION type string value 'pagination', + VALUES type string value 'values', + EXAMPLES type string value 'examples', + EXAMPLE type string value 'example', + DIALOG_NODES type string value 'dialog_nodes', + DIALOGNODE type string value 'dialogNode', + COUNTEREXAMPLE type string value 'counterexample', + WEBHOOKS type string value 'webhooks', + PARAMETERS type string value 'parameters', + RESULT_VARIABLE type string value 'result_variable', + CREDENTIALS type string value 'credentials', + DIALOGNODES type string value 'dialogNodes', + BEHAVIOR type string value 'behavior', + SELECTOR type string value 'selector', + GENERIC type string value 'generic', + MODIFIERS type string value 'modifiers', + RESPONSE_TYPE type string value 'response_type', + SELECTION_POLICY type string value 'selection_policy', + DELIMITER type string value 'delimiter', + TIME type string value 'time', + TYPING type string value 'typing', + SOURCE type string value 'source', + PREFERENCE type string value 'preference', + OPTIONS type string value 'options', + MESSAGE_TO_HUMAN_AGENT type string value 'message_to_human_agent', + QUERY type string value 'query', + QUERY_TYPE type string value 'query_type', + FILTER type string value 'filter', + DISCOVERY_VERSION type string value 'discovery_version', + OVERWRITE type string value 'overwrite', + LABEL type string value 'label', + TOPIC type string value 'topic', + MESSAGE type string value 'message', + PATH type string value 'path', + ERROR type string value 'error', + ERRORS type string value 'errors', + CODE type string value 'code', + REQUEST type string value 'request', + RESPONSE type string value 'response', + LOG_ID type string value 'log_id', + REQUEST_TIMESTAMP type string value 'request_timestamp', + RESPONSE_TIMESTAMP type string value 'response_timestamp', + LOGS type string value 'logs', + LEVEL type string value 'level', + MSG type string value 'msg', + NEXT_URL type string value 'next_url', + MATCHED type string value 'matched', + NEXT_CURSOR type string value 'next_cursor', + DEPLOYMENT type string value 'deployment', + USER_ID type string value 'user_id', + LOG_MESSAGES type string value 'log_messages', + LOGMESSAGES type string value 'logMessages', + REFRESH_URL type string value 'refresh_url', + TOTAL type string value 'total', + REFRESH_CURSOR type string value 'refresh_cursor', + CONFIDENCE type string value 'confidence', + GROUPS type string value 'groups', + INTERPRETATION type string value 'interpretation', + ROLE type string value 'role', + CALENDAR_TYPE type string value 'calendar_type', + DATETIME_LINK type string value 'datetime_link', + FESTIVAL type string value 'festival', + GRANULARITY type string value 'granularity', + RANGE_LINK type string value 'range_link', + RANGE_MODIFIER type string value 'range_modifier', + RELATIVE_DAY type string value 'relative_day', + RELATIVE_MONTH type string value 'relative_month', + RELATIVE_WEEK type string value 'relative_week', + RELATIVE_WEEKEND type string value 'relative_weekend', + RELATIVE_YEAR type string value 'relative_year', + SPECIFIC_DAY type string value 'specific_day', + SPECIFIC_DAY_OF_WEEK type string value 'specific_day_of_week', + SPECIFIC_MONTH type string value 'specific_month', + SPECIFIC_QUARTER type string value 'specific_quarter', + SPECIFIC_YEAR type string value 'specific_year', + NUMERIC_VALUE type string value 'numeric_value', + SUBTYPE type string value 'subtype', + PART_OF_DAY type string value 'part_of_day', + RELATIVE_HOUR type string value 'relative_hour', + RELATIVE_MINUTE type string value 'relative_minute', + RELATIVE_SECOND type string value 'relative_second', + SPECIFIC_HOUR type string value 'specific_hour', + SPECIFIC_MINUTE type string value 'specific_minute', + SPECIFIC_SECOND type string value 'specific_second', + TIMEZONE type string value 'timezone', + SUGGESTIONS type string value 'suggestions', + URL type string value 'url', + HEADERS type string value 'headers', + WORKSPACES type string value 'workspaces', + TOOLING type string value 'tooling', + DISAMBIGUATION type string value 'disambiguation', + HUMAN_AGENT_ASSIST type string value 'human_agent_assist', + SYSTEM_ENTITIES type string value 'system_entities', + OFF_TOPIC type string value 'off_topic', + PROMPT type string value 'prompt', + NONE_OF_THE_ABOVE_PROMPT type string value 'none_of_the_above_prompt', + ENABLED type string value 'enabled', + SENSITIVITY type string value 'sensitivity', + RANDOMIZE type string value 'randomize', + MAX_SUGGESTIONS type string value 'max_suggestions', + SUGGESTION_TEXT_POLICY type string value 'suggestion_text_policy', + STORE_GENERIC_RESPONSES type string value 'store_generic_responses', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Get response to user input. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! The message to be sent. This includes the user's input, along with optional + "! intents, entities, and context from the last response. + "! @parameter I_NODES_VISITED_DETAILS | + "! Whether to include additional diagnostic information about the dialog nodes that + "! were visited during processing of the message. + "! @parameter E_RESPONSE | + "! Service return value of type T_MESSAGE_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods MESSAGE + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_MESSAGE_REQUEST optional + !I_NODES_VISITED_DETAILS type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_MESSAGE_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List workspaces. + "! + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned workspaces will be sorted. To reverse the sort + "! order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORKSPACE_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_WORKSPACES + importing + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORKSPACE_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create workspace. + "! + "! @parameter I_BODY | + "! The content of the new workspace.
+ "!
+ "! The maximum size for this data is 50MB. If you need to import a larger + "! workspace, consider importing the workspace without intents and entities and + "! then adding them separately. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORKSPACE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_WORKSPACE + importing + !I_BODY type T_CREATE_WORKSPACE optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORKSPACE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get information about a workspace. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter I_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. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORKSPACE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_WORKSPACE + importing + !I_WORKSPACE_ID type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_SORT type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORKSPACE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update workspace. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! Valid data defining the new and updated workspace content.
+ "!
+ "! The maximum size for this data is 50MB. If you need to import a larger amount of + "! workspace data, consider importing components such as intents and entities + "! using separate operations. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORKSPACE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_WORKSPACE + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_UPDATE_WORKSPACE optional + !I_APPEND type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORKSPACE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete workspace. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_WORKSPACE + importing + !I_WORKSPACE_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List intents. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_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. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned intents will be sorted. To reverse the sort + "! order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_INTENT_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_INTENTS + importing + !I_WORKSPACE_ID type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_INTENT_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create intent. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! The content of the new intent. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_INTENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_INTENT + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_CREATE_INTENT + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_INTENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get intent. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_INTENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_INTENT + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_INTENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update intent. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_BODY | + "! The updated content of the intent.
+ "!
+ "! 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 user input examples for an intent, the previously existing + "! examples are discarded and replaced with the new examples specified in the + "! update. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_INTENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_INTENT + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_BODY type T_UPDATE_INTENT + !I_APPEND type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_INTENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete intent. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_INTENT + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List user input examples. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned examples will be sorted. To reverse the sort + "! order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXAMPLE_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_EXAMPLES + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXAMPLE_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create user input example. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_BODY | + "! The content of the new user input example. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_EXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_BODY type T_EXAMPLE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get user input example. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_TEXT | + "! The text of the user input example. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_EXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_TEXT type STRING + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update user input example. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_TEXT | + "! The text of the user input example. + "! @parameter I_BODY | + "! The new text of the user input example. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_EXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_TEXT type STRING + !I_BODY type T_UPDATE_EXAMPLE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete user input example. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_INTENT | + "! The intent name. + "! @parameter I_TEXT | + "! The text of the user input example. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_EXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_INTENT type STRING + !I_TEXT type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List counterexamples. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned counterexamples will be sorted. To reverse the + "! sort order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_COUNTEREXAMPLES + importing + !I_WORKSPACE_ID type STRING + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COUNTEREXAMPLE_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create counterexample. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! The content of the new counterexample. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_COUNTEREXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_COUNTEREXAMPLE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COUNTEREXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get counterexample. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_TEXT | + "! The text of a user input counterexample (for example, `What are you wearing?`). + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_COUNTEREXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_TEXT type STRING + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COUNTEREXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update counterexample. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_TEXT | + "! The text of a user input counterexample (for example, `What are you wearing?`). + "! @parameter I_BODY | + "! The text of the counterexample. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_COUNTEREXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_TEXT type STRING + !I_BODY type T_UPDATE_COUNTEREXAMPLE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COUNTEREXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete counterexample. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_TEXT | + "! The text of a user input counterexample (for example, `What are you wearing?`). + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_COUNTEREXAMPLE + importing + !I_WORKSPACE_ID type STRING + !I_TEXT type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List entities. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_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. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned entities will be sorted. To reverse the sort + "! order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENTITY_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_ENTITIES + importing + !I_WORKSPACE_ID type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENTITY_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create entity. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! The content of the new entity. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENTITY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_ENTITY + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_CREATE_ENTITY + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENTITY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get entity. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENTITY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_ENTITY + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENTITY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update entity. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_BODY | + "! The updated content of the entity. 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 values for an entity, the + "! previously existing values are discarded and replaced with the new values + "! specified in the update. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENTITY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_ENTITY + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_BODY type T_UPDATE_ENTITY + !I_APPEND type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENTITY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete entity. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_ENTITY + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List entity mentions. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENTITY_MENTION_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_MENTIONS + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENTITY_MENTION_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List entity values. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_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. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned entity values will be sorted. To reverse the + "! sort order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_VALUE_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_VALUES + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VALUE_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create entity value. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_BODY | + "! The new entity value. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_VALUE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_VALUE + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_BODY type T_CREATE_VALUE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VALUE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get entity value. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_VALUE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_VALUE + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_EXPORT type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VALUE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update entity value. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_BODY | + "! The updated content of the entity value.
+ "!
+ "! 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 synonyms for an entity value, the previously existing + "! synonyms are discarded and replaced with the new synonyms specified in the + "! update. + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_VALUE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_VALUE + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_BODY type T_UPDATE_VALUE + !I_APPEND type BOOLEAN default c_boolean_false + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VALUE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete entity value. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_VALUE + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List entity value synonyms. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned entity value synonyms will be sorted. To reverse + "! the sort order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_SYNONYM_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_SYNONYMS + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SYNONYM_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create entity value synonym. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_BODY | + "! The new synonym. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_SYNONYM + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_SYNONYM + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_BODY type T_SYNONYM + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SYNONYM + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get entity value synonym. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_SYNONYM | + "! The text of the synonym. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_SYNONYM + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_SYNONYM + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_SYNONYM type STRING + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SYNONYM + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update entity value synonym. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_SYNONYM | + "! The text of the synonym. + "! @parameter I_BODY | + "! The updated entity value synonym. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_SYNONYM + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_SYNONYM + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_SYNONYM type STRING + !I_BODY type T_UPDATE_SYNONYM + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SYNONYM + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete entity value synonym. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_ENTITY | + "! The name of the entity. + "! @parameter I_VALUE | + "! The text of the entity value. + "! @parameter I_SYNONYM | + "! The text of the synonym. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_SYNONYM + importing + !I_WORKSPACE_ID type STRING + !I_ENTITY type STRING + !I_VALUE type STRING + !I_SYNONYM type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List dialog nodes. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_SORT | + "! The attribute by which returned dialog nodes will be sorted. To reverse the sort + "! order, prefix the value with a minus sign (`-`). + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_DIALOG_NODE_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_DIALOG_NODES + importing + !I_WORKSPACE_ID type STRING + !I_PAGE_LIMIT type INTEGER optional + !I_SORT type STRING optional + !I_CURSOR type STRING optional + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DIALOG_NODE_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create dialog node. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_BODY | + "! A CreateDialogNode object defining the content of the new dialog node. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_DIALOG_NODE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_DIALOG_NODE + importing + !I_WORKSPACE_ID type STRING + !I_BODY type T_DIALOG_NODE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DIALOG_NODE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get dialog node. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_DIALOG_NODE | + "! The dialog node ID (for example, `get_order`). + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_DIALOG_NODE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_DIALOG_NODE + importing + !I_WORKSPACE_ID type STRING + !I_DIALOG_NODE type STRING + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DIALOG_NODE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update dialog node. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_DIALOG_NODE | + "! The dialog node ID (for example, `get_order`). + "! @parameter I_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. + "! @parameter I_INCLUDE_AUDIT | + "! Whether to include the audit properties (`created` and `updated` timestamps) in + "! the response. + "! @parameter E_RESPONSE | + "! Service return value of type T_DIALOG_NODE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_DIALOG_NODE + importing + !I_WORKSPACE_ID type STRING + !I_DIALOG_NODE type STRING + !I_BODY type T_UPDATE_DIALOG_NODE + !I_INCLUDE_AUDIT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DIALOG_NODE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete dialog node. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_DIALOG_NODE | + "! The dialog node ID (for example, `get_order`). + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_DIALOG_NODE + importing + !I_WORKSPACE_ID type STRING + !I_DIALOG_NODE type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List log events in a workspace. + "! + "! @parameter I_WORKSPACE_ID | + "! Unique identifier of the workspace. + "! @parameter I_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 (`-`). + "! @parameter I_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-ref + "! erence#filter-reference). + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter E_RESPONSE | + "! Service return value of type T_LOG_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_LOGS + importing + !I_WORKSPACE_ID type STRING + !I_SORT type STRING optional + !I_FILTER type STRING optional + !I_PAGE_LIMIT type INTEGER optional + !I_CURSOR type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LOG_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List log events in all workspaces. + "! + "! @parameter I_FILTER | + "! A cacheable parameter that limits the results to those matching the specified + "! filter. You must specify a filter query that includes a value for `language`, + "! as well as a value for `request.context.system.assistant_id`, `workspace_id`, + "! or `request.context.metadata.deployment`. For more information, see the + "! [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-ref + "! erence#filter-reference). + "! @parameter I_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 (`-`). + "! @parameter I_PAGE_LIMIT | + "! The number of records to return in each page of results. + "! @parameter I_CURSOR | + "! A token identifying the page of results to retrieve. + "! @parameter E_RESPONSE | + "! Service return value of type T_LOG_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_ALL_LOGS + importing + !I_FILTER type STRING + !I_SORT type STRING optional + !I_PAGE_LIMIT type INTEGER optional + !I_CURSOR type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LOG_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_ASSISTANT_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Watson Assistant v1'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_ASSISTANT_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/assistant/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092810'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->MESSAGE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_MESSAGE_REQUEST(optional) +* | [--->] I_NODES_VISITED_DETAILS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_MESSAGE_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method MESSAGE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/message'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_NODES_VISITED_DETAILS is supplied. + lv_queryparam = i_NODES_VISITED_DETAILS. + add_query_parameter( + exporting + i_parameter = `nodes_visited_details` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_BODY is initial. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_WORKSPACES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORKSPACE_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_WORKSPACES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_WORKSPACE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_BODY TYPE T_CREATE_WORKSPACE(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORKSPACE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_WORKSPACE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_BODY is initial. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_WORKSPACE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORKSPACE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_WORKSPACE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_WORKSPACE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_WORKSPACE(optional) +* | [--->] I_APPEND TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORKSPACE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_WORKSPACE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_APPEND is supplied. + lv_queryparam = i_APPEND. + add_query_parameter( + exporting + i_parameter = `append` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_BODY is initial. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_WORKSPACE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_WORKSPACE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_INTENTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_INTENT_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_INTENTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_INTENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_CREATE_INTENT +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_INTENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_INTENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_INTENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_INTENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_INTENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_INTENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_INTENT +* | [--->] I_APPEND TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_INTENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_INTENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_APPEND is supplied. + lv_queryparam = i_APPEND. + add_query_parameter( + exporting + i_parameter = `append` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_INTENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_INTENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_EXAMPLES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXAMPLE_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_EXAMPLES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}/examples'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_BODY TYPE T_EXAMPLE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}/examples'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_EXAMPLE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_INTENT TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/intents/{intent}/examples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{intent}` in ls_request_prop-url-path with i_INTENT ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_COUNTEREXAMPLES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COUNTEREXAMPLE_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_COUNTEREXAMPLES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/counterexamples'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_COUNTEREXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_COUNTEREXAMPLE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COUNTEREXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_COUNTEREXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/counterexamples'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_COUNTEREXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COUNTEREXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_COUNTEREXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/counterexamples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_COUNTEREXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_COUNTEREXAMPLE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COUNTEREXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_COUNTEREXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/counterexamples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_COUNTEREXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_TEXT TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_COUNTEREXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/counterexamples/{text}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{text}` in ls_request_prop-url-path with i_TEXT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_ENTITIES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENTITY_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_ENTITIES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_ENTITY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_CREATE_ENTITY +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENTITY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_ENTITY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_ENTITY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENTITY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_ENTITY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_ENTITY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_ENTITY +* | [--->] I_APPEND TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENTITY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_ENTITY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_APPEND is supplied. + lv_queryparam = i_APPEND. + add_query_parameter( + exporting + i_parameter = `append` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_ENTITY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_ENTITY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_MENTIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENTITY_MENTION_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_MENTIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/mentions'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_VALUES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VALUE_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_VALUES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_VALUE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_BODY TYPE T_CREATE_VALUE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VALUE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_VALUE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_VALUE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_EXPORT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VALUE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_VALUE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_EXPORT is supplied. + lv_queryparam = i_EXPORT. + add_query_parameter( + exporting + i_parameter = `export` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_VALUE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_VALUE +* | [--->] I_APPEND TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VALUE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_VALUE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_APPEND is supplied. + lv_queryparam = i_APPEND. + add_query_parameter( + exporting + i_parameter = `append` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_VALUE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_VALUE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_SYNONYMS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SYNONYM_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_SYNONYMS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_SYNONYM +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_BODY TYPE T_SYNONYM +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SYNONYM +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_SYNONYM. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_SYNONYM +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_SYNONYM TYPE STRING +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SYNONYM +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_SYNONYM. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + replace all occurrences of `{synonym}` in ls_request_prop-url-path with i_SYNONYM ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_SYNONYM +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_SYNONYM TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_SYNONYM +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SYNONYM +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_SYNONYM. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + replace all occurrences of `{synonym}` in ls_request_prop-url-path with i_SYNONYM ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_SYNONYM +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_ENTITY TYPE STRING +* | [--->] I_VALUE TYPE STRING +* | [--->] I_SYNONYM TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_SYNONYM. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/entities/{entity}/values/{value}/synonyms/{synonym}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{entity}` in ls_request_prop-url-path with i_ENTITY ignoring case. + replace all occurrences of `{value}` in ls_request_prop-url-path with i_VALUE ignoring case. + replace all occurrences of `{synonym}` in ls_request_prop-url-path with i_SYNONYM ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_DIALOG_NODES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DIALOG_NODE_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_DIALOG_NODES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/dialog_nodes'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->CREATE_DIALOG_NODE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_BODY TYPE T_DIALOG_NODE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DIALOG_NODE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_DIALOG_NODE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/dialog_nodes'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->GET_DIALOG_NODE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_DIALOG_NODE TYPE STRING +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DIALOG_NODE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_DIALOG_NODE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{dialog_node}` in ls_request_prop-url-path with i_DIALOG_NODE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->UPDATE_DIALOG_NODE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_DIALOG_NODE TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_DIALOG_NODE +* | [--->] I_INCLUDE_AUDIT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DIALOG_NODE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_DIALOG_NODE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{dialog_node}` in ls_request_prop-url-path with i_DIALOG_NODE ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_INCLUDE_AUDIT is supplied. + lv_queryparam = i_INCLUDE_AUDIT. + add_query_parameter( + exporting + i_parameter = `include_audit` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_DIALOG_NODE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_DIALOG_NODE TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_DIALOG_NODE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/dialog_nodes/{dialog_node}'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + replace all occurrences of `{dialog_node}` in ls_request_prop-url-path with i_DIALOG_NODE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_LOGS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_WORKSPACE_ID TYPE STRING +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_FILTER TYPE STRING(optional) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LOG_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_LOGS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/workspaces/{workspace_id}/logs'. + replace all occurrences of `{workspace_id}` in ls_request_prop-url-path with i_WORKSPACE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_FILTER is supplied. + lv_queryparam = escape( val = i_FILTER format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `filter` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->LIST_ALL_LOGS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILTER TYPE STRING +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LOG_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_ALL_LOGS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/logs'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_FILTER format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `filter` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V1->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/user_data'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_ASSISTANT_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_assistant_v1.clas.xml b/src/zcl_ibmc_assistant_v1.clas.xml new file mode 100644 index 0000000..d53c171 --- /dev/null +++ b/src/zcl_ibmc_assistant_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_ASSISTANT_V1 + E + IBM Watson Assistant V1 + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_assistant_v2.clas.abap b/src/zcl_ibmc_assistant_v2.clas.abap new file mode 100644 index 0000000..469d2d8 --- /dev/null +++ b/src/zcl_ibmc_assistant_v2.clas.abap @@ -0,0 +1,1251 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +"!

Watson Assistant v2

+"! The IBM Watson™ Assistant service combines machine learning, natural +"! language understanding, and an integrated dialog editor to create conversation +"! flows between your apps and your users.
+"!
+"! The Assistant v2 API provides runtime methods your client application can use to +"! send user input to an assistant and receive a response.
+class ZCL_IBMC_ASSISTANT_V2 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Dialog log message details. + begin of T_DIALOG_LOG_MESSAGE, + "! The severity of the log message. + LEVEL type STRING, + "! The text of the log message. + MESSAGE type STRING, + end of T_DIALOG_LOG_MESSAGE. + types: + "! No documentation available. + begin of T_DIALOG_NODES_VISITED, + "! A dialog node that was triggered during processing of the input message. + DIALOG_NODE type STRING, + "! The title of the dialog node. + TITLE type STRING, + "! The conditions that trigger the dialog node. + CONDITIONS type STRING, + end of T_DIALOG_NODES_VISITED. + types: + "! Additional detailed information about a message response and how it was + "! generated. + begin of T_MESSAGE_OUTPUT_DEBUG, + "! An array of objects containing detailed diagnostic information about the nodes + "! that were triggered during processing of the input message. + NODES_VISITED type STANDARD TABLE OF T_DIALOG_NODES_VISITED WITH NON-UNIQUE DEFAULT KEY, + "! An array of up to 50 messages logged with the request. + LOG_MESSAGES type STANDARD TABLE OF T_DIALOG_LOG_MESSAGE WITH NON-UNIQUE DEFAULT KEY, + "! Assistant sets this to true when this message response concludes or interrupts a + "! dialog. + BRANCH_EXITED type BOOLEAN, + "! When `branch_exited` is set to `true` by the Assistant, the + "! `branch_exited_reason` specifies whether the dialog completed by itself or got + "! interrupted. + BRANCH_EXITED_REASON type STRING, + end of T_MESSAGE_OUTPUT_DEBUG. + types: + "! No documentation available. + T_EMPTY_RESPONSE type JSONOBJECT. + types: + "! No documentation available. + begin of T_SESSION_RESPONSE, + "! The session ID. + SESSION_ID type STRING, + end of T_SESSION_RESPONSE. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_NUM, + "! A recognized numeric value, represented as an integer or double. + NUMERIC_VALUE type NUMBER, + "! 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`). + RANGE_LINK type STRING, + "! The type of numeric value recognized in the user input (`integer` or + "! `rational`). + SUBTYPE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_NUM. + types: + "! An alternative value for the recognized entity. + begin of T_RUNTIME_ENTITY_ALTERNATIVE, + "! The entity value that was recognized in the user input. + VALUE type STRING, + "! A decimal percentage that represents Watson's confidence in the recognized + "! entity. + CONFIDENCE type NUMBER, + end of T_RUNTIME_ENTITY_ALTERNATIVE. + types: + "! 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. + begin of T_RUNTIME_ENTITY_ROLE, + "! The relationship of the entity to the range. + TYPE type STRING, + end of T_RUNTIME_ENTITY_ROLE. + types: + "! No documentation available. + begin of T_RT_ENTITY_INTERPRETATION, + "! The calendar used to represent a recognized date (for example, `Gregorian`). + CALENDAR_TYPE type STRING, + "! 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). + DATETIME_LINK type STRING, + "! 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. + FESTIVAL type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RANGE_MODIFIER type STRING, + "! 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`). + RELATIVE_DAY type NUMBER, + "! 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`). + RELATIVE_MONTH type NUMBER, + "! 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). + RELATIVE_WEEK type NUMBER, + "! 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`). + RELATIVE_WEEKEND type NUMBER, + "! 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`). + RELATIVE_YEAR type NUMBER, + "! A recognized mention of a specific date, represented numerically as the date + "! within the month (for example, `30` for `June 30`.). + SPECIFIC_DAY type NUMBER, + "! A recognized mention of a specific day of the week as a lowercase string (for + "! example, `monday`). + SPECIFIC_DAY_OF_WEEK type STRING, + "! A recognized mention of a specific month, represented numerically (for example, + "! `7` for `July`). + SPECIFIC_MONTH type NUMBER, + "! A recognized mention of a specific quarter, represented numerically (for + "! example, `3` for `the third quarter`). + SPECIFIC_QUARTER type NUMBER, + "! A recognized mention of a specific year (for example, `2016`). + SPECIFIC_YEAR type NUMBER, + "! A recognized numeric value, represented as an integer or double. + NUMERIC_VALUE type NUMBER, + "! The type of numeric value recognized in the user input (`integer` or + "! `rational`). + SUBTYPE type STRING, + "! 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`). + PART_OF_DAY type STRING, + "! 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`). + RELATIVE_HOUR type NUMBER, + "! 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`). + RELATIVE_MINUTE type NUMBER, + "! 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`). + RELATIVE_SECOND type NUMBER, + "! A recognized specific hour mentioned as part of a time value (for example, `10` + "! for `10:15 AM`.). + SPECIFIC_HOUR type NUMBER, + "! A recognized specific minute mentioned as part of a time value (for example, + "! `15` for `10:15 AM`.). + SPECIFIC_MINUTE type NUMBER, + "! A recognized specific second mentioned as part of a time value (for example, + "! `30` for `10:15:30 AM`.). + SPECIFIC_SECOND type NUMBER, + "! A recognized time zone mentioned as part of a time value (for example, `EST`). + TIMEZONE type STRING, + end of T_RT_ENTITY_INTERPRETATION. + types: + "! Optional properties that control how the assistant responds. + begin of T_MESSAGE_INPUT_OPTIONS, + "! Whether to return additional diagnostic information. Set to `true` to return + "! additional information under the `output.debug` key. + DEBUG type BOOLEAN, + "! 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. + RESTART type BOOLEAN, + "! Whether to return more than one intent. Set to `true` to return all matching + "! intents. + ALTERNATE_INTENTS type BOOLEAN, + "! Whether to return session context with the response. If you specify `true`, the + "! response will include the `context` property. + RETURN_CONTEXT type BOOLEAN, + end of T_MESSAGE_INPUT_OPTIONS. + types: + "! An intent identified in the user input. + begin of T_RUNTIME_INTENT, + "! The name of the recognized intent. + INTENT type STRING, + "! A decimal percentage that represents Watson's confidence in the intent. + CONFIDENCE type DOUBLE, + end of T_RUNTIME_INTENT. + types: + "! No documentation available. + begin of T_CAPTURE_GROUP, + "! A recognized capture group for the entity. + GROUP type STRING, + "! Zero-based character offsets that indicate where the entity value begins and + "! ends in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_CAPTURE_GROUP. + types: + "! The entity value that was recognized in the user input. + begin of T_RUNTIME_ENTITY, + "! An entity detected in the input. + ENTITY type STRING, + "! An array of zero-based character offsets that indicate where the detected entity + "! values begin and end in the input text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + "! The term in the input text that was recognized as an entity value. + VALUE type STRING, + "! A decimal percentage that represents Watson's confidence in the recognized + "! entity. + CONFIDENCE type NUMBER, + "! Any metadata for the entity. + METADATA type MAP, + "! The recognized capture groups for the entity, as defined by the entity pattern. + GROUPS type STANDARD TABLE OF T_CAPTURE_GROUP WITH NON-UNIQUE DEFAULT KEY, + "! 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-syste + "! m-entities). + INTERPRETATION type T_RT_ENTITY_INTERPRETATION, + "! 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. + ALTERNATIVES type STANDARD TABLE OF T_RUNTIME_ENTITY_ALTERNATIVE WITH NON-UNIQUE DEFAULT KEY, + "! 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. + ROLE type T_RUNTIME_ENTITY_ROLE, + end of T_RUNTIME_ENTITY. + types: + "! An input object that includes the input text. + begin of T_MESSAGE_INPUT, + "! The type of user input. Currently, only text input is supported. + MESSAGE_TYPE type STRING, + "! The text of the user input. This string cannot contain carriage return, newline, + "! or tab characters. + TEXT type STRING, + "! Optional properties that control how the assistant responds. + OPTIONS type T_MESSAGE_INPUT_OPTIONS, + "! Intents to use when evaluating the user input. Include intents from the previous + "! response to continue using those intents rather than trying to recognize + "! intents in the new input. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! Entities to use when evaluating the message. Include entities from the previous + "! response to continue using those entities rather than detecting entities in the + "! new input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! For internal use only. + SUGGESTION_ID type STRING, + end of T_MESSAGE_INPUT. + types: + "! An object defining the message input to be sent to the assistant if the user + "! selects the corresponding option. + begin of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + end of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE. + types: + "! No documentation available. + begin of T_DIA_NODE_OUTPUT_OPT_ELEMENT, + "! The user-facing label for the option. + LABEL type STRING, + "! An object defining the message input to be sent to the assistant if the user + "! selects the corresponding option. + VALUE type T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + end of T_DIA_NODE_OUTPUT_OPT_ELEMENT. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_OPTION, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + "! The preferred type of control to display. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_OPTION. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_DATE, + "! The calendar used to represent a recognized date (for example, `Gregorian`). + CALENDAR_TYPE type STRING, + "! A unique identifier used to associate a 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). + DATETIME_LINK type STRING, + "! 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. + FESTIVAL type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RANGE_MODIFIER type STRING, + "! 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`). + RELATIVE_DAY type NUMBER, + "! 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`). + RELATIVE_MONTH type NUMBER, + "! 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). + RELATIVE_WEEK type NUMBER, + "! 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`). + RELATIVE_WEEKEND type NUMBER, + "! 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`). + RELATIVE_YEAR type NUMBER, + "! A recognized mention of a specific date, represented numerically as the date + "! within the month (for example, `30` for `June 30`.). + SPECIFIC_DAY type NUMBER, + "! A recognized mention of a specific day of the week as a lowercase string (for + "! example, `monday`). + SPECIFIC_DAY_OF_WEEK type STRING, + "! A recognized mention of a specific month, represented numerically (for example, + "! `7` for `July`). + SPECIFIC_MONTH type NUMBER, + "! A recognized mention of a specific quarter, represented numerically (for + "! example, `3` for `the third quarter`). + SPECIFIC_QUARTER type NUMBER, + "! A recognized mention of a specific year (for example, `2016`). + SPECIFIC_YEAR type NUMBER, + end of T_RT_ENTTY_INTRPRTTN_SYS_DATE. + types: + "! An object containing segments of text from search results with query-matching + "! text highlighted using HTML <em> tags. + begin of T_SEARCH_RESULT_HIGHLIGHT, + "! An array of strings containing segments taken from body text in the search + "! results, with query-matching substrings highlighted. + BODY type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array of strings containing segments taken from title text in the search + "! results, with query-matching substrings highlighted. + TITLE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array of strings containing segments taken from URLs in the search results, + "! with query-matching substrings highlighted. + URL type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SEARCH_RESULT_HIGHLIGHT. + types: + "! An object defining the message input to be sent to the assistant if the user + "! selects the corresponding disambiguation option. + begin of T_DIALOG_SUGGESTION_VALUE, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + end of T_DIALOG_SUGGESTION_VALUE. + types: + "! An object containing search result metadata from the Discovery service. + begin of T_SEARCH_RESULT_METADATA, + "! The confidence score for the given result. For more information about how the + "! confidence is calculated, see the Discovery service + "! [documentation](../discovery#query-your-collection). + CONFIDENCE type DOUBLE, + "! 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. + SCORE type DOUBLE, + end of T_SEARCH_RESULT_METADATA. + types: + "! No documentation available. + begin of T_SEARCH_RESULT, + "! The unique identifier of the document in the Discovery service collection.
+ "!
+ "! This property is included in responses from search skills, which are a beta + "! feature available only to Plus or Premium plan users. + ID type STRING, + "! An object containing search result metadata from the Discovery service. + RESULT_METADATA type T_SEARCH_RESULT_METADATA, + "! 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. + BODY type STRING, + "! 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. + TITLE type STRING, + "! The URL of the original data object in its native data source. + URL type STRING, + "! An object containing segments of text from search results with query-matching + "! text highlighted using HTML <em> tags. + HIGHLIGHT type T_SEARCH_RESULT_HIGHLIGHT, + end of T_SEARCH_RESULT. + types: + "! No documentation available. + begin of T_DIALOG_SUGGESTION, + "! The user-facing label for the disambiguation option. This label is taken from + "! the **title** or **user_label** property of the corresponding dialog node, + "! depending on the disambiguation options. + LABEL type STRING, + "! An object defining the message input to be sent to the assistant if the user + "! selects the corresponding disambiguation option. + VALUE type T_DIALOG_SUGGESTION_VALUE, + "! The dialog output that will be returned from the Watson Assistant service if the + "! user selects the corresponding option. + OUTPUT type MAP, + end of T_DIALOG_SUGGESTION. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_GENERIC, + "! The type of response returned by the dialog node. The specified response type + "! must be supported by the client application or channel.
+ "!
+ "! **Note:** The **suggestion** response type is part of the disambiguation + "! feature, which is only available for Premium users. + RESPONSE_TYPE type STRING, + "! The text of the response. + TEXT type STRING, + "! How long to pause, in milliseconds. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. + TYPING type BOOLEAN, + "! The URL of the image. + SOURCE type STRING, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + "! The preferred type of control to display. + PREFERENCE type STRING, + "! An array of objects describing the options from which the user can choose. + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! A message to be sent to the human agent who will be taking over the + "! conversation. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! A label identifying the topic of the conversation, derived from the + "! **user_label** property of the relevant node. + TOPIC type STRING, + "! An array of objects describing the possible matching dialog nodes from which the + "! user can choose.
+ "!
+ "! **Note:** The **suggestions** property is part of the disambiguation feature, + "! which is only available for Premium users. + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + "! The title or introductory text to show before the response. This text is defined + "! in the search skill configuration. + HEADER type STRING, + "! An array of objects containing search results. + RESULTS type STANDARD TABLE OF T_SEARCH_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_GENERIC. + types: + "! No documentation available. + begin of T_ERROR_DETAIL, + "! Description of a specific constraint violation. + MESSAGE type STRING, + "! The location of the constraint violation. + PATH type STRING, + end of T_ERROR_DETAIL. + types: + "! No documentation available. + begin of T_ERROR_RESPONSE, + "! General description of an error. + ERROR type STRING, + "! Collection of specific constraint violations associated with the error. + ERRORS type STANDARD TABLE OF T_ERROR_DETAIL WITH NON-UNIQUE DEFAULT KEY, + "! HTTP status code for the error response. + CODE type INTEGER, + end of T_ERROR_RESPONSE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_IMAGE, + "! The URL of the image. + SOURCE type STRING, + "! The title to show before the response. + TITLE type STRING, + "! The description to show with the the response. + DESCRIPTION type STRING, + end of T_RUNTIME_RESPONSE_TYPE_IMAGE. + types: + "! No documentation available. + begin of T_DIALOG_NODE_ACTION, + "! The name of the action. + NAME type STRING, + "! The type of action to invoke. + TYPE type STRING, + "! A map of key/value pairs to be provided to the action. + PARAMETERS type MAP, + "! The location in the dialog context where the result of the action is stored. + RESULT_VARIABLE type STRING, + "! The name of the context variable that the client application will use to pass in + "! credentials for the action. + CREDENTIALS type STRING, + end of T_DIALOG_NODE_ACTION. + types: + "! Built-in system properties that apply to all skills used by the assistant. + begin of T_MSSG_CONTEXT_GLOBAL_SYSTEM, + "! The user time zone. The assistant uses the time zone to correctly resolve + "! relative time references. + TIMEZONE type STRING, + "! A string value that identifies the user who is interacting with the assistant. + "! The client must provide a unique identifier for each individual end user who + "! accesses the application. For Plus and Premium plans, this user ID is used to + "! identify unique users for billing purposes. This string cannot contain carriage + "! return, newline, or tab characters. + USER_ID type STRING, + "! 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). + TURN_COUNT type INTEGER, + "! 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. + LOCALE type STRING, + "! The base time for interpreting any relative time mentions in the user input. The + "! specified time overrides the current server time, and is used to calculate + "! times mentioned in relative terms such as `now` or `tomorrow`. This can be + "! useful for simulating past or future times for testing purposes, or when + "! analyzing documents such as news articles.
+ "!
+ "! This value must be a UTC time value formatted according to ISO 8601 (for + "! example, `2019-06-26T12:00:00Z` for noon on 26 June 2019.
+ "!
+ "! This property is included only if the new system entities are enabled for the + "! skill. + REFERENCE_TIME type STRING, + end of T_MSSG_CONTEXT_GLOBAL_SYSTEM. + types: + "! Information that is shared by all skills used by the Assistant. + begin of T_MESSAGE_CONTEXT_GLOBAL, + "! Built-in system properties that apply to all skills used by the assistant. + SYSTEM type T_MSSG_CONTEXT_GLOBAL_SYSTEM, + end of T_MESSAGE_CONTEXT_GLOBAL. + types: + "! Information specific to particular skills used by the Assistant.
+ "!
+ "! **Note:** Currently, only a single property named `main skill` is supported. + "! This object contains variables that apply to the dialog skill used by the + "! assistant. + T_MESSAGE_CONTEXT_SKILLS type MAP. + types: + "! No documentation available. + begin of T_MESSAGE_CONTEXT, + "! Information that is shared by all skills used by the Assistant. + GLOBAL type T_MESSAGE_CONTEXT_GLOBAL, + "! Information specific to particular skills used by the Assistant.
+ "!
+ "! **Note:** Currently, only a single property named `main skill` is supported. + "! This object contains variables that apply to the dialog skill used by the + "! assistant. + SKILLS type T_MESSAGE_CONTEXT_SKILLS, + end of T_MESSAGE_CONTEXT. + types: + "! Assistant output to be rendered or processed by the client. + begin of T_MESSAGE_OUTPUT, + "! Output intended for any channel. It is the responsibility of the client + "! application to implement the supported response types. + GENERIC type STANDARD TABLE OF T_RUNTIME_RESPONSE_GENERIC WITH NON-UNIQUE DEFAULT KEY, + "! An array of intents recognized in the user input, sorted in descending order of + "! confidence. + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + "! An array of entities identified in the user input. + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects describing any actions requested by the dialog node. + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + "! Additional detailed information about a message response and how it was + "! generated. + DEBUG type T_MESSAGE_OUTPUT_DEBUG, + "! 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. + USER_DEFINED type MAP, + end of T_MESSAGE_OUTPUT. + types: + "! A response from the Watson Assistant service. + begin of T_MESSAGE_RESPONSE, + "! Assistant output to be rendered or processed by the client. + OUTPUT type T_MESSAGE_OUTPUT, + "! State information for the conversation. The context is stored by the assistant + "! on a per-session basis. You can use this property to access context + "! variables.
+ "!
+ "! **Note:** The context is included in message responses only if + "! **return_context**=`true` in the message request. + CONTEXT type T_MESSAGE_CONTEXT, + end of T_MESSAGE_RESPONSE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_TEXT, + "! The text of the response. + TEXT type STRING, + end of T_RUNTIME_RESPONSE_TYPE_TEXT. + types: + "! No documentation available. + begin of T_RT_ENTTY_INTRPRTTN_SYS_TIME, + "! 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). + DATETIME_LINK type STRING, + "! The precision or duration of a time range specified by a recognized `@sys-time` + "! or `@sys-date` entity. + GRANULARITY type STRING, + "! 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`). + PART_OF_DAY type STRING, + "! 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`). + RANGE_LINK type STRING, + "! 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`). + RELATIVE_HOUR type NUMBER, + "! 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`). + RELATIVE_MINUTE type NUMBER, + "! 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`). + RELATIVE_SECOND type NUMBER, + "! A recognized specific hour mentioned as part of a time value (for example, `10` + "! for `10:15 AM`.). + SPECIFIC_HOUR type NUMBER, + "! A recognized specific minute mentioned as part of a time value (for example, + "! `15` for `10:15 AM`.). + SPECIFIC_MINUTE type NUMBER, + "! A recognized specific second mentioned as part of a time value (for example, + "! `30` for `10:15:30 AM`.). + SPECIFIC_SECOND type NUMBER, + "! A recognized time zone mentioned as part of a time value (for example, `EST`). + TIMEZONE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_TIME. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_PAUSE, + "! How long to pause, in milliseconds. + TIME type INTEGER, + "! Whether to send a "user is typing" event during the pause. + TYPING type BOOLEAN, + end of T_RUNTIME_RESPONSE_TYPE_PAUSE. + types: + "! No documentation available. + begin of T_RUNTIME_RESPONSE_TYPE_SEARCH, + "! The title or introductory text to show before the response. This text is defined + "! in the search skill configuration. + HEADER type STRING, + "! An array of objects containing search results. + RESULTS type STANDARD TABLE OF T_SEARCH_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_SEARCH. + types: + "! No documentation available. + begin of T_RT_RESPONSE_TYPE_SUGGESTION, + "! The title or introductory text to show before the response. + TITLE type STRING, + "! An array of objects describing the possible matching dialog nodes from which the + "! user can choose.
+ "!
+ "! **Note:** The **suggestions** property is part of the disambiguation feature, + "! which is only available for Premium users. + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + end of T_RT_RESPONSE_TYPE_SUGGESTION. + types: + "! Contains information specific to a particular skill used by the Assistant. + begin of T_MESSAGE_CONTEXT_SKILL, + "! Arbitrary variables that can be read and written by a particular skill. + USER_DEFINED type MAP, + "! For internal use only. + SYSTEM type MAP, + end of T_MESSAGE_CONTEXT_SKILL. + types: + "! No documentation available. + begin of T_RT_RESP_TYP_CONNECT_TO_AGENT, + "! A message to be sent to the human agent who will be taking over the + "! conversation. + MESSAGE_TO_HUMAN_AGENT type STRING, + "! A label identifying the topic of the conversation, derived from the + "! **user_label** property of the relevant node. + TOPIC type STRING, + end of T_RT_RESP_TYP_CONNECT_TO_AGENT. + types: + "! A request formatted for the Watson Assistant service. + begin of T_MESSAGE_REQUEST, + "! An input object that includes the input text. + INPUT type T_MESSAGE_INPUT, + "! State information for the conversation. The context is stored by the assistant + "! on a per-session basis. You can use this property to set or modify context + "! variables, which can also be accessed by dialog nodes. + CONTEXT type T_MESSAGE_CONTEXT, + end of T_MESSAGE_REQUEST. + +constants: + begin of C_REQUIRED_FIELDS, + T_DIALOG_LOG_MESSAGE type string value '|LEVEL|MESSAGE|', + T_DIALOG_NODES_VISITED type string value '|', + T_MESSAGE_OUTPUT_DEBUG type string value '|', + T_SESSION_RESPONSE type string value '|SESSION_ID|', + T_RT_ENTTY_INTRPRTTN_SYS_NUM type string value '|', + T_RUNTIME_ENTITY_ALTERNATIVE type string value '|', + T_RUNTIME_ENTITY_ROLE type string value '|', + T_RT_ENTITY_INTERPRETATION type string value '|', + T_MESSAGE_INPUT_OPTIONS type string value '|', + T_RUNTIME_INTENT type string value '|INTENT|CONFIDENCE|', + T_CAPTURE_GROUP type string value '|GROUP|', + T_RUNTIME_ENTITY type string value '|ENTITY|LOCATION|VALUE|', + T_MESSAGE_INPUT type string value '|', + T_DIA_ND_OUTPUT_OPT_ELEM_VALUE type string value '|', + T_DIA_NODE_OUTPUT_OPT_ELEMENT type string value '|LABEL|VALUE|', + T_RUNTIME_RESPONSE_TYPE_OPTION type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_DATE type string value '|', + T_SEARCH_RESULT_HIGHLIGHT type string value '|', + T_DIALOG_SUGGESTION_VALUE type string value '|', + T_SEARCH_RESULT_METADATA type string value '|', + T_SEARCH_RESULT type string value '|ID|RESULT_METADATA|', + T_DIALOG_SUGGESTION type string value '|LABEL|VALUE|', + T_RUNTIME_RESPONSE_GENERIC type string value '|RESPONSE_TYPE|', + T_ERROR_DETAIL type string value '|MESSAGE|', + T_ERROR_RESPONSE type string value '|ERROR|CODE|', + T_RUNTIME_RESPONSE_TYPE_IMAGE type string value '|', + T_DIALOG_NODE_ACTION type string value '|NAME|RESULT_VARIABLE|', + T_MSSG_CONTEXT_GLOBAL_SYSTEM type string value '|', + T_MESSAGE_CONTEXT_GLOBAL type string value '|', + T_MESSAGE_CONTEXT type string value '|', + T_MESSAGE_OUTPUT type string value '|', + T_MESSAGE_RESPONSE type string value '|OUTPUT|', + T_RUNTIME_RESPONSE_TYPE_TEXT type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_TIME type string value '|', + T_RUNTIME_RESPONSE_TYPE_PAUSE type string value '|', + T_RUNTIME_RESPONSE_TYPE_SEARCH type string value '|', + T_RT_RESPONSE_TYPE_SUGGESTION type string value '|', + T_MESSAGE_CONTEXT_SKILL type string value '|', + T_RT_RESP_TYP_CONNECT_TO_AGENT type string value '|', + T_MESSAGE_REQUEST type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + DEBUG type string value 'debug', + RESTART type string value 'restart', + ALTERNATE_INTENTS type string value 'alternate_intents', + RETURN_CONTEXT type string value 'return_context', + INTENT type string value 'intent', + CONFIDENCE type string value 'confidence', + ENTITY type string value 'entity', + LOCATION type string value 'location', + VALUE type string value 'value', + METADATA type string value 'metadata', + INNER type string value 'inner', + GROUPS type string value 'groups', + INTERPRETATION type string value 'interpretation', + ALTERNATIVES type string value 'alternatives', + ROLE type string value 'role', + CALENDAR_TYPE type string value 'calendar_type', + DATETIME_LINK type string value 'datetime_link', + FESTIVAL type string value 'festival', + GRANULARITY type string value 'granularity', + RANGE_LINK type string value 'range_link', + RANGE_MODIFIER type string value 'range_modifier', + RELATIVE_DAY type string value 'relative_day', + RELATIVE_MONTH type string value 'relative_month', + RELATIVE_WEEK type string value 'relative_week', + RELATIVE_WEEKEND type string value 'relative_weekend', + RELATIVE_YEAR type string value 'relative_year', + SPECIFIC_DAY type string value 'specific_day', + SPECIFIC_DAY_OF_WEEK type string value 'specific_day_of_week', + SPECIFIC_MONTH type string value 'specific_month', + SPECIFIC_QUARTER type string value 'specific_quarter', + SPECIFIC_YEAR type string value 'specific_year', + NUMERIC_VALUE type string value 'numeric_value', + SUBTYPE type string value 'subtype', + PART_OF_DAY type string value 'part_of_day', + RELATIVE_HOUR type string value 'relative_hour', + RELATIVE_MINUTE type string value 'relative_minute', + RELATIVE_SECOND type string value 'relative_second', + SPECIFIC_HOUR type string value 'specific_hour', + SPECIFIC_MINUTE type string value 'specific_minute', + SPECIFIC_SECOND type string value 'specific_second', + TIMEZONE type string value 'timezone', + TYPE type string value 'type', + MESSAGE_TYPE type string value 'message_type', + TEXT type string value 'text', + OPTIONS type string value 'options', + INTENTS type string value 'intents', + ENTITIES type string value 'entities', + SUGGESTION_ID type string value 'suggestion_id', + USER_ID type string value 'user_id', + TURN_COUNT type string value 'turn_count', + LOCALE type string value 'locale', + REFERENCE_TIME type string value 'reference_time', + SYSTEM type string value 'system', + USER_DEFINED type string value 'user_defined', + GLOBAL type string value 'global', + SKILLS type string value 'skills', + INPUT type string value 'input', + CONTEXT type string value 'context', + LEVEL type string value 'level', + MESSAGE type string value 'message', + TIME type string value 'time', + TYPING type string value 'typing', + SOURCE type string value 'source', + TITLE type string value 'title', + DESCRIPTION type string value 'description', + LABEL type string value 'label', + PREFERENCE type string value 'preference', + MESSAGE_TO_HUMAN_AGENT type string value 'message_to_human_agent', + TOPIC type string value 'topic', + SUGGESTIONS type string value 'suggestions', + OUTPUT type string value 'output', + RESPONSE_TYPE type string value 'response_type', + HEADER type string value 'header', + RESULTS type string value 'results', + NAME type string value 'name', + PARAMETERS type string value 'parameters', + RESULT_VARIABLE type string value 'result_variable', + CREDENTIALS type string value 'credentials', + NODES_VISITED type string value 'nodes_visited', + NODESVISITED type string value 'nodesVisited', + LOG_MESSAGES type string value 'log_messages', + LOGMESSAGES type string value 'logMessages', + BRANCH_EXITED type string value 'branch_exited', + BRANCH_EXITED_REASON type string value 'branch_exited_reason', + GENERIC type string value 'generic', + ACTIONS type string value 'actions', + PATH type string value 'path', + ERROR type string value 'error', + ERRORS type string value 'errors', + CODE type string value 'code', + BODY type string value 'body', + URL type string value 'url', + SCORE type string value 'score', + ID type string value 'id', + RESULT_METADATA type string value 'result_metadata', + HIGHLIGHT type string value 'highlight', + SESSION_ID type string value 'session_id', + GROUP type string value 'group', + DIALOG_NODE type string value 'dialog_node', + CONDITIONS type string value 'conditions', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Create a session. + "! + "! @parameter I_ASSISTANT_ID | + "! Unique identifier of the assistant. To find the assistant ID in the Watson + "! Assistant user interface, open the assistant settings and click **API + "! Details**. For information about creating assistants, see the + "! [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant- + "! add#assistant-add-task).
+ "!
+ "! **Note:** Currently, the v2 API does not support creating assistants. + "! @parameter E_RESPONSE | + "! Service return value of type T_SESSION_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_SESSION + importing + !I_ASSISTANT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SESSION_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete session. + "! + "! @parameter I_ASSISTANT_ID | + "! Unique identifier of the assistant. To find the assistant ID in the Watson + "! Assistant user interface, open the assistant settings and click **API + "! Details**. For information about creating assistants, see the + "! [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant- + "! add#assistant-add-task).
+ "!
+ "! **Note:** Currently, the v2 API does not support creating assistants. + "! @parameter I_SESSION_ID | + "! Unique identifier of the session. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_SESSION + importing + !I_ASSISTANT_ID type STRING + !I_SESSION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Send user input to assistant. + "! + "! @parameter I_ASSISTANT_ID | + "! Unique identifier of the assistant. To find the assistant ID in the Watson + "! Assistant user interface, open the assistant settings and click **API + "! Details**. For information about creating assistants, see the + "! [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant- + "! add#assistant-add-task).
+ "!
+ "! **Note:** Currently, the v2 API does not support creating assistants. + "! @parameter I_SESSION_ID | + "! Unique identifier of the session. + "! @parameter I_REQUEST | + "! The message to be sent. This includes the user's input, along with optional + "! content such as intents and entities. + "! @parameter E_RESPONSE | + "! Service return value of type T_MESSAGE_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods MESSAGE + importing + !I_ASSISTANT_ID type STRING + !I_SESSION_ID type STRING + !I_REQUEST type T_MESSAGE_REQUEST optional + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_MESSAGE_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_ASSISTANT_V2 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V2->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Watson Assistant v2'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_ASSISTANT_V2->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/assistant/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V2->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092813'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V2->CREATE_SESSION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ASSISTANT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SESSION_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_SESSION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v2/assistants/{assistant_id}/sessions'. + replace all occurrences of `{assistant_id}` in ls_request_prop-url-path with i_ASSISTANT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V2->DELETE_SESSION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ASSISTANT_ID TYPE STRING +* | [--->] I_SESSION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_SESSION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v2/assistants/{assistant_id}/sessions/{session_id}'. + replace all occurrences of `{assistant_id}` in ls_request_prop-url-path with i_ASSISTANT_ID ignoring case. + replace all occurrences of `{session_id}` in ls_request_prop-url-path with i_SESSION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_ASSISTANT_V2->MESSAGE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ASSISTANT_ID TYPE STRING +* | [--->] I_SESSION_ID TYPE STRING +* | [--->] I_REQUEST TYPE T_MESSAGE_REQUEST(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_MESSAGE_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method MESSAGE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v2/assistants/{assistant_id}/sessions/{session_id}/message'. + replace all occurrences of `{assistant_id}` in ls_request_prop-url-path with i_ASSISTANT_ID ignoring case. + replace all occurrences of `{session_id}` in ls_request_prop-url-path with i_SESSION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_REQUEST is initial. + lv_datatype = get_datatype( i_REQUEST ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_REQUEST i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'request' i_value = i_REQUEST ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_REQUEST to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_ASSISTANT_V2->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_assistant_v2.clas.xml b/src/zcl_ibmc_assistant_v2.clas.xml new file mode 100644 index 0000000..a6bf585 --- /dev/null +++ b/src/zcl_ibmc_assistant_v2.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_ASSISTANT_V2 + E + IBM Watson Assistant V2 + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_compare_comply_v1.clas.abap b/src/zcl_ibmc_compare_comply_v1.clas.abap new file mode 100644 index 0000000..9f9f440 --- /dev/null +++ b/src/zcl_ibmc_compare_comply_v1.clas.abap @@ -0,0 +1,2851 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +"!

Compare and Comply

+"! IBM Watson™ Compare and Comply analyzes governing documents to provide +"! details about critical aspects of the documents.
+class ZCL_IBMC_COMPARE_COMPLY_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + begin of T_LOCATION, + "! The element's `begin` index. + BEGIN type LONG, + "! The element's `end` index. + END type LONG, + end of T_LOCATION. + types: + "! A pair of `nature` and `party` objects. The `nature` object identifies the + "! effect of the element on the identified `party`, and the `party` object + "! identifies the affected party. + begin of T_LABEL, + "! The identified `nature` of the element. + NATURE type STRING, + "! The identified `party` of the element. + PARTY type STRING, + end of T_LABEL. + types: + "! Identification of a specific type. + begin of T_TYPE_LABEL_COMPARISON, + "! A pair of `nature` and `party` objects. The `nature` object identifies the + "! effect of the element on the identified `party`, and the `party` object + "! identifies the affected party. + LABEL type T_LABEL, + end of T_TYPE_LABEL_COMPARISON. + types: + "! The locations of each paragraph in the input document. + begin of T_PARAGRAPHS, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_PARAGRAPHS. + types: + "! Document counts. + begin of T_DOC_COUNTS, + "! Total number of documents. + TOTAL type INTEGER, + "! Number of pending documents. + PENDING type INTEGER, + "! Number of documents successfully processed. + SUCCESSFUL type INTEGER, + "! Number of documents not successfully processed. + FAILED type INTEGER, + end of T_DOC_COUNTS. + types: + "! Identification of a specific type. + begin of T_TYPE_LABEL, + "! A pair of `nature` and `party` objects. The `nature` object identifies the + "! effect of the element on the identified `party`, and the `party` object + "! identifies the affected party. + LABEL type T_LABEL, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_TYPE_LABEL. + types: + "! Brief information about the input document. + begin of T_SHORT_DOC, + "! The title of the input document, if identified. + TITLE type STRING, + "! The MD5 hash of the input document. + HASH type STRING, + end of T_SHORT_DOC. + types: + "! Information defining an element's subject matter. + begin of T_CATEGORY, + "! The category of the associated element. + LABEL type STRING, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_CATEGORY. + types: + "! The original labeling from the input document, without the submitted feedback. + begin of T_ORIGINAL_LABELS_OUT, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! A string identifying the type of modification the feedback entry in the + "! `updated_labels` array. Possible values are `added`, `not_changed`, and + "! `removed`. + MODIFICATION type STRING, + end of T_ORIGINAL_LABELS_OUT. + types: + "! The updated labeling from the input document, accounting for the submitted + "! feedback. + begin of T_UPDATED_LABELS_OUT, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! The type of modification the feedback entry in the `updated_labels` array. + "! Possible values are `added`, `not_changed`, and `removed`. + MODIFICATION type STRING, + end of T_UPDATED_LABELS_OUT. + types: + "! Pagination details, if required by the length of the output. + begin of T_PAGINATION, + "! A token identifying the current page of results. + REFRESH_CURSOR type STRING, + "! A token identifying the next page of results. + NEXT_CURSOR type STRING, + "! The URL that returns the current page of results. + REFRESH_URL type STRING, + "! The URL that returns the next page of results. + NEXT_URL type STRING, + "! Reserved for future use. + TOTAL type LONG, + end of T_PAGINATION. + types: + "! Information returned from the **Add Feedback** method. + begin of T_FEEDBACK_DATA_OUTPUT, + "! A string identifying the user adding the feedback. The only permitted value is + "! `element_classification`. + FEEDBACK_TYPE type STRING, + "! Brief information about the input document. + DOCUMENT type T_SHORT_DOC, + "! An optional string identifying the model ID. The only permitted value is + "! `contracts`. + MODEL_ID type STRING, + "! An optional string identifying the version of the model used. + MODEL_VERSION type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text to which the feedback applies. + TEXT type STRING, + "! The original labeling from the input document, without the submitted feedback. + ORIGINAL_LABELS type T_ORIGINAL_LABELS_OUT, + "! The updated labeling from the input document, accounting for the submitted + "! feedback. + UPDATED_LABELS type T_UPDATED_LABELS_OUT, + "! Pagination details, if required by the length of the output. + PAGINATION type T_PAGINATION, + end of T_FEEDBACK_DATA_OUTPUT. + types: + "! List of document attributes. + begin of T_ATTRIBUTE, + "! The type of attribute. + TYPE type STRING, + "! The text associated with the attribute. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_ATTRIBUTE. + types: + "! Information defining an element's subject matter. + begin of T_CATEGORY_COMPARISON, + "! The category of the associated element. + LABEL type STRING, + end of T_CATEGORY_COMPARISON. + types: + "! Element that does not align semantically between two compared documents. + begin of T_UNALIGNED_ELEMENT, + "! The label assigned to the document by the value of the `file_1_label` or + "! `file_2_label` parameters on the **Compare two documents** method. + DOCUMENT_LABEL type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text of the element. + TEXT type STRING, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + "! List of document attributes. + ATTRIBUTES type STANDARD TABLE OF T_ATTRIBUTE WITH NON-UNIQUE DEFAULT KEY, + end of T_UNALIGNED_ELEMENT. + types: + "! The updated labeling from the input document, accounting for the submitted + "! feedback. + begin of T_UPDATED_LABELS_IN, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATED_LABELS_IN. + types: + "! An array that contains the `text` value of a row header that is applicable to + "! this body cell. + T_ROW_HEADER_TEXTS type TT_String. + types: + "! A list of `begin` and `end` indexes that indicate the locations of the elements + "! in the input document. + begin of T_ELEMENT_LOCATIONS, + "! An integer that indicates the starting position of the element in the input + "! document. + BEGIN type INTEGER, + "! An integer that indicates the ending position of the element in the input + "! document. + END type INTEGER, + end of T_ELEMENT_LOCATIONS. + types: + "! The leading sentences in a section or subsection of the input document. + begin of T_LEADING_SENTENCE, + "! The text of the leading sentence. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! An array of `location` objects that lists the locations of detected leading + "! sentences. + ELEMENT_LOCATIONS type STANDARD TABLE OF T_ELEMENT_LOCATIONS WITH NON-UNIQUE DEFAULT KEY, + end of T_LEADING_SENTENCE. + types: + "! An array containing one object per section or subsection detected in the input + "! document. Sections and subsections are not nested; instead, they are flattened + "! out and can be placed back in order by using the `begin` and `end` values of + "! the element and the `level` value of the section. + begin of T_SECTION_TITLES, + "! The text of the section title, if identified. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! An integer indicating the level at which the section is located in the input + "! document. For example, `1` represents a top-level section, `2` represents a + "! subsection within the level `1` section, and so forth. + LEVEL type INTEGER, + "! An array of `location` objects that lists the locations of detected section + "! titles. + ELEMENT_LOCATIONS type STANDARD TABLE OF T_ELEMENT_LOCATIONS WITH NON-UNIQUE DEFAULT KEY, + end of T_SECTION_TITLES. + types: + "! The structure of the input document. + begin of T_DOC_STRUCTURE, + "! An array containing one object per section or subsection identified in the input + "! document. + SECTION_TITLES type STANDARD TABLE OF T_SECTION_TITLES WITH NON-UNIQUE DEFAULT KEY, + "! An array containing one object per section or subsection, in parallel with the + "! `section_titles` array, that details the leading sentences in the corresponding + "! section or subsection. + LEADING_SENTENCES type STANDARD TABLE OF T_LEADING_SENTENCE WITH NON-UNIQUE DEFAULT KEY, + "! An array containing one object per paragraph, in parallel with the + "! `section_titles` and `leading_sentences` arrays. + PARAGRAPHS type STANDARD TABLE OF T_PARAGRAPHS WITH NON-UNIQUE DEFAULT KEY, + end of T_DOC_STRUCTURE. + types: + "! 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`. + T_COLUMN_HEADER_TEXTS_NORM type TT_String. + types: + "! No documentation available. + begin of T_ERROR_RESPONSE, + "! The HTTP error status code. + CODE type INTEGER, + "! A message describing the error. + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! A contact. + begin of T_CONTACT, + "! A string listing the name of the contact. + NAME type STRING, + "! A string listing the role of the contact. + ROLE type STRING, + end of T_CONTACT. + types: + "! The table's section title, if identified. + begin of T_SECTION_TITLE, + "! The text of the section title, if identified. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_SECTION_TITLE. + types: + "! Column-level cells, each applicable as a header to other cells in the same + "! column as itself, of the current table. + begin of T_COLUMN_HEADERS, + "! The unique ID of the cell in the current table. + CELL_ID type STRING, + "! The location of the column header cell in the current table as defined by its + "! `begin` and `end` offsets, respectfully, in the input document. + LOCATION type JSONOBJECT, + "! The textual contents of this cell from the input document without associated + "! markup content. + TEXT type STRING, + "! If you provide customization input, the normalized version of the cell text + "! according to the customization; otherwise, the same value as `text`. + TEXT_NORMALIZED type STRING, + "! The `begin` index of this cell's `row` location in the current table. + ROW_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `row` location in the current table. + ROW_INDEX_END type LONG, + "! The `begin` index of this cell's `column` location in the current table. + COLUMN_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `column` location in the current table. + COLUMN_INDEX_END type LONG, + end of T_COLUMN_HEADERS. + types: + "! Text that is related to the contents of the table and that precedes or follows + "! the current table. + begin of T_CONTEXTS, + "! The related text. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_CONTEXTS. + types: + "! If identified, the title or caption of the current table of the form `Table x.: + "! ...`. Empty when no title is identified. When exposed, the `title` is also + "! excluded from the `contexts` array of the same table. + begin of T_TABLE_TITLE, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text of the identified table title or caption. + TEXT type STRING, + end of T_TABLE_TITLE. + types: + "! Cells that are not table header, column header, or row header cells. + begin of T_BODY_CELLS, + "! The unique ID of the cell in the current table. + CELL_ID type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The textual contents of this cell from the input document without associated + "! markup content. + TEXT type STRING, + "! The `begin` index of this cell's `row` location in the current table. + ROW_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `row` location in the current table. + ROW_INDEX_END type LONG, + "! The `begin` index of this cell's `column` location in the current table. + COLUMN_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `column` location in the current table. + COLUMN_INDEX_END type LONG, + "! An array that contains the `id` value of a row header that is applicable to this + "! body cell. + ROW_HEADER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array that contains the `text` value of a row header that is applicable to + "! this body cell. + ROW_HEADER_TEXTS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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`. + ROW_HEADER_TEXTS_NORMALIZED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array that contains the `id` value of a column header that is applicable to + "! the current cell. + COLUMN_HEADER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array that contains the `text` value of a column header that is applicable to + "! the current cell. + COLUMN_HEADER_TEXTS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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`. + COLUMN_HEADER_TEXTS_NORMALIZED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! No documentation available. + ATTRIBUTES type STANDARD TABLE OF T_ATTRIBUTE WITH NON-UNIQUE DEFAULT KEY, + end of T_BODY_CELLS. + types: + "! A key in a key-value pair. + begin of T_KEY, + "! The unique ID of the key in the table. + CELL_ID type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text content of the table cell without HTML markup. + TEXT type STRING, + end of T_KEY. + types: + "! A value in a key-value pair. + begin of T_VALUE, + "! The unique ID of the value in the table. + CELL_ID type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text content of the table cell without HTML markup. + TEXT type STRING, + end of T_VALUE. + types: + "! Key-value pairs detected across cell boundaries. + begin of T_KEY_VALUE_PAIR, + "! A key in a key-value pair. + KEY type T_KEY, + "! A list of values in a key-value pair. + VALUE type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_KEY_VALUE_PAIR. + types: + "! The contents of the current table's header. + begin of T_TABLE_HEADERS, + "! The unique ID of the cell in the current table. + CELL_ID type STRING, + "! The location of the table header cell in the current table as defined by its + "! `begin` and `end` offsets, respectfully, in the input document. + LOCATION type JSONOBJECT, + "! The textual contents of the cell from the input document without associated + "! markup content. + TEXT type STRING, + "! The `begin` index of this cell's `row` location in the current table. + ROW_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `row` location in the current table. + ROW_INDEX_END type LONG, + "! The `begin` index of this cell's `column` location in the current table. + COLUMN_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `column` location in the current table. + COLUMN_INDEX_END type LONG, + end of T_TABLE_HEADERS. + types: + "! Row-level cells, each applicable as a header to other cells in the same row as + "! itself, of the current table. + begin of T_ROW_HEADERS, + "! The unique ID of the cell in the current table. + CELL_ID type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The textual contents of this cell from the input document without associated + "! markup content. + TEXT type STRING, + "! If you provide customization input, the normalized version of the cell text + "! according to the customization; otherwise, the same value as `text`. + TEXT_NORMALIZED type STRING, + "! The `begin` index of this cell's `row` location in the current table. + ROW_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `row` location in the current table. + ROW_INDEX_END type LONG, + "! The `begin` index of this cell's `column` location in the current table. + COLUMN_INDEX_BEGIN type LONG, + "! The `end` index of this cell's `column` location in the current table. + COLUMN_INDEX_END type LONG, + end of T_ROW_HEADERS. + types: + "! The contents of the tables extracted from a document. + begin of T_TABLES, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The textual contents of the current table from the input document without + "! associated markup content. + TEXT type STRING, + "! The table's section title, if identified. + SECTION_TITLE type T_SECTION_TITLE, + "! If identified, the title or caption of the current table of the form `Table x.: + "! ...`. Empty when no title is identified. When exposed, the `title` is also + "! excluded from the `contexts` array of the same table. + TITLE type T_TABLE_TITLE, + "! An array of table-level cells that apply as headers to all the other cells in + "! the current table. + TABLE_HEADERS type STANDARD TABLE OF T_TABLE_HEADERS WITH NON-UNIQUE DEFAULT KEY, + "! An array of row-level cells, each applicable as a header to other cells in the + "! same row as itself, of the current table. + ROW_HEADERS type STANDARD TABLE OF T_ROW_HEADERS WITH NON-UNIQUE DEFAULT KEY, + "! An array of column-level cells, each applicable as a header to other cells in + "! the same column as itself, of the current table. + COLUMN_HEADERS type STANDARD TABLE OF T_COLUMN_HEADERS WITH NON-UNIQUE DEFAULT KEY, + "! 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. + BODY_CELLS type STANDARD TABLE OF T_BODY_CELLS WITH NON-UNIQUE DEFAULT KEY, + "! An array of objects that list text that is related to the table contents and + "! that precedes or follows the current table. + CONTEXTS type STANDARD TABLE OF T_CONTEXTS WITH NON-UNIQUE DEFAULT KEY, + "! An array of key-value pairs identified in the current table. + KEY_VALUE_PAIRS type STANDARD TABLE OF T_KEY_VALUE_PAIR WITH NON-UNIQUE DEFAULT KEY, + end of T_TABLES. + types: + "! Information about the parsed input document. + begin of T_DOC_INFO, + "! The full text of the parsed document in HTML format. + HTML type STRING, + "! The title of the parsed document. If the service did not detect a title, the + "! value of this element is `null`. + TITLE type STRING, + "! The MD5 hash of the input document. + HASH type STRING, + end of T_DOC_INFO. + types: + "! The analysis of the document's tables. + begin of T_TABLE_RETURN, + "! Information about the parsed input document. + DOCUMENT type T_DOC_INFO, + "! The ID of the model used to extract the table contents. The value for table + "! extraction is `tables`. + MODEL_ID type STRING, + "! The version of the `tables` model ID. + MODEL_VERSION type STRING, + "! Definitions of the tables identified in the input document. + TABLES type STANDARD TABLE OF T_TABLES WITH NON-UNIQUE DEFAULT KEY, + end of T_TABLE_RETURN. + types: + "! Information about the document and the submitted feedback. + begin of T_FEEDBACK_RETURN, + "! The unique ID of the feedback object. + FEEDBACK_ID type STRING, + "! An optional string identifying the person submitting feedback. + USER_ID type STRING, + "! An optional comment from the person submitting the feedback. + COMMENT type STRING, + "! Timestamp listing the creation time of the feedback submission. + CREATED type DATETIME, + "! Information returned from the **Add Feedback** method. + FEEDBACK_DATA type T_FEEDBACK_DATA_OUTPUT, + end of T_FEEDBACK_RETURN. + types: + "! The details of the normalized text, if applicable. This element is optional; it + "! is returned only if normalized text exists. + begin of T_INTERPRETATION, + "! The value that was located in the normalized text. + VALUE type STRING, + "! An integer or float expressing the numeric value of the `value` key. + NUMERIC_VALUE type NUMBER, + "! A string listing the unit of the value that was found in the normalized + "! text.
+ "!
+ "! **Note:** The value of `unit` is the [ISO-4217 currency + "! code](https://www.iso.org/iso-4217-currency-codes.html) identified for the + "! currency amount (for example, `USD` or `EUR`). If the service cannot + "! disambiguate a currency symbol (for example, `$` or `£`), the value of `unit` + "! contains the ambiguous symbol as-is. + UNIT type STRING, + end of T_INTERPRETATION. + types: + "! A monetary amount identified in the input document. + begin of T_CONTRACT_AMTS, + "! The confidence level in the identification of the contract amount. + CONFIDENCE_LEVEL type STRING, + "! The monetary amount. + TEXT type STRING, + "! The normalized form of the amount, which is listed as a string. This element is + "! optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! The details of the normalized text, if applicable. This element is optional; it + "! is returned only if normalized text exists. + INTERPRETATION type T_INTERPRETATION, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_CONTRACT_AMTS. + types: + "! The contract currencies that are declared in the document. + begin of T_CONTRACT_CURRENCIES, + "! The confidence level in the identification of the contract currency. + CONFIDENCE_LEVEL type STRING, + "! The contract currency. + TEXT type STRING, + "! The normalized form of the contract currency, which is listed as a string in + "! [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) format. This + "! element is optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_CONTRACT_CURRENCIES. + types: + "! The document's payment duration or durations. + begin of T_PAYMENT_TERMS, + "! The confidence level in the identification of the payment term. + CONFIDENCE_LEVEL type STRING, + "! The payment term (duration). + TEXT type STRING, + "! The normalized form of the payment term, which is listed as a string. This + "! element is optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! The details of the normalized text, if applicable. This element is optional; it + "! is returned only if normalized text exists. + INTERPRETATION type T_INTERPRETATION, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_PAYMENT_TERMS. + types: + "! A component part of the document. + begin of T_ELEMENT, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text of the element. + TEXT type STRING, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! List of document attributes. + ATTRIBUTES type STANDARD TABLE OF T_ATTRIBUTE WITH NON-UNIQUE DEFAULT KEY, + end of T_ELEMENT. + types: + "! Termination dates identified in the input document. + begin of T_TERMINATION_DATES, + "! The confidence level in the identification of the termination date. + CONFIDENCE_LEVEL type STRING, + "! The termination date. + TEXT type STRING, + "! The normalized form of the termination date, which is listed as a string. This + "! element is optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_TERMINATION_DATES. + types: + "! The contract type identified in the input document. + begin of T_CONTRACT_TYPES, + "! The confidence level in the identification of the contract type. + CONFIDENCE_LEVEL type STRING, + "! The contract type. + TEXT type STRING, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_CONTRACT_TYPES. + types: + "! An effective date. + begin of T_EFFECTIVE_DATES, + "! The confidence level in the identification of the effective date. + CONFIDENCE_LEVEL type STRING, + "! The effective date, listed as a string. + TEXT type STRING, + "! The normalized form of the effective date, which is listed as a string. This + "! element is optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_EFFECTIVE_DATES. + types: + "! A mention of a party. + begin of T_MENTION, + "! The name of the party. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_MENTION. + types: + "! A party's address. + begin of T_ADDRESS, + "! A string listing the address. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_ADDRESS. + types: + "! A party and its corresponding role, including address and contact information if + "! identified. + begin of T_PARTIES, + "! The normalized form of the party's name. + PARTY type STRING, + "! A string identifying the party's role. + ROLE type STRING, + "! A string that identifies the importance of the party. + IMPORTANCE type STRING, + "! A list of the party's address or addresses. + ADDRESSES type STANDARD TABLE OF T_ADDRESS WITH NON-UNIQUE DEFAULT KEY, + "! A list of the names and roles of contacts identified in the input document. + CONTACTS type STANDARD TABLE OF T_CONTACT WITH NON-UNIQUE DEFAULT KEY, + "! A list of the party's mentions in the input document. + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + end of T_PARTIES. + types: + "! Basic information about the input document. + begin of T_DOCUMENT, + "! Document title, if detected. + TITLE type STRING, + "! The input document converted into HTML format. + HTML type STRING, + "! The MD5 hash value of the input document. + HASH type STRING, + "! The label applied to the input document with the calling method's `file_1_label` + "! or `file_2_label` value. This field is specified only in the output of the + "! **Comparing two documents** method. + LABEL type STRING, + end of T_DOCUMENT. + types: + "! The duration or durations of the contract. + begin of T_CONTRACT_TERMS, + "! The confidence level in the identification of the contract term. + CONFIDENCE_LEVEL type STRING, + "! The contract term (duration). + TEXT type STRING, + "! The normalized form of the contract term, which is listed as a string. This + "! element is optional; it is returned only if normalized text exists. + TEXT_NORMALIZED type STRING, + "! The details of the normalized text, if applicable. This element is optional; it + "! is returned only if normalized text exists. + INTERPRETATION type T_INTERPRETATION, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + end of T_CONTRACT_TERMS. + types: + "! The analysis of objects returned by the **Element classification** method. + begin of T_CLASSIFY_RETURN, + "! Basic information about the input document. + DOCUMENT type T_DOCUMENT, + "! The analysis model used to classify the input document. For the **Element + "! classification** method, the only valid value is `contracts`. + MODEL_ID type STRING, + "! The version of the analysis model identified by the value of the `model_id` key. + "! + MODEL_VERSION type STRING, + "! Document elements identified by the service. + ELEMENTS type STANDARD TABLE OF T_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! The date or dates on which the document becomes effective. + EFFECTIVE_DATES type STANDARD TABLE OF T_EFFECTIVE_DATES WITH NON-UNIQUE DEFAULT KEY, + "! The monetary amounts that identify the total amount of the contract that needs + "! to be paid from one party to another. + CONTRACT_AMOUNTS type STANDARD TABLE OF T_CONTRACT_AMTS WITH NON-UNIQUE DEFAULT KEY, + "! The dates on which the document is to be terminated. + TERMINATION_DATES type STANDARD TABLE OF T_TERMINATION_DATES WITH NON-UNIQUE DEFAULT KEY, + "! The contract type as declared in the document. + CONTRACT_TYPES type STANDARD TABLE OF T_CONTRACT_TYPES WITH NON-UNIQUE DEFAULT KEY, + "! The durations of the contract. + CONTRACT_TERMS type STANDARD TABLE OF T_CONTRACT_TERMS WITH NON-UNIQUE DEFAULT KEY, + "! The document's payment durations. + PAYMENT_TERMS type STANDARD TABLE OF T_PAYMENT_TERMS WITH NON-UNIQUE DEFAULT KEY, + "! The contract currencies as declared in the document. + CONTRACT_CURRENCIES type STANDARD TABLE OF T_CONTRACT_CURRENCIES WITH NON-UNIQUE DEFAULT KEY, + "! Definition of tables identified in the input document. + TABLES type STANDARD TABLE OF T_TABLES WITH NON-UNIQUE DEFAULT KEY, + "! The structure of the input document. + DOCUMENT_STRUCTURE type T_DOC_STRUCTURE, + "! Definitions of the parties identified in the input document. + PARTIES type STANDARD TABLE OF T_PARTIES WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFY_RETURN. + types: + "! The original labeling from the input document, without the submitted feedback. + begin of T_ORIGINAL_LABELS_IN, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + end of T_ORIGINAL_LABELS_IN. + types: + "! Details of semantically aligned elements. + begin of T_ELEMENT_PAIR, + "! The label of the document (that is, the value of either the `file_1_label` or + "! `file_2_label` parameters) in which the element occurs. + DOCUMENT_LABEL type STRING, + "! The contents of the element. + TEXT type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! Description of the action specified by the element and whom it affects. + TYPES type STANDARD TABLE OF T_TYPE_LABEL_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + "! List of functional categories into which the element falls; in other words, the + "! subject matter of the element. + CATEGORIES type STANDARD TABLE OF T_CATEGORY_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + "! List of document attributes. + ATTRIBUTES type STANDARD TABLE OF T_ATTRIBUTE WITH NON-UNIQUE DEFAULT KEY, + end of T_ELEMENT_PAIR. + types: + "! No documentation available. + begin of T_ALIGNED_ELEMENT, + "! Identifies two elements that semantically align between the compared documents. + ELEMENT_PAIR type STANDARD TABLE OF T_ELEMENT_PAIR WITH NON-UNIQUE DEFAULT KEY, + "! Specifies whether the aligned element is identical. Elements are considered + "! identical despite minor differences such as leading punctuation, + "! end-of-sentence punctuation, whitespace, the presence or absence of definite or + "! indefinite articles, and others. + IDENTICAL_TEXT type BOOLEAN, + "! Hashed values that you can send to IBM to provide feedback or receive support. + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Indicates that the elements aligned are contractual clauses of significance. + SIGNIFICANT_ELEMENTS type BOOLEAN, + end of T_ALIGNED_ELEMENT. + types: + "! The comparison of the two submitted documents. + begin of T_COMPARE_RETURN, + "! The analysis model used to compare the input documents. For the **Compare two + "! documents** method, the only valid value is `contracts`. + MODEL_ID type STRING, + "! The version of the analysis model identified by the value of the `model_id` key. + "! + MODEL_VERSION type STRING, + "! Information about the documents being compared. + DOCUMENTS type STANDARD TABLE OF T_DOCUMENT WITH NON-UNIQUE DEFAULT KEY, + "! A list of pairs of elements that semantically align between the compared + "! documents. + ALIGNED_ELEMENTS type STANDARD TABLE OF T_ALIGNED_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + "! A list of elements that do not semantically align between the compared + "! documents. + UNALIGNED_ELEMENTS type STANDARD TABLE OF T_UNALIGNED_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_COMPARE_RETURN. + types: + "! The HTML converted from an input document. + begin of T_HTMLRETURN, + "! The number of pages in the input document. + NUM_PAGES type STRING, + "! The author of the input document, if identified. + AUTHOR type STRING, + "! The publication date of the input document, if identified. + PUBLICATION_DATE type STRING, + "! The title of the input document, if identified. + TITLE type STRING, + "! The HTML version of the input document. + HTML type STRING, + end of T_HTMLRETURN. + types: + "! Feedback data for submission. + begin of T_FEEDBACK_DATA_INPUT, + "! The type of feedback. The only permitted value is `element_classification`. + FEEDBACK_TYPE type STRING, + "! Brief information about the input document. + DOCUMENT type T_SHORT_DOC, + "! An optional string identifying the model ID. The only permitted value is + "! `contracts`. + MODEL_ID type STRING, + "! An optional string identifying the version of the model used. + MODEL_VERSION type STRING, + "! The numeric location of the identified element in the document, represented with + "! two integers labeled `begin` and `end`. + LOCATION type T_LOCATION, + "! The text on which to submit feedback. + TEXT type STRING, + "! The original labeling from the input document, without the submitted feedback. + ORIGINAL_LABELS type T_ORIGINAL_LABELS_IN, + "! The updated labeling from the input document, accounting for the submitted + "! feedback. + UPDATED_LABELS type T_UPDATED_LABELS_IN, + end of T_FEEDBACK_DATA_INPUT. + types: + "! An array that contains the `id` value of a row header that is applicable to this + "! body cell. + T_ROW_HEADER_IDS type TT_String. + types: + "! The batch-request status. + begin of T_BATCH_STATUS, + "! The method to be run against the documents. Possible values are + "! `html_conversion`, `element_classification`, and `tables`. + FUNCTION type STRING, + "! The geographical location of the Cloud Object Storage input bucket as listed on + "! the **Endpoint** tab of your COS instance; for example, `us-geo`, `eu-geo`, or + "! `ap-geo`. + INPUT_BUCKET_LOCATION type STRING, + "! The name of the Cloud Object Storage input bucket. + INPUT_BUCKET_NAME type STRING, + "! The geographical location of the Cloud Object Storage output bucket as listed on + "! the **Endpoint** tab of your COS instance; for example, `us-geo`, `eu-geo`, or + "! `ap-geo`. + OUTPUT_BUCKET_LOCATION type STRING, + "! The name of the Cloud Object Storage output bucket. + OUTPUT_BUCKET_NAME type STRING, + "! The unique identifier for the batch request. + BATCH_ID type STRING, + "! Document counts. + DOCUMENT_COUNTS type T_DOC_COUNTS, + "! The status of the batch request. + STATUS type STRING, + "! The creation time of the batch request. + CREATED type DATETIME, + "! The time of the most recent update to the batch request. + UPDATED type DATETIME, + end of T_BATCH_STATUS. + types: + "! The results of a successful **List Batches** request. + begin of T_BATCHES, + "! A list of the status of all batch requests. + BATCHES type STANDARD TABLE OF T_BATCH_STATUS WITH NON-UNIQUE DEFAULT KEY, + end of T_BATCHES. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! The document to convert. + FILE type FILE, + end of T_INLINE_OBJECT. + types: + "! An array that contains the `id` value of a column header that is applicable to + "! the current cell. + T_COLUMN_HEADER_IDS type TT_String. + types: + "! 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`. + T_ROW_HEADER_TEXTS_NORMALIZED type TT_String. + types: + "! An array that contains the `text` value of a column header that is applicable to + "! the current cell. + T_COLUMN_HEADER_TEXTS type TT_String. + types: + "! The status and message of the deletion request. + begin of T_FEEDBACK_DELETED, + "! HTTP return code. + STATUS type INTEGER, + "! Status message returned from the service. + MESSAGE type STRING, + end of T_FEEDBACK_DELETED. + types: + "! The feedback to be added to an element in the document. + begin of T_FEEDBACK_INPUT, + "! An optional string identifying the user. + USER_ID type STRING, + "! An optional comment on or description of the feedback. + COMMENT type STRING, + "! Feedback data for submission. + FEEDBACK_DATA type T_FEEDBACK_DATA_INPUT, + end of T_FEEDBACK_INPUT. + types: + "! No documentation available. + begin of T_INLINE_OBJECT1, + "! The document to classify. + FILE type FILE, + end of T_INLINE_OBJECT1. + types: + "! No documentation available. + begin of T_INLINE_OBJECT2, + "! The document on which to run table extraction. + FILE type FILE, + end of T_INLINE_OBJECT2. + types: + "! No documentation available. + begin of T_INLINE_OBJECT3, + "! The first document to compare. + FILE_1 type FILE, + "! The second document to compare. + FILE_2 type FILE, + end of T_INLINE_OBJECT3. + types: + "! No documentation available. + begin of T_INLINE_OBJECT4, + "! A JSON file containing the input Cloud Object Storage credentials. At a minimum, + "! the credentials must enable `READ` permissions on the bucket defined by the + "! `input_bucket_name` parameter. + INPUT_CREDENTIALS_FILE type FILE, + "! The geographical location of the Cloud Object Storage input bucket as listed on + "! the **Endpoint** tab of your Cloud Object Storage instance; for example, + "! `us-geo`, `eu-geo`, or `ap-geo`. + INPUT_BUCKET_LOCATION type STRING, + "! The name of the Cloud Object Storage input bucket. + INPUT_BUCKET_NAME type STRING, + "! A JSON file that lists the Cloud Object Storage output credentials. At a + "! minimum, the credentials must enable `READ` and `WRITE` permissions on the + "! bucket defined by the `output_bucket_name` parameter. + OUTPUT_CREDENTIALS_FILE type FILE, + "! The geographical location of the Cloud Object Storage output bucket as listed on + "! the **Endpoint** tab of your Cloud Object Storage instance; for example, + "! `us-geo`, `eu-geo`, or `ap-geo`. + OUTPUT_BUCKET_LOCATION type STRING, + "! The name of the Cloud Object Storage output bucket. + OUTPUT_BUCKET_NAME type STRING, + end of T_INLINE_OBJECT4. + types: + "! The results of a successful **Get Feedback** request for a single feedback + "! entry. + begin of T_GET_FEEDBACK, + "! A string uniquely identifying the feedback entry. + FEEDBACK_ID type STRING, + "! A timestamp identifying the creation time of the feedback entry. + CREATED type DATETIME, + "! A string containing the user's comment about the feedback entry. + COMMENT type STRING, + "! Information returned from the **Add Feedback** method. + FEEDBACK_DATA type T_FEEDBACK_DATA_OUTPUT, + end of T_GET_FEEDBACK. + types: + "! The results of a successful **List Feedback** request for all feedback. + begin of T_FEEDBACK_LIST, + "! A list of all feedback for the document. + FEEDBACK type STANDARD TABLE OF T_GET_FEEDBACK WITH NON-UNIQUE DEFAULT KEY, + end of T_FEEDBACK_LIST. + types: + "! A list of values in a key-value pair. + T_VALUES type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY. + +constants: + begin of C_REQUIRED_FIELDS, + T_LOCATION type string value '|BEGIN|END|', + T_LABEL type string value '|NATURE|PARTY|', + T_TYPE_LABEL_COMPARISON type string value '|', + T_PARAGRAPHS type string value '|', + T_DOC_COUNTS type string value '|', + T_TYPE_LABEL type string value '|', + T_SHORT_DOC type string value '|', + T_CATEGORY type string value '|', + T_ORIGINAL_LABELS_OUT type string value '|', + T_UPDATED_LABELS_OUT type string value '|', + T_PAGINATION type string value '|', + T_FEEDBACK_DATA_OUTPUT type string value '|', + T_ATTRIBUTE type string value '|', + T_CATEGORY_COMPARISON type string value '|', + T_UNALIGNED_ELEMENT type string value '|', + T_UPDATED_LABELS_IN type string value '|TYPES|CATEGORIES|', + T_ELEMENT_LOCATIONS type string value '|', + T_LEADING_SENTENCE type string value '|', + T_SECTION_TITLES type string value '|', + T_DOC_STRUCTURE type string value '|', + T_ERROR_RESPONSE type string value '|CODE|ERROR|', + T_CONTACT type string value '|', + T_SECTION_TITLE type string value '|', + T_COLUMN_HEADERS type string value '|', + T_CONTEXTS type string value '|', + T_TABLE_TITLE type string value '|', + T_BODY_CELLS type string value '|', + T_KEY type string value '|', + T_VALUE type string value '|', + T_KEY_VALUE_PAIR type string value '|', + T_TABLE_HEADERS type string value '|', + T_ROW_HEADERS type string value '|', + T_TABLES type string value '|', + T_DOC_INFO type string value '|', + T_TABLE_RETURN type string value '|', + T_FEEDBACK_RETURN type string value '|', + T_INTERPRETATION type string value '|', + T_CONTRACT_AMTS type string value '|', + T_CONTRACT_CURRENCIES type string value '|', + T_PAYMENT_TERMS type string value '|', + T_ELEMENT type string value '|', + T_TERMINATION_DATES type string value '|', + T_CONTRACT_TYPES type string value '|', + T_EFFECTIVE_DATES type string value '|', + T_MENTION type string value '|', + T_ADDRESS type string value '|', + T_PARTIES type string value '|', + T_DOCUMENT type string value '|', + T_CONTRACT_TERMS type string value '|', + T_CLASSIFY_RETURN type string value '|', + T_ORIGINAL_LABELS_IN type string value '|TYPES|CATEGORIES|', + T_ELEMENT_PAIR type string value '|', + T_ALIGNED_ELEMENT type string value '|', + T_COMPARE_RETURN type string value '|', + T_HTMLRETURN type string value '|', + T_FEEDBACK_DATA_INPUT type string value '|FEEDBACK_TYPE|LOCATION|TEXT|ORIGINAL_LABELS|UPDATED_LABELS|', + T_BATCH_STATUS type string value '|', + T_BATCHES type string value '|', + T_INLINE_OBJECT type string value '|FILE|', + T_FEEDBACK_DELETED type string value '|', + T_FEEDBACK_INPUT type string value '|FEEDBACK_DATA|', + T_INLINE_OBJECT1 type string value '|FILE|', + T_INLINE_OBJECT2 type string value '|FILE|', + T_INLINE_OBJECT3 type string value '|FILE_1|FILE_2|', + T_INLINE_OBJECT4 type string value '|INPUT_CREDENTIALS_FILE|INPUT_BUCKET_LOCATION|INPUT_BUCKET_NAME|OUTPUT_CREDENTIALS_FILE|OUTPUT_BUCKET_LOCATION|OUTPUT_BUCKET_NAME|', + T_GET_FEEDBACK type string value '|', + T_FEEDBACK_LIST type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + NUM_PAGES type string value 'num_pages', + AUTHOR type string value 'author', + PUBLICATION_DATE type string value 'publication_date', + TITLE type string value 'title', + HTML type string value 'html', + DOCUMENT type string value 'document', + MODEL_ID type string value 'model_id', + MODEL_VERSION type string value 'model_version', + ELEMENTS type string value 'elements', + EFFECTIVE_DATES type string value 'effective_dates', + EFFECTIVEDATES type string value 'effectiveDates', + CONTRACT_AMOUNTS type string value 'contract_amounts', + CONTRACTAMOUNTS type string value 'contractAmounts', + TERMINATION_DATES type string value 'termination_dates', + TERMINATIONDATES type string value 'terminationDates', + CONTRACT_TYPES type string value 'contract_types', + CONTRACTTYPES type string value 'contractTypes', + CONTRACT_TERMS type string value 'contract_terms', + CONTRACTTERMS type string value 'contractTerms', + PAYMENT_TERMS type string value 'payment_terms', + PAYMENTTERMS type string value 'paymentTerms', + CONTRACT_CURRENCIES type string value 'contract_currencies', + CONTRACTCURRENCIES type string value 'contractCurrencies', + TABLES type string value 'tables', + DOCUMENT_STRUCTURE type string value 'document_structure', + PARTIES type string value 'parties', + SECTION_TITLES type string value 'section_titles', + SECTIONTITLES type string value 'sectionTitles', + LEADING_SENTENCES type string value 'leading_sentences', + LEADINGSENTENCES type string value 'leadingSentences', + PARAGRAPHS type string value 'paragraphs', + DOCUMENTS type string value 'documents', + ALIGNED_ELEMENTS type string value 'aligned_elements', + ALIGNEDELEMENTS type string value 'alignedElements', + UNALIGNED_ELEMENTS type string value 'unaligned_elements', + UNALIGNEDELEMENTS type string value 'unalignedElements', + ELEMENT_PAIR type string value 'element_pair', + ELEMENTPAIR type string value 'elementPair', + IDENTICAL_TEXT type string value 'identical_text', + PROVENANCE_IDS type string value 'provenance_ids', + PROVENANCEIDS type string value 'provenanceIds', + SIGNIFICANT_ELEMENTS type string value 'significant_elements', + DOCUMENT_LABEL type string value 'document_label', + LOCATION type string value 'location', + TEXT type string value 'text', + TYPES type string value 'types', + CATEGORIES type string value 'categories', + ATTRIBUTES type string value 'attributes', + LABEL type string value 'label', + HASH type string value 'hash', + CODE type string value 'code', + ERROR type string value 'error', + SECTION_TITLE type string value 'section_title', + TABLE_HEADERS type string value 'table_headers', + TABLEHEADERS type string value 'tableHeaders', + ROW_HEADERS type string value 'row_headers', + ROWHEADERS type string value 'rowHeaders', + COLUMN_HEADERS type string value 'column_headers', + COLUMNHEADERS type string value 'columnHeaders', + BODY_CELLS type string value 'body_cells', + BODYCELLS type string value 'bodyCells', + CONTEXTS type string value 'contexts', + KEY_VALUE_PAIRS type string value 'key_value_pairs', + KEYVALUEPAIRS type string value 'keyValuePairs', + LEVEL type string value 'level', + ELEMENT_LOCATIONS type string value 'element_locations', + ELEMENTLOCATIONS type string value 'elementLocations', + BEGIN type string value 'begin', + END type string value 'end', + CELL_ID type string value 'cell_id', + ROW_INDEX_BEGIN type string value 'row_index_begin', + ROW_INDEX_END type string value 'row_index_end', + COLUMN_INDEX_BEGIN type string value 'column_index_begin', + COLUMN_INDEX_END type string value 'column_index_end', + TEXT_NORMALIZED type string value 'text_normalized', + KEY type string value 'key', + VALUE type string value 'value', + ROW_HEADER_IDS type string value 'row_header_ids', + ROWHEADERIDS type string value 'rowHeaderIds', + ROW_HEADER_TEXTS type string value 'row_header_texts', + ROWHEADERTEXTS type string value 'rowHeaderTexts', + ROW_HEADER_TEXTS_NORMALIZED type string value 'row_header_texts_normalized', + ROWHEADERTEXTSNORMALIZED type string value 'rowHeaderTextsNormalized', + COLUMN_HEADER_IDS type string value 'column_header_ids', + COLUMNHEADERIDS type string value 'columnHeaderIds', + COLUMN_HEADER_TEXTS type string value 'column_header_texts', + COLUMNHEADERTEXTS type string value 'columnHeaderTexts', + COLUMN_HEADER_TEXTS_NORMALIZED type string value 'column_header_texts_normalized', + COLUMNHEADERTEXTSNORMALIZED type string value 'columnHeaderTextsNormalized', + USER_ID type string value 'user_id', + COMMENT type string value 'comment', + FEEDBACK_DATA type string value 'feedback_data', + FEEDBACK_ID type string value 'feedback_id', + CREATED type string value 'created', + FEEDBACK_TYPE type string value 'feedback_type', + ORIGINAL_LABELS type string value 'original_labels', + UPDATED_LABELS type string value 'updated_labels', + PAGINATION type string value 'pagination', + REFRESH_CURSOR type string value 'refresh_cursor', + NEXT_CURSOR type string value 'next_cursor', + REFRESH_URL type string value 'refresh_url', + NEXT_URL type string value 'next_url', + TOTAL type string value 'total', + MODIFICATION type string value 'modification', + FEEDBACK type string value 'feedback', + STATUS type string value 'status', + MESSAGE type string value 'message', + TYPE type string value 'type', + NATURE type string value 'nature', + PARTY type string value 'party', + FUNCTION type string value 'function', + INPUT_BUCKET_LOCATION type string value 'input_bucket_location', + INPUT_BUCKET_NAME type string value 'input_bucket_name', + OUTPUT_BUCKET_LOCATION type string value 'output_bucket_location', + OUTPUT_BUCKET_NAME type string value 'output_bucket_name', + BATCH_ID type string value 'batch_id', + DOCUMENT_COUNTS type string value 'document_counts', + UPDATED type string value 'updated', + BATCHES type string value 'batches', + PENDING type string value 'pending', + SUCCESSFUL type string value 'successful', + FAILED type string value 'failed', + ROLE type string value 'role', + IMPORTANCE type string value 'importance', + ADDRESSES type string value 'addresses', + CONTACTS type string value 'contacts', + MENTIONS type string value 'mentions', + NAME type string value 'name', + CONFIDENCE_LEVEL type string value 'confidence_level', + INTERPRETATION type string value 'interpretation', + NUMERIC_VALUE type string value 'numeric_value', + UNIT type string value 'unit', + FILE type string value 'file', + FILE_1 type string value 'file_1', + FILE_2 type string value 'file_2', + INPUT_CREDENTIALS_FILE type string value 'input_credentials_file', + OUTPUT_CREDENTIALS_FILE type string value 'output_credentials_file', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Convert document to HTML. + "! + "! @parameter I_FILE | + "! The document to convert. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_HTMLRETURN + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CONVERT_TO_HTML + importing + !I_FILE type FILE + !I_FILE_CONTENT_TYPE type STRING optional + !I_MODEL type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_HTMLRETURN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Classify the elements of a document. + "! + "! @parameter I_FILE | + "! The document to classify. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFY_RETURN + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CLASSIFY_ELEMENTS + importing + !I_FILE type FILE + !I_FILE_CONTENT_TYPE type STRING optional + !I_MODEL type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFY_RETURN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Extract a document's tables. + "! + "! @parameter I_FILE | + "! The document on which to run table extraction. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_TABLE_RETURN + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods EXTRACT_TABLES + importing + !I_FILE type FILE + !I_FILE_CONTENT_TYPE type STRING optional + !I_MODEL type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TABLE_RETURN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Compare two documents. + "! + "! @parameter I_FILE_1 | + "! The first document to compare. + "! @parameter I_FILE_2 | + "! The second document to compare. + "! @parameter I_FILE_1_CONTENT_TYPE | + "! The content type of file1. + "! @parameter I_FILE_2_CONTENT_TYPE | + "! The content type of file2. + "! @parameter I_FILE_1_LABEL | + "! A text label for the first document. + "! @parameter I_FILE_2_LABEL | + "! A text label for the second document. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_COMPARE_RETURN + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods COMPARE_DOCUMENTS + importing + !I_FILE_1 type FILE + !I_FILE_2 type FILE + !I_FILE_1_CONTENT_TYPE type STRING optional + !I_FILE_2_CONTENT_TYPE type STRING optional + !I_FILE_1_LABEL type STRING default 'file_1' + !I_FILE_2_LABEL type STRING default 'file_2' + !I_MODEL type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COMPARE_RETURN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Add feedback. + "! + "! @parameter I_FEEDBACK_DATA | + "! An object that defines the feedback to be submitted. + "! @parameter E_RESPONSE | + "! Service return value of type T_FEEDBACK_RETURN + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_FEEDBACK + importing + !I_FEEDBACK_DATA type T_FEEDBACK_INPUT + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_FEEDBACK_RETURN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List the feedback in a document. + "! + "! @parameter I_FEEDBACK_TYPE | + "! An optional string that filters the output to include only feedback with the + "! specified feedback type. The only permitted value is `element_classification`. + "! @parameter I_BEFORE | + "! An optional string in the format `YYYY-MM-DD` that filters the output to include + "! only feedback that was added before the specified date. + "! @parameter I_AFTER | + "! An optional string in the format `YYYY-MM-DD` that filters the output to include + "! only feedback that was added after the specified date. + "! @parameter I_DOCUMENT_TITLE | + "! An optional string that filters the output to include only feedback from the + "! document with the specified `document_title`. + "! @parameter I_MODEL_ID | + "! An optional string that filters the output to include only feedback with the + "! specified `model_id`. The only permitted value is `contracts`. + "! @parameter I_MODEL_VERSION | + "! An optional string that filters the output to include only feedback with the + "! specified `model_version`. + "! @parameter I_CATEGORY_REMOVED | + "! An optional string in the form of a comma-separated list of categories. If it is + "! specified, the service filters the output to include only feedback that has at + "! least one category from the list removed. + "! @parameter I_CATEGORY_ADDED | + "! An optional string in the form of a comma-separated list of categories. If this + "! is specified, the service filters the output to include only feedback that has + "! at least one category from the list added. + "! @parameter I_CATEGORY_NOT_CHANGED | + "! An optional string in the form of a comma-separated list of categories. If this + "! is specified, the service filters the output to include only feedback that has + "! at least one category from the list unchanged. + "! @parameter I_TYPE_REMOVED | + "! An optional string of comma-separated `nature`:`party` pairs. If this is + "! specified, the service filters the output to include only feedback that has at + "! least one `nature`:`party` pair from the list removed. + "! @parameter I_TYPE_ADDED | + "! An optional string of comma-separated `nature`:`party` pairs. If this is + "! specified, the service filters the output to include only feedback that has at + "! least one `nature`:`party` pair from the list removed. + "! @parameter I_TYPE_NOT_CHANGED | + "! An optional string of comma-separated `nature`:`party` pairs. If this is + "! specified, the service filters the output to include only feedback that has at + "! least one `nature`:`party` pair from the list unchanged. + "! @parameter I_PAGE_LIMIT | + "! An optional integer specifying the number of documents that you want the service + "! to return. + "! @parameter I_CURSOR | + "! An optional string that returns the set of documents after the previous set. Use + "! this parameter with the `page_limit` parameter. + "! @parameter I_SORT | + "! An optional comma-separated list of fields in the document to sort on. You can + "! optionally specify the sort direction by prefixing the value of the field with + "! `-` for descending order or `+` for ascending order (the default). Currently + "! permitted sorting fields are `created`, `user_id`, and `document_title`. + "! @parameter I_INCLUDE_TOTAL | + "! An optional boolean value. If specified as `true`, the `pagination` object in + "! the output includes a value called `total` that gives the total count of + "! feedback created. + "! @parameter E_RESPONSE | + "! Service return value of type T_FEEDBACK_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_FEEDBACK + importing + !I_FEEDBACK_TYPE type STRING optional + !I_BEFORE type DATE optional + !I_AFTER type DATE optional + !I_DOCUMENT_TITLE type STRING optional + !I_MODEL_ID type STRING optional + !I_MODEL_VERSION type STRING optional + !I_CATEGORY_REMOVED type STRING optional + !I_CATEGORY_ADDED type STRING optional + !I_CATEGORY_NOT_CHANGED type STRING optional + !I_TYPE_REMOVED type STRING optional + !I_TYPE_ADDED type STRING optional + !I_TYPE_NOT_CHANGED type STRING optional + !I_PAGE_LIMIT type INTEGER optional + !I_CURSOR type STRING optional + !I_SORT type STRING optional + !I_INCLUDE_TOTAL type BOOLEAN optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_FEEDBACK_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a specified feedback entry. + "! + "! @parameter I_FEEDBACK_ID | + "! A string that specifies the feedback entry to be included in the output. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_GET_FEEDBACK + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_FEEDBACK + importing + !I_FEEDBACK_ID type STRING + !I_MODEL type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GET_FEEDBACK + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a specified feedback entry. + "! + "! @parameter I_FEEDBACK_ID | + "! A string that specifies the feedback entry to be deleted from the document. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_FEEDBACK_DELETED + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_FEEDBACK + importing + !I_FEEDBACK_ID type STRING + !I_MODEL type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_FEEDBACK_DELETED + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Submit a batch-processing request. + "! + "! @parameter I_FUNCTION | + "! The Compare and Comply method to run across the submitted input documents. + "! @parameter I_INPUT_CREDENTIALS_FILE | + "! A JSON file containing the input Cloud Object Storage credentials. At a minimum, + "! the credentials must enable `READ` permissions on the bucket defined by the + "! `input_bucket_name` parameter. + "! @parameter I_INPUT_BUCKET_LOCATION | + "! The geographical location of the Cloud Object Storage input bucket as listed on + "! the **Endpoint** tab of your Cloud Object Storage instance; for example, + "! `us-geo`, `eu-geo`, or `ap-geo`. + "! @parameter I_INPUT_BUCKET_NAME | + "! The name of the Cloud Object Storage input bucket. + "! @parameter I_OUTPUT_CREDENTIALS_FILE | + "! A JSON file that lists the Cloud Object Storage output credentials. At a + "! minimum, the credentials must enable `READ` and `WRITE` permissions on the + "! bucket defined by the `output_bucket_name` parameter. + "! @parameter I_OUTPUT_BUCKET_LOCATION | + "! The geographical location of the Cloud Object Storage output bucket as listed on + "! the **Endpoint** tab of your Cloud Object Storage instance; for example, + "! `us-geo`, `eu-geo`, or `ap-geo`. + "! @parameter I_OUTPUT_BUCKET_NAME | + "! The name of the Cloud Object Storage output bucket. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_BATCH_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_BATCH + importing + !I_FUNCTION type STRING + !I_INPUT_CREDENTIALS_FILE type FILE + !I_INPUT_BUCKET_LOCATION type STRING + !I_INPUT_BUCKET_NAME type STRING + !I_OUTPUT_CREDENTIALS_FILE type FILE + !I_OUTPUT_BUCKET_LOCATION type STRING + !I_OUTPUT_BUCKET_NAME type STRING + !I_MODEL type STRING optional + !I_INPUT_CREDENTIALS_FILE_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_OUTPUT_CREDENTIALS_FILE_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_BATCH_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List submitted batch-processing jobs. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_BATCHES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_BATCHES + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_BATCHES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get information about a specific batch-processing job. + "! + "! @parameter I_BATCH_ID | + "! The ID of the batch-processing job whose information you want to retrieve. + "! @parameter E_RESPONSE | + "! Service return value of type T_BATCH_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_BATCH + importing + !I_BATCH_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_BATCH_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a pending or active batch-processing job. + "! + "! @parameter I_BATCH_ID | + "! The ID of the batch-processing job you want to update. + "! @parameter I_ACTION | + "! The action you want to perform on the specified batch-processing job. + "! @parameter I_MODEL | + "! The analysis model to be used by the service. For the **Element classification** + "! and **Compare two documents** methods, the default is `contracts`. For the + "! **Extract tables** method, the default is `tables`. These defaults apply to the + "! standalone methods as well as to the methods' use in batch-processing requests. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_BATCH_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_BATCH + importing + !I_BATCH_ID type STRING + !I_ACTION type STRING + !I_MODEL type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_BATCH_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_COMPARE_COMPLY_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Compare and Comply'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_COMPARE_COMPLY_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/compare-comply/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092814'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->CONVERT_TO_HTML +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILE TYPE FILE +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_HTMLRETURN +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CONVERT_TO_HTML. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/html_conversion'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_FILE is initial. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->CLASSIFY_ELEMENTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILE TYPE FILE +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFY_RETURN +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CLASSIFY_ELEMENTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/element_classification'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_FILE is initial. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->EXTRACT_TABLES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILE TYPE FILE +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TABLE_RETURN +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method EXTRACT_TABLES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/tables'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_FILE is initial. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->COMPARE_DOCUMENTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILE_1 TYPE FILE +* | [--->] I_FILE_2 TYPE FILE +* | [--->] I_FILE_1_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_FILE_2_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_FILE_1_LABEL TYPE STRING (default ='file_1') +* | [--->] I_FILE_2_LABEL TYPE STRING (default ='file_2') +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COMPARE_RETURN +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method COMPARE_DOCUMENTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/comparison'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_FILE_1_LABEL is supplied. + lv_queryparam = escape( val = i_FILE_1_LABEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `file_1_label` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_FILE_2_LABEL is supplied. + lv_queryparam = escape( val = i_FILE_2_LABEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `file_2_label` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_FILE_1 is initial. + lv_extension = get_file_extension( I_file_1_content_type ). + lv_value = `form-data; name="file_1"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_1_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE_1. + append ls_form_part to lt_form_part. + endif. + + if not i_FILE_2 is initial. + lv_extension = get_file_extension( I_file_2_content_type ). + lv_value = `form-data; name="file_2"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_2_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE_2. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->ADD_FEEDBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FEEDBACK_DATA TYPE T_FEEDBACK_INPUT +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_FEEDBACK_RETURN +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_FEEDBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/feedback'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_FEEDBACK_DATA ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_FEEDBACK_DATA i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'feedback_data' i_value = i_FEEDBACK_DATA ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_FEEDBACK_DATA to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->LIST_FEEDBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FEEDBACK_TYPE TYPE STRING(optional) +* | [--->] I_BEFORE TYPE DATE(optional) +* | [--->] I_AFTER TYPE DATE(optional) +* | [--->] I_DOCUMENT_TITLE TYPE STRING(optional) +* | [--->] I_MODEL_ID TYPE STRING(optional) +* | [--->] I_MODEL_VERSION TYPE STRING(optional) +* | [--->] I_CATEGORY_REMOVED TYPE STRING(optional) +* | [--->] I_CATEGORY_ADDED TYPE STRING(optional) +* | [--->] I_CATEGORY_NOT_CHANGED TYPE STRING(optional) +* | [--->] I_TYPE_REMOVED TYPE STRING(optional) +* | [--->] I_TYPE_ADDED TYPE STRING(optional) +* | [--->] I_TYPE_NOT_CHANGED TYPE STRING(optional) +* | [--->] I_PAGE_LIMIT TYPE INTEGER(optional) +* | [--->] I_CURSOR TYPE STRING(optional) +* | [--->] I_SORT TYPE STRING(optional) +* | [--->] I_INCLUDE_TOTAL TYPE BOOLEAN(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_FEEDBACK_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_FEEDBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/feedback'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_FEEDBACK_TYPE is supplied. + lv_queryparam = escape( val = i_FEEDBACK_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `feedback_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_BEFORE is supplied. + lv_queryparam = i_BEFORE. + add_query_parameter( + exporting + i_parameter = `before` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_AFTER is supplied. + lv_queryparam = i_AFTER. + add_query_parameter( + exporting + i_parameter = `after` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_DOCUMENT_TITLE is supplied. + lv_queryparam = escape( val = i_DOCUMENT_TITLE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `document_title` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_MODEL_ID is supplied. + lv_queryparam = escape( val = i_MODEL_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_MODEL_VERSION is supplied. + lv_queryparam = escape( val = i_MODEL_VERSION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model_version` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CATEGORY_REMOVED is supplied. + lv_queryparam = escape( val = i_CATEGORY_REMOVED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `category_removed` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CATEGORY_ADDED is supplied. + lv_queryparam = escape( val = i_CATEGORY_ADDED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `category_added` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CATEGORY_NOT_CHANGED is supplied. + lv_queryparam = escape( val = i_CATEGORY_NOT_CHANGED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `category_not_changed` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TYPE_REMOVED is supplied. + lv_queryparam = escape( val = i_TYPE_REMOVED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `type_removed` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TYPE_ADDED is supplied. + lv_queryparam = escape( val = i_TYPE_ADDED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `type_added` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TYPE_NOT_CHANGED is supplied. + lv_queryparam = escape( val = i_TYPE_NOT_CHANGED format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `type_not_changed` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PAGE_LIMIT is supplied. + lv_queryparam = i_PAGE_LIMIT. + add_query_parameter( + exporting + i_parameter = `page_limit` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CURSOR is supplied. + lv_queryparam = escape( val = i_CURSOR format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `cursor` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INCLUDE_TOTAL is supplied. + lv_queryparam = i_INCLUDE_TOTAL. + add_query_parameter( + exporting + i_parameter = `include_total` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->GET_FEEDBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FEEDBACK_ID TYPE STRING +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GET_FEEDBACK +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_FEEDBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/feedback/{feedback_id}'. + replace all occurrences of `{feedback_id}` in ls_request_prop-url-path with i_FEEDBACK_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->DELETE_FEEDBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FEEDBACK_ID TYPE STRING +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_FEEDBACK_DELETED +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_FEEDBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/feedback/{feedback_id}'. + replace all occurrences of `{feedback_id}` in ls_request_prop-url-path with i_FEEDBACK_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->CREATE_BATCH +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FUNCTION TYPE STRING +* | [--->] I_INPUT_CREDENTIALS_FILE TYPE FILE +* | [--->] I_INPUT_BUCKET_LOCATION TYPE STRING +* | [--->] I_INPUT_BUCKET_NAME TYPE STRING +* | [--->] I_OUTPUT_CREDENTIALS_FILE TYPE FILE +* | [--->] I_OUTPUT_BUCKET_LOCATION TYPE STRING +* | [--->] I_OUTPUT_BUCKET_NAME TYPE STRING +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_INPUT_CREDENTIALS_FILE_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_OUTPUT_CREDENTIALS_FILE_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_BATCH_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_BATCH. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/batches'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_FUNCTION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `function` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_INPUT_BUCKET_LOCATION is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="input_bucket_location"' ##NO_TEXT. + lv_formdata = i_INPUT_BUCKET_LOCATION. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_INPUT_BUCKET_NAME is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="input_bucket_name"' ##NO_TEXT. + lv_formdata = i_INPUT_BUCKET_NAME. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_OUTPUT_BUCKET_LOCATION is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="output_bucket_location"' ##NO_TEXT. + lv_formdata = i_OUTPUT_BUCKET_LOCATION. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_OUTPUT_BUCKET_NAME is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="output_bucket_name"' ##NO_TEXT. + lv_formdata = i_OUTPUT_BUCKET_NAME. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_INPUT_CREDENTIALS_FILE is initial. + lv_extension = get_file_extension( I_INPUT_CREDENTIALS_FILE_CT ). + lv_value = `form-data; name="input_credentials_file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_INPUT_CREDENTIALS_FILE_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_INPUT_CREDENTIALS_FILE. + append ls_form_part to lt_form_part. + endif. + + if not i_OUTPUT_CREDENTIALS_FILE is initial. + lv_extension = get_file_extension( I_OUTPUT_CREDENTIALS_FILE_CT ). + lv_value = `form-data; name="output_credentials_file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_OUTPUT_CREDENTIALS_FILE_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_OUTPUT_CREDENTIALS_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->LIST_BATCHES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_BATCHES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_BATCHES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/batches'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->GET_BATCH +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_BATCH_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_BATCH_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_BATCH. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/batches/{batch_id}'. + replace all occurrences of `{batch_id}` in ls_request_prop-url-path with i_BATCH_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_COMPARE_COMPLY_V1->UPDATE_BATCH +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_BATCH_ID TYPE STRING +* | [--->] I_ACTION TYPE STRING +* | [--->] I_MODEL TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_BATCH_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_BATCH. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/batches/{batch_id}'. + replace all occurrences of `{batch_id}` in ls_request_prop-url-path with i_BATCH_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_ACTION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `action` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_COMPARE_COMPLY_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_compare_comply_v1.clas.xml b/src/zcl_ibmc_compare_comply_v1.clas.xml new file mode 100644 index 0000000..ad98c9c --- /dev/null +++ b/src/zcl_ibmc_compare_comply_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_COMPARE_COMPLY_V1 + E + IBM Watson Compare and Comply + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_discovery_v1.clas.abap b/src/zcl_ibmc_discovery_v1.clas.abap new file mode 100644 index 0000000..5a479bf --- /dev/null +++ b/src/zcl_ibmc_discovery_v1.clas.abap @@ -0,0 +1,8442 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! IBM Watson™ Discovery is a cognitive search and content analytics engine +"! that you can add to applications to identify patterns, trends and actionable +"! insights to drive better decision-making. Securely unify structured and +"! unstructured data with pre-enriched content, and use a simplified query +"! language to eliminate the need for manual filtering of results.
+class ZCL_IBMC_DISCOVERY_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! An aggregation produced by Discovery to analyze the input provided. + begin of T_QUERY_AGGREGATION, + "! The type of aggregation command used. For example: term, filter, max, min, etc. + TYPE type STRING, + "! Array of aggregation results. + RESULTS type STANDARD TABLE OF DATA_REFERENCE WITH NON-UNIQUE DEFAULT KEY, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! Aggregations returned by Discovery. + AGGREGATIONS type STANDARD TABLE OF DATA_REFERENCE WITH NON-UNIQUE DEFAULT KEY, + end of T_QUERY_AGGREGATION. + types: + "! Aggregation results for the specified query. + begin of T_AGGREGATION_RESULT, + "! Key that matched the aggregation type. + KEY type STRING, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! Aggregations returned in the case of chained aggregations. + AGGREGATIONS type STANDARD TABLE OF T_QUERY_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + end of T_AGGREGATION_RESULT. + types: + "! Training status details. + begin of T_TRAINING_STATUS, + "! The total number of training examples uploaded to this collection. + TOTAL_EXAMPLES type INTEGER, + "! When `true`, the collection has been successfully trained. + AVAILABLE type BOOLEAN, + "! When `true`, the collection is currently processing training. + PROCESSING type BOOLEAN, + "! When `true`, the collection has a sufficent amount of queries added for training + "! to occur. + MINIMUM_QUERIES_ADDED type BOOLEAN, + "! When `true`, the collection has a sufficent amount of examples added for + "! training to occur. + MINIMUM_EXAMPLES_ADDED type BOOLEAN, + "! When `true`, the collection has a sufficent amount of diversity in labeled + "! results for training to occur. + SUFFICIENT_LABEL_DIVERSITY type BOOLEAN, + "! The number of notices associated with this data set. + NOTICES type INTEGER, + "! The timestamp of when the collection was successfully trained. + SUCCESSFULLY_TRAINED type DATETIME, + "! The timestamp of when the data was uploaded. + DATA_UPDATED type DATETIME, + end of T_TRAINING_STATUS. + types: + "! Object describing the current status of the wordlist. + begin of T_TOKEN_DICT_STATUS_RESPONSE, + "! Current wordlist status for the specified collection. + STATUS type STRING, + "! The type for this wordlist. Can be `tokenization_dictionary` or `stopwords`. + TYPE type STRING, + end of T_TOKEN_DICT_STATUS_RESPONSE. + types: + "! An object that indicates the Categories enrichment will be applied to the + "! specified field. + T_NLU_ENRICHMENT_CATEGORIES type MAP. + types: + "! An object specifying the relations enrichment and related parameters. + begin of T_NLU_ENRICHMENT_RELATIONS, + "! *For use with `natural_language_understanding` enrichments only.* The enrichement + "! * model to use with relationship extraction. May be a custom model provided by + "! * Watson Knowledge Studio, the default public model is`en-news`. + MODEL type STRING, + end of T_NLU_ENRICHMENT_RELATIONS. + types: + "! An object specifying the sentiment extraction enrichment and related parameters. + "! + begin of T_NLU_ENRICHMENT_SENTIMENT, + "! When `true`, sentiment analysis is performed on the entire field. + DOCUMENT type BOOLEAN, + "! A comma-separated list of target strings that will have any associated sentiment + "! analyzed. + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_NLU_ENRICHMENT_SENTIMENT. + types: + "! An object specifiying the semantic roles enrichment and related parameters. + begin of T_NL_ENRICHMENT_SEMANTIC_ROLES, + "! When `true`, entities are extracted from the identified sentence parts. + ENTITIES type BOOLEAN, + "! When `true`, keywords are extracted from the identified sentence parts. + KEYWORDS type BOOLEAN, + "! The maximum number of semantic roles enrichments to extact from each instance of + "! the specified field. + LIMIT type INTEGER, + end of T_NL_ENRICHMENT_SEMANTIC_ROLES. + types: + "! An object speficying the Entities enrichment and related parameters. + begin of T_NLU_ENRICHMENT_ENTITIES, + "! When `true`, sentiment analysis of entities will be performed on the specified + "! field. + SENTIMENT type BOOLEAN, + "! When `true`, emotion detection of entities will be performed on the specified + "! field. + EMOTION type BOOLEAN, + "! The maximum number of entities to extract for each instance of the specified + "! field. + LIMIT type INTEGER, + "! When `true`, the number of mentions of each identified entity is recorded. The + "! default is `false`. + MENTIONS type BOOLEAN, + "! When `true`, the types of mentions for each idetifieid entity is recorded. The + "! default is `false`. + MENTION_TYPES type BOOLEAN, + "! When `true`, a list of sentence locations for each instance of each identified + "! entity is recorded. The default is `false`. + SENTENCE_LOCATIONS type BOOLEAN, + "! The enrichement model to use with entity extraction. May be a custom model + "! provided by Watson Knowledge Studio, or the default public model `alchemy`. + MODEL type STRING, + end of T_NLU_ENRICHMENT_ENTITIES. + types: + "! An object specifying the emotion detection enrichment and related parameters. + begin of T_NLU_ENRICHMENT_EMOTION, + "! When `true`, emotion detection is performed on the entire field. + DOCUMENT type BOOLEAN, + "! A comma-separated list of target strings that will have any associated emotions + "! detected. + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_NLU_ENRICHMENT_EMOTION. + types: + "! An object specifiying the concepts enrichment and related parameters. + begin of T_NLU_ENRICHMENT_CONCEPTS, + "! The maximum number of concepts enrichments to extact from each instance of the + "! specified field. + LIMIT type INTEGER, + end of T_NLU_ENRICHMENT_CONCEPTS. + types: + "! An object specifying the Keyword enrichment and related parameters. + begin of T_NLU_ENRICHMENT_KEYWORDS, + "! When `true`, sentiment analysis of keywords will be performed on the specified + "! field. + SENTIMENT type BOOLEAN, + "! When `true`, emotion detection of keywords will be performed on the specified + "! field. + EMOTION type BOOLEAN, + "! The maximum number of keywords to extract for each instance of the specified + "! field. + LIMIT type INTEGER, + end of T_NLU_ENRICHMENT_KEYWORDS. + types: + "! Object containing Natural Language Understanding features to be used. + begin of T_NLU_ENRICHMENT_FEATURES, + "! An object specifying the Keyword enrichment and related parameters. + KEYWORDS type T_NLU_ENRICHMENT_KEYWORDS, + "! An object speficying the Entities enrichment and related parameters. + ENTITIES type T_NLU_ENRICHMENT_ENTITIES, + "! An object specifying the sentiment extraction enrichment and related parameters. + "! + SENTIMENT type T_NLU_ENRICHMENT_SENTIMENT, + "! An object specifying the emotion detection enrichment and related parameters. + EMOTION type T_NLU_ENRICHMENT_EMOTION, + "! An object that indicates the Categories enrichment will be applied to the + "! specified field. + CATEGORIES type T_NLU_ENRICHMENT_CATEGORIES, + "! An object specifiying the semantic roles enrichment and related parameters. + SEMANTIC_ROLES type T_NL_ENRICHMENT_SEMANTIC_ROLES, + "! An object specifying the relations enrichment and related parameters. + RELATIONS type T_NLU_ENRICHMENT_RELATIONS, + "! An object specifiying the concepts enrichment and related parameters. + CONCEPTS type T_NLU_ENRICHMENT_CONCEPTS, + end of T_NLU_ENRICHMENT_FEATURES. + types: + "! An object representing the configuration options to use for the + "! `natural_language_understanding` enrichments. + begin of T_NLU_ENRICHMENT_OPTIONS, + "! Object containing Natural Language Understanding features to be used. + FEATURES type T_NLU_ENRICHMENT_FEATURES, + "! ISO 639-1 code indicating the language to use for the analysis. This code + "! overrides the automatic language detection performed by the service. Valid + "! codes are `ar` (Arabic), `en` (English), `fr` (French), `de` (German), `it` + "! (Italian), `pt` (Portuguese), `ru` (Russian), `es` (Spanish), and `sv` + "! (Swedish). **Note:** Not all features support all languages, automatic + "! detection is recommended. + LANGUAGE type STRING, + end of T_NLU_ENRICHMENT_OPTIONS. + types: + "! An object defining a single tokenizaion rule. + begin of T_TOKEN_DICT_RULE, + "! The string to tokenize. + TEXT type STRING, + "! Array of tokens that the `text` field is split into when found. + TOKENS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Array of tokens that represent the content of the `text` field in an alternate + "! character set. + READINGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The part of speech that the `text` string belongs to. For example `noun`. Custom + "! parts of speech can be specified. + PART_OF_SPEECH type STRING, + end of T_TOKEN_DICT_RULE. + types: + "! Tokenization dictionary describing how words are tokenized during ingestion and + "! at query time. + begin of T_TOKEN_DICT, + "! An array of tokenization rules. Each rule contains, the original `text` string, + "! component `tokens`, any alternate character set `readings`, and which + "! `part_of_speech` the text is from. + TOKENIZATION_RULES type STANDARD TABLE OF T_TOKEN_DICT_RULE WITH NON-UNIQUE DEFAULT KEY, + end of T_TOKEN_DICT. + types: + "! No documentation available. + begin of T_FILTER, + "! The match the aggregated results queried for. + MATCH type STRING, + end of T_FILTER. + types: + "! Object defining which URL to crawl and how to crawl it. + begin of T_SOURCE_OPTIONS_WEB_CRAWL, + "! The starting URL to crawl. + URL type STRING, + "! When `true`, crawls of the specified URL are limited to the host part of the + "! **url** field. + LIMIT_TO_STARTING_HOSTS type BOOLEAN, + "! The number of concurrent URLs to fetch. `gentle` means one URL is fetched at a + "! time with a delay between each call. `normal` means as many as two URLs are + "! fectched concurrently with a short delay between fetch calls. `aggressive` + "! means that up to ten URLs are fetched concurrently with a short delay between + "! fetch calls. + CRAWL_SPEED type STRING, + "! When `true`, allows the crawl to interact with HTTPS sites with SSL certificates + "! with untrusted signers. + ALLOW_UNTRUSTED_CERTIFICATE type BOOLEAN, + "! The maximum number of hops to make from the initial URL. When a page is crawled + "! each link on that page will also be crawled if it is within the + "! **maximum_hops** from the initial URL. The first page crawled is 0 hops, each + "! link crawled from the first page is 1 hop, each link crawled from those pages + "! is 2 hops, and so on. + MAXIMUM_HOPS type INTEGER, + "! The maximum milliseconds to wait for a response from the web server. + REQUEST_TIMEOUT type INTEGER, + "! When `true`, the crawler will ignore any `robots.txt` encountered by the + "! crawler. This should only ever be done when crawling a web site the user owns. + "! This must be be set to `true` when a **gateway_id** is specied in the + "! **credentials**. + OVERRIDE_ROBOTS_TXT type BOOLEAN, + "! Array of URL's to be excluded while crawling. The crawler will not follow links + "! which contains this string. For example, listing `https://ibm.com/watson` also + "! excludes `https://ibm.com/watson/discovery`. + BLACKLIST type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SOURCE_OPTIONS_WEB_CRAWL. + types: + "! Object containing details of the stored credentials.
+ "!
+ "! Obtain credentials for your source from the administrator of the source. + begin of T_CREDENTIAL_DETAILS, + "! The authentication method for this credentials definition. The + "! **credential_type** specified must be supported by the **source_type**. The + "! following combinations are possible:
+ "!
+ "! - `"source_type": "box"` - valid `credential_type`s: `oauth2`
+ "! - `"source_type": "salesforce"` - valid `credential_type`s: + "! `username_password`
+ "! - `"source_type": "sharepoint"` - valid `credential_type`s: `saml` with + "! **source_version** of `online`, or `ntlm_v1` with **source_version** of + "! `2016`
+ "! - `"source_type": "web_crawl"` - valid `credential_type`s: `noauth` or + "! `basic`
+ "! - "source_type": "cloud_object_storage"` - valid `credential_type`s: + "! `aws4_hmac`. + CREDENTIAL_TYPE type STRING, + "! The **client_id** of the source that these credentials connect to. Only valid, + "! and required, with a **credential_type** of `oauth2`. + CLIENT_ID type STRING, + "! The **enterprise_id** of the Box site that these credentials connect to. Only + "! valid, and required, with a **source_type** of `box`. + ENTERPRISE_ID type STRING, + "! The **url** of the source that these credentials connect to. Only valid, and + "! required, with a **credential_type** of `username_password`, `noauth`, and + "! `basic`. + URL type STRING, + "! The **username** of the source that these credentials connect to. Only valid, + "! and required, with a **credential_type** of `saml`, `username_password`, + "! `basic`, or `ntlm_v1`. + USERNAME type STRING, + "! The **organization_url** of the source that these credentials connect to. Only + "! valid, and required, with a **credential_type** of `saml`. + ORGANIZATION_URL type STRING, + "! The **site_collection.path** of the source that these credentials connect to. + "! Only valid, and required, with a **source_type** of `sharepoint`. + SITE_COLLECTION_PATH type STRING, + "! The **client_secret** of the source that these credentials connect to. Only + "! valid, and required, with a **credential_type** of `oauth2`. This value is + "! never returned and is only used when creating or modifying **credentials**. + CLIENT_SECRET type STRING, + "! The **public_key_id** of the source that these credentials connect to. Only + "! valid, and required, with a **credential_type** of `oauth2`. This value is + "! never returned and is only used when creating or modifying **credentials**. + PUBLIC_KEY_ID type STRING, + "! The **private_key** of the source that these credentials connect to. Only valid, + "! and required, with a **credential_type** of `oauth2`. This value is never + "! returned and is only used when creating or modifying **credentials**. + PRIVATE_KEY type STRING, + "! The **passphrase** of the source that these credentials connect to. Only valid, + "! and required, with a **credential_type** of `oauth2`. This value is never + "! returned and is only used when creating or modifying **credentials**. + PASSPHRASE type STRING, + "! The **password** of the source that these credentials connect to. Only valid, + "! and required, with **credential_type**s of `saml`, `username_password`, + "! `basic`, or `ntlm_v1`.
+ "!
+ "! **Note:** When used with a **source_type** of `salesforce`, the password + "! consists of the Salesforce password and a valid Salesforce security token + "! concatenated. This value is never returned and is only used when creating or + "! modifying **credentials**. + PASSWORD type STRING, + "! The ID of the **gateway** to be connected through (when connecting to intranet + "! sites). Only valid with a **credential_type** of `noauth`, `basic`, or + "! `ntlm_v1`. Gateways are created using the + "! `/v1/environments/{environment_id}/gateways` methods. + GATEWAY_ID type STRING, + "! The type of Sharepoint repository to connect to. Only valid, and required, with + "! a **source_type** of `sharepoint`. + SOURCE_VERSION type STRING, + "! SharePoint OnPrem WebApplication URL. Only valid, and required, with a + "! **source_version** of `2016`. If a port is not supplied, the default to port + "! `80` for http and port `443` for https connections are used. + WEB_APPLICATION_URL type STRING, + "! The domain used to log in to your OnPrem SharePoint account. Only valid, and + "! required, with a **source_version** of `2016`. + DOMAIN type STRING, + "! The endpoint associated with the cloud object store that your are connecting to. + "! Only valid, and required, with a **credential_type** of `aws4_hmac`. + ENDPOINT type STRING, + "! The access key ID associated with the cloud object store. Only valid, and + "! required, with a **credential_type** of `aws4_hmac`. This value is never + "! returned and is only used when creating or modifying **credentials**. For more + "! infomation, see the [cloud object store + "! documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=c + "! loud-object-storage-using-hmac-credentials#using-hmac-credentials). + ACCESS_KEY_ID type STRING, + "! The secret access key associated with the cloud object store. Only valid, and + "! required, with a **credential_type** of `aws4_hmac`. This value is never + "! returned and is only used when creating or modifying **credentials**. For more + "! infomation, see the [cloud object store + "! documentation](https://cloud.ibm.com/docs/services/cloud-object-storage?topic=c + "! loud-object-storage-using-hmac-credentials#using-hmac-credentials). + SECRET_ACCESS_KEY type STRING, + end of T_CREDENTIAL_DETAILS. + types: + "! Object containing credential information. + begin of T_CREDENTIALS, + "! Unique identifier for this set of credentials. + CREDENTIAL_ID type STRING, + "! The source that this credentials object connects to.
+ "! - `box` indicates the credentials are used to connect an instance of Enterprise + "! Box.
+ "! - `salesforce` indicates the credentials are used to connect to + "! Salesforce.
+ "! - `sharepoint` indicates the credentials are used to connect to Microsoft + "! SharePoint Online.
+ "! - `web_crawl` indicates the credentials are used to perform a web crawl.
+ "! = `cloud_object_storage` indicates the credentials are used to connect to an + "! IBM Cloud Object Store. + SOURCE_TYPE type STRING, + "! Object containing details of the stored credentials.
+ "!
+ "! Obtain credentials for your source from the administrator of the source. + CREDENTIAL_DETAILS type T_CREDENTIAL_DETAILS, + "! The current status of this set of credentials. `connected` indicates that the + "! credentials are available to use with the source configuration of a collection. + "! `invalid` refers to the credentials (for example, the password provided has + "! expired) and must be corrected before they can be used with a collection. + STATUS type STRING, + end of T_CREDENTIALS. + types: + "! Object containing array of credential definitions. + begin of T_CREDENTIALS_LIST, + "! An array of credential definitions that were created for this instance. + CREDENTIALS type STANDARD TABLE OF T_CREDENTIALS WITH NON-UNIQUE DEFAULT KEY, + end of T_CREDENTIALS_LIST. + types: + "! Summary of the collection usage in the environment. + begin of T_COLLECTION_USAGE, + "! Number of active collections in the environment. + AVAILABLE type INTEGER, + "! Total number of collections allowed in the environment. + MAXIMUM_ALLOWED type INTEGER, + end of T_COLLECTION_USAGE. + types: + "! Summary of the disk usage statistics for the environment. + begin of T_DISK_USAGE, + "! Number of bytes within the environment's disk capacity that are currently used + "! to store data. + USED_BYTES type INTEGER, + "! Total number of bytes available in the environment's disk capacity. + MAXIMUM_ALLOWED_BYTES type INTEGER, + end of T_DISK_USAGE. + types: + "! Summary of the document usage statistics for the environment. + begin of T_ENVIRONMENT_DOCUMENTS, + "! Number of documents indexed for the environment. + INDEXED type INTEGER, + "! Total number of documents allowed in the environment's capacity. + MAXIMUM_ALLOWED type INTEGER, + end of T_ENVIRONMENT_DOCUMENTS. + types: + "! Details about the resource usage and capacity of the environment. + begin of T_INDEX_CAPACITY, + "! Summary of the document usage statistics for the environment. + DOCUMENTS type T_ENVIRONMENT_DOCUMENTS, + "! Summary of the disk usage statistics for the environment. + DISK_USAGE type T_DISK_USAGE, + "! Summary of the collection usage in the environment. + COLLECTIONS type T_COLLECTION_USAGE, + end of T_INDEX_CAPACITY. + types: + "! Information about the Continuous Relevancy Training for this environment. + begin of T_SEARCH_STATUS, + "! Current scope of the training. Always returned as `environment`. + SCOPE type STRING, + "! The current status of Continuous Relevancy Training for this environment. + STATUS type STRING, + "! Long description of the current Continuous Relevancy Training status. + STATUS_DESCRIPTION type STRING, + "! The date stamp of the most recent completed training for this environment. + LAST_TRAINED type DATE, + end of T_SEARCH_STATUS. + types: + "! Details about an environment. + begin of T_ENVIRONMENT, + "! Unique identifier for the environment. + ENVIRONMENT_ID type STRING, + "! Name that identifies the environment. + NAME type STRING, + "! Description of the environment. + DESCRIPTION type STRING, + "! Creation date of the environment, in the format `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. + CREATED type DATETIME, + "! Date of most recent environment update, in the format + "! `yyyy-MM-dd'T'HH:mm:ss.SSS'Z'`. + UPDATED type DATETIME, + "! Current status of the environment. `resizing` is displayed when a request to + "! increase the environment size has been made, but is still in the process of + "! being completed. + STATUS type STRING, + "! If `true`, the environment contains read-only collections that are maintained by + "! IBM. + READ_ONLY type BOOLEAN, + "! Current size of the environment. + SIZE type STRING, + "! The new size requested for this environment. Only returned when the environment + "! *status* is `resizing`.
+ "!
+ "! *Note:* Querying and indexing can still be performed during an environment + "! upsize. + REQUESTED_SIZE type STRING, + "! Details about the resource usage and capacity of the environment. + INDEX_CAPACITY type T_INDEX_CAPACITY, + "! Information about the Continuous Relevancy Training for this environment. + SEARCH_STATUS type T_SEARCH_STATUS, + end of T_ENVIRONMENT. + types: + "! Response object containing an array of configured environments. + begin of T_LIST_ENVIRONMENTS_RESPONSE, + "! An array of [environments] that are available for the service instance. + ENVIRONMENTS type STANDARD TABLE OF T_ENVIRONMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_ENVIRONMENTS_RESPONSE. + types: + "! Gatway deletion confirmation. + begin of T_GATEWAY_DELETE, + "! The gateway ID of the deleted gateway. + GATEWAY_ID type STRING, + "! The status of the request. + STATUS type STRING, + end of T_GATEWAY_DELETE. + types: + "! Training example details. + begin of T_TRAINING_EXAMPLE, + "! The document ID associated with this training example. + DOCUMENT_ID type STRING, + "! The cross reference associated with this training example. + CROSS_REFERENCE type STRING, + "! The relevance of the training example. + RELEVANCE type INTEGER, + end of T_TRAINING_EXAMPLE. + types: + "! Training query details. + begin of T_TRAINING_QUERY, + "! The query ID associated with the training query. + QUERY_ID type STRING, + "! The natural text query for the training query. + NATURAL_LANGUAGE_QUERY type STRING, + "! The filter used on the collection before the **natural_language_query** is + "! applied. + FILTER type STRING, + "! Array of training examples. + EXAMPLES type STANDARD TABLE OF T_TRAINING_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_QUERY. + types: + "! A passage query result. + begin of T_QUERY_PASSAGES, + "! The unique identifier of the document from which the passage has been extracted. + "! + DOCUMENT_ID type STRING, + "! The confidence score of the passages's analysis. A higher score indicates + "! greater confidence. + PASSAGE_SCORE type DOUBLE, + "! The content of the extracted passage. + PASSAGE_TEXT type STRING, + "! The position of the first character of the extracted passage in the originating + "! field. + START_OFFSET type INTEGER, + "! The position of the last character of the extracted passage in the originating + "! field. + END_OFFSET type INTEGER, + "! The label of the field from which the passage has been extracted. + FIELD type STRING, + end of T_QUERY_PASSAGES. + types: + "! Object containing normalization operations. + begin of T_NORMALIZATION_OPERATION, + "! Identifies what type of operation to perform.
+ "!
+ "! **copy** - Copies the value of the **source_field** to the **destination_field** + "! field. If the **destination_field** already exists, then the value of the + "! **source_field** overwrites the original value of the **destination_field**. + "!
+ "!
+ "! **move** - Renames (moves) the **source_field** to the **destination_field**. If + "! the **destination_field** already exists, then the value of the + "! **source_field** overwrites the original value of the **destination_field**. + "! Rename is identical to copy, except that the **source_field** is removed after + "! the value has been copied to the **destination_field** (it is the same as a + "! _copy_ followed by a _remove_).
+ "!
+ "! **merge** - Merges the value of the **source_field** with the value of the + "! **destination_field**. The **destination_field** is converted into an array if + "! it is not already an array, and the value of the **source_field** is appended + "! to the array. This operation removes the **source_field** after the merge. If + "! the **source_field** does not exist in the current document, then the + "! **destination_field** is still converted into an array (if it is not an array + "! already). This conversion ensures the type for **destination_field** is + "! consistent across all documents.
+ "!
+ "! **remove** - Deletes the **source_field** field. The **destination_field** is + "! ignored for this operation.
+ "!
+ "! **remove_nulls** - Removes all nested null (blank) field values from the + "! ingested document. **source_field** and **destination_field** are ignored by + "! this operation because _remove_nulls_ operates on the entire ingested document. + "! Typically, **remove_nulls** is invoked as the last normalization operation (if + "! it is invoked at all, it can be time-expensive). + OPERATION type STRING, + "! The source field for the operation. + SOURCE_FIELD type STRING, + "! The destination field for the operation. + DESTINATION_FIELD type STRING, + end of T_NORMALIZATION_OPERATION. + types: + "! Font matching configuration. + begin of T_FONT_SETTING, + "! The HTML heading level that any content with the matching font is converted to. + LEVEL type INTEGER, + "! The minimum size of the font to match. + MIN_SIZE type INTEGER, + "! The maximum size of the font to match. + MAX_SIZE type INTEGER, + "! When `true`, the font is matched if it is bold. + BOLD type BOOLEAN, + "! When `true`, the font is matched if it is italic. + ITALIC type BOOLEAN, + "! The name of the font. + NAME type STRING, + end of T_FONT_SETTING. + types: + "! Microsoft Word styles to convert into a specified HTML head level. + begin of T_WORD_STYLE, + "! HTML head level that content matching this style is tagged with. + LEVEL type INTEGER, + "! Array of word style names to convert. + NAMES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_WORD_STYLE. + types: + "! Object containing heading detection conversion settings for Microsoft Word + "! documents. + begin of T_WORD_HEADING_DETECTION, + "! Array of font matching configurations. + FONTS type STANDARD TABLE OF T_FONT_SETTING WITH NON-UNIQUE DEFAULT KEY, + "! Array of Microsoft Word styles to convert. + STYLES type STANDARD TABLE OF T_WORD_STYLE WITH NON-UNIQUE DEFAULT KEY, + end of T_WORD_HEADING_DETECTION. + types: + "! Object containing heading detection conversion settings for PDF documents. + begin of T_PDF_HEADING_DETECTION, + "! Array of font matching configurations. + FONTS type STANDARD TABLE OF T_FONT_SETTING WITH NON-UNIQUE DEFAULT KEY, + end of T_PDF_HEADING_DETECTION. + types: + "! A list of PDF conversion settings. + begin of T_PDF_SETTINGS, + "! Object containing heading detection conversion settings for PDF documents. + HEADING type T_PDF_HEADING_DETECTION, + end of T_PDF_SETTINGS. + types: + "! Object that defines a box folder to crawl with this configuration. + begin of T_SOURCE_OPTIONS_FOLDER, + "! The Box user ID of the user who owns the folder to crawl. + OWNER_USER_ID type STRING, + "! The Box folder ID of the folder to crawl. + FOLDER_ID type STRING, + "! The maximum number of documents to crawl for this folder. By default, all + "! documents in the folder are crawled. + LIMIT type INTEGER, + end of T_SOURCE_OPTIONS_FOLDER. + types: + "! Object defining a cloud object store bucket to crawl. + begin of T_SOURCE_OPTIONS_BUCKETS, + "! The name of the cloud object store bucket to crawl. + NAME type STRING, + "! The number of documents to crawl from this cloud object store bucket. If not + "! specified, all documents in the bucket are crawled. + LIMIT type INTEGER, + end of T_SOURCE_OPTIONS_BUCKETS. + types: + "! Object containing the schedule information for the source. + begin of T_SOURCE_SCHEDULE, + "! When `true`, the source is re-crawled based on the **frequency** field in this + "! object. When `false` the source is not re-crawled; When `false` and connecting + "! to Salesforce the source is crawled annually. + ENABLED type BOOLEAN, + "! The time zone to base source crawl times on. Possible values correspond to the + "! IANA (Internet Assigned Numbers Authority) time zones list. + TIME_ZONE type STRING, + "! The crawl schedule in the specified **time_zone**.
+ "!
+ "! - `five_minutes`: Runs every five minutes.
+ "! - `hourly`: Runs every hour.
+ "! - `daily`: Runs every day between 00:00 and 06:00.
+ "! - `weekly`: Runs every week on Sunday between 00:00 and 06:00.
+ "! - `monthly`: Runs the on the first Sunday of every month between 00:00 and + "! 06:00. + FREQUENCY type STRING, + end of T_SOURCE_SCHEDULE. + types: + "! Object that defines a Salesforce document object type crawl with this + "! configuration. + begin of T_SOURCE_OPTIONS_OBJECT, + "! The name of the Salesforce document object to crawl. For example, `case`. + NAME type STRING, + "! The maximum number of documents to crawl for this document object. By default, + "! all documents in the document object are crawled. + LIMIT type INTEGER, + end of T_SOURCE_OPTIONS_OBJECT. + types: + "! Object that defines a Microsoft SharePoint site collection to crawl with this + "! configuration. + begin of T_SOURCE_OPTIONS_SITE_COLL, + "! The Microsoft SharePoint Online site collection path to crawl. The path must be + "! be relative to the **organization_url** that was specified in the credentials + "! associated with this source configuration. + SITE_COLLECTION_PATH1 type STRING, + "! The maximum number of documents to crawl for this site collection. By default, + "! all documents in the site collection are crawled. + LIMIT type INTEGER, + end of T_SOURCE_OPTIONS_SITE_COLL. + types: + "! The **options** object defines which items to crawl from the source system. + begin of T_SOURCE_OPTIONS, + "! Array of folders to crawl from the Box source. Only valid, and required, when + "! the **type** field of the **source** object is set to `box`. + FOLDERS type STANDARD TABLE OF T_SOURCE_OPTIONS_FOLDER WITH NON-UNIQUE DEFAULT KEY, + "! Array of Salesforce document object types to crawl from the Salesforce source. + "! Only valid, and required, when the **type** field of the **source** object is + "! set to `salesforce`. + OBJECTS type STANDARD TABLE OF T_SOURCE_OPTIONS_OBJECT WITH NON-UNIQUE DEFAULT KEY, + "! Array of Microsoft SharePointoint Online site collections to crawl from the + "! SharePoint source. Only valid and required when the **type** field of the + "! **source** object is set to `sharepoint`. + SITE_COLLECTIONS type STANDARD TABLE OF T_SOURCE_OPTIONS_SITE_COLL WITH NON-UNIQUE DEFAULT KEY, + "! Array of Web page URLs to begin crawling the web from. Only valid and required + "! when the **type** field of the **source** object is set to `web_crawl`. + URLS type STANDARD TABLE OF T_SOURCE_OPTIONS_WEB_CRAWL WITH NON-UNIQUE DEFAULT KEY, + "! Array of cloud object store buckets to begin crawling. Only valid and required + "! when the **type** field of the **source** object is set to + "! `cloud_object_store`, and the **crawl_all_buckets** field is `false` or not + "! specified. + BUCKETS type STANDARD TABLE OF T_SOURCE_OPTIONS_BUCKETS WITH NON-UNIQUE DEFAULT KEY, + "! When `true`, all buckets in the specified cloud object store are crawled. If set + "! to `true`, the **buckets** array must not be specified. + CRAWL_ALL_BUCKETS type BOOLEAN, + end of T_SOURCE_OPTIONS. + types: + "! Object containing source parameters for the configuration. + begin of T_SOURCE, + "! The type of source to connect to.
+ "! - `box` indicates the configuration is to connect an instance of Enterprise + "! Box.
+ "! - `salesforce` indicates the configuration is to connect to Salesforce.
+ "! - `sharepoint` indicates the configuration is to connect to Microsoft + "! SharePoint Online.
+ "! - `web_crawl` indicates the configuration is to perform a web page crawl.
+ "! - `cloud_object_storage` indicates the configuration is to connect to a cloud + "! object store. + TYPE type STRING, + "! The **credential_id** of the credentials to use to connect to the source. + "! Credentials are defined using the **credentials** method. The **source_type** + "! of the credentials used must match the **type** field specified in this object. + "! + CREDENTIAL_ID type STRING, + "! Object containing the schedule information for the source. + SCHEDULE type T_SOURCE_SCHEDULE, + "! The **options** object defines which items to crawl from the source system. + OPTIONS type T_SOURCE_OPTIONS, + end of T_SOURCE. + types: + "! Object containing an array of XPaths. + begin of T_XPATH_PATTERNS, + "! An array to XPaths. + XPATHS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_XPATH_PATTERNS. + types: + "! Options which are specific to a particular enrichment. + begin of T_ENRICHMENT_OPTIONS, + "! Object containing Natural Language Understanding features to be used. + FEATURES type T_NLU_ENRICHMENT_FEATURES, + "! ISO 639-1 code indicating the language to use for the analysis. This code + "! overrides the automatic language detection performed by the service. Valid + "! codes are `ar` (Arabic), `en` (English), `fr` (French), `de` (German), `it` + "! (Italian), `pt` (Portuguese), `ru` (Russian), `es` (Spanish), and `sv` + "! (Swedish). **Note:** Not all features support all languages, automatic + "! detection is recommended. + LANGUAGE type STRING, + "! *For use with `elements` enrichments only.* The element extraction model to use. + "! * Models available are: `contract`. + MODEL type STRING, + end of T_ENRICHMENT_OPTIONS. + types: + "! Enrichment step to perform on the document. Each enrichment is performed on the + "! specified field in the order that they are listed in the configuration. + begin of T_ENRICHMENT, + "! Describes what the enrichment step does. + DESCRIPTION type STRING, + "! 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. + DESTINATION_FIELD type STRING, + "! Field to be enriched.
+ "!
+ "! Arrays can be specified as the **source_field** if the **enrichment** service + "! for this enrichment is set to `natural_language_undstanding`. + SOURCE_FIELD type STRING, + "! Indicates that the enrichments will overwrite the destination_field field if it + "! already exists. + OVERWRITE type BOOLEAN, + "! Name of the enrichment service to call. Current options are + "! `natural_language_understanding` and `elements`.
+ "!
+ "! When using `natual_language_understanding`, the **options** object must contain + "! Natural Language Understanding options.
+ "!
+ "! When using `elements` the **options** object must contain Element + "! Classification options. Additionally, when using the `elements` enrichment the + "! configuration specified and files ingested must meet all the criteria specified + "! in [the + "! documentation](https://cloud.ibm.com/docs/services/discovery?topic=discovery-el + "! ement-classification#element-classification). + ENRICHMENT type STRING, + "! If true, then most errors generated during the enrichment process will be + "! treated as warnings and will not cause the document to fail processing. + IGNORE_DOWNSTREAM_ERRORS type BOOLEAN, + "! Options which are specific to a particular enrichment. + OPTIONS type T_ENRICHMENT_OPTIONS, + end of T_ENRICHMENT. + types: + "! A list of Document Segmentation settings. + begin of T_SEGMENT_SETTINGS, + "! Enables/disables the Document Segmentation feature. + ENABLED type BOOLEAN, + "! Defines the heading level that splits into document segments. Valid values are + "! h1, h2, h3, h4, h5, h6. The content of the header field that the segmentation + "! splits at is used as the **title** field for that segmented result. Only valid + "! if used with a collection that has **enabled** set to `false` in the + "! **smart_document_understanding** object. + SELECTOR_TAGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Defines the annotated smart document understanding fields that the document is + "! split on. The content of the annotated field that the segmentation splits at is + "! used as the **title** field for that segmented result. For example, if the + "! field `sub-title` is specified, when a document is uploaded each time the smart + "! documement understanding conversion encounters a field of type `sub-title` the + "! document is split at that point and the content of the field used as the title + "! of the remaining content. Thnis split is performed for all instances of the + "! listed fields in the uploaded document. Only valid if used with a collection + "! that has **enabled** set to `true` in the **smart_document_understanding** + "! object. + ANNOTATED_FIELDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SEGMENT_SETTINGS. + types: + "! A list of Word conversion settings. + begin of T_WORD_SETTINGS, + "! Object containing heading detection conversion settings for Microsoft Word + "! documents. + HEADING type T_WORD_HEADING_DETECTION, + end of T_WORD_SETTINGS. + types: + "! A list of HTML conversion settings. + begin of T_HTML_SETTINGS, + "! Array of HTML tags that are excluded completely. + EXCLUDE_TAGS_COMPLETELY type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Array of HTML tags which are excluded but still retain content. + EXCLUDE_TAGS_KEEP_CONTENT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Object containing an array of XPaths. + KEEP_CONTENT type T_XPATH_PATTERNS, + "! Object containing an array of XPaths. + EXCLUDE_CONTENT type T_XPATH_PATTERNS, + "! An array of HTML tag attributes to keep in the converted document. + KEEP_TAG_ATTRIBUTES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Array of HTML tag attributes to exclude. + EXCLUDE_TAG_ATTRIBUTES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_HTML_SETTINGS. + types: + "! Document conversion settings. + begin of T_CONVERSIONS, + "! A list of PDF conversion settings. + PDF type T_PDF_SETTINGS, + "! A list of Word conversion settings. + WORD type T_WORD_SETTINGS, + "! A list of HTML conversion settings. + HTML type T_HTML_SETTINGS, + "! A list of Document Segmentation settings. + SEGMENT type T_SEGMENT_SETTINGS, + "! 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. + JSON_NORMALIZATIONS type STANDARD TABLE OF T_NORMALIZATION_OPERATION WITH NON-UNIQUE DEFAULT KEY, + "! When `true`, automatic text extraction from images (this includes images + "! embedded in supported document formats, for example PDF, and suppported image + "! formats, for example TIFF) is performed on documents uploaded to the + "! collection. This field is supported on **Advanced** and higher plans only. + "! **Lite** plans do not support image text recognition. + IMAGE_TEXT_RECOGNITION type BOOLEAN, + end of T_CONVERSIONS. + types: + "! A custom configuration for the environment. + begin of T_CONFIGURATION, + "! The unique identifier of the configuration. + CONFIGURATION_ID type STRING, + "! The name of the configuration. + NAME type STRING, + "! The creation date of the configuration in the format + "! yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. + CREATED type DATETIME, + "! The timestamp of when the configuration was last updated in the format + "! yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. + UPDATED type DATETIME, + "! The description of the configuration, if available. + DESCRIPTION type STRING, + "! Document conversion settings. + CONVERSIONS type T_CONVERSIONS, + "! An array of document enrichment settings for the configuration. + ENRICHMENTS type STANDARD TABLE OF T_ENRICHMENT WITH NON-UNIQUE DEFAULT KEY, + "! 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. + NORMALIZATIONS type STANDARD TABLE OF T_NORMALIZATION_OPERATION WITH NON-UNIQUE DEFAULT KEY, + "! Object containing source parameters for the configuration. + SOURCE type T_SOURCE, + end of T_CONFIGURATION. + types: + "! Object containing an array of available configurations. + begin of T_LIST_CONFIGURATIONS_RESPONSE, + "! An array of configurations that are available for the service instance. + CONFIGURATIONS type STANDARD TABLE OF T_CONFIGURATION WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_CONFIGURATIONS_RESPONSE. + types: + "! Object containing source crawl status information. + begin of T_SOURCE_STATUS, + "! The current status of the source crawl for this collection. This field returns + "! `not_configured` if the default configuration for this source does not have a + "! **source** object defined.
+ "!
+ "! - `running` indicates that a crawl to fetch more documents is in progress.
+ "! - `complete` indicates that the crawl has completed with no errors.
+ "! - `queued` indicates that the crawl has been paused by the system and will + "! automatically restart when possible.
+ "! - `unknown` indicates that an unidentified error has occured in the service. + STATUS type STRING, + "! Date in `RFC 3339` format indicating the time of the next crawl attempt. + NEXT_CRAWL type DATETIME, + end of T_SOURCE_STATUS. + types: + "! Object returned after credentials are deleted. + begin of T_DELETE_CREDENTIALS, + "! The unique identifier of the credentials that have been deleted. + CREDENTIAL_ID type STRING, + "! The status of the deletion request. + STATUS type STRING, + end of T_DELETE_CREDENTIALS. + types: + "! A notice produced for the collection. + begin of T_NOTICE, + "! 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. + NOTICE_ID type STRING, + "! The creation date of the collection in the format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. + CREATED type DATETIME, + "! Unique identifier of the document. + DOCUMENT_ID type STRING, + "! Unique identifier of the query used for relevance training. + QUERY_ID type STRING, + "! Severity level of the notice. + SEVERITY type STRING, + "! Ingestion or training step in which the notice occurred. Typical step values + "! include: `classify_elements`, `smartDocumentUnderstanding`, `ingestion`, + "! `indexing`, `convert`. **Note:** This is not a complete list, other values + "! might be returned. + STEP type STRING, + "! The description of the notice. + DESCRIPTION type STRING, + end of T_NOTICE. + types: + "! Information returned after an uploaded document is accepted. + begin of T_DOCUMENT_ACCEPTED, + "! The unique identifier of the ingested document. + DOCUMENT_ID type STRING, + "! Status of the document in the ingestion process. A status of `processing` is + "! returned for documents that are ingested with a *version* date before + "! `2019-01-01`. The `pending` status is returned for all others. + STATUS type STRING, + "! Array of notices produced by the document-ingestion process. + NOTICES type STANDARD TABLE OF T_NOTICE WITH NON-UNIQUE DEFAULT KEY, + end of T_DOCUMENT_ACCEPTED. + types: + "! Object describing a specific gateway. + begin of T_GATEWAY, + "! The gateway ID of the gateway. + GATEWAY_ID type STRING, + "! The user defined name of the gateway. + NAME type STRING, + "! The current status of the gateway. `connected` means the gateway is connected to + "! the remotly installed gateway. `idle` means this gateway is not currently in + "! use. + STATUS type STRING, + "! The generated **token** for this gateway. The value of this field is used when + "! configuring the remotly installed gateway. + TOKEN type STRING, + "! The generated **token_id** for this gateway. The value of this field is used + "! when configuring the remotly installed gateway. + TOKEN_ID type STRING, + end of T_GATEWAY. + types: + "! Aggregation result data for the requested metric. + begin of T_METRIC_AGGREGATION_RESULT, + "! Date in string form representing the start of this interval. + KEY_AS_STRING type DATETIME, + "! Unix epoch time equivalent of the **key_as_string**, that represents the start + "! of this interval. + KEY type LONG, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! The number of queries with associated events divided by the total number of + "! queries for the interval. Only returned with **event_rate** metrics. + EVENT_RATE type DOUBLE, + end of T_METRIC_AGGREGATION_RESULT. + types: + "! An aggregation analyzing log information for queries and events. + begin of T_METRIC_AGGREGATION, + "! The measurement interval for this metric. Metric intervals are always 1 day + "! (`1d`). + INTERVAL type STRING, + "! The event type associated with this metric result. This field, when present, + "! will always be `click`. + EVENT_TYPE type STRING, + "! Array of metric aggregation query results. + RESULTS type STANDARD TABLE OF T_METRIC_AGGREGATION_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_METRIC_AGGREGATION. + types: + "! The response generated from a call to a **metrics** method. + begin of T_METRIC_RESPONSE, + "! Array of metric aggregations. + AGGREGATIONS type STANDARD TABLE OF T_METRIC_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + end of T_METRIC_RESPONSE. + types: + "! Metadata of a query result. + begin of T_QUERY_RESULT_METADATA, + "! 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. + SCORE type DOUBLE, + "! The confidence score for the given result. Calculated based on how relevant the + "! result is estimated to be. confidence can range from `0.0` to `1.0`. The higher + "! the number, the more relevant the document. The `confidence` value for a result + "! was calculated using the model specified in the `document_retrieval_strategy` + "! field of the result set. + CONFIDENCE type DOUBLE, + end of T_QUERY_RESULT_METADATA. + types: + "! Query result object. + begin of T_QUERY_NOTICES_RESULT, + "! The unique identifier of the document. + ID type STRING, + "! Metadata of the document. + METADATA type MAP, + "! The collection ID of the collection containing the document for this result. + COLLECTION_ID type STRING, + "! Metadata of a query result. + RESULT_METADATA type T_QUERY_RESULT_METADATA, + "! The internal status code returned by the ingestion subsystem indicating the + "! overall result of ingesting the source document. + CODE type INTEGER, + "! Name of the original source file (if available). + FILENAME type STRING, + "! The type of the original source file. + FILE_TYPE type STRING, + "! The SHA-1 hash of the original source file (formatted as a hexadecimal string). + SHA1 type STRING, + "! Array of notices for the document. + NOTICES type STANDARD TABLE OF T_NOTICE WITH NON-UNIQUE DEFAULT KEY, + end of T_QUERY_NOTICES_RESULT. + types: + "! Each object in the **results** array corresponds to an individual document + "! returned by the original query. + begin of T_LOG_QRY_RESP_RSLT_DOCS_RSLT, + "! The result rank of this document. A position of `1` indicates that it was the + "! first returned result. + POSITION type INTEGER, + "! The **document_id** of the document that this result represents. + DOCUMENT_ID type STRING, + "! The raw score of this result. A higher score indicates a greater match to the + "! query parameters. + SCORE type DOUBLE, + "! The confidence score of the result's analysis. A higher score indicating greater + "! confidence. + CONFIDENCE type DOUBLE, + "! The **collection_id** of the document represented by this result. + COLLECTION_ID type STRING, + end of T_LOG_QRY_RESP_RSLT_DOCS_RSLT. + types: + "! Object containing result information that was returned by the query used to + "! create this log entry. Only returned with logs of type `query`. + begin of T_LOG_QUERY_RESP_RESULT_DOCS, + "! Array of log query response results. + RESULTS type STANDARD TABLE OF T_LOG_QRY_RESP_RSLT_DOCS_RSLT WITH NON-UNIQUE DEFAULT KEY, + "! The number of results returned in the query associate with this log. + COUNT type INTEGER, + end of T_LOG_QUERY_RESP_RESULT_DOCS. + types: + "! Object containing field details. + begin of T_FIELD, + "! The name of the field. + FIELD type STRING, + "! The type of the field. + TYPE type STRING, + end of T_FIELD. + types: + "! Query event data object. + begin of T_EVENT_DATA, + "! The **environment_id** associated with the query that the event is associated + "! with. + ENVIRONMENT_ID type STRING, + "! The session token that was returned as part of the query results that this event + "! is associated with. + SESSION_TOKEN type STRING, + "! The optional timestamp for the event that was created. If not provided, the time + "! that the event was created in the log was used. + CLIENT_TIMESTAMP type DATETIME, + "! The rank of the result item which the event is associated with. + DISPLAY_RANK type INTEGER, + "! The **collection_id** of the document that this event is associated with. + COLLECTION_ID type STRING, + "! The **document_id** of the document that this event is associated with. + DOCUMENT_ID type STRING, + "! The query identifier stored in the log. The query and any events associated with + "! that query are stored with the same **query_id**. + QUERY_ID type STRING, + end of T_EVENT_DATA. + types: + "! An object defining the event being created. + begin of T_CREATE_EVENT_OBJECT, + "! The event type to be created. + TYPE type STRING, + "! Query event data object. + DATA type T_EVENT_DATA, + end of T_CREATE_EVENT_OBJECT. + types: + "! No documentation available. + begin of T_NESTED, + "! The area of the results the aggregation was restricted to. + PATH type STRING, + end of T_NESTED. + types: + "! Object that describes a long query. + begin of T_QUERY_LARGE, + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + FILTER type STRING, + "! 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. + QUERY type STRING, + "! A natural language query that returns relevant documents by utilizing training + "! data and natural language understanding. + NATURAL_LANGUAGE_QUERY type STRING, + "! A passages query that returns the most relevant passages from the results. + PASSAGES type BOOLEAN, + "! An aggregation search that returns an exact answer by combining query search + "! with filters. Useful for applications to build lists, tables, and time series. + "! For a full list of possible aggregations, see the Query reference. + AGGREGATION type STRING, + "! Number of results to return. + COUNT type INTEGER, + "! A comma-separated list of the portion of the document hierarchy to return. + RETURN type STRING, + "! 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. + OFFSET type INTEGER, + "! A comma-separated list of fields in the document to sort on. You can optionally + "! specify a sort direction by prefixing the field with `-` for descending or `+` + "! for ascending. Ascending is the default sort direction if no prefix is + "! specified. This parameter cannot be used in the same query as the **bias** + "! parameter. + SORT type STRING, + "! When true, a highlight field is returned for each result which contains the + "! fields which match the query with `<em></em>` tags around the + "! matching query terms. + HIGHLIGHT type BOOLEAN, + "! A comma-separated list of fields that passages are drawn from. If this parameter + "! not specified, then all top-level fields are included. + PASSAGES_FIELDS type STRING, + "! 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`. + PASSAGES_COUNT type INTEGER, + "! The approximate number of characters that any one passage will have. + PASSAGES_CHARACTERS type INTEGER, + "! When `true`, and used with a Watson Discovery News collection, duplicate results + "! (based on the contents of the **title** field) are removed. Duplicate + "! comparison is limited to the current query only; **offset** is not considered. + "! This parameter is currently Beta functionality. + DEDUPLICATE type BOOLEAN, + "! 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. + DEDUPLICATE_FIELD type STRING, + "! When `true`, results are returned based on their similarity to the document IDs + "! specified in the **similar.document_ids** parameter. + SIMILAR type BOOLEAN, + "! A comma-separated list of document IDs to find similar documents.
+ "!
+ "! **Tip:** Include the **natural_language_query** parameter to expand the scope of + "! the document similarity search with the natural language query. Other query + "! parameters, such as **filter** and **query**, are subsequently applied and + "! reduce the scope. + SIMILAR_DOCUMENT_IDS type STRING, + "! A comma-separated list of field names that are used as a basis for comparison to + "! identify similar documents. If not specified, the entire document is used for + "! comparison. + SIMILAR_FIELDS type STRING, + "! Field which the returned results will be biased against. The specified field + "! must be either a **date** or **number** format. When a **date** type field is + "! specified returned results are biased towards field values closer to the + "! current date. When a **number** type field is specified, returned results are + "! biased towards higher field values. This parameter cannot be used in the same + "! query as the **sort** parameter. + BIAS type STRING, + end of T_QUERY_LARGE. + types: + "! Object containing user-defined name. + begin of T_GATEWAY_NAME, + "! User-defined name. + NAME type STRING, + end of T_GATEWAY_NAME. + types: + "! Object containing collection document count information. + begin of T_DOCUMENT_COUNTS, + "! The total number of available documents in the collection. + AVAILABLE type LONG, + "! The number of documents in the collection that are currently being processed. + PROCESSING type LONG, + "! The number of documents in the collection that failed to be ingested. + FAILED type LONG, + "! The number of documents that have been uploaded to the collection, but have not + "! yet started processing. + PENDING type LONG, + end of T_DOCUMENT_COUNTS. + types: + "! Information about custom smart document understanding fields that exist in this + "! collection. + begin of T_SDU_STATUS_CUSTOM_FIELDS, + "! The number of custom fields defined for this collection. + DEFINED type LONG, + "! The maximum number of custom fields that are allowed in this collection. + MAXIMUM_ALLOWED type LONG, + end of T_SDU_STATUS_CUSTOM_FIELDS. + types: + "! Object containing smart document understanding information for this collection. + begin of T_SDU_STATUS, + "! When `true`, smart document understanding conversion is enabled for this + "! collection. All collections created with a version date after `2019-04-30` have + "! smart document understanding enabled. If `false`, documents added to the + "! collection are converted using the **conversion** settings specified in the + "! configuration associated with the collection. + ENABLED type BOOLEAN, + "! The total number of pages annotated using smart document understanding in this + "! collection. + TOTAL_ANNOTATED_PAGES type LONG, + "! The current number of pages that can be used for training smart document + "! understanding. The `total_pages` number is calculated as the total number of + "! pages identified from the documents listed in the **total_documents** field. + TOTAL_PAGES type LONG, + "! The total number of documents in this collection that can be used to train smart + "! document understanding. For **lite** plan collections, the maximum is the first + "! 20 uploaded documents (not including HTML or JSON documents). For other plans, + "! the maximum is the first 40 uploaded documents (not including HTML or JSON + "! documents). When the maximum is reached, additional documents uploaded to the + "! collection are not considered for training smart document understanding. + TOTAL_DOCUMENTS type LONG, + "! Information about custom smart document understanding fields that exist in this + "! collection. + CUSTOM_FIELDS type T_SDU_STATUS_CUSTOM_FIELDS, + end of T_SDU_STATUS. + types: + "! Object containing information about the crawl status of this collection. + begin of T_COLLECTION_CRAWL_STATUS, + "! Object containing source crawl status information. + SOURCE_CRAWL type T_SOURCE_STATUS, + end of T_COLLECTION_CRAWL_STATUS. + types: + "! Summary of the disk usage statistics for this collection. + begin of T_COLLECTION_DISK_USAGE, + "! Number of bytes used by the collection. + USED_BYTES type INTEGER, + end of T_COLLECTION_DISK_USAGE. + types: + "! A collection for storing documents. + begin of T_COLLECTION, + "! The unique identifier of the collection. + COLLECTION_ID type STRING, + "! The name of the collection. + NAME type STRING, + "! The description of the collection. + DESCRIPTION type STRING, + "! The creation date of the collection in the format + "! yyyy-MM-dd'T'HH:mmcon:ss.SSS'Z'. + CREATED type DATETIME, + "! The timestamp of when the collection was last updated in the format + "! yyyy-MM-dd'T'HH:mm:ss.SSS'Z'. + UPDATED type DATETIME, + "! The status of the collection. + STATUS type STRING, + "! The unique identifier of the collection's configuration. + CONFIGURATION_ID type STRING, + "! The language of the documents stored in the collection. Permitted values include + "! `en` (English), `de` (German), and `es` (Spanish). + LANGUAGE type STRING, + "! Object containing collection document count information. + DOCUMENT_COUNTS type T_DOCUMENT_COUNTS, + "! Summary of the disk usage statistics for this collection. + DISK_USAGE type T_COLLECTION_DISK_USAGE, + "! Training status details. + TRAINING_STATUS type T_TRAINING_STATUS, + "! Object containing information about the crawl status of this collection. + CRAWL_STATUS type T_COLLECTION_CRAWL_STATUS, + "! Object containing smart document understanding information for this collection. + SMART_DOCUMENT_UNDERSTANDING type T_SDU_STATUS, + end of T_COLLECTION. + types: + "! Array of Microsoft Word styles to convert. + T_WORD_STYLES type STANDARD TABLE OF T_WORD_STYLE WITH NON-UNIQUE DEFAULT KEY. + types: + "! An object representing the configuration options to use for the `elements` + "! enrichment. + begin of T_ELEMENTS_ENRICHMENT_OPTIONS, + "! *For use with `elements` enrichments only.* The element extraction model to use. + "! * Models available are: `contract`. + MODEL type STRING, + end of T_ELEMENTS_ENRICHMENT_OPTIONS. + types: + "! Object containing information about a new environment. + begin of T_CREATE_ENVIRONMENT_REQUEST, + "! Name that identifies the environment. + NAME type STRING, + "! Description of the environment. + DESCRIPTION type STRING, + "! Size of the environment. In the Lite plan the default and only accepted value is + "! `LT`, in all other plans the default is `S`. + SIZE type STRING, + end of T_CREATE_ENVIRONMENT_REQUEST. + types: + "! Object containing specification for a new collection. + begin of T_CREATE_COLLECTION_REQUEST, + "! The name of the collection to be created. + NAME type STRING, + "! A description of the collection. + DESCRIPTION type STRING, + "! The ID of the configuration in which the collection is to be created. + CONFIGURATION_ID type STRING, + "! The language of the documents stored in the collection, in the form of an ISO + "! 639-1 language code. + LANGUAGE type STRING, + end of T_CREATE_COLLECTION_REQUEST. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! The content of the stopword list to ingest. + STOPWORD_FILE type FILE, + end of T_INLINE_OBJECT. + types: + "! Query result object. + begin of T_QUERY_RESULT, + "! The unique identifier of the document. + ID type STRING, + "! Metadata of the document. + METADATA type MAP, + "! The collection ID of the collection containing the document for this result. + COLLECTION_ID type STRING, + "! Metadata of a query result. + RESULT_METADATA type T_QUERY_RESULT_METADATA, + end of T_QUERY_RESULT. + types: + "! Top hit information for this query. + begin of T_TOP_HITS_RESULTS, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! Top results returned by the aggregation. + HITS type STANDARD TABLE OF T_QUERY_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_TOP_HITS_RESULTS. + types: + "! Response object returned when deleting a colleciton. + begin of T_DELETE_COLLECTION_RESPONSE, + "! The unique identifier of the collection that is being deleted. + COLLECTION_ID type STRING, + "! The status of the collection. The status of a successful deletion operation is + "! `deleted`. + STATUS type STRING, + end of T_DELETE_COLLECTION_RESPONSE. + types: + "! No documentation available. + begin of T_TERM, + "! The field where the aggregation is located in the document. + FIELD type STRING, + "! The number of terms identified. + COUNT type INTEGER, + end of T_TERM. + types: + "! An object containing an array of autocompletion suggestions. + begin of T_COMPLETIONS, + "! Array of autcomplete suggestion based on the provided prefix. + COMPLETIONS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_COMPLETIONS. + types: + "! An object contain retrieval type information. + begin of T_RETRIEVAL_DETAILS, + "! Indentifies the document retrieval strategy used for this query. + "! `relevancy_training` indicates that the results were returned using a relevancy + "! trained model. `continuous_relevancy_training` indicates that the results were + "! returned using the continuous relevancy training model created by result + "! feedback analysis. `untrained` means the results were returned using the + "! standard untrained model.
+ "!
+ "! **Note**: In the event of trained collections being queried, but the trained + "! model is not used to return results, the **document_retrieval_strategy** will + "! be listed as `untrained`. + DOCUMENT_RETRIEVAL_STRATEGY type STRING, + end of T_RETRIEVAL_DETAILS. + types: + "! Response object returned when deleting an environment. + begin of T_DELETE_ENVIRONMENT_RESPONSE, + "! The unique identifier for the environment. + ENVIRONMENT_ID type STRING, + "! Status of the environment. + STATUS type STRING, + end of T_DELETE_ENVIRONMENT_RESPONSE. + types: + "! 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`). + begin of T_LST_COLLECTION_FIELDS_RESP, + "! An array containing information about each field in the collections. + FIELDS type STANDARD TABLE OF T_FIELD WITH NON-UNIQUE DEFAULT KEY, + end of T_LST_COLLECTION_FIELDS_RESP. + types: + "! Object containing collection update information. + begin of T_UPDATE_COLLECTION_REQUEST, + "! The name of the collection. + NAME type STRING, + "! A description of the collection. + DESCRIPTION type STRING, + "! The ID of the configuration in which the collection is to be updated. + CONFIGURATION_ID type STRING, + end of T_UPDATE_COLLECTION_REQUEST. + types: + "! Object containing gateways array. + begin of T_GATEWAY_LIST, + "! Array of configured gateway connections. + GATEWAYS type STANDARD TABLE OF T_GATEWAY WITH NON-UNIQUE DEFAULT KEY, + end of T_GATEWAY_LIST. + types: + "! Aggregation result data for the requested metric. + begin of T_METRIC_TOKEN_AGGR_RESULT, + "! The content of the **natural_language_query** parameter used in the query that + "! this result represents. + KEY type STRING, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! The number of queries with associated events divided by the total number of + "! queries currently stored (queries and events are stored in the log for 30 + "! days). + EVENT_RATE type DOUBLE, + end of T_METRIC_TOKEN_AGGR_RESULT. + types: + "! An aggregation analyzing log information for queries and events. + begin of T_METRIC_TOKEN_AGGREGATION, + "! The event type associated with this metric result. This field, when present, + "! will always be `click`. + EVENT_TYPE type STRING, + "! Array of results for the metric token aggregation. + RESULTS type STANDARD TABLE OF T_METRIC_TOKEN_AGGR_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_METRIC_TOKEN_AGGREGATION. + types: + "! Object that describes a long query. + begin of T_COLL_QUERY_LARGE, + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + FILTER type STRING, + "! 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. + QUERY type STRING, + "! A natural language query that returns relevant documents by utilizing training + "! data and natural language understanding. + NATURAL_LANGUAGE_QUERY type STRING, + "! A passages query that returns the most relevant passages from the results. + PASSAGES type BOOLEAN, + "! An aggregation search that returns an exact answer by combining query search + "! with filters. Useful for applications to build lists, tables, and time series. + "! For a full list of possible aggregations, see the Query reference. + AGGREGATION type STRING, + "! Number of results to return. + COUNT type INTEGER, + "! A comma-separated list of the portion of the document hierarchy to return. + RETURN type STRING, + "! 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. + OFFSET type INTEGER, + "! A comma-separated list of fields in the document to sort on. You can optionally + "! specify a sort direction by prefixing the field with `-` for descending or `+` + "! for ascending. Ascending is the default sort direction if no prefix is + "! specified. This parameter cannot be used in the same query as the **bias** + "! parameter. + SORT type STRING, + "! When true, a highlight field is returned for each result which contains the + "! fields which match the query with `<em></em>` tags around the + "! matching query terms. + HIGHLIGHT type BOOLEAN, + "! A comma-separated list of fields that passages are drawn from. If this parameter + "! not specified, then all top-level fields are included. + PASSAGES_FIELDS type STRING, + "! 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`. + PASSAGES_COUNT type INTEGER, + "! The approximate number of characters that any one passage will have. + PASSAGES_CHARACTERS type INTEGER, + "! When `true`, and used with a Watson Discovery News collection, duplicate results + "! (based on the contents of the **title** field) are removed. Duplicate + "! comparison is limited to the current query only; **offset** is not considered. + "! This parameter is currently Beta functionality. + DEDUPLICATE type BOOLEAN, + "! 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. + DEDUPLICATE_FIELD type STRING, + "! When `true`, results are returned based on their similarity to the document IDs + "! specified in the **similar.document_ids** parameter. + SIMILAR type BOOLEAN, + "! A comma-separated list of document IDs to find similar documents.
+ "!
+ "! **Tip:** Include the **natural_language_query** parameter to expand the scope of + "! the document similarity search with the natural language query. Other query + "! parameters, such as **filter** and **query**, are subsequently applied and + "! reduce the scope. + SIMILAR_DOCUMENT_IDS type STRING, + "! A comma-separated list of field names that are used as a basis for comparison to + "! identify similar documents. If not specified, the entire document is used for + "! comparison. + SIMILAR_FIELDS type STRING, + "! Field which the returned results will be biased against. The specified field + "! must be either a **date** or **number** format. When a **date** type field is + "! specified returned results are biased towards field values closer to the + "! current date. When a **number** type field is specified, returned results are + "! biased towards higher field values. This parameter cannot be used in the same + "! query as the **sort** parameter. + BIAS type STRING, + "! When `true` and the **natural_language_query** parameter is used, the + "! **natural_languge_query** parameter is spell checked. The most likely + "! correction is retunred in the **suggested_query** field of the response (if one + "! exists).
+ "!
+ "! **Important:** this parameter is only valid when using the Cloud Pak version of + "! Discovery. + SPELLING_SUGGESTIONS type BOOLEAN, + end of T_COLL_QUERY_LARGE. + types: + "! Object containing environment update information. + begin of T_UPDATE_ENVIRONMENT_REQUEST, + "! Name that identifies the environment. + NAME type STRING, + "! Description of the environment. + DESCRIPTION type STRING, + "! Size that the environment should be increased to. Environment size cannot be + "! modified when using a Lite plan. Environment size can only increased and not + "! decreased. + SIZE type STRING, + end of T_UPDATE_ENVIRONMENT_REQUEST. + types: + "! Information returned when a configuration is deleted. + begin of T_DEL_CONFIGURATION_RESPONSE, + "! The unique identifier for the configuration. + CONFIGURATION_ID type STRING, + "! Status of the configuration. A deleted configuration has the status deleted. + STATUS type STRING, + "! An array of notice messages, if any. + NOTICES type STANDARD TABLE OF T_NOTICE WITH NON-UNIQUE DEFAULT KEY, + end of T_DEL_CONFIGURATION_RESPONSE. + types: + "! A response containing the documents and aggregations for the query. + begin of T_QUERY_RESPONSE, + "! The number of matching results for the query. + MATCHING_RESULTS type INTEGER, + "! Array of document results for the query. + RESULTS type STANDARD TABLE OF T_QUERY_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! Array of aggregation results for the query. + AGGREGATIONS type STANDARD TABLE OF T_QUERY_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + "! Array of passage results for the query. + PASSAGES type STANDARD TABLE OF T_QUERY_PASSAGES WITH NON-UNIQUE DEFAULT KEY, + "! The number of duplicate results removed. + DUPLICATES_REMOVED type INTEGER, + "! The session token for this query. The session token can be used to add events + "! associated with this query to the query and event log.
+ "!
+ "! **Important:** Session tokens are case sensitive. + SESSION_TOKEN type STRING, + "! An object contain retrieval type information. + RETRIEVAL_DETAILS type T_RETRIEVAL_DETAILS, + "! The suggestions for a misspelled natural language query. + SUGGESTED_QUERY type STRING, + end of T_QUERY_RESPONSE. + types: + "! No documentation available. + begin of T_TIMESLICE, + "! The field where the aggregation is located in the document. + FIELD type STRING, + "! Interval of the aggregation. Valid date interval values are second/seconds + "! minute/minutes, hour/hours, day/days, week/weeks, month/months, and year/years. + "! + INTERVAL type STRING, + "! Used to indicate that anomaly detection should be performed. Anomaly detection + "! is used to locate unusual datapoints within a time series. + ANOMALY type BOOLEAN, + end of T_TIMESLICE. + types: + "! Training query to add. + begin of T_NEW_TRAINING_QUERY, + "! The natural text query for the new training query. + NATURAL_LANGUAGE_QUERY type STRING, + "! The filter used on the collection before the **natural_language_query** is + "! applied. + FILTER type STRING, + "! Array of training examples. + EXAMPLES type STANDARD TABLE OF T_TRAINING_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_NEW_TRAINING_QUERY. + types: + "! Status information about a submitted document. + begin of T_DOCUMENT_STATUS, + "! The unique identifier of the document. + DOCUMENT_ID type STRING, + "! The unique identifier for the configuration. + CONFIGURATION_ID type STRING, + "! Status of the document in the ingestion process. + STATUS type STRING, + "! Description of the document status. + STATUS_DESCRIPTION type STRING, + "! Name of the original source file (if available). + FILENAME type STRING, + "! The type of the original source file. + FILE_TYPE type STRING, + "! The SHA-1 hash of the original source file (formatted as a hexadecimal string). + SHA1 type STRING, + "! Array of notices produced by the document-ingestion process. + NOTICES type STANDARD TABLE OF T_NOTICE WITH NON-UNIQUE DEFAULT KEY, + end of T_DOCUMENT_STATUS. + types: + "! Object that describes a long query. + begin of T_FED_QUERY_LARGE, + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + FILTER type STRING, + "! 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. + QUERY type STRING, + "! A natural language query that returns relevant documents by utilizing training + "! data and natural language understanding. + NATURAL_LANGUAGE_QUERY type STRING, + "! A passages query that returns the most relevant passages from the results. + PASSAGES type BOOLEAN, + "! An aggregation search that returns an exact answer by combining query search + "! with filters. Useful for applications to build lists, tables, and time series. + "! For a full list of possible aggregations, see the Query reference. + AGGREGATION type STRING, + "! Number of results to return. + COUNT type INTEGER, + "! A comma-separated list of the portion of the document hierarchy to return. + RETURN type STRING, + "! 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. + OFFSET type INTEGER, + "! A comma-separated list of fields in the document to sort on. You can optionally + "! specify a sort direction by prefixing the field with `-` for descending or `+` + "! for ascending. Ascending is the default sort direction if no prefix is + "! specified. This parameter cannot be used in the same query as the **bias** + "! parameter. + SORT type STRING, + "! When true, a highlight field is returned for each result which contains the + "! fields which match the query with `<em></em>` tags around the + "! matching query terms. + HIGHLIGHT type BOOLEAN, + "! A comma-separated list of fields that passages are drawn from. If this parameter + "! not specified, then all top-level fields are included. + PASSAGES_FIELDS type STRING, + "! 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`. + PASSAGES_COUNT type INTEGER, + "! The approximate number of characters that any one passage will have. + PASSAGES_CHARACTERS type INTEGER, + "! When `true`, and used with a Watson Discovery News collection, duplicate results + "! (based on the contents of the **title** field) are removed. Duplicate + "! comparison is limited to the current query only; **offset** is not considered. + "! This parameter is currently Beta functionality. + DEDUPLICATE type BOOLEAN, + "! 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. + DEDUPLICATE_FIELD type STRING, + "! When `true`, results are returned based on their similarity to the document IDs + "! specified in the **similar.document_ids** parameter. + SIMILAR type BOOLEAN, + "! A comma-separated list of document IDs to find similar documents.
+ "!
+ "! **Tip:** Include the **natural_language_query** parameter to expand the scope of + "! the document similarity search with the natural language query. Other query + "! parameters, such as **filter** and **query**, are subsequently applied and + "! reduce the scope. + SIMILAR_DOCUMENT_IDS type STRING, + "! A comma-separated list of field names that are used as a basis for comparison to + "! identify similar documents. If not specified, the entire document is used for + "! comparison. + SIMILAR_FIELDS type STRING, + "! Field which the returned results will be biased against. The specified field + "! must be either a **date** or **number** format. When a **date** type field is + "! specified returned results are biased towards field values closer to the + "! current date. When a **number** type field is specified, returned results are + "! biased towards higher field values. This parameter cannot be used in the same + "! query as the **sort** parameter. + BIAS type STRING, + "! A comma-separated list of collection IDs to be queried against. + COLLECTION_IDS type STRING, + end of T_FED_QUERY_LARGE. + types: + "! An error response object. + begin of T_ERROR_RESPONSE, + "! The HTTP error status code. + CODE type INTEGER, + "! A message describing the error. + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! 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. + begin of T_EXPANSION, + "! A list of terms that will be expanded for this expansion. If specified, only the + "! items in this list are expanded. + INPUT_TERMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! A list of terms that this expansion will be expanded to. If specified without + "! **input_terms**, it also functions as the input term list. + EXPANDED_TERMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_EXPANSION. + types: + "! The query expansion definitions for the specified collection. + begin of T_EXPANSIONS, + "! An array of query expansion definitions.
+ "!
+ "! Each object in the **expansions** array represents a term or set of terms that + "! will be expanded into other terms. Each expansion object can be configured as + "! bidirectional or unidirectional. Bidirectional means that all terms are + "! expanded to all other terms in the object. Unidirectional means that a set list + "! of terms can be expanded into a second list of terms.
+ "!
+ "! To create a bi-directional expansion specify an **expanded_terms** array. When + "! found in a query, all items in the **expanded_terms** array are then expanded + "! to the other items in the same array.
+ "!
+ "! To create a uni-directional expansion, specify both an array of **input_terms** + "! and an array of **expanded_terms**. When items in the **input_terms** array are + "! present in a query, they are expanded using the items listed in the + "! **expanded_terms** array. + EXPANSIONS type STANDARD TABLE OF T_EXPANSION WITH NON-UNIQUE DEFAULT KEY, + end of T_EXPANSIONS. + types: + "! An object defining the event being created. + begin of T_CREATE_EVENT_RESPONSE, + "! The event type that was created. + TYPE type STRING, + "! Query event data object. + DATA type T_EVENT_DATA, + end of T_CREATE_EVENT_RESPONSE. + types: + "! An array of document enrichment settings for the configuration. + T_ENRICHMENTS type STANDARD TABLE OF T_ENRICHMENT WITH NON-UNIQUE DEFAULT KEY. + types: + "! The response generated from a call to a **metrics** method that evaluates + "! tokens. + begin of T_METRIC_TOKEN_RESPONSE, + "! Array of metric token aggregations. + AGGREGATIONS type STANDARD TABLE OF T_METRIC_TOKEN_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + end of T_METRIC_TOKEN_RESPONSE. + types: + "! Object containing an array of training examples. + begin of T_TRAINING_EXAMPLE_LIST, + "! Array of training examples. + EXAMPLES type STANDARD TABLE OF T_TRAINING_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_EXAMPLE_LIST. + types: + "! Information returned when a document is deleted. + begin of T_DELETE_DOCUMENT_RESPONSE, + "! The unique identifier of the document. + DOCUMENT_ID type STRING, + "! Status of the document. A deleted document has the status deleted. + STATUS type STRING, + end of T_DELETE_DOCUMENT_RESPONSE. + types: + "! No documentation available. + begin of T_TOP_HITS, + "! Number of top hits returned by the aggregation. + SIZE type INTEGER, + "! No documentation available. + HITS type T_TOP_HITS_RESULTS, + end of T_TOP_HITS. + types: + "! Individual result object for a **logs** query. Each object represents either a + "! query to a Discovery collection or an event that is associated with a query. + begin of T_LOG_QUERY_RESPONSE_RESULT, + "! The environment ID that is associated with this log entry. + ENVIRONMENT_ID type STRING, + "! The **customer_id** label that was specified in the header of the query or event + "! API call that corresponds to this log entry. + CUSTOMER_ID type STRING, + "! The type of log entry returned.
+ "!
+ "! **query** indicates that the log represents the results of a call to the single + "! collection **query** method.
+ "!
+ "! **event** indicates that the log represents a call to the **events** API. + DOCUMENT_TYPE type STRING, + "! The value of the **natural_language_query** query parameter that was used to + "! create these results. Only returned with logs of type **query**.
+ "!
+ "! **Note:** Other query parameters (such as **filter** or **deduplicate**) might + "! have been used with this query, but are not recorded. + NATURAL_LANGUAGE_QUERY type STRING, + "! Object containing result information that was returned by the query used to + "! create this log entry. Only returned with logs of type `query`. + DOCUMENT_RESULTS type T_LOG_QUERY_RESP_RESULT_DOCS, + "! Date that the log result was created. Returned in `YYYY-MM-DDThh:mm:ssZ` format. + "! + CREATED_TIMESTAMP type DATETIME, + "! Date specified by the user when recording an event. Returned in + "! `YYYY-MM-DDThh:mm:ssZ` format. Only returned with logs of type **event**. + CLIENT_TIMESTAMP type DATETIME, + "! Identifier that corresponds to the **natural_language_query** string used in the + "! original or associated query. All **event** and **query** log entries that have + "! the same original **natural_language_query** string also have them same + "! **query_id**. This field can be used to recall all **event** and **query** log + "! results that have the same original query (**event** logs do not contain the + "! original **natural_language_query** field). + QUERY_ID type STRING, + "! Unique identifier (within a 24-hour period) that identifies a single `query` log + "! and any `event` logs that were created for it.
+ "!
+ "! **Note:** If the exact same query is run at the exact same time on different + "! days, the **session_token** for those queries might be identical. However, the + "! **created_timestamp** differs.
+ "!
+ "! **Note:** Session tokens are case sensitive. To avoid matching on session tokens + "! that are identical except for case, use the exact match operator (`::`) when + "! you query for a specific session token. + SESSION_TOKEN type STRING, + "! The collection ID of the document associated with this event. Only returned with + "! logs of type `event`. + COLLECTION_ID type STRING, + "! The original display rank of the document associated with this event. Only + "! returned with logs of type `event`. + DISPLAY_RANK type INTEGER, + "! The document ID of the document associated with this event. Only returned with + "! logs of type `event`. + DOCUMENT_ID type STRING, + "! The type of event that this object respresents. Possible values are
+ "!
+ "! - `query` the log of a query to a collection
+ "!
+ "! - `click` the result of a call to the **events** endpoint. + EVENT_TYPE type STRING, + "! The type of result that this **event** is associated with. Only returned with + "! logs of type `event`. + RESULT_TYPE type STRING, + end of T_LOG_QUERY_RESPONSE_RESULT. + types: + "! Object containing results that match the requested **logs** query. + begin of T_LOG_QUERY_RESPONSE, + "! Number of matching results. + MATCHING_RESULTS type INTEGER, + "! Array of log query response results. + RESULTS type STANDARD TABLE OF T_LOG_QUERY_RESPONSE_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_LOG_QUERY_RESPONSE. + types: + "! 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. + T_NORMALIZATIONS type STANDARD TABLE OF T_NORMALIZATION_OPERATION WITH NON-UNIQUE DEFAULT KEY. + types: + "! Training example to add. + begin of T_TRAINING_EXAMPLE_PATCH, + "! The example to add. + CROSS_REFERENCE type STRING, + "! The relevance value for this example. + RELEVANCE type INTEGER, + end of T_TRAINING_EXAMPLE_PATCH. + types: + "! Response object containing an array of collection details. + begin of T_LIST_COLLECTIONS_RESPONSE, + "! An array containing information about each collection in the environment. + COLLECTIONS type STANDARD TABLE OF T_COLLECTION WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_COLLECTIONS_RESPONSE. + types: + "! No documentation available. + begin of T_CALCULATION, + "! The field where the aggregation is located in the document. + FIELD type STRING, + "! Value of the aggregation. + VALUE type DOUBLE, + end of T_CALCULATION. + types: + "! Training information for a specific collection. + begin of T_TRAINING_DATA_SET, + "! The environment id associated with this training data set. + ENVIRONMENT_ID type STRING, + "! The collection id associated with this training data set. + COLLECTION_ID type STRING, + "! Array of training queries. + QUERIES type STANDARD TABLE OF T_TRAINING_QUERY WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_DATA_SET. + types: + "! Array of font matching configurations. + T_FONT_SETTINGS type STANDARD TABLE OF T_FONT_SETTING WITH NON-UNIQUE DEFAULT KEY. + types: + "! Object containing notice query results. + begin of T_QUERY_NOTICES_RESPONSE, + "! The number of matching results. + MATCHING_RESULTS type INTEGER, + "! Array of document results that match the query. + RESULTS type STANDARD TABLE OF T_QUERY_NOTICES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! Array of aggregation results that match the query. + AGGREGATIONS type STANDARD TABLE OF T_QUERY_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + "! Array of passage results that match the query. + PASSAGES type STANDARD TABLE OF T_QUERY_PASSAGES WITH NON-UNIQUE DEFAULT KEY, + "! The number of duplicates removed from this notices query. + DUPLICATES_REMOVED type INTEGER, + end of T_QUERY_NOTICES_RESPONSE. + types: + "! No documentation available. + begin of T_HISTOGRAM, + "! The field where the aggregation is located in the document. + FIELD type STRING, + "! Interval of the aggregation. (For 'histogram' type). + INTERVAL type INTEGER, + end of T_HISTOGRAM. + +constants: + begin of C_REQUIRED_FIELDS, + T_QUERY_AGGREGATION type string value '|', + T_AGGREGATION_RESULT type string value '|', + T_TRAINING_STATUS type string value '|', + T_TOKEN_DICT_STATUS_RESPONSE type string value '|', + T_NLU_ENRICHMENT_RELATIONS type string value '|', + T_NLU_ENRICHMENT_SENTIMENT type string value '|', + T_NL_ENRICHMENT_SEMANTIC_ROLES type string value '|', + T_NLU_ENRICHMENT_ENTITIES type string value '|', + T_NLU_ENRICHMENT_EMOTION type string value '|', + T_NLU_ENRICHMENT_CONCEPTS type string value '|', + T_NLU_ENRICHMENT_KEYWORDS type string value '|', + T_NLU_ENRICHMENT_FEATURES type string value '|', + T_NLU_ENRICHMENT_OPTIONS type string value '|', + T_TOKEN_DICT_RULE type string value '|TEXT|TOKENS|PART_OF_SPEECH|', + T_TOKEN_DICT type string value '|', + T_FILTER type string value '|', + T_SOURCE_OPTIONS_WEB_CRAWL type string value '|URL|', + T_CREDENTIAL_DETAILS type string value '|', + T_CREDENTIALS type string value '|', + T_CREDENTIALS_LIST type string value '|', + T_COLLECTION_USAGE type string value '|', + T_DISK_USAGE type string value '|', + T_ENVIRONMENT_DOCUMENTS type string value '|', + T_INDEX_CAPACITY type string value '|', + T_SEARCH_STATUS type string value '|', + T_ENVIRONMENT type string value '|', + T_LIST_ENVIRONMENTS_RESPONSE type string value '|', + T_GATEWAY_DELETE type string value '|', + T_TRAINING_EXAMPLE type string value '|', + T_TRAINING_QUERY type string value '|', + T_QUERY_PASSAGES type string value '|', + T_NORMALIZATION_OPERATION type string value '|', + T_FONT_SETTING type string value '|', + T_WORD_STYLE type string value '|', + T_WORD_HEADING_DETECTION type string value '|', + T_PDF_HEADING_DETECTION type string value '|', + T_PDF_SETTINGS type string value '|', + T_SOURCE_OPTIONS_FOLDER type string value '|OWNER_USER_ID|FOLDER_ID|', + T_SOURCE_OPTIONS_BUCKETS type string value '|NAME|', + T_SOURCE_SCHEDULE type string value '|', + T_SOURCE_OPTIONS_OBJECT type string value '|NAME|', + T_SOURCE_OPTIONS_SITE_COLL type string value '|SITE_COLLECTION_PATH1|', + T_SOURCE_OPTIONS type string value '|', + T_SOURCE type string value '|', + T_XPATH_PATTERNS type string value '|', + T_ENRICHMENT_OPTIONS type string value '|', + T_ENRICHMENT type string value '|DESTINATION_FIELD|SOURCE_FIELD|ENRICHMENT|', + T_SEGMENT_SETTINGS type string value '|', + T_WORD_SETTINGS type string value '|', + T_HTML_SETTINGS type string value '|', + T_CONVERSIONS type string value '|', + T_CONFIGURATION type string value '|NAME|', + T_LIST_CONFIGURATIONS_RESPONSE type string value '|', + T_SOURCE_STATUS type string value '|', + T_DELETE_CREDENTIALS type string value '|', + T_NOTICE type string value '|', + T_DOCUMENT_ACCEPTED type string value '|', + T_GATEWAY type string value '|', + T_METRIC_AGGREGATION_RESULT type string value '|', + T_METRIC_AGGREGATION type string value '|', + T_METRIC_RESPONSE type string value '|', + T_QUERY_RESULT_METADATA type string value '|SCORE|', + T_QUERY_NOTICES_RESULT type string value '|', + T_LOG_QRY_RESP_RSLT_DOCS_RSLT type string value '|', + T_LOG_QUERY_RESP_RESULT_DOCS type string value '|', + T_FIELD type string value '|', + T_EVENT_DATA type string value '|ENVIRONMENT_ID|SESSION_TOKEN|COLLECTION_ID|DOCUMENT_ID|', + T_CREATE_EVENT_OBJECT type string value '|TYPE|DATA|', + T_NESTED type string value '|', + T_QUERY_LARGE type string value '|', + T_GATEWAY_NAME type string value '|', + T_DOCUMENT_COUNTS type string value '|', + T_SDU_STATUS_CUSTOM_FIELDS type string value '|', + T_SDU_STATUS type string value '|', + T_COLLECTION_CRAWL_STATUS type string value '|', + T_COLLECTION_DISK_USAGE type string value '|', + T_COLLECTION type string value '|', + T_ELEMENTS_ENRICHMENT_OPTIONS type string value '|', + T_CREATE_ENVIRONMENT_REQUEST type string value '|NAME|', + T_CREATE_COLLECTION_REQUEST type string value '|NAME|', + T_INLINE_OBJECT type string value '|STOPWORD_FILE|', + T_QUERY_RESULT type string value '|', + T_TOP_HITS_RESULTS type string value '|', + T_DELETE_COLLECTION_RESPONSE type string value '|COLLECTION_ID|STATUS|', + T_TERM type string value '|', + T_COMPLETIONS type string value '|', + T_RETRIEVAL_DETAILS type string value '|', + T_DELETE_ENVIRONMENT_RESPONSE type string value '|ENVIRONMENT_ID|STATUS|', + T_LST_COLLECTION_FIELDS_RESP type string value '|', + T_UPDATE_COLLECTION_REQUEST type string value '|NAME|', + T_GATEWAY_LIST type string value '|', + T_METRIC_TOKEN_AGGR_RESULT type string value '|', + T_METRIC_TOKEN_AGGREGATION type string value '|', + T_COLL_QUERY_LARGE type string value '|', + T_UPDATE_ENVIRONMENT_REQUEST type string value '|', + T_DEL_CONFIGURATION_RESPONSE type string value '|CONFIGURATION_ID|STATUS|', + T_QUERY_RESPONSE type string value '|', + T_TIMESLICE type string value '|', + T_NEW_TRAINING_QUERY type string value '|', + T_DOCUMENT_STATUS type string value '|DOCUMENT_ID|STATUS|STATUS_DESCRIPTION|NOTICES|', + T_FED_QUERY_LARGE type string value '|COLLECTION_IDS|', + T_ERROR_RESPONSE type string value '|CODE|ERROR|', + T_EXPANSION type string value '|EXPANDED_TERMS|', + T_EXPANSIONS type string value '|EXPANSIONS|', + T_CREATE_EVENT_RESPONSE type string value '|', + T_METRIC_TOKEN_RESPONSE type string value '|', + T_TRAINING_EXAMPLE_LIST type string value '|', + T_DELETE_DOCUMENT_RESPONSE type string value '|', + T_TOP_HITS type string value '|', + T_LOG_QUERY_RESPONSE_RESULT type string value '|', + T_LOG_QUERY_RESPONSE type string value '|', + T_TRAINING_EXAMPLE_PATCH type string value '|', + T_LIST_COLLECTIONS_RESPONSE type string value '|', + T_CALCULATION type string value '|', + T_TRAINING_DATA_SET type string value '|', + T_QUERY_NOTICES_RESPONSE type string value '|', + T_HISTOGRAM type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + ENVIRONMENT_ID type string value 'environment_id', + NAME type string value 'name', + DESCRIPTION type string value 'description', + CREATED type string value 'created', + UPDATED type string value 'updated', + STATUS type string value 'status', + READ_ONLY type string value 'read_only', + SIZE type string value 'size', + REQUESTED_SIZE type string value 'requested_size', + INDEX_CAPACITY type string value 'index_capacity', + SEARCH_STATUS type string value 'search_status', + DOCUMENTS type string value 'documents', + DISK_USAGE type string value 'disk_usage', + COLLECTIONS type string value 'collections', + USED_BYTES type string value 'used_bytes', + MAXIMUM_ALLOWED_BYTES type string value 'maximum_allowed_bytes', + AVAILABLE type string value 'available', + MAXIMUM_ALLOWED type string value 'maximum_allowed', + INDEXED type string value 'indexed', + ENVIRONMENTS type string value 'environments', + CONFIGURATION_ID type string value 'configuration_id', + LANGUAGE type string value 'language', + COLLECTION_ID type string value 'collection_id', + DOCUMENT_COUNTS type string value 'document_counts', + TRAINING_STATUS type string value 'training_status', + CRAWL_STATUS type string value 'crawl_status', + SMART_DOCUMENT_UNDERSTANDING type string value 'smart_document_understanding', + PROCESSING type string value 'processing', + FAILED type string value 'failed', + PENDING type string value 'pending', + CONVERSIONS type string value 'conversions', + ENRICHMENTS type string value 'enrichments', + ENRICHMENT type string value 'enrichment', + NORMALIZATIONS type string value 'normalizations', + NORMALIZATION type string value 'normalization', + SOURCE type string value 'source', + PDF type string value 'pdf', + WORD type string value 'word', + HTML type string value 'html', + SEGMENT type string value 'segment', + JSON_NORMALIZATIONS type string value 'json_normalizations', + IMAGE_TEXT_RECOGNITION type string value 'image_text_recognition', + HEADING type string value 'heading', + FONTS type string value 'fonts', + FONTSETTING type string value 'fontSetting', + STYLES type string value 'styles', + WORDSTYLE type string value 'wordStyle', + LEVEL type string value 'level', + NAMES type string value 'names', + EXCLUDE_TAGS_COMPLETELY type string value 'exclude_tags_completely', + EXCLUDETAGSCOMPLETELY type string value 'excludeTagsCompletely', + EXCLUDE_TAGS_KEEP_CONTENT type string value 'exclude_tags_keep_content', + EXCLUDETAGSKEEPCONTENT type string value 'excludeTagsKeepContent', + KEEP_CONTENT type string value 'keep_content', + EXCLUDE_CONTENT type string value 'exclude_content', + KEEP_TAG_ATTRIBUTES type string value 'keep_tag_attributes', + KEEPTAGATTRIBUTES type string value 'keepTagAttributes', + EXCLUDE_TAG_ATTRIBUTES type string value 'exclude_tag_attributes', + EXCLUDETAGATTRIBUTES type string value 'excludeTagAttributes', + ENABLED type string value 'enabled', + SELECTOR_TAGS type string value 'selector_tags', + SELECTORTAGS type string value 'selectorTags', + ANNOTATED_FIELDS type string value 'annotated_fields', + ANNOTATEDFIELDS type string value 'annotatedFields', + XPATHS type string value 'xpaths', + MIN_SIZE type string value 'min_size', + MAX_SIZE type string value 'max_size', + BOLD type string value 'bold', + ITALIC type string value 'italic', + DESTINATION_FIELD type string value 'destination_field', + SOURCE_FIELD type string value 'source_field', + OVERWRITE type string value 'overwrite', + IGNORE_DOWNSTREAM_ERRORS type string value 'ignore_downstream_errors', + OPTIONS type string value 'options', + FEATURES type string value 'features', + MODEL type string value 'model', + OPERATION type string value 'operation', + CONFIGURATIONS type string value 'configurations', + NOTICES type string value 'notices', + DOCUMENT_ID type string value 'document_id', + STATUS_DESCRIPTION type string value 'status_description', + FILENAME type string value 'filename', + FILE_TYPE type string value 'file_type', + SHA1 type string value 'sha1', + FIELDS type string value 'fields', + FIELD type string value 'field', + TYPE type string value 'type', + MATCHING_RESULTS type string value 'matching_results', + RESULTS type string value 'results', + AGGREGATIONS type string value 'aggregations', + PASSAGES type string value 'passages', + DUPLICATES_REMOVED type string value 'duplicates_removed', + SESSION_TOKEN type string value 'session_token', + RETRIEVAL_DETAILS type string value 'retrieval_details', + SUGGESTED_QUERY type string value 'suggested_query', + ID type string value 'id', + METADATA type string value 'metadata', + INNER type string value 'inner', + RESULT_METADATA type string value 'result_metadata', + SCORE type string value 'score', + CONFIDENCE type string value 'confidence', + CODE type string value 'code', + KEY type string value 'key', + INTERVAL type string value 'interval', + VALUE type string value 'value', + COUNT type string value 'count', + MATCH type string value 'match', + PATH type string value 'path', + ANOMALY type string value 'anomaly', + HITS type string value 'hits', + TOTAL_EXAMPLES type string value 'total_examples', + MINIMUM_QUERIES_ADDED type string value 'minimum_queries_added', + MINIMUM_EXAMPLES_ADDED type string value 'minimum_examples_added', + SUFFICIENT_LABEL_DIVERSITY type string value 'sufficient_label_diversity', + SUCCESSFULLY_TRAINED type string value 'successfully_trained', + DATA_UPDATED type string value 'data_updated', + QUERIES type string value 'queries', + QUERY_ID type string value 'query_id', + NATURAL_LANGUAGE_QUERY type string value 'natural_language_query', + FILTER type string value 'filter', + EXAMPLES type string value 'examples', + CROSS_REFERENCE type string value 'cross_reference', + RELEVANCE type string value 'relevance', + NOTICE_ID type string value 'notice_id', + SEVERITY type string value 'severity', + STEP type string value 'step', + ERROR type string value 'error', + PASSAGE_SCORE type string value 'passage_score', + PASSAGE_TEXT type string value 'passage_text', + START_OFFSET type string value 'start_offset', + END_OFFSET type string value 'end_offset', + KEYWORDS type string value 'keywords', + ENTITIES type string value 'entities', + SENTIMENT type string value 'sentiment', + EMOTION type string value 'emotion', + CATEGORIES type string value 'categories', + SEMANTIC_ROLES type string value 'semantic_roles', + RELATIONS type string value 'relations', + CONCEPTS type string value 'concepts', + LIMIT type string value 'limit', + MENTIONS type string value 'mentions', + MENTION_TYPES type string value 'mention_types', + SENTENCE_LOCATIONS type string value 'sentence_locations', + DOCUMENT type string value 'document', + TARGETS type string value 'targets', + TARGET type string value 'target', + EXPANSIONS type string value 'expansions', + INPUT_TERMS type string value 'input_terms', + INPUTTERMS type string value 'inputTerms', + EXPANDED_TERMS type string value 'expanded_terms', + EXPANDEDTERMS type string value 'expandedTerms', + DATA type string value 'data', + CLIENT_TIMESTAMP type string value 'client_timestamp', + DISPLAY_RANK type string value 'display_rank', + EVENT_TYPE type string value 'event_type', + KEY_AS_STRING type string value 'key_as_string', + EVENT_RATE type string value 'event_rate', + CUSTOMER_ID type string value 'customer_id', + DOCUMENT_TYPE type string value 'document_type', + DOCUMENT_RESULTS type string value 'document_results', + CREATED_TIMESTAMP type string value 'created_timestamp', + RESULT_TYPE type string value 'result_type', + POSITION type string value 'position', + CREDENTIALS type string value 'credentials', + CREDENTIAL_ID type string value 'credential_id', + SOURCE_TYPE type string value 'source_type', + CREDENTIAL_DETAILS type string value 'credential_details', + CREDENTIAL_TYPE type string value 'credential_type', + CLIENT_ID type string value 'client_id', + ENTERPRISE_ID type string value 'enterprise_id', + URL type string value 'url', + USERNAME type string value 'username', + ORGANIZATION_URL type string value 'organization_url', + SITE_COLLECTION_PATH type string value 'site_collection.path', + CLIENT_SECRET type string value 'client_secret', + PUBLIC_KEY_ID type string value 'public_key_id', + PRIVATE_KEY type string value 'private_key', + PASSPHRASE type string value 'passphrase', + PASSWORD type string value 'password', + GATEWAY_ID type string value 'gateway_id', + SOURCE_VERSION type string value 'source_version', + WEB_APPLICATION_URL type string value 'web_application_url', + DOMAIN type string value 'domain', + ENDPOINT type string value 'endpoint', + ACCESS_KEY_ID type string value 'access_key_id', + SECRET_ACCESS_KEY type string value 'secret_access_key', + NEXT_CRAWL type string value 'next_crawl', + SCHEDULE type string value 'schedule', + TIME_ZONE type string value 'time_zone', + FREQUENCY type string value 'frequency', + FOLDERS type string value 'folders', + OBJECTS type string value 'objects', + SITE_COLLECTIONS type string value 'site_collections', + SITECOLLECTIONS type string value 'siteCollections', + URLS type string value 'urls', + BUCKETS type string value 'buckets', + CRAWL_ALL_BUCKETS type string value 'crawl_all_buckets', + OWNER_USER_ID type string value 'owner_user_id', + FOLDER_ID type string value 'folder_id', + SITE_COLLECTION_PATH1 type string value 'site_collection_path', + SCOPE type string value 'scope', + LAST_TRAINED type string value 'last_trained', + QUERY type string value 'query', + AGGREGATION type string value 'aggregation', + RETURN type string value 'return', + OFFSET type string value 'offset', + SORT type string value 'sort', + HIGHLIGHT type string value 'highlight', + PASSAGES_FIELDS type string value 'passages.fields', + PASSAGES_COUNT type string value 'passages.count', + PASSAGES_CHARACTERS type string value 'passages.characters', + DEDUPLICATE type string value 'deduplicate', + DEDUPLICATE_FIELD type string value 'deduplicate.field', + SIMILAR type string value 'similar', + SIMILAR_DOCUMENT_IDS type string value 'similar.document_ids', + SIMILAR_FIELDS type string value 'similar.fields', + BIAS type string value 'bias', + TOKENIZATION_RULES type string value 'tokenization_rules', + TOKENIZATIONRULES type string value 'tokenizationRules', + TEXT type string value 'text', + TOKENS type string value 'tokens', + READINGS type string value 'readings', + PART_OF_SPEECH type string value 'part_of_speech', + DOCUMENT_RETRIEVAL_STRATEGY type string value 'document_retrieval_strategy', + LIMIT_TO_STARTING_HOSTS type string value 'limit_to_starting_hosts', + CRAWL_SPEED type string value 'crawl_speed', + ALLOW_UNTRUSTED_CERTIFICATE type string value 'allow_untrusted_certificate', + MAXIMUM_HOPS type string value 'maximum_hops', + REQUEST_TIMEOUT type string value 'request_timeout', + OVERRIDE_ROBOTS_TXT type string value 'override_robots_txt', + BLACKLIST type string value 'blacklist', + GATEWAYS type string value 'gateways', + TOKEN type string value 'token', + TOKEN_ID type string value 'token_id', + TOTAL_ANNOTATED_PAGES type string value 'total_annotated_pages', + TOTAL_PAGES type string value 'total_pages', + TOTAL_DOCUMENTS type string value 'total_documents', + CUSTOM_FIELDS type string value 'custom_fields', + COMPLETIONS type string value 'completions', + COLLECTION_IDS type string value 'collection_ids', + SPELLING_SUGGESTIONS type string value 'spelling_suggestions', + SOURCE_CRAWL type string value 'source_crawl', + DEFINED type string value 'defined', + STOPWORD_FILE type string value 'stopword_file', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Create an environment. + "! + "! @parameter I_BODY | + "! An object that defines an environment name and optional description. The fields + "! in this object are not approved for personal information and cannot be deleted + "! based on customer ID. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENVIRONMENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_ENVIRONMENT + importing + !I_BODY type T_CREATE_ENVIRONMENT_REQUEST + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENVIRONMENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List environments. + "! + "! @parameter I_NAME | + "! Show only the environment with the given name. + "! @parameter E_RESPONSE | + "! Service return value of type T_LIST_ENVIRONMENTS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_ENVIRONMENTS + importing + !I_NAME type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LIST_ENVIRONMENTS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get environment info. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENVIRONMENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_ENVIRONMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENVIRONMENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update an environment. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_BODY | + "! An object that defines the environment's name and, optionally, description. + "! @parameter E_RESPONSE | + "! Service return value of type T_ENVIRONMENT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_ENVIRONMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_BODY type T_UPDATE_ENVIRONMENT_REQUEST + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ENVIRONMENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete environment. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_ENVIRONMENT_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_ENVIRONMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_ENVIRONMENT_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List fields across collections. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_IDS | + "! A comma-separated list of collection IDs to be queried against. + "! @parameter E_RESPONSE | + "! Service return value of type T_LST_COLLECTION_FIELDS_RESP + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_FIELDS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_IDS type TT_STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LST_COLLECTION_FIELDS_RESP + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Add configuration. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CONFIGURATION | + "! Input an object that enables you to customize how your content is ingested and + "! what enrichments are added to your data.
+ "!
+ "! **name** is required and must be unique within the current **environment**. All + "! other properties are optional.
+ "!
+ "! If the input configuration contains the **configuration_id**, **created**, or + "! **updated** properties, then they will be ignored and overridden by the system + "! (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 will be + "! ignored and will 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_CONFIGURATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_CONFIGURATION + importing + !I_ENVIRONMENT_ID type STRING + !I_CONFIGURATION type T_CONFIGURATION + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CONFIGURATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List configurations. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_NAME | + "! Find configurations with the given name. + "! @parameter E_RESPONSE | + "! Service return value of type T_LIST_CONFIGURATIONS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_CONFIGURATIONS + importing + !I_ENVIRONMENT_ID type STRING + !I_NAME type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LIST_CONFIGURATIONS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get configuration details. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CONFIGURATION_ID | + "! The ID of the configuration. + "! @parameter E_RESPONSE | + "! Service return value of type T_CONFIGURATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CONFIGURATION + importing + !I_ENVIRONMENT_ID type STRING + !I_CONFIGURATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CONFIGURATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a configuration. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CONFIGURATION_ID | + "! The ID of the configuration. + "! @parameter I_CONFIGURATION | + "! Input an object that enables you to update and customize how your data is + "! ingested and what enrichments are added to your data. The **name** parameter + "! is required and must be unique within the current **environment**. All other + "! properties are optional, but if they are omitted the default values replace + "! the current value of each omitted property.
+ "!
+ "! If the input configuration contains the **configuration_id**, **created**, or + "! **updated** properties, 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 updating 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_CONFIGURATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_CONFIGURATION + importing + !I_ENVIRONMENT_ID type STRING + !I_CONFIGURATION_ID type STRING + !I_CONFIGURATION type T_CONFIGURATION + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CONFIGURATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a configuration. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CONFIGURATION_ID | + "! The ID of the configuration. + "! @parameter E_RESPONSE | + "! Service return value of type T_DEL_CONFIGURATION_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_CONFIGURATION + importing + !I_ENVIRONMENT_ID type STRING + !I_CONFIGURATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DEL_CONFIGURATION_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a collection. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_BODY | + "! Input an object that allows you to add a collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_COLLECTION + importing + !I_ENVIRONMENT_ID type STRING + !I_BODY type T_CREATE_COLLECTION_REQUEST + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List collections. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_NAME | + "! Find collections with the given name. + "! @parameter E_RESPONSE | + "! Service return value of type T_LIST_COLLECTIONS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_COLLECTIONS + importing + !I_ENVIRONMENT_ID type STRING + !I_NAME type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LIST_COLLECTIONS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get collection details. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_COLLECTION + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a collection. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_BODY | + "! Input an object that allows you to update a collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_COLLECTION + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_BODY type T_UPDATE_COLLECTION_REQUEST + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a collection. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_COLLECTION_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_COLLECTION + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_COLLECTION_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List collection fields. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_LST_COLLECTION_FIELDS_RESP + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_COLLECTION_FIELDS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LST_COLLECTION_FIELDS_RESP + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Get the expansion list. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXPANSIONS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_EXPANSIONS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXPANSIONS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create or update expansion list. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_BODY | + "! An object that defines the expansion list. + "! @parameter E_RESPONSE | + "! Service return value of type T_EXPANSIONS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_EXPANSIONS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_BODY type T_EXPANSIONS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_EXPANSIONS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete the expansion list. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_EXPANSIONS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get tokenization dictionary status. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_TOKEN_DICT_STATUS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_TOKENIZATION_DICT_STATUS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TOKEN_DICT_STATUS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create tokenization dictionary. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_TOKENIZATION_DICTIONARY | + "! An object that represents the tokenization dictionary to be uploaded. + "! @parameter E_RESPONSE | + "! Service return value of type T_TOKEN_DICT_STATUS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_TOKENIZATION_DICTIONARY + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_TOKENIZATION_DICTIONARY type T_TOKEN_DICT optional + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TOKEN_DICT_STATUS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete tokenization dictionary. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_TOKENIZATION_DICTIONARY + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get stopword list status. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_TOKEN_DICT_STATUS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_STOPWORD_LIST_STATUS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TOKEN_DICT_STATUS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create stopword list. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_STOPWORD_FILE | + "! The content of the stopword list to ingest. + "! @parameter I_STOPWORD_FILENAME | + "! The filename for stopwordFile. + "! @parameter E_RESPONSE | + "! Service return value of type T_TOKEN_DICT_STATUS_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_STOPWORD_LIST + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_STOPWORD_FILE type FILE + !I_STOPWORD_FILENAME type STRING + !I_STOPWORD_FILE_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TOKEN_DICT_STATUS_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom stopword list. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_STOPWORD_LIST + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Add a document. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_FILE | + "! The content of the document to ingest. The maximum supported file size when + "! adding a file to a collection is 50 megabytes, the maximum supported file size + "! when testing a configuration is 1 megabyte. Files larger than the supported + "! size are rejected. + "! @parameter I_FILENAME | + "! The filename for file. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_METADATA | + "! The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 + "! MB are rejected. Example: ``` {
+ "! "Creator": "Johnny Appleseed",
+ "! "Subject": "Apples"
+ "! } ```. + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_ACCEPTED + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_DOCUMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_FILE type FILE optional + !I_FILENAME type STRING optional + !I_FILE_CONTENT_TYPE type STRING optional + !I_METADATA type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_ACCEPTED + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get document details. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_DOCUMENT_ID | + "! The ID of the document. + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_DOCUMENT_STATUS + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_DOCUMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a document. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_DOCUMENT_ID | + "! The ID of the document. + "! @parameter I_FILE | + "! The content of the document to ingest. The maximum supported file size when + "! adding a file to a collection is 50 megabytes, the maximum supported file size + "! when testing a configuration is 1 megabyte. Files larger than the supported + "! size are rejected. + "! @parameter I_FILENAME | + "! The filename for file. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_METADATA | + "! The maximum supported metadata file size is 1 MB. Metadata parts larger than 1 + "! MB are rejected. Example: ``` {
+ "! "Creator": "Johnny Appleseed",
+ "! "Subject": "Apples"
+ "! } ```. + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_ACCEPTED + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_DOCUMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_DOCUMENT_ID type STRING + !I_FILE type FILE optional + !I_FILENAME type STRING optional + !I_FILE_CONTENT_TYPE type STRING optional + !I_METADATA type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_ACCEPTED + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a document. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_DOCUMENT_ID | + "! The ID of the document. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_DOCUMENT_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_DOCUMENT + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_DOCUMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_DOCUMENT_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Query a collection. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_LONG | + "! An object that represents the query to be submitted. + "! @parameter I_X_WATSON_LOGGING_OPT_OUT | + "! If `true`, queries are not stored in the Discovery **Logs** endpoint. + "! @parameter E_RESPONSE | + "! Service return value of type T_QUERY_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods QUERY + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_LONG type T_COLL_QUERY_LARGE optional + !I_X_WATSON_LOGGING_OPT_OUT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_QUERY_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Query system notices. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_FILTER | + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + "! @parameter I_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. + "! @parameter I_NATURAL_LANGUAGE_QUERY | + "! A natural language query that returns relevant documents by utilizing training + "! data and natural language understanding. + "! @parameter I_PASSAGES | + "! A passages query that returns the most relevant passages from the results. + "! @parameter I_AGGREGATION | + "! An aggregation search that returns an exact answer by combining query search + "! with filters. Useful for applications to build lists, tables, and time series. + "! For a full list of possible aggregations, see the Query reference. + "! @parameter I_COUNT | + "! Number of results to return. The maximum for the **count** and **offset** values + "! together in any one query is **10000**. + "! @parameter I_RETURN | + "! A comma-separated list of the portion of the document hierarchy to return. + "! @parameter I_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**. + "! @parameter I_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. + "! @parameter I_HIGHLIGHT | + "! When true, a highlight field is returned for each result which contains the + "! fields which match the query with `<em></em>` tags around the + "! matching query terms. + "! @parameter I_PASSAGES_FIELDS | + "! A comma-separated list of fields that passages are drawn from. If this parameter + "! not specified, then all top-level fields are included. + "! @parameter I_PASSAGES_COUNT | + "! The maximum number of passages to return. The search returns fewer passages if + "! the requested total is not found. + "! @parameter I_PASSAGES_CHARACTERS | + "! The approximate number of characters that any one passage will have. + "! @parameter I_DEDUPLICATE_FIELD | + "! 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. + "! @parameter I_SIMILAR | + "! When `true`, results are returned based on their similarity to the document IDs + "! specified in the **similar.document_ids** parameter. + "! @parameter I_SIMILAR_DOCUMENT_IDS | + "! A comma-separated list of document IDs to find similar documents.
+ "!
+ "! **Tip:** Include the **natural_language_query** parameter to expand the scope of + "! the document similarity search with the natural language query. Other query + "! parameters, such as **filter** and **query**, are subsequently applied and + "! reduce the scope. + "! @parameter I_SIMILAR_FIELDS | + "! A comma-separated list of field names that are used as a basis for comparison to + "! identify similar documents. If not specified, the entire document is used for + "! comparison. + "! @parameter E_RESPONSE | + "! Service return value of type T_QUERY_NOTICES_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods QUERY_NOTICES + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_FILTER type STRING optional + !I_QUERY type STRING optional + !I_NATURAL_LANGUAGE_QUERY type STRING optional + !I_PASSAGES type BOOLEAN optional + !I_AGGREGATION type STRING optional + !I_COUNT type INTEGER optional + !I_RETURN type TT_STRING optional + !I_OFFSET type INTEGER optional + !I_SORT type TT_STRING optional + !I_HIGHLIGHT type BOOLEAN default c_boolean_false + !I_PASSAGES_FIELDS type TT_STRING optional + !I_PASSAGES_COUNT type INTEGER optional + !I_PASSAGES_CHARACTERS type INTEGER optional + !I_DEDUPLICATE_FIELD type STRING optional + !I_SIMILAR type BOOLEAN default c_boolean_false + !I_SIMILAR_DOCUMENT_IDS type TT_STRING optional + !I_SIMILAR_FIELDS type TT_STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_QUERY_NOTICES_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Query multiple collections. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_QUERY_LONG | + "! No documentation available. + "! @parameter I_X_WATSON_LOGGING_OPT_OUT | + "! If `true`, queries are not stored in the Discovery **Logs** endpoint. + "! @parameter E_RESPONSE | + "! Service return value of type T_QUERY_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods FEDERATED_QUERY + importing + !I_ENVIRONMENT_ID type STRING + !I_QUERY_LONG type T_FED_QUERY_LARGE + !I_X_WATSON_LOGGING_OPT_OUT type BOOLEAN default c_boolean_false + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_QUERY_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Query multiple collection system notices. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_IDS | + "! A comma-separated list of collection IDs to be queried against. + "! @parameter I_FILTER | + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + "! @parameter I_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. + "! @parameter I_NATURAL_LANGUAGE_QUERY | + "! A natural language query that returns relevant documents by utilizing training + "! data and natural language understanding. + "! @parameter I_AGGREGATION | + "! An aggregation search that returns an exact answer by combining query search + "! with filters. Useful for applications to build lists, tables, and time series. + "! For a full list of possible aggregations, see the Query reference. + "! @parameter I_COUNT | + "! Number of results to return. The maximum for the **count** and **offset** values + "! together in any one query is **10000**. + "! @parameter I_RETURN | + "! A comma-separated list of the portion of the document hierarchy to return. + "! @parameter I_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**. + "! @parameter I_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. + "! @parameter I_HIGHLIGHT | + "! When true, a highlight field is returned for each result which contains the + "! fields which match the query with `<em></em>` tags around the + "! matching query terms. + "! @parameter I_DEDUPLICATE_FIELD | + "! 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. + "! @parameter I_SIMILAR | + "! When `true`, results are returned based on their similarity to the document IDs + "! specified in the **similar.document_ids** parameter. + "! @parameter I_SIMILAR_DOCUMENT_IDS | + "! A comma-separated list of document IDs to find similar documents.
+ "!
+ "! **Tip:** Include the **natural_language_query** parameter to expand the scope of + "! the document similarity search with the natural language query. Other query + "! parameters, such as **filter** and **query**, are subsequently applied and + "! reduce the scope. + "! @parameter I_SIMILAR_FIELDS | + "! A comma-separated list of field names that are used as a basis for comparison to + "! identify similar documents. If not specified, the entire document is used for + "! comparison. + "! @parameter E_RESPONSE | + "! Service return value of type T_QUERY_NOTICES_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods FEDERATED_QUERY_NOTICES + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_IDS type TT_STRING + !I_FILTER type STRING optional + !I_QUERY type STRING optional + !I_NATURAL_LANGUAGE_QUERY type STRING optional + !I_AGGREGATION type STRING optional + !I_COUNT type INTEGER optional + !I_RETURN type TT_STRING optional + !I_OFFSET type INTEGER optional + !I_SORT type TT_STRING optional + !I_HIGHLIGHT type BOOLEAN default c_boolean_false + !I_DEDUPLICATE_FIELD type STRING optional + !I_SIMILAR type BOOLEAN default c_boolean_false + !I_SIMILAR_DOCUMENT_IDS type TT_STRING optional + !I_SIMILAR_FIELDS type TT_STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_QUERY_NOTICES_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get Autocomplete Suggestions. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_PREFIX | + "! The prefix to use for autocompletion. For example, the prefix `Ho` could + "! autocomplete to `Hot`, `Housing`, or `How do I upgrade`. Possible completions + "! are. + "! @parameter I_FIELD | + "! The field in the result documents that autocompletion suggestions are identified + "! from. + "! @parameter I_COUNT | + "! The number of autocompletion suggestions to return. + "! @parameter E_RESPONSE | + "! Service return value of type T_COMPLETIONS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_AUTOCOMPLETION + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_PREFIX type STRING + !I_FIELD type STRING optional + !I_COUNT type INTEGER optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COMPLETIONS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List training data. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_DATA_SET + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_TRAINING_DATA + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_DATA_SET + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add query to training data. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_BODY | + "! The body of the training data query that is to be added to the collection's + "! training data. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_QUERY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_TRAINING_DATA + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_BODY type T_NEW_TRAINING_QUERY + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_QUERY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete all training data. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_ALL_TRAINING_DATA + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get details about a query. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_QUERY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_TRAINING_DATA + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_QUERY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a training data query. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_TRAINING_DATA + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List examples for a training data query. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_EXAMPLE_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_TRAINING_EXAMPLES + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_EXAMPLE_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add example to training data query. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter I_BODY | + "! The body of the example that is to be added to the specified query. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_TRAINING_EXAMPLE + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_BODY type T_TRAINING_EXAMPLE + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete example for training data query. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter I_EXAMPLE_ID | + "! The ID of the document as it is indexed. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_TRAINING_EXAMPLE + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_EXAMPLE_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Change label or cross reference for example. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter I_EXAMPLE_ID | + "! The ID of the document as it is indexed. + "! @parameter I_BODY | + "! The body of the example that is to be added to the specified query. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_TRAINING_EXAMPLE + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_EXAMPLE_ID type STRING + !I_BODY type T_TRAINING_EXAMPLE_PATCH + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get details for training data example. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_COLLECTION_ID | + "! The ID of the collection. + "! @parameter I_QUERY_ID | + "! The ID of the query used for training. + "! @parameter I_EXAMPLE_ID | + "! The ID of the document as it is indexed. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_EXAMPLE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_TRAINING_EXAMPLE + importing + !I_ENVIRONMENT_ID type STRING + !I_COLLECTION_ID type STRING + !I_QUERY_ID type STRING + !I_EXAMPLE_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_EXAMPLE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create event. + "! + "! @parameter I_QUERY_EVENT | + "! An object that defines a query event to be added to the log. + "! @parameter E_RESPONSE | + "! Service return value of type T_CREATE_EVENT_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_EVENT + importing + !I_QUERY_EVENT type T_CREATE_EVENT_OBJECT + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CREATE_EVENT_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Search the query and event log. + "! + "! @parameter I_FILTER | + "! A cacheable query that excludes documents that don't mention the query content. + "! Filter searches are better for metadata-type searches and for assessing the + "! concepts in the data set. + "! @parameter I_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. + "! @parameter I_COUNT | + "! Number of results to return. The maximum for the **count** and **offset** values + "! together in any one query is **10000**. + "! @parameter I_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**. + "! @parameter I_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. + "! @parameter E_RESPONSE | + "! Service return value of type T_LOG_QUERY_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods QUERY_LOG + importing + !I_FILTER type STRING optional + !I_QUERY type STRING optional + !I_COUNT type INTEGER optional + !I_OFFSET type INTEGER optional + !I_SORT type TT_STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LOG_QUERY_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Number of queries over time. + "! + "! @parameter I_START_TIME | + "! Metric is computed from data recorded after this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_END_TIME | + "! Metric is computed from data recorded before this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_RESULT_TYPE | + "! The type of result to consider when calculating the metric. + "! @parameter E_RESPONSE | + "! Service return value of type T_METRIC_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_METRICS_QUERY + importing + !I_START_TIME type DATETIME optional + !I_END_TIME type DATETIME optional + !I_RESULT_TYPE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_METRIC_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Number of queries with an event over time. + "! + "! @parameter I_START_TIME | + "! Metric is computed from data recorded after this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_END_TIME | + "! Metric is computed from data recorded before this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_RESULT_TYPE | + "! The type of result to consider when calculating the metric. + "! @parameter E_RESPONSE | + "! Service return value of type T_METRIC_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_METRICS_QUERY_EVENT + importing + !I_START_TIME type DATETIME optional + !I_END_TIME type DATETIME optional + !I_RESULT_TYPE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_METRIC_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Number of queries with no search results over time. + "! + "! @parameter I_START_TIME | + "! Metric is computed from data recorded after this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_END_TIME | + "! Metric is computed from data recorded before this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_RESULT_TYPE | + "! The type of result to consider when calculating the metric. + "! @parameter E_RESPONSE | + "! Service return value of type T_METRIC_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_METRICS_QUERY_NO_RESULTS + importing + !I_START_TIME type DATETIME optional + !I_END_TIME type DATETIME optional + !I_RESULT_TYPE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_METRIC_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Percentage of queries with an associated event. + "! + "! @parameter I_START_TIME | + "! Metric is computed from data recorded after this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_END_TIME | + "! Metric is computed from data recorded before this timestamp; must be in + "! `YYYY-MM-DDThh:mm:ssZ` format. + "! @parameter I_RESULT_TYPE | + "! The type of result to consider when calculating the metric. + "! @parameter E_RESPONSE | + "! Service return value of type T_METRIC_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_METRICS_EVENT_RATE + importing + !I_START_TIME type DATETIME optional + !I_END_TIME type DATETIME optional + !I_RESULT_TYPE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_METRIC_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Most frequent query tokens with an event. + "! + "! @parameter I_COUNT | + "! Number of results to return. The maximum for the **count** and **offset** values + "! together in any one query is **10000**. + "! @parameter E_RESPONSE | + "! Service return value of type T_METRIC_TOKEN_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_METRICS_QUERY_TOKEN_EVENT + importing + !I_COUNT type INTEGER optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_METRIC_TOKEN_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List credentials. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter E_RESPONSE | + "! Service return value of type T_CREDENTIALS_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_CREDENTIALS + importing + !I_ENVIRONMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CREDENTIALS_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create credentials. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CREDENTIALS_PARAMETER | + "! An object that defines an individual set of source credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_CREDENTIALS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_CREDENTIALS + importing + !I_ENVIRONMENT_ID type STRING + !I_CREDENTIALS_PARAMETER type T_CREDENTIALS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CREDENTIALS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! View Credentials. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CREDENTIAL_ID | + "! The unique identifier for a set of source credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_CREDENTIALS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CREDENTIALS + importing + !I_ENVIRONMENT_ID type STRING + !I_CREDENTIAL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CREDENTIALS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update credentials. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CREDENTIAL_ID | + "! The unique identifier for a set of source credentials. + "! @parameter I_CREDENTIALS_PARAMETER | + "! An object that defines an individual set of source credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_CREDENTIALS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_CREDENTIALS + importing + !I_ENVIRONMENT_ID type STRING + !I_CREDENTIAL_ID type STRING + !I_CREDENTIALS_PARAMETER type T_CREDENTIALS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CREDENTIALS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete credentials. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_CREDENTIAL_ID | + "! The unique identifier for a set of source credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_CREDENTIALS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_CREDENTIALS + importing + !I_ENVIRONMENT_ID type STRING + !I_CREDENTIAL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_CREDENTIALS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List Gateways. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter E_RESPONSE | + "! Service return value of type T_GATEWAY_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_GATEWAYS + importing + !I_ENVIRONMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GATEWAY_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create Gateway. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_GATEWAY_NAME | + "! The name of the gateway to created. + "! @parameter E_RESPONSE | + "! Service return value of type T_GATEWAY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_GATEWAY + importing + !I_ENVIRONMENT_ID type STRING + !I_GATEWAY_NAME type T_GATEWAY_NAME optional + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GATEWAY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List Gateway Details. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_GATEWAY_ID | + "! The requested gateway ID. + "! @parameter E_RESPONSE | + "! Service return value of type T_GATEWAY + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_GATEWAY + importing + !I_ENVIRONMENT_ID type STRING + !I_GATEWAY_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GATEWAY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete Gateway. + "! + "! @parameter I_ENVIRONMENT_ID | + "! The ID of the environment. + "! @parameter I_GATEWAY_ID | + "! The requested gateway ID. + "! @parameter E_RESPONSE | + "! Service return value of type T_GATEWAY_DELETE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_GATEWAY + importing + !I_ENVIRONMENT_ID type STRING + !I_GATEWAY_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GATEWAY_DELETE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_DISCOVERY_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Discovery'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_DISCOVERY_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/discovery/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092816'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_ENVIRONMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_BODY TYPE T_CREATE_ENVIRONMENT_REQUEST +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENVIRONMENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_ENVIRONMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_ENVIRONMENTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_NAME TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LIST_ENVIRONMENTS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_ENVIRONMENTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_NAME is supplied. + lv_queryparam = escape( val = i_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_ENVIRONMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENVIRONMENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_ENVIRONMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_ENVIRONMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_ENVIRONMENT_REQUEST +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ENVIRONMENT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_ENVIRONMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_ENVIRONMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_ENVIRONMENT_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_ENVIRONMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_FIELDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_IDS TYPE TT_STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LST_COLLECTION_FIELDS_RESP +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_FIELDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/fields'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + data: + lv_item_COLLECTION_IDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_COLLECTION_IDS into lv_item_COLLECTION_IDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_COLLECTION_IDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `collection_ids` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_CONFIGURATION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CONFIGURATION TYPE T_CONFIGURATION +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CONFIGURATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_CONFIGURATION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/configurations'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CONFIGURATION ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CONFIGURATION i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'configuration' i_value = i_CONFIGURATION ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CONFIGURATION to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_CONFIGURATIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_NAME TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LIST_CONFIGURATIONS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_CONFIGURATIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/configurations'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_NAME is supplied. + lv_queryparam = escape( val = i_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_CONFIGURATION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CONFIGURATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CONFIGURATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CONFIGURATION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/configurations/{configuration_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{configuration_id}` in ls_request_prop-url-path with i_CONFIGURATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_CONFIGURATION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CONFIGURATION_ID TYPE STRING +* | [--->] I_CONFIGURATION TYPE T_CONFIGURATION +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CONFIGURATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_CONFIGURATION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/configurations/{configuration_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{configuration_id}` in ls_request_prop-url-path with i_CONFIGURATION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CONFIGURATION ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CONFIGURATION i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'configuration' i_value = i_CONFIGURATION ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CONFIGURATION to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_CONFIGURATION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CONFIGURATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DEL_CONFIGURATION_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_CONFIGURATION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/configurations/{configuration_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{configuration_id}` in ls_request_prop-url-path with i_CONFIGURATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_BODY TYPE T_CREATE_COLLECTION_REQUEST +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_COLLECTIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_NAME TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LIST_COLLECTIONS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_COLLECTIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_NAME is supplied. + lv_queryparam = escape( val = i_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_BODY TYPE T_UPDATE_COLLECTION_REQUEST +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_COLLECTION_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_COLLECTION_FIELDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LST_COLLECTION_FIELDS_RESP +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_COLLECTION_FIELDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/fields'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_EXPANSIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXPANSIONS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_EXPANSIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/expansions'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_EXPANSIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_BODY TYPE T_EXPANSIONS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_EXPANSIONS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_EXPANSIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/expansions'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_EXPANSIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_EXPANSIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/expansions'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_TOKENIZATION_DICT_STATUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TOKEN_DICT_STATUS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_TOKENIZATION_DICT_STATUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_TOKENIZATION_DICTIONARY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_TOKENIZATION_DICTIONARY TYPE T_TOKEN_DICT(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TOKEN_DICT_STATUS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_TOKENIZATION_DICTIONARY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_TOKENIZATION_DICTIONARY is initial. + lv_datatype = get_datatype( i_TOKENIZATION_DICTIONARY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TOKENIZATION_DICTIONARY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'tokenization_dictionary' i_value = i_TOKENIZATION_DICTIONARY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TOKENIZATION_DICTIONARY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_TOKENIZATION_DICTIONARY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_TOKENIZATION_DICTIONARY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/tokenization_dictionary'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_STOPWORD_LIST_STATUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TOKEN_DICT_STATUS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_STOPWORD_LIST_STATUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_STOPWORD_LIST +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_STOPWORD_FILE TYPE FILE +* | [--->] I_STOPWORD_FILENAME TYPE STRING +* | [--->] I_STOPWORD_FILE_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TOKEN_DICT_STATUS_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_STOPWORD_LIST. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_STOPWORD_FILE is initial. + if not I_stopword_filename is initial. + lv_value = `form-data; name="stopword_file"; filename="` && I_stopword_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_STOPWORD_FILE_CT ). + lv_value = `form-data; name="stopword_file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_STOPWORD_FILE_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_STOPWORD_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_STOPWORD_LIST +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_STOPWORD_LIST. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/word_lists/stopwords'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->ADD_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_FILE TYPE FILE(optional) +* | [--->] I_FILENAME TYPE STRING(optional) +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_METADATA TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_ACCEPTED +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/documents'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_METADATA is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="metadata"' ##NO_TEXT. + lv_formdata = i_METADATA. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_FILE is initial. + if not I_filename is initial. + lv_value = `form-data; name="file"; filename="` && I_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_DOCUMENT_STATUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_DOCUMENT_STATUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [--->] I_FILE TYPE FILE(optional) +* | [--->] I_FILENAME TYPE STRING(optional) +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_METADATA TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_ACCEPTED +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_METADATA is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="metadata"' ##NO_TEXT. + lv_formdata = i_METADATA. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_FILE is initial. + if not I_filename is initial. + lv_value = `form-data; name="file"; filename="` && I_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_DOCUMENT_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/documents/{document_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->QUERY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_LONG TYPE T_COLL_QUERY_LARGE(optional) +* | [--->] I_X_WATSON_LOGGING_OPT_OUT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_QUERY_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method QUERY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/query'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_X_WATSON_LOGGING_OPT_OUT is supplied. + lv_headerparam = I_X_WATSON_LOGGING_OPT_OUT. + add_header_parameter( + exporting + i_parameter = 'X-Watson-Logging-Opt-Out' + i_value = lv_headerparam + i_is_boolean = c_boolean_true + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_QUERY_LONG is initial. + lv_datatype = get_datatype( i_QUERY_LONG ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_QUERY_LONG i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'query_long' i_value = i_QUERY_LONG ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_QUERY_LONG to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->QUERY_NOTICES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_FILTER TYPE STRING(optional) +* | [--->] I_QUERY TYPE STRING(optional) +* | [--->] I_NATURAL_LANGUAGE_QUERY TYPE STRING(optional) +* | [--->] I_PASSAGES TYPE BOOLEAN(optional) +* | [--->] I_AGGREGATION TYPE STRING(optional) +* | [--->] I_COUNT TYPE INTEGER(optional) +* | [--->] I_RETURN TYPE TT_STRING(optional) +* | [--->] I_OFFSET TYPE INTEGER(optional) +* | [--->] I_SORT TYPE TT_STRING(optional) +* | [--->] I_HIGHLIGHT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PASSAGES_FIELDS TYPE TT_STRING(optional) +* | [--->] I_PASSAGES_COUNT TYPE INTEGER(optional) +* | [--->] I_PASSAGES_CHARACTERS TYPE INTEGER(optional) +* | [--->] I_DEDUPLICATE_FIELD TYPE STRING(optional) +* | [--->] I_SIMILAR TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_SIMILAR_DOCUMENT_IDS TYPE TT_STRING(optional) +* | [--->] I_SIMILAR_FIELDS TYPE TT_STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_QUERY_NOTICES_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method QUERY_NOTICES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/notices'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_FILTER is supplied. + lv_queryparam = escape( val = i_FILTER format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `filter` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_QUERY is supplied. + lv_queryparam = escape( val = i_QUERY format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `query` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_NATURAL_LANGUAGE_QUERY is supplied. + lv_queryparam = escape( val = i_NATURAL_LANGUAGE_QUERY format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `natural_language_query` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PASSAGES is supplied. + lv_queryparam = i_PASSAGES. + add_query_parameter( + exporting + i_parameter = `passages` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_AGGREGATION is supplied. + lv_queryparam = escape( val = i_AGGREGATION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `aggregation` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_COUNT is supplied. + lv_queryparam = i_COUNT. + add_query_parameter( + exporting + i_parameter = `count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RETURN is supplied. + data: + lv_item_RETURN type STRING. + clear: lv_queryparam, lv_sep. + loop at i_RETURN into lv_item_RETURN. + lv_queryparam = lv_queryparam && lv_sep && lv_item_RETURN. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `return` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_OFFSET is supplied. + lv_queryparam = i_OFFSET. + add_query_parameter( + exporting + i_parameter = `offset` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + data: + lv_item_SORT type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SORT into lv_item_SORT. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SORT. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_HIGHLIGHT is supplied. + lv_queryparam = i_HIGHLIGHT. + add_query_parameter( + exporting + i_parameter = `highlight` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PASSAGES_FIELDS is supplied. + data: + lv_item_PASSAGES_FIELDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_PASSAGES_FIELDS into lv_item_PASSAGES_FIELDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_PASSAGES_FIELDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `passages.fields` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PASSAGES_COUNT is supplied. + lv_queryparam = i_PASSAGES_COUNT. + add_query_parameter( + exporting + i_parameter = `passages.count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PASSAGES_CHARACTERS is supplied. + lv_queryparam = i_PASSAGES_CHARACTERS. + add_query_parameter( + exporting + i_parameter = `passages.characters` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_DEDUPLICATE_FIELD is supplied. + lv_queryparam = escape( val = i_DEDUPLICATE_FIELD format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `deduplicate.field` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR is supplied. + lv_queryparam = i_SIMILAR. + add_query_parameter( + exporting + i_parameter = `similar` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR_DOCUMENT_IDS is supplied. + data: + lv_item_SIMILAR_DOCUMENT_IDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SIMILAR_DOCUMENT_IDS into lv_item_SIMILAR_DOCUMENT_IDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SIMILAR_DOCUMENT_IDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `similar.document_ids` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR_FIELDS is supplied. + data: + lv_item_SIMILAR_FIELDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SIMILAR_FIELDS into lv_item_SIMILAR_FIELDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SIMILAR_FIELDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `similar.fields` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->FEDERATED_QUERY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_QUERY_LONG TYPE T_FED_QUERY_LARGE +* | [--->] I_X_WATSON_LOGGING_OPT_OUT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_QUERY_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method FEDERATED_QUERY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/query'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_X_WATSON_LOGGING_OPT_OUT is supplied. + lv_headerparam = I_X_WATSON_LOGGING_OPT_OUT. + add_header_parameter( + exporting + i_parameter = 'X-Watson-Logging-Opt-Out' + i_value = lv_headerparam + i_is_boolean = c_boolean_true + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_QUERY_LONG ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_QUERY_LONG i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'query_long' i_value = i_QUERY_LONG ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_QUERY_LONG to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->FEDERATED_QUERY_NOTICES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_IDS TYPE TT_STRING +* | [--->] I_FILTER TYPE STRING(optional) +* | [--->] I_QUERY TYPE STRING(optional) +* | [--->] I_NATURAL_LANGUAGE_QUERY TYPE STRING(optional) +* | [--->] I_AGGREGATION TYPE STRING(optional) +* | [--->] I_COUNT TYPE INTEGER(optional) +* | [--->] I_RETURN TYPE TT_STRING(optional) +* | [--->] I_OFFSET TYPE INTEGER(optional) +* | [--->] I_SORT TYPE TT_STRING(optional) +* | [--->] I_HIGHLIGHT TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_DEDUPLICATE_FIELD TYPE STRING(optional) +* | [--->] I_SIMILAR TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_SIMILAR_DOCUMENT_IDS TYPE TT_STRING(optional) +* | [--->] I_SIMILAR_FIELDS TYPE TT_STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_QUERY_NOTICES_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method FEDERATED_QUERY_NOTICES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/notices'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + data: + lv_item_COLLECTION_IDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_COLLECTION_IDS into lv_item_COLLECTION_IDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_COLLECTION_IDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `collection_ids` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_FILTER is supplied. + lv_queryparam = escape( val = i_FILTER format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `filter` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_QUERY is supplied. + lv_queryparam = escape( val = i_QUERY format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `query` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_NATURAL_LANGUAGE_QUERY is supplied. + lv_queryparam = escape( val = i_NATURAL_LANGUAGE_QUERY format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `natural_language_query` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_AGGREGATION is supplied. + lv_queryparam = escape( val = i_AGGREGATION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `aggregation` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_COUNT is supplied. + lv_queryparam = i_COUNT. + add_query_parameter( + exporting + i_parameter = `count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RETURN is supplied. + data: + lv_item_RETURN type STRING. + clear: lv_queryparam, lv_sep. + loop at i_RETURN into lv_item_RETURN. + lv_queryparam = lv_queryparam && lv_sep && lv_item_RETURN. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `return` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_OFFSET is supplied. + lv_queryparam = i_OFFSET. + add_query_parameter( + exporting + i_parameter = `offset` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + data: + lv_item_SORT type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SORT into lv_item_SORT. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SORT. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_HIGHLIGHT is supplied. + lv_queryparam = i_HIGHLIGHT. + add_query_parameter( + exporting + i_parameter = `highlight` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_DEDUPLICATE_FIELD is supplied. + lv_queryparam = escape( val = i_DEDUPLICATE_FIELD format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `deduplicate.field` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR is supplied. + lv_queryparam = i_SIMILAR. + add_query_parameter( + exporting + i_parameter = `similar` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR_DOCUMENT_IDS is supplied. + data: + lv_item_SIMILAR_DOCUMENT_IDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SIMILAR_DOCUMENT_IDS into lv_item_SIMILAR_DOCUMENT_IDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SIMILAR_DOCUMENT_IDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `similar.document_ids` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SIMILAR_FIELDS is supplied. + data: + lv_item_SIMILAR_FIELDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SIMILAR_FIELDS into lv_item_SIMILAR_FIELDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SIMILAR_FIELDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `similar.fields` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_AUTOCOMPLETION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_PREFIX TYPE STRING +* | [--->] I_FIELD TYPE STRING(optional) +* | [--->] I_COUNT TYPE INTEGER(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COMPLETIONS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_AUTOCOMPLETION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/autocompletion'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_PREFIX format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `prefix` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_FIELD is supplied. + lv_queryparam = escape( val = i_FIELD format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `field` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_COUNT is supplied. + lv_queryparam = i_COUNT. + add_query_parameter( + exporting + i_parameter = `count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_DATA_SET +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->ADD_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_BODY TYPE T_NEW_TRAINING_QUERY +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_QUERY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_ALL_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_ALL_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_QUERY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_TRAINING_EXAMPLES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_EXAMPLE_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_TRAINING_EXAMPLES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_TRAINING_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_BODY TYPE T_TRAINING_EXAMPLE +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_TRAINING_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_TRAINING_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_EXAMPLE_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_TRAINING_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + replace all occurrences of `{example_id}` in ls_request_prop-url-path with i_EXAMPLE_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_TRAINING_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_EXAMPLE_ID TYPE STRING +* | [--->] I_BODY TYPE T_TRAINING_EXAMPLE_PATCH +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_TRAINING_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + replace all occurrences of `{example_id}` in ls_request_prop-url-path with i_EXAMPLE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_TRAINING_EXAMPLE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_QUERY_ID TYPE STRING +* | [--->] I_EXAMPLE_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_EXAMPLE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_TRAINING_EXAMPLE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/collections/{collection_id}/training_data/{query_id}/examples/{example_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{query_id}` in ls_request_prop-url-path with i_QUERY_ID ignoring case. + replace all occurrences of `{example_id}` in ls_request_prop-url-path with i_EXAMPLE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/user_data'. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_EVENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_QUERY_EVENT TYPE T_CREATE_EVENT_OBJECT +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CREATE_EVENT_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_EVENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/events'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_QUERY_EVENT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_QUERY_EVENT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'query_event' i_value = i_QUERY_EVENT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_QUERY_EVENT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->QUERY_LOG +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILTER TYPE STRING(optional) +* | [--->] I_QUERY TYPE STRING(optional) +* | [--->] I_COUNT TYPE INTEGER(optional) +* | [--->] I_OFFSET TYPE INTEGER(optional) +* | [--->] I_SORT TYPE TT_STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LOG_QUERY_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method QUERY_LOG. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/logs'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_FILTER is supplied. + lv_queryparam = escape( val = i_FILTER format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `filter` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_QUERY is supplied. + lv_queryparam = escape( val = i_QUERY format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `query` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_COUNT is supplied. + lv_queryparam = i_COUNT. + add_query_parameter( + exporting + i_parameter = `count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_OFFSET is supplied. + lv_queryparam = i_OFFSET. + add_query_parameter( + exporting + i_parameter = `offset` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + data: + lv_item_SORT type STRING. + clear: lv_queryparam, lv_sep. + loop at i_SORT into lv_item_SORT. + lv_queryparam = lv_queryparam && lv_sep && lv_item_SORT. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_METRICS_QUERY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_START_TIME TYPE DATETIME(optional) +* | [--->] I_END_TIME TYPE DATETIME(optional) +* | [--->] I_RESULT_TYPE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_METRIC_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_METRICS_QUERY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/metrics/number_of_queries'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_START_TIME is supplied. + lv_queryparam = i_START_TIME. + add_query_parameter( + exporting + i_parameter = `start_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_TIME is supplied. + lv_queryparam = i_END_TIME. + add_query_parameter( + exporting + i_parameter = `end_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RESULT_TYPE is supplied. + lv_queryparam = escape( val = i_RESULT_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `result_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_METRICS_QUERY_EVENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_START_TIME TYPE DATETIME(optional) +* | [--->] I_END_TIME TYPE DATETIME(optional) +* | [--->] I_RESULT_TYPE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_METRIC_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_METRICS_QUERY_EVENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/metrics/number_of_queries_with_event'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_START_TIME is supplied. + lv_queryparam = i_START_TIME. + add_query_parameter( + exporting + i_parameter = `start_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_TIME is supplied. + lv_queryparam = i_END_TIME. + add_query_parameter( + exporting + i_parameter = `end_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RESULT_TYPE is supplied. + lv_queryparam = escape( val = i_RESULT_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `result_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_METRICS_QUERY_NO_RESULTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_START_TIME TYPE DATETIME(optional) +* | [--->] I_END_TIME TYPE DATETIME(optional) +* | [--->] I_RESULT_TYPE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_METRIC_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_METRICS_QUERY_NO_RESULTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/metrics/number_of_queries_with_no_search_results'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_START_TIME is supplied. + lv_queryparam = i_START_TIME. + add_query_parameter( + exporting + i_parameter = `start_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_TIME is supplied. + lv_queryparam = i_END_TIME. + add_query_parameter( + exporting + i_parameter = `end_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RESULT_TYPE is supplied. + lv_queryparam = escape( val = i_RESULT_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `result_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_METRICS_EVENT_RATE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_START_TIME TYPE DATETIME(optional) +* | [--->] I_END_TIME TYPE DATETIME(optional) +* | [--->] I_RESULT_TYPE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_METRIC_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_METRICS_EVENT_RATE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/metrics/event_rate'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_START_TIME is supplied. + lv_queryparam = i_START_TIME. + add_query_parameter( + exporting + i_parameter = `start_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_TIME is supplied. + lv_queryparam = i_END_TIME. + add_query_parameter( + exporting + i_parameter = `end_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RESULT_TYPE is supplied. + lv_queryparam = escape( val = i_RESULT_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `result_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_METRICS_QUERY_TOKEN_EVENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COUNT TYPE INTEGER(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_METRIC_TOKEN_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_METRICS_QUERY_TOKEN_EVENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/metrics/top_query_tokens_with_event_rate'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_COUNT is supplied. + lv_queryparam = i_COUNT. + add_query_parameter( + exporting + i_parameter = `count` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_CREDENTIALS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CREDENTIALS_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_CREDENTIALS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/credentials'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_CREDENTIALS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CREDENTIALS_PARAMETER TYPE T_CREDENTIALS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CREDENTIALS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_CREDENTIALS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/credentials'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CREDENTIALS_PARAMETER ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CREDENTIALS_PARAMETER i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'credentials_parameter' i_value = i_CREDENTIALS_PARAMETER ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CREDENTIALS_PARAMETER to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_CREDENTIALS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CREDENTIAL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CREDENTIALS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CREDENTIALS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/credentials/{credential_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{credential_id}` in ls_request_prop-url-path with i_CREDENTIAL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->UPDATE_CREDENTIALS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CREDENTIAL_ID TYPE STRING +* | [--->] I_CREDENTIALS_PARAMETER TYPE T_CREDENTIALS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CREDENTIALS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_CREDENTIALS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/credentials/{credential_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{credential_id}` in ls_request_prop-url-path with i_CREDENTIAL_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CREDENTIALS_PARAMETER ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CREDENTIALS_PARAMETER i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'credentials_parameter' i_value = i_CREDENTIALS_PARAMETER ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CREDENTIALS_PARAMETER to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_CREDENTIALS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_CREDENTIAL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_CREDENTIALS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_CREDENTIALS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/credentials/{credential_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{credential_id}` in ls_request_prop-url-path with i_CREDENTIAL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->LIST_GATEWAYS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GATEWAY_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_GATEWAYS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/gateways'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->CREATE_GATEWAY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_GATEWAY_NAME TYPE T_GATEWAY_NAME(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GATEWAY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_GATEWAY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/gateways'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_GATEWAY_NAME is initial. + lv_datatype = get_datatype( i_GATEWAY_NAME ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_GATEWAY_NAME i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'gateway_name' i_value = i_GATEWAY_NAME ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_GATEWAY_NAME to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->GET_GATEWAY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_GATEWAY_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GATEWAY +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_GATEWAY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/gateways/{gateway_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{gateway_id}` in ls_request_prop-url-path with i_GATEWAY_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_DISCOVERY_V1->DELETE_GATEWAY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ENVIRONMENT_ID TYPE STRING +* | [--->] I_GATEWAY_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GATEWAY_DELETE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_GATEWAY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/environments/{environment_id}/gateways/{gateway_id}'. + replace all occurrences of `{environment_id}` in ls_request_prop-url-path with i_ENVIRONMENT_ID ignoring case. + replace all occurrences of `{gateway_id}` in ls_request_prop-url-path with i_GATEWAY_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_DISCOVERY_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_discovery_v1.clas.xml b/src/zcl_ibmc_discovery_v1.clas.xml new file mode 100644 index 0000000..9387c1e --- /dev/null +++ b/src/zcl_ibmc_discovery_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_DISCOVERY_V1 + E + Watson Discovery V1 + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_lang_translator_v3.clas.abap b/src/zcl_ibmc_lang_translator_v3.clas.abap new file mode 100644 index 0000000..08e1991 --- /dev/null +++ b/src/zcl_ibmc_lang_translator_v3.clas.abap @@ -0,0 +1,1463 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! 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.
+class ZCL_IBMC_LANG_TRANSLATOR_V3 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! A globally unique string that identifies the underlying model that is used for + "! translation. + T_MODEL_ID type String. + types: + "! No documentation available. + begin of T_IDENTIFIABLE_LANGUAGE, + "! The language code for an identifiable language. + LANGUAGE type STRING, + "! The name of the identifiable language. + NAME type STRING, + end of T_IDENTIFIABLE_LANGUAGE. + types: + "! No documentation available. + begin of T_IDENTIFIABLE_LANGUAGES, + "! A list of all languages that the service can identify. + LANGUAGES type STANDARD TABLE OF T_IDENTIFIABLE_LANGUAGE WITH NON-UNIQUE DEFAULT KEY, + end of T_IDENTIFIABLE_LANGUAGES. + types: + "! No documentation available. + begin of T_TRANSLATION, + "! Translation output in UTF-8. + TRANSLATION type STRING, + end of T_TRANSLATION. + types: + "! No documentation available. + begin of T_TRANSLATION_RESULT, + "! An estimate of the number of words in the input text. + WORD_COUNT type INTEGER, + "! Number of characters in the input text. + CHARACTER_COUNT type INTEGER, + "! List of translation output in UTF-8, corresponding to the input text entries. + TRANSLATIONS type STANDARD TABLE OF T_TRANSLATION WITH NON-UNIQUE DEFAULT KEY, + end of T_TRANSLATION_RESULT. + types: + "! No documentation available. + begin of T_IDENTIFIED_LANGUAGE, + "! The language code for an identified language. + LANGUAGE type STRING, + "! The confidence score for the identified language. + CONFIDENCE type DOUBLE, + end of T_IDENTIFIED_LANGUAGE. + types: + "! No documentation available. + begin of T_IDENTIFIED_LANGUAGES, + "! A ranking of identified languages with confidence scores. + LANGUAGES type STANDARD TABLE OF T_IDENTIFIED_LANGUAGE WITH NON-UNIQUE DEFAULT KEY, + end of T_IDENTIFIED_LANGUAGES. + types: + "! Translation target language code. + T_TARGET type String. + types: + "! The status of the translation job associated with a submitted document. + T_TRANSLATION_STATUS type String. + types: + "! Document information, including translation status. + begin of T_DOCUMENT_STATUS, + "! System generated ID identifying a document being translated using one specific + "! translation model. + DOCUMENT_ID type STRING, + "! filename from the submission (if it was missing in the multipart-form, + "! 'noname.<ext matching content type>' is used. + FILENAME type STRING, + "! The status of the translation job associated with a submitted document. + STATUS type STRING, + "! A globally unique string that identifies the underlying model that is used for + "! translation. + MODEL_ID type STRING, + "! Model ID of the base model that was used to customize the model. If the model is + "! not a custom model, this will be absent or an empty string. + BASE_MODEL_ID type STRING, + "! Translation source language code. + SOURCE type STRING, + "! Translation target language code. + TARGET type STRING, + "! The time when the document was submitted. + CREATED type DATETIME, + "! The time when the translation completed. + COMPLETED type DATETIME, + "! An estimate of the number of words in the source document. Returned only if + "! `status` is `available`. + WORD_COUNT type INTEGER, + "! The number of characters in the source document, present only if + "! status=available. + CHARACTER_COUNT type INTEGER, + end of T_DOCUMENT_STATUS. + types: + "! No documentation available. + begin of T_ERROR_RESPONSE, + "! The http error code. + CODE type INTEGER, + "! A short description of the error. + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! Translation source language code. + T_SOURCE type String. + types: + "! No documentation available. + begin of T_INLINE_OBJECT1, + "! The model to use for translation. `model_id` or both `source` and `target` are + "! required. + MODEL_ID type STRING, + "! Language code that specifies the language of the source document. + SOURCE type STRING, + "! Language code that specifies the target language for translation. + TARGET type STRING, + "! To use a previously submitted document as the source for a new translation, + "! enter the `document_id` of the document. + DOCUMENT_ID type STRING, + "! The contents of the source file to translate.
+ "!
+ "! [Supported file + "! types](https://cloud.ibm.com/docs/services/language-translator?topic=language-t + "! ranslator-document-translator-tutorial#supported-file-formats)
+ "!
+ "! Maximum file size: **20 MB**. + FILE type FILE, + end of T_INLINE_OBJECT1. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! 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. + FORCED_GLOSSARY type FILE, + "! 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. + PARALLEL_CORPUS type FILE, + end of T_INLINE_OBJECT. + types: + "! Response payload for models. + begin of T_TRANSLATION_MODEL, + "! A globally unique string that identifies the underlying model that is used for + "! translation. + MODEL_ID type STRING, + "! Optional name that can be specified when the model is created. + NAME type STRING, + "! Translation source language code. + SOURCE type STRING, + "! Translation target language code. + TARGET type STRING, + "! 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. + BASE_MODEL_ID type STRING, + "! The domain of the translation model. + DOMAIN type STRING, + "! Whether this model can be used as a base for customization. Customized models + "! are not further customizable, and some base models are not customizable. + CUSTOMIZABLE type BOOLEAN, + "! 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. + DEFAULT_MODEL type BOOLEAN, + "! Either an empty string, indicating the model is not a custom model, or the ID of + "! the service instance that created the model. + OWNER type STRING, + "! Availability of a model. + STATUS type STRING, + end of T_TRANSLATION_MODEL. + types: + "! The response type for listing existing translation models. + begin of T_TRANSLATION_MODELS, + "! An array of available models. + MODELS type STANDARD TABLE OF T_TRANSLATION_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_TRANSLATION_MODELS. + types: + "! Model ID of the base model that was used to customize the model. If the model is + "! not a custom model, this will be absent or an empty string. + T_BASE_MODEL_ID type String. + types: + "! System generated ID identifying a document being translated using one specific + "! translation model. + T_DOCUMENT_ID type String. + types: + "! No documentation available. + begin of T_TRANSLATE_REQUEST, + "! Input text in UTF-8 encoding. Multiple entries will result in multiple + "! translations in the response. + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! A globally unique string that identifies the underlying model that is used for + "! translation. + MODEL_ID type STRING, + "! Translation source language code. + SOURCE type STRING, + "! Translation target language code. + TARGET type STRING, + end of T_TRANSLATE_REQUEST. + types: + "! No documentation available. + begin of T_DELETE_MODEL_RESULT, + "! "OK" indicates that the model was successfully deleted. + STATUS type STRING, + end of T_DELETE_MODEL_RESULT. + types: + "! No documentation available. + begin of T_DOCUMENT_LIST, + "! An array of all previously submitted documents. + DOCUMENTS type STANDARD TABLE OF T_DOCUMENT_STATUS WITH NON-UNIQUE DEFAULT KEY, + end of T_DOCUMENT_LIST. + +constants: + begin of C_REQUIRED_FIELDS, + T_IDENTIFIABLE_LANGUAGE type string value '|LANGUAGE|NAME|', + T_IDENTIFIABLE_LANGUAGES type string value '|LANGUAGES|', + T_TRANSLATION type string value '|TRANSLATION|', + T_TRANSLATION_RESULT type string value '|WORD_COUNT|CHARACTER_COUNT|TRANSLATIONS|', + T_IDENTIFIED_LANGUAGE type string value '|LANGUAGE|CONFIDENCE|', + T_IDENTIFIED_LANGUAGES type string value '|LANGUAGES|', + T_DOCUMENT_STATUS type string value '|DOCUMENT_ID|FILENAME|STATUS|MODEL_ID|SOURCE|TARGET|CREATED|', + T_ERROR_RESPONSE type string value '|CODE|ERROR|', + T_INLINE_OBJECT1 type string value '|FILE|', + T_INLINE_OBJECT type string value '|', + T_TRANSLATION_MODEL type string value '|MODEL_ID|', + T_TRANSLATION_MODELS type string value '|MODELS|', + T_TRANSLATE_REQUEST type string value '|TEXT|', + T_DELETE_MODEL_RESULT type string value '|STATUS|', + T_DOCUMENT_LIST type string value '|DOCUMENTS|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + DOCUMENTS type string value 'documents', + DOCUMENT_ID type string value 'document_id', + FILENAME type string value 'filename', + STATUS type string value 'status', + MODEL_ID type string value 'model_id', + BASE_MODEL_ID type string value 'base_model_id', + SOURCE type string value 'source', + TARGET type string value 'target', + CREATED type string value 'created', + COMPLETED type string value 'completed', + WORD_COUNT type string value 'word_count', + CHARACTER_COUNT type string value 'character_count', + MODELS type string value 'models', + NAME type string value 'name', + DOMAIN type string value 'domain', + CUSTOMIZABLE type string value 'customizable', + DEFAULT_MODEL type string value 'default_model', + OWNER type string value 'owner', + TEXT type string value 'text', + TRANSLATIONS type string value 'translations', + TRANSLATION type string value 'translation', + LANGUAGES type string value 'languages', + LANGUAGE type string value 'language', + CONFIDENCE type string value 'confidence', + CODE type string value 'code', + ERROR type string value 'error', + FORCED_GLOSSARY type string value 'forced_glossary', + PARALLEL_CORPUS type string value 'parallel_corpus', + FILE type string value 'file', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Translate. + "! + "! @parameter I_REQUEST | + "! The translate request containing the text, and either a model ID or source and + "! target language pair. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRANSLATION_RESULT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TRANSLATE + importing + !I_REQUEST type T_TRANSLATE_REQUEST + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRANSLATION_RESULT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List identifiable languages. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_IDENTIFIABLE_LANGUAGES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_IDENTIFIABLE_LANGUAGES + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_IDENTIFIABLE_LANGUAGES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Identify language. + "! + "! @parameter I_TEXT | + "! Input text in UTF-8 format. + "! @parameter E_RESPONSE | + "! Service return value of type T_IDENTIFIED_LANGUAGES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods IDENTIFY + importing + !I_TEXT type STRING + !I_contenttype type string default 'text/plain' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_IDENTIFIED_LANGUAGES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List models. + "! + "! @parameter I_SOURCE | + "! Specify a language code to filter results by source language. + "! @parameter I_TARGET | + "! Specify a language code to filter results by target language. + "! @parameter I_DEFAULT | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRANSLATION_MODELS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_MODELS + importing + !I_SOURCE type STRING optional + !I_TARGET type STRING optional + !I_DEFAULT type BOOLEAN optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRANSLATION_MODELS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create model. + "! + "! @parameter I_BASE_MODEL_ID | + "! 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. + "! @parameter I_FORCED_GLOSSARY | + "! 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. + "! @parameter I_PARALLEL_CORPUS | + "! 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. + "! @parameter I_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. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRANSLATION_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_MODEL + importing + !I_BASE_MODEL_ID type STRING + !I_FORCED_GLOSSARY type FILE optional + !I_PARALLEL_CORPUS type FILE optional + !I_NAME type STRING optional + !I_FORCED_GLOSSARY_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_PARALLEL_CORPUS_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRANSLATION_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete model. + "! + "! @parameter I_MODEL_ID | + "! Model ID of the model to delete. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_MODEL_RESULT + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_MODEL + importing + !I_MODEL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_MODEL_RESULT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get model details. + "! + "! @parameter I_MODEL_ID | + "! Model ID of the model to get. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRANSLATION_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_MODEL + importing + !I_MODEL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRANSLATION_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List documents. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_DOCUMENTS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Translate document. + "! + "! @parameter I_FILE | + "! The contents of the source file to translate.
+ "!
+ "! [Supported file + "! types](https://cloud.ibm.com/docs/services/language-translator?topic=language-t + "! ranslator-document-translator-tutorial#supported-file-formats)
+ "!
+ "! Maximum file size: **20 MB**. + "! @parameter I_FILENAME | + "! The filename for file. + "! @parameter I_FILE_CONTENT_TYPE | + "! The content type of file. + "! @parameter I_MODEL_ID | + "! The model to use for translation. `model_id` or both `source` and `target` are + "! required. + "! @parameter I_SOURCE | + "! Language code that specifies the language of the source document. + "! @parameter I_TARGET | + "! Language code that specifies the target language for translation. + "! @parameter I_DOCUMENT_ID | + "! To use a previously submitted document as the source for a new translation, + "! enter the `document_id` of the document. + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TRANSLATE_DOCUMENT + importing + !I_FILE type FILE + !I_FILENAME type STRING + !I_FILE_CONTENT_TYPE type STRING optional + !I_MODEL_ID type STRING optional + !I_SOURCE type STRING optional + !I_TARGET type STRING optional + !I_DOCUMENT_ID type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get document status. + "! + "! @parameter I_DOCUMENT_ID | + "! The document ID of the document. + "! @parameter E_RESPONSE | + "! Service return value of type T_DOCUMENT_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_DOCUMENT_STATUS + importing + !I_DOCUMENT_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DOCUMENT_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete document. + "! + "! @parameter I_DOCUMENT_ID | + "! Document ID of the document to delete. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_DOCUMENT + importing + !I_DOCUMENT_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get translated document. + "! + "! @parameter I_DOCUMENT_ID | + "! The document ID of the document that was submitted for translation. + "! @parameter I_ACCEPT | + "! The type of the response: application/powerpoint, application/mspowerpoint, + "! application/x-rtf, application/json, application/xml, application/vnd.ms-excel, + "! application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, + "! application/vnd.ms-powerpoint, + "! application/vnd.openxmlformats-officedocument.presentationml.presentation, + "! application/msword, + "! application/vnd.openxmlformats-officedocument.wordprocessingml.document, + "! application/vnd.oasis.opendocument.spreadsheet, + "! application/vnd.oasis.opendocument.presentation, + "! application/vnd.oasis.opendocument.text, application/pdf, application/rtf, + "! text/html, text/json, text/plain, text/richtext, text/rtf, or text/xml. A + "! character encoding can be specified by including a `charset` parameter. For + "! example, 'text/html;charset=utf-8'. + "! @parameter E_RESPONSE | + "! Service return value of type FILE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_TRANSLATED_DOCUMENT + importing + !I_DOCUMENT_ID type STRING + !I_ACCEPT type STRING optional + exporting + !E_RESPONSE type FILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_LANG_TRANSLATOR_V3 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Language Translator'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/language-translator/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092819'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->TRANSLATE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_REQUEST TYPE T_TRANSLATE_REQUEST +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRANSLATION_RESULT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TRANSLATE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/translate'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_REQUEST ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_REQUEST i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'request' i_value = i_REQUEST ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_REQUEST to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->LIST_IDENTIFIABLE_LANGUAGES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_IDENTIFIABLE_LANGUAGES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_IDENTIFIABLE_LANGUAGES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/identifiable_languages'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->IDENTIFY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_TEXT TYPE STRING +* | [--->] I_contenttype TYPE string (default ='text/plain') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_IDENTIFIED_LANGUAGES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method IDENTIFY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/identify'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_TEXT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TEXT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'text' i_value = i_TEXT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TEXT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->LIST_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_SOURCE TYPE STRING(optional) +* | [--->] I_TARGET TYPE STRING(optional) +* | [--->] I_DEFAULT TYPE BOOLEAN(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRANSLATION_MODELS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/models'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_SOURCE is supplied. + lv_queryparam = escape( val = i_SOURCE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `source` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TARGET is supplied. + lv_queryparam = escape( val = i_TARGET format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `target` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_DEFAULT is supplied. + lv_queryparam = i_DEFAULT. + add_query_parameter( + exporting + i_parameter = `default` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->CREATE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_BASE_MODEL_ID TYPE STRING +* | [--->] I_FORCED_GLOSSARY TYPE FILE(optional) +* | [--->] I_PARALLEL_CORPUS TYPE FILE(optional) +* | [--->] I_NAME TYPE STRING(optional) +* | [--->] I_FORCED_GLOSSARY_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_PARALLEL_CORPUS_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRANSLATION_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/models'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_BASE_MODEL_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `base_model_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_NAME is supplied. + lv_queryparam = escape( val = i_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_FORCED_GLOSSARY is initial. + lv_extension = get_file_extension( I_FORCED_GLOSSARY_CT ). + lv_value = `form-data; name="forced_glossary"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_FORCED_GLOSSARY_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FORCED_GLOSSARY. + append ls_form_part to lt_form_part. + endif. + + if not i_PARALLEL_CORPUS is initial. + lv_extension = get_file_extension( I_PARALLEL_CORPUS_CT ). + lv_value = `form-data; name="parallel_corpus"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_PARALLEL_CORPUS_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_PARALLEL_CORPUS. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->DELETE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_MODEL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_MODEL_RESULT +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/models/{model_id}'. + replace all occurrences of `{model_id}` in ls_request_prop-url-path with i_MODEL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_MODEL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRANSLATION_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/models/{model_id}'. + replace all occurrences of `{model_id}` in ls_request_prop-url-path with i_MODEL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->LIST_DOCUMENTS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_DOCUMENTS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/documents'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->TRANSLATE_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_FILE TYPE FILE +* | [--->] I_FILENAME TYPE STRING +* | [--->] I_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_MODEL_ID TYPE STRING(optional) +* | [--->] I_SOURCE TYPE STRING(optional) +* | [--->] I_TARGET TYPE STRING(optional) +* | [--->] I_DOCUMENT_ID TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TRANSLATE_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/documents'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_MODEL_ID is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="model_id"' ##NO_TEXT. + lv_formdata = i_MODEL_ID. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_SOURCE is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="source"' ##NO_TEXT. + lv_formdata = i_SOURCE. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_TARGET is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="target"' ##NO_TEXT. + lv_formdata = i_TARGET. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_DOCUMENT_ID is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="document_id"' ##NO_TEXT. + lv_formdata = i_DOCUMENT_ID. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_FILE is initial. + if not I_filename is initial. + lv_value = `form-data; name="file"; filename="` && I_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_file_content_type ). + lv_value = `form-data; name="file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_DOCUMENT_STATUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DOCUMENT_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_DOCUMENT_STATUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/documents/{document_id}'. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->DELETE_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/documents/{document_id}'. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_LANG_TRANSLATOR_V3->GET_TRANSLATED_DOCUMENT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_DOCUMENT_ID TYPE STRING +* | [--->] I_ACCEPT TYPE STRING(optional) +* | [<---] E_RESPONSE TYPE FILE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_TRANSLATED_DOCUMENT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/documents/{document_id}/translated_document'. + replace all occurrences of `{document_id}` in ls_request_prop-url-path with i_DOCUMENT_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_ACCEPT is supplied. + lv_headerparam = I_ACCEPT. + add_header_parameter( + exporting + i_parameter = 'Accept' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve file data + e_response = get_response_binary( lo_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_LANG_TRANSLATOR_V3->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_lang_translator_v3.clas.xml b/src/zcl_ibmc_lang_translator_v3.clas.xml new file mode 100644 index 0000000..6f47e3f --- /dev/null +++ b/src/zcl_ibmc_lang_translator_v3.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_LANG_TRANSLATOR_V3 + E + IBM Watson Language Translator + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_nat_lang_class_v1.clas.abap b/src/zcl_ibmc_nat_lang_class_v1.clas.abap new file mode 100644 index 0000000..b1cc5d2 --- /dev/null +++ b/src/zcl_ibmc_nat_lang_class_v1.clas.abap @@ -0,0 +1,792 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! 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.
+class ZCL_IBMC_NAT_LANG_CLASS_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Response payload for HTTP errors. + begin of T_ERROR_RESPONSE, + "! HTTP status code. + CODE type INTEGER, + "! Error name. + ERROR type STRING, + "! Error description. + DESCRIPTION type STRING, + end of T_ERROR_RESPONSE. + types: + "! Request payload to classify. + begin of T_CLASSIFY_INPUT, + "! The submitted phrase. The maximum length is 2048 characters. + TEXT type STRING, + end of T_CLASSIFY_INPUT. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! 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`). + TRAINING_METADATA type FILE, + "! Training data in CSV format. Each text value must have at least one class. The + "! data can include up to 3,000 classes and 20,000 records. For details, see [Data + "! preparation](https://cloud.ibm.com/docs/natural-language-classifier?topic=natur + "! al-language-classifier-using-your-data). + TRAINING_DATA type FILE, + end of T_INLINE_OBJECT. + types: + "! Class and confidence. + begin of T_CLASSIFIED_CLASS, + "! A decimal percentage that represents the confidence that Watson has in this + "! class. Higher values represent higher confidences. + CONFIDENCE type DOUBLE, + "! Class label. + CLASS_NAME type STRING, + end of T_CLASSIFIED_CLASS. + types: + "! Response from the classifier for a phrase in a collection. + begin of T_COLLECTION_ITEM, + "! The submitted phrase. The maximum length is 2048 characters. + TEXT type STRING, + "! The class with the highest confidence. + TOP_CLASS type STRING, + "! An array of up to ten class-confidence pairs sorted in descending order of + "! confidence. + CLASSES type STANDARD TABLE OF T_CLASSIFIED_CLASS WITH NON-UNIQUE DEFAULT KEY, + end of T_COLLECTION_ITEM. + types: + "! A classifier for natural language phrases. + begin of T_CLASSIFIER, + "! User-supplied name for the classifier. + NAME type STRING, + "! Link to the classifier. + URL type STRING, + "! The state of the classifier. + STATUS type STRING, + "! Unique identifier for this classifier. + CLASSIFIER_ID type STRING, + "! Date and time (UTC) the classifier was created. + CREATED type DATETIME, + "! Additional detail about the status. + STATUS_DESCRIPTION type STRING, + "! The language used for the classifier. + LANGUAGE type STRING, + end of T_CLASSIFIER. + types: + "! List of available classifiers. + begin of T_CLASSIFIER_LIST, + "! The classifiers available to the user. Returns an empty array if no classifiers + "! are available. + CLASSIFIERS type STANDARD TABLE OF T_CLASSIFIER WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFIER_LIST. + types: + "! Response from the classifier for a phrase. + begin of T_CLASSIFICATION, + "! Unique identifier for this classifier. + CLASSIFIER_ID type STRING, + "! Link to the classifier. + URL type STRING, + "! The submitted phrase. + TEXT type STRING, + "! The class with the highest confidence. + TOP_CLASS type STRING, + "! An array of up to ten class-confidence pairs sorted in descending order of + "! confidence. + CLASSES type STANDARD TABLE OF T_CLASSIFIED_CLASS WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFICATION. + types: + "! Request payload to classify. + begin of T_CLASSIFY_COLLECTION_INPUT, + "! The submitted phrases. + COLLECTION type STANDARD TABLE OF T_CLASSIFY_INPUT WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFY_COLLECTION_INPUT. + types: + "! Response payload for Cloud errors. + begin of T_ERROR_CLOUD, + "! HTTP status code. + CODE type INTEGER, + "! Error name. + ERROR type STRING, + end of T_ERROR_CLOUD. + types: + "! No documentation available. + T_EMPTY type JSONOBJECT. + types: + "! Response from the classifier for multiple phrases. + begin of T_CLASSIFICATION_COLLECTION, + "! Unique identifier for this classifier. + CLASSIFIER_ID type STRING, + "! Link to the classifier. + URL type STRING, + "! An array of classifier responses for each submitted phrase. + COLLECTION type STANDARD TABLE OF T_COLLECTION_ITEM WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFICATION_COLLECTION. + +constants: + begin of C_REQUIRED_FIELDS, + T_ERROR_RESPONSE type string value '|', + T_CLASSIFY_INPUT type string value '|TEXT|', + T_INLINE_OBJECT type string value '|TRAINING_METADATA|TRAINING_DATA|', + T_CLASSIFIED_CLASS type string value '|', + T_COLLECTION_ITEM type string value '|', + T_CLASSIFIER type string value '|URL|CLASSIFIER_ID|', + T_CLASSIFIER_LIST type string value '|CLASSIFIERS|', + T_CLASSIFICATION type string value '|', + T_CLASSIFY_COLLECTION_INPUT type string value '|COLLECTION|', + T_ERROR_CLOUD type string value '|', + T_CLASSIFICATION_COLLECTION type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + CODE type string value 'code', + ERROR type string value 'error', + DESCRIPTION type string value 'description', + CLASSIFIERS type string value 'classifiers', + NAME type string value 'name', + URL type string value 'url', + STATUS type string value 'status', + CLASSIFIER_ID type string value 'classifier_id', + CREATED type string value 'created', + STATUS_DESCRIPTION type string value 'status_description', + LANGUAGE type string value 'language', + COLLECTION type string value 'collection', + TEXT type string value 'text', + TOP_CLASS type string value 'top_class', + CLASSES type string value 'classes', + CONFIDENCE type string value 'confidence', + CLASS_NAME type string value 'class_name', + CLASSIFYINPUT type string value 'classifyInput', + TRAINING_METADATA type string value 'training_metadata', + TRAINING_DATA type string value 'training_data', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Classify a phrase. + "! + "! @parameter I_CLASSIFIER_ID | + "! Classifier ID to use. + "! @parameter I_BODY | + "! Phrase to classify. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFICATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CLASSIFY + importing + !I_CLASSIFIER_ID type STRING + !I_BODY type T_CLASSIFY_INPUT + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFICATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Classify multiple phrases. + "! + "! @parameter I_CLASSIFIER_ID | + "! Classifier ID to use. + "! @parameter I_BODY | + "! Phrase to classify. You can submit up to 30 text phrases in a request. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFICATION_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CLASSIFY_COLLECTION + importing + !I_CLASSIFIER_ID type STRING + !I_BODY type T_CLASSIFY_COLLECTION_INPUT + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFICATION_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create classifier. + "! + "! @parameter I_TRAINING_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`). + "! @parameter I_TRAINING_DATA | + "! Training data in CSV format. Each text value must have at least one class. The + "! data can include up to 3,000 classes and 20,000 records. For details, see [Data + "! preparation](https://cloud.ibm.com/docs/natural-language-classifier?topic=natur + "! al-language-classifier-using-your-data). + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_CLASSIFIER + importing + !I_TRAINING_METADATA type FILE + !I_TRAINING_DATA type FILE + !I_TRAINING_METADATA_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_TRAINING_DATA_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List classifiers. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_CLASSIFIERS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get information about a classifier. + "! + "! @parameter I_CLASSIFIER_ID | + "! Classifier ID to query. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CLASSIFIER + importing + !I_CLASSIFIER_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete classifier. + "! + "! @parameter I_CLASSIFIER_ID | + "! Classifier ID to delete. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_CLASSIFIER + importing + !I_CLASSIFIER_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_NAT_LANG_CLASS_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Natural Language Classifier'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/natural-language-classifier/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092820'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CLASSIFY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_BODY TYPE T_CLASSIFY_INPUT +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFICATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CLASSIFY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers/{classifier_id}/classify'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CLASSIFY_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_BODY TYPE T_CLASSIFY_COLLECTION_INPUT +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFICATION_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CLASSIFY_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers/{classifier_id}/classify_collection'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_BODY ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_BODY i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'body' i_value = i_BODY ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_BODY to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->CREATE_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_TRAINING_METADATA TYPE FILE +* | [--->] I_TRAINING_DATA TYPE FILE +* | [--->] I_TRAINING_METADATA_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_TRAINING_DATA_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_TRAINING_METADATA is initial. + lv_extension = get_file_extension( I_TRAINING_METADATA_CT ). + lv_value = `form-data; name="training_metadata"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_TRAINING_METADATA_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_TRAINING_METADATA. + append ls_form_part to lt_form_part. + endif. + + if not i_TRAINING_DATA is initial. + lv_extension = get_file_extension( I_TRAINING_DATA_CT ). + lv_value = `form-data; name="training_data"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_TRAINING_DATA_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_TRAINING_DATA. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->LIST_CLASSIFIERS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_CLASSIFIERS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->GET_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers/{classifier_id}'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_CLASS_V1->DELETE_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/classifiers/{classifier_id}'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_NAT_LANG_CLASS_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_nat_lang_class_v1.clas.xml b/src/zcl_ibmc_nat_lang_class_v1.clas.xml new file mode 100644 index 0000000..16dc6d9 --- /dev/null +++ b/src/zcl_ibmc_nat_lang_class_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_NAT_LANG_CLASS_V1 + E + IBM Watson Natural Language Classifier + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap b/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap new file mode 100644 index 0000000..ff67b55 --- /dev/null +++ b/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap @@ -0,0 +1,1320 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! 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/services/natural-language-understanding?topi +"! c=natural-language-understanding-customizing) with Watson Knowledge Studio to +"! detect custom entities and relations in Natural Language Understanding.
+class ZCL_IBMC_NAT_LANG_UNDRSTND_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_ENTITY, + "! Entity type. + TYPE type STRING, + "! The entity text. + TEXT type STRING, + end of T_SEMANTIC_ROLES_ENTITY. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_KEYWORD, + "! The keyword text. + TEXT type STRING, + end of T_SEMANTIC_ROLES_KEYWORD. + types: + "! The extracted subject from the sentence. + begin of T_SMNTC_ROLES_RESULT_SUBJECT, + "! Text that corresponds to the subject role. + TEXT type STRING, + "! An array of extracted entities. + ENTITIES type STANDARD TABLE OF T_SEMANTIC_ROLES_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of extracted keywords. + KEYWORDS type STANDARD TABLE OF T_SEMANTIC_ROLES_KEYWORD WITH NON-UNIQUE DEFAULT KEY, + end of T_SMNTC_ROLES_RESULT_SUBJECT. + types: + "! The extracted object from the sentence. + begin of T_SEMANTIC_ROLES_RESULT_OBJECT, + "! Object text. + TEXT type STRING, + "! An array of extracted keywords. + KEYWORDS type STANDARD TABLE OF T_SEMANTIC_ROLES_KEYWORD WITH NON-UNIQUE DEFAULT KEY, + end of T_SEMANTIC_ROLES_RESULT_OBJECT. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_VERB, + "! The keyword text. + TEXT type STRING, + "! Verb tense. + TENSE type STRING, + end of T_SEMANTIC_ROLES_VERB. + types: + "! The extracted action from the sentence. + begin of T_SEMANTIC_ROLES_RESULT_ACTION, + "! Analyzed text that corresponds to the action. + TEXT type STRING, + "! normalized version of the action. + NORMALIZED type STRING, + "! No documentation available. + VERB type T_SEMANTIC_ROLES_VERB, + end of T_SEMANTIC_ROLES_RESULT_ACTION. + types: + "! The object containing the actions and the objects the actions act upon. + begin of T_SEMANTIC_ROLES_RESULT, + "! Sentence from the source that contains the subject, action, and object. + SENTENCE type STRING, + "! The extracted subject from the sentence. + SUBJECT type T_SMNTC_ROLES_RESULT_SUBJECT, + "! The extracted action from the sentence. + ACTION type T_SEMANTIC_ROLES_RESULT_ACTION, + "! The extracted object from the sentence. + OBJECT type T_SEMANTIC_ROLES_RESULT_OBJECT, + end of T_SEMANTIC_ROLES_RESULT. + types: + "! Parses sentences into subject, action, and object form.
+ "!
+ "! Supported languages: English, German, Japanese, Korean, Spanish. + begin of T_SEMANTIC_ROLES_OPTIONS, + "! Maximum number of semantic_roles results to return. + LIMIT type INTEGER, + "! Set this to `true` to return keyword information for subjects and objects. + KEYWORDS type BOOLEAN, + "! Set this to `true` to return entity information for subjects and objects. + ENTITIES type BOOLEAN, + end of T_SEMANTIC_ROLES_OPTIONS. + types: + "! Metadata associated with this custom model. + begin of T_MODEL_METADATA, + "! An optional name for the model. + NAME type STRING, + "! An optional map of metadata key-value pairs to store with this model. + USER_METADATA type MAP, + "! The language code of this model. + LANGUAGE type STRING, + "! An optional description of the model. + DESCRIPTION type STRING, + "! An optional version string. + VERSION type STRING, + "! ID of the Watson Knowledge Studio workspace that deployed this model to Natural + "! Language Understanding. + WORKSPACE_ID type STRING, + "! The description of the version. + VERSION_DESCRIPTION type STRING, + end of T_MODEL_METADATA. + types: + "! An entity that corresponds with an argument in a relation. + begin of T_RELATION_ENTITY, + "! Text that corresponds to the entity. + TEXT type STRING, + "! Entity type. + TYPE type STRING, + end of T_RELATION_ENTITY. + types: + "! No documentation available. + begin of T_RELATION_ARGUMENT, + "! An array of extracted entities. + ENTITIES type STANDARD TABLE OF T_RELATION_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! Character offsets indicating the beginning and end of the mention in the + "! analyzed text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + "! Text that corresponds to the argument. + TEXT type STRING, + end of T_RELATION_ARGUMENT. + types: + "! The relations between entities found in the content. + begin of T_RELATIONS_RESULT, + "! Confidence score for the relation. Higher values indicate greater confidence. + SCORE type DOUBLE, + "! The sentence that contains the relation. + SENTENCE type STRING, + "! The type of the relation. + TYPE type STRING, + "! Entity mentions that are involved in the relation. + ARGUMENTS type STANDARD TABLE OF T_RELATION_ARGUMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RELATIONS_RESULT. + types: + "! No documentation available. + begin of T_MODEL, + "! When the status is `available`, the model is ready to use. + STATUS type STRING, + "! Unique model ID. + MODEL_ID type STRING, + "! ISO 639-1 code indicating the language of the model. + LANGUAGE type STRING, + "! Model description. + DESCRIPTION type STRING, + "! ID of the Watson Knowledge Studio workspace that deployed this model to Natural + "! Language Understanding. + WORKSPACE_ID type STRING, + "! The model version, if it was manually provided in Watson Knowledge Studio. + VERSION type STRING, + "! The description of the version, if it was manually provided in Watson Knowledge + "! Studio. + VERSION_DESCRIPTION type STRING, + "! A dateTime indicating when the model was created. + CREATED type DATETIME, + end of T_MODEL. + types: + "! No documentation available. + begin of T_FEATURE_SENTIMENT_RESULTS, + "! Sentiment score from -1 (negative) to 1 (positive). + SCORE type DOUBLE, + end of T_FEATURE_SENTIMENT_RESULTS. + types: + "! No documentation available. + begin of T_EMOTION_SCORES, + "! Anger score from 0 to 1. A higher score means that the text is more likely to + "! convey anger. + ANGER type DOUBLE, + "! Disgust score from 0 to 1. A higher score means that the text is more likely to + "! convey disgust. + DISGUST type DOUBLE, + "! Fear score from 0 to 1. A higher score means that the text is more likely to + "! convey fear. + FEAR type DOUBLE, + "! Joy score from 0 to 1. A higher score means that the text is more likely to + "! convey joy. + JOY type DOUBLE, + "! Sadness score from 0 to 1. A higher score means that the text is more likely to + "! convey sadness. + SADNESS type DOUBLE, + end of T_EMOTION_SCORES. + types: + "! The author of the analyzed content. + begin of T_AUTHOR, + "! Name of the author. + NAME type STRING, + end of T_AUTHOR. + types: + "! RSS or ATOM feed found on the webpage. + begin of T_FEED, + "! URL of the RSS or ATOM feed. + LINK type STRING, + end of T_FEED. + types: + "! Webpage metadata, such as the author and the title of the page. + begin of T_FEATURES_RESULTS_METADATA, + "! The authors of the document. + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + "! The publication date in the format ISO 8601. + PUBLICATION_DATE type STRING, + "! The title of the document. + TITLE type STRING, + "! URL of a prominent image on the webpage. + IMAGE type STRING, + "! RSS/ATOM feeds found on the webpage. + FEEDS type STANDARD TABLE OF T_FEED WITH NON-UNIQUE DEFAULT KEY, + end of T_FEATURES_RESULTS_METADATA. + types: + "! No documentation available. + begin of T_ENTITY_MENTION, + "! Entity mention text. + TEXT type STRING, + "! Character offsets indicating the beginning and end of the mention in the + "! analyzed text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + "! Confidence in the entity identification from 0 to 1. Higher values indicate + "! higher confidence. In standard entities requests, confidence is returned only + "! for English text. All entities requests that use custom models return the + "! confidence score. + CONFIDENCE type DOUBLE, + end of T_ENTITY_MENTION. + types: + "! Disambiguation information for the entity. + begin of T_DISAMBIGUATION_RESULT, + "! Common entity name. + NAME type STRING, + "! Link to the corresponding DBpedia resource. + DBPEDIA_RESOURCE type STRING, + "! Entity subtype information. + SUBTYPE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_DISAMBIGUATION_RESULT. + types: + "! The important people, places, geopolitical entities and other types of entities + "! in your content. + begin of T_ENTITIES_RESULT, + "! Entity type. + TYPE type STRING, + "! The name of the entity. + TEXT type STRING, + "! Relevance score from 0 to 1. Higher values indicate greater relevance. + RELEVANCE type DOUBLE, + "! Confidence in the entity identification from 0 to 1. Higher values indicate + "! higher confidence. In standard entities requests, confidence is returned only + "! for English text. All entities requests that use custom models return the + "! confidence score. + CONFIDENCE type DOUBLE, + "! Entity mentions and locations. + MENTIONS type STANDARD TABLE OF T_ENTITY_MENTION WITH NON-UNIQUE DEFAULT KEY, + "! How many times the entity was mentioned in the text. + COUNT type INTEGER, + "! Emotion analysis results for the entity, enabled with the `emotion` option. + EMOTION type T_EMOTION_SCORES, + "! Sentiment analysis results for the entity, enabled with the `sentiment` option. + SENTIMENT type T_FEATURE_SENTIMENT_RESULTS, + "! Disambiguation information for the entity. + DISAMBIGUATION type T_DISAMBIGUATION_RESULT, + end of T_ENTITIES_RESULT. + types: + "! Emotion results for a specified target. + begin of T_TARGETED_EMOTION_RESULTS, + "! Targeted text. + TEXT type STRING, + "! The emotion results for the target. + EMOTION type T_EMOTION_SCORES, + end of T_TARGETED_EMOTION_RESULTS. + types: + "! The important keywords in the content, organized by relevance. + begin of T_KEYWORDS_RESULT, + "! Number of times the keyword appears in the analyzed text. + COUNT type INTEGER, + "! Relevance score from 0 to 1. Higher values indicate greater relevance. + RELEVANCE type DOUBLE, + "! The keyword text. + TEXT type STRING, + "! Emotion analysis results for the keyword, enabled with the `emotion` option. + EMOTION type T_EMOTION_SCORES, + "! Sentiment analysis results for the keyword, enabled with the `sentiment` option. + "! + SENTIMENT type T_FEATURE_SENTIMENT_RESULTS, + end of T_KEYWORDS_RESULT. + types: + "! No documentation available. + begin of T_TARGETED_SENTIMENT_RESULTS, + "! Targeted text. + TEXT type STRING, + "! Sentiment score from -1 (negative) to 1 (positive). + SCORE type DOUBLE, + end of T_TARGETED_SENTIMENT_RESULTS. + types: + "! Relevant text that contributed to the categorization. + begin of T_CATEGORIES_RELEVANT_TEXT, + "! Text from the analyzed source that supports the categorization. + TEXT type STRING, + end of T_CATEGORIES_RELEVANT_TEXT. + types: + "! Emotion results for the document as a whole. + begin of T_DOCUMENT_EMOTION_RESULTS, + "! Emotion results for the document as a whole. + EMOTION type T_EMOTION_SCORES, + end of T_DOCUMENT_EMOTION_RESULTS. + types: + "! No documentation available. + begin of T_DOCUMENT_SENTIMENT_RESULTS, + "! Indicates whether the sentiment is positive, neutral, or negative. + LABEL type STRING, + "! Sentiment score from -1 (negative) to 1 (positive). + SCORE type DOUBLE, + end of T_DOCUMENT_SENTIMENT_RESULTS. + types: + "! The sentiment of the content. + begin of T_SENTIMENT_RESULT, + "! The document level sentiment. + DOCUMENT type T_DOCUMENT_SENTIMENT_RESULTS, + "! The targeted sentiment to analyze. + TARGETS type STANDARD TABLE OF T_TARGETED_SENTIMENT_RESULTS WITH NON-UNIQUE DEFAULT KEY, + end of T_SENTIMENT_RESULT. + types: + "! No documentation available. + begin of T_TOKEN_RESULT, + "! The token as it appears in the analyzed text. + TEXT type STRING, + "! The part of speech of the token. For descriptions of the values, see [Universal + "! Dependencies POS tags](https://universaldependencies.org/u/pos/). + PART_OF_SPEECH type STRING, + "! Character offsets indicating the beginning and end of the token in the analyzed + "! text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + "! The [lemma](https://wikipedia.org/wiki/Lemma_%28morphology%29) of the token. + LEMMA type STRING, + end of T_TOKEN_RESULT. + types: + "! No documentation available. + begin of T_SENTENCE_RESULT, + "! The sentence. + TEXT type STRING, + "! Character offsets indicating the beginning and end of the sentence in the + "! analyzed text. + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_SENTENCE_RESULT. + types: + "! Tokens and sentences returned from syntax analysis. + begin of T_SYNTAX_RESULT, + "! No documentation available. + TOKENS type STANDARD TABLE OF T_TOKEN_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! No documentation available. + SENTENCES type STANDARD TABLE OF T_SENTENCE_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_SYNTAX_RESULT. + types: + "! The general concepts referenced or alluded to in the analyzed text. + begin of T_CONCEPTS_RESULT, + "! Name of the concept. + TEXT type STRING, + "! Relevance score between 0 and 1. Higher scores indicate greater relevance. + RELEVANCE type DOUBLE, + "! Link to the corresponding DBpedia resource. + DBPEDIA_RESOURCE type STRING, + end of T_CONCEPTS_RESULT. + types: + "! Information that helps to explain what contributed to the categories result. + begin of T_CTGRS_RESULT_EXPLANATION, + "! 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. + RELEVANT_TEXT type STANDARD TABLE OF T_CATEGORIES_RELEVANT_TEXT WITH NON-UNIQUE DEFAULT KEY, + end of T_CTGRS_RESULT_EXPLANATION. + types: + "! A categorization of the analyzed text. + begin of T_CATEGORIES_RESULT, + "! The path to the category through the 5-level taxonomy hierarchy. For the + "! complete list of categories, see the [Categories + "! hierarchy](https://cloud.ibm.com/docs/services/natural-language-understanding?t + "! opic=natural-language-understanding-categories#categories-hierarchy) + "! documentation. + LABEL type STRING, + "! Confidence score for the category classification. Higher values indicate greater + "! confidence. + SCORE type DOUBLE, + "! Information that helps to explain what contributed to the categories result. + EXPLANATION type T_CTGRS_RESULT_EXPLANATION, + end of T_CATEGORIES_RESULT. + types: + "! 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. + begin of T_EMOTION_RESULT, + "! Emotion results for the document as a whole. + DOCUMENT type T_DOCUMENT_EMOTION_RESULTS, + "! Emotion results for specified targets. + TARGETS type STANDARD TABLE OF T_TARGETED_EMOTION_RESULTS WITH NON-UNIQUE DEFAULT KEY, + end of T_EMOTION_RESULT. + types: + "! Analysis results for each requested feature. + begin of T_FEATURES_RESULTS, + "! The general concepts referenced or alluded to in the analyzed text. + CONCEPTS type STANDARD TABLE OF T_CONCEPTS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The entities detected in the analyzed text. + ENTITIES type STANDARD TABLE OF T_ENTITIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The keywords from the analyzed text. + KEYWORDS type STANDARD TABLE OF T_KEYWORDS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The categories that the service assigned to the analyzed text. + CATEGORIES type STANDARD TABLE OF T_CATEGORIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The anger, disgust, fear, joy, or sadness conveyed by the content. + EMOTION type T_EMOTION_RESULT, + "! Webpage metadata, such as the author and the title of the page. + METADATA type T_FEATURES_RESULTS_METADATA, + "! The relationships between entities in the content. + RELATIONS type STANDARD TABLE OF T_RELATIONS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! Sentences parsed into `subject`, `action`, and `object` form. + SEMANTIC_ROLES type STANDARD TABLE OF T_SEMANTIC_ROLES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The sentiment of the content. + SENTIMENT type T_SENTIMENT_RESULT, + "! Tokens and sentences returned from syntax analysis. + SYNTAX type T_SYNTAX_RESULT, + end of T_FEATURES_RESULTS. + types: + "! The authors, publication date, title, prominent page image, and RSS/ATOM feeds + "! of the webpage. Supports URL and HTML input types. + begin of T_METADATA_RESULT, + "! The authors of the document. + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + "! The publication date in the format ISO 8601. + PUBLICATION_DATE type STRING, + "! The title of the document. + TITLE type STRING, + "! URL of a prominent image on the webpage. + IMAGE type STRING, + "! RSS/ATOM feeds found on the webpage. + FEEDS type STANDARD TABLE OF T_FEED WITH NON-UNIQUE DEFAULT KEY, + end of T_METADATA_RESULT. + types: + "! No documentation available. + begin of T_ERROR_RESPONSE, + "! The HTTP error status code. + CODE type INTEGER, + "! A message describing the error. + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! 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. + begin of T_EMOTION_OPTIONS, + "! Set this to `false` to hide document-level emotion results. + DOCUMENT type BOOLEAN, + "! Emotion results will be returned for each target string that is found in the + "! document. + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_EMOTION_OPTIONS. + types: + "! Usage information. + begin of T_USAGE, + "! Number of features used in the API call. + FEATURES type INTEGER, + "! Number of text characters processed. + TEXT_CHARACTERS type INTEGER, + "! Number of 10,000-character units processed. + TEXT_UNITS type INTEGER, + end of T_USAGE. + types: + "! 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. + begin of T_SENTIMENT_OPTIONS, + "! Set this to `false` to hide document-level sentiment results. + DOCUMENT type BOOLEAN, + "! Sentiment results will be returned for each target string that is found in the + "! document. + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SENTIMENT_OPTIONS. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_ACTION, + "! Analyzed text that corresponds to the action. + TEXT type STRING, + "! normalized version of the action. + NORMALIZED type STRING, + "! No documentation available. + VERB type T_SEMANTIC_ROLES_VERB, + end of T_SEMANTIC_ROLES_ACTION. + types: + "! Tokenization options. + begin of T_SYNTAX_OPTIONS_TOKENS, + "! Set this to `true` to return the lemma for each token. + LEMMA type BOOLEAN, + "! Set this to `true` to return the part of speech for each token. + PART_OF_SPEECH type BOOLEAN, + end of T_SYNTAX_OPTIONS_TOKENS. + types: + "! Returns important keywords in the content.
+ "!
+ "! Supported languages: English, French, German, Italian, Japanese, Korean, + "! Portuguese, Russian, Spanish, Swedish. + begin of T_KEYWORDS_OPTIONS, + "! Maximum number of keywords to return. + LIMIT type INTEGER, + "! Set this to `true` to return sentiment information for detected keywords. + SENTIMENT type BOOLEAN, + "! Set this to `true` to analyze emotion for detected keywords. + EMOTION type BOOLEAN, + end of T_KEYWORDS_OPTIONS. + types: + "! Recognizes when two entities are related and identifies the type of relation. + "! For example, an `awardedTo` relation might connect the entities "Nobel Prize" + "! and "Albert Einstein". See [Relation + "! types](https://cloud.ibm.com/docs/services/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. + begin of T_RELATIONS_OPTIONS, + "! Enter a [custom + "! model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic + "! =natural-language-understanding-customizing) ID to override the default model. + MODEL type STRING, + end of T_RELATIONS_OPTIONS. + types: + "! Identifies people, cities, organizations, and other entities in the content. See + "! [Entity types and + "! subtypes](https://cloud.ibm.com/docs/services/natural-language-understanding?to + "! pic=natural-language-understanding-entity-types).
+ "!
+ "! Supported languages: English, French, German, Italian, Japanese, Korean, + "! Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported + "! only through custom models. + begin of T_ENTITIES_OPTIONS, + "! Maximum number of entities to return. + LIMIT type INTEGER, + "! Set this to `true` to return locations of entity mentions. + MENTIONS type BOOLEAN, + "! Enter a [custom + "! model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic + "! =natural-language-understanding-customizing) ID to override the standard entity + "! detection model. + MODEL type STRING, + "! Set this to `true` to return sentiment information for detected entities. + SENTIMENT type BOOLEAN, + "! Set this to `true` to analyze emotion for detected keywords. + EMOTION type BOOLEAN, + end of T_ENTITIES_OPTIONS. + types: + "! 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. + begin of T_CONCEPTS_OPTIONS, + "! Maximum number of concepts to return. + LIMIT type INTEGER, + end of T_CONCEPTS_OPTIONS. + types: + "! 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. + T_METADATA_OPTIONS type JSONOBJECT. + types: + "! Returns tokens and sentences from the input text. + begin of T_SYNTAX_OPTIONS, + "! Tokenization options. + TOKENS type T_SYNTAX_OPTIONS_TOKENS, + "! Set this to `true` to return sentence information. + SENTENCES type BOOLEAN, + end of T_SYNTAX_OPTIONS. + types: + "! Returns a five-level taxonomy of the content. The top three categories are + "! returned.
+ "!
+ "! Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, + "! Portuguese, Spanish. + begin of T_CATEGORIES_OPTIONS, + "! Set this to `true` to return explanations for each categorization. **This is + "! available only for English categories.**. + EXPLANATION type BOOLEAN, + "! Maximum number of categories to return. + LIMIT type INTEGER, + "! Enter a [custom + "! model](https://cloud.ibm.com/docs/services/natural-language-understanding?topic + "! =natural-language-understanding-customizing) ID to override the standard + "! categories model.
+ "!
+ "! The custom categories experimental feature will be retired on 19 December 2019. + "! On that date, deployed custom categories models will no longer be accessible in + "! Natural Language Understanding. The feature will be removed from Knowledge + "! Studio on an earlier date. Custom categories models will no longer be + "! accessible in Knowledge Studio on 17 December 2019. + MODEL type STRING, + end of T_CATEGORIES_OPTIONS. + types: + "! Analysis features and options. + begin of T_FEATURES, + "! 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. + CONCEPTS type T_CONCEPTS_OPTIONS, + "! 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. + EMOTION type T_EMOTION_OPTIONS, + "! Identifies people, cities, organizations, and other entities in the content. See + "! [Entity types and + "! subtypes](https://cloud.ibm.com/docs/services/natural-language-understanding?to + "! pic=natural-language-understanding-entity-types).
+ "!
+ "! Supported languages: English, French, German, Italian, Japanese, Korean, + "! Portuguese, Russian, Spanish, Swedish. Arabic, Chinese, and Dutch are supported + "! only through custom models. + ENTITIES type T_ENTITIES_OPTIONS, + "! Returns important keywords in the content.
+ "!
+ "! Supported languages: English, French, German, Italian, Japanese, Korean, + "! Portuguese, Russian, Spanish, Swedish. + KEYWORDS type T_KEYWORDS_OPTIONS, + "! 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. + METADATA type T_METADATA_OPTIONS, + "! Recognizes when two entities are related and identifies the type of relation. + "! For example, an `awardedTo` relation might connect the entities "Nobel Prize" + "! and "Albert Einstein". See [Relation + "! types](https://cloud.ibm.com/docs/services/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. + RELATIONS type T_RELATIONS_OPTIONS, + "! Parses sentences into subject, action, and object form.
+ "!
+ "! Supported languages: English, German, Japanese, Korean, Spanish. + SEMANTIC_ROLES type T_SEMANTIC_ROLES_OPTIONS, + "! 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. + SENTIMENT type T_SENTIMENT_OPTIONS, + "! Returns a five-level taxonomy of the content. The top three categories are + "! returned.
+ "!
+ "! Supported languages: Arabic, English, French, German, Italian, Japanese, Korean, + "! Portuguese, Spanish. + CATEGORIES type T_CATEGORIES_OPTIONS, + "! Returns tokens and sentences from the input text. + SYNTAX type T_SYNTAX_OPTIONS, + end of T_FEATURES. + types: + "! Webpage metadata, such as the author and the title of the page. + begin of T_ANALYSIS_RESULTS_METADATA, + "! The authors of the document. + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + "! The publication date in the format ISO 8601. + PUBLICATION_DATE type STRING, + "! The title of the document. + TITLE type STRING, + "! URL of a prominent image on the webpage. + IMAGE type STRING, + "! RSS/ATOM feeds found on the webpage. + FEEDS type STANDARD TABLE OF T_FEED WITH NON-UNIQUE DEFAULT KEY, + end of T_ANALYSIS_RESULTS_METADATA. + types: + "! API usage information for the request. + begin of T_ANALYSIS_RESULTS_USAGE, + "! Number of features used in the API call. + FEATURES type INTEGER, + "! Number of text characters processed. + TEXT_CHARACTERS type INTEGER, + "! Number of 10,000-character units processed. + TEXT_UNITS type INTEGER, + end of T_ANALYSIS_RESULTS_USAGE. + types: + "! Results of the analysis, organized by feature. + begin of T_ANALYSIS_RESULTS, + "! Language used to analyze the text. + LANGUAGE type STRING, + "! Text that was used in the analysis. + ANALYZED_TEXT type STRING, + "! URL of the webpage that was analyzed. + RETRIEVED_URL type STRING, + "! API usage information for the request. + USAGE type T_ANALYSIS_RESULTS_USAGE, + "! The general concepts referenced or alluded to in the analyzed text. + CONCEPTS type STANDARD TABLE OF T_CONCEPTS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The entities detected in the analyzed text. + ENTITIES type STANDARD TABLE OF T_ENTITIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The keywords from the analyzed text. + KEYWORDS type STANDARD TABLE OF T_KEYWORDS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The categories that the service assigned to the analyzed text. + CATEGORIES type STANDARD TABLE OF T_CATEGORIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The anger, disgust, fear, joy, or sadness conveyed by the content. + EMOTION type T_EMOTION_RESULT, + "! Webpage metadata, such as the author and the title of the page. + METADATA type T_ANALYSIS_RESULTS_METADATA, + "! The relationships between entities in the content. + RELATIONS type STANDARD TABLE OF T_RELATIONS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! Sentences parsed into `subject`, `action`, and `object` form. + SEMANTIC_ROLES type STANDARD TABLE OF T_SEMANTIC_ROLES_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! The sentiment of the content. + SENTIMENT type T_SENTIMENT_RESULT, + "! Tokens and sentences returned from syntax analysis. + SYNTAX type T_SYNTAX_RESULT, + end of T_ANALYSIS_RESULTS. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_SUBJECT, + "! Text that corresponds to the subject role. + TEXT type STRING, + "! An array of extracted entities. + ENTITIES type STANDARD TABLE OF T_SEMANTIC_ROLES_ENTITY WITH NON-UNIQUE DEFAULT KEY, + "! An array of extracted keywords. + KEYWORDS type STANDARD TABLE OF T_SEMANTIC_ROLES_KEYWORD WITH NON-UNIQUE DEFAULT KEY, + end of T_SEMANTIC_ROLES_SUBJECT. + types: + "! Custom models that are available for entities and relations. + begin of T_LIST_MODELS_RESULTS, + "! An array of available models. + MODELS type STANDARD TABLE OF T_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_MODELS_RESULTS. + types: + "! No documentation available. + begin of T_SEMANTIC_ROLES_OBJECT, + "! Object text. + TEXT type STRING, + "! An array of extracted keywords. + KEYWORDS type STANDARD TABLE OF T_SEMANTIC_ROLES_KEYWORD WITH NON-UNIQUE DEFAULT KEY, + end of T_SEMANTIC_ROLES_OBJECT. + types: + "! An object containing request parameters. + begin of T_PARAMETERS, + "! The plain text to analyze. One of the `text`, `html`, or `url` parameters is + "! required. + TEXT type STRING, + "! The HTML file to analyze. One of the `text`, `html`, or `url` parameters is + "! required. + HTML type STRING, + "! The webpage to analyze. One of the `text`, `html`, or `url` parameters is + "! required. + URL type STRING, + "! Specific features to analyze the document for. + FEATURES type T_FEATURES, + "! Set this to `false` to disable webpage cleaning. To learn more about webpage + "! cleaning, see the [Analyzing + "! webpages](https://cloud.ibm.com/docs/services/natural-language-understanding?to + "! pic=natural-language-understanding-analyzing-webpages) documentation. + CLEAN type BOOLEAN, + "! An [XPath + "! query](https://cloud.ibm.com/docs/services/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`. + XPATH type STRING, + "! Whether to use raw HTML content if text cleaning fails. + FALLBACK_TO_RAW type BOOLEAN, + "! Whether or not to return the analyzed text. + RETURN_ANALYZED_TEXT type BOOLEAN, + "! ISO 639-1 code that specifies the language of your text. This overrides + "! automatic language detection. Language support differs depending on the + "! features you include in your analysis. See [Language + "! support](https://cloud.ibm.com/docs/services/natural-language-understanding?top + "! ic=natural-language-understanding-language-support) for more information. + LANGUAGE type STRING, + "! Sets the maximum number of characters that are processed by the service. + LIMIT_TEXT_CHARACTERS type INTEGER, + end of T_PARAMETERS. + types: + "! Link to the corresponding DBpedia resource. + T_DBPEDIA_RESOURCE type String. + types: + "! Metadata associated with this custom model. + begin of T_MODEL_FILE_AND_METADATA, + "! An optional name for the model. + NAME type STRING, + "! An optional map of metadata key-value pairs to store with this model. + USER_METADATA type MAP, + "! The language code of this model. + LANGUAGE type STRING, + "! An optional description of the model. + DESCRIPTION type STRING, + "! An optional version string. + VERSION type STRING, + "! ID of the Watson Knowledge Studio workspace that deployed this model to Natural + "! Language Understanding. + WORKSPACE_ID type STRING, + "! The description of the version. + VERSION_DESCRIPTION type STRING, + "! No documentation available. + FILE type FILE, + end of T_MODEL_FILE_AND_METADATA. + types: + "! Delete model results. + begin of T_DELETE_MODEL_RESULTS, + "! model_id of the deleted model. + DELETED type STRING, + end of T_DELETE_MODEL_RESULTS. + +constants: + begin of C_REQUIRED_FIELDS, + T_SEMANTIC_ROLES_ENTITY type string value '|', + T_SEMANTIC_ROLES_KEYWORD type string value '|', + T_SMNTC_ROLES_RESULT_SUBJECT type string value '|', + T_SEMANTIC_ROLES_RESULT_OBJECT type string value '|', + T_SEMANTIC_ROLES_VERB type string value '|', + T_SEMANTIC_ROLES_RESULT_ACTION type string value '|', + T_SEMANTIC_ROLES_RESULT type string value '|', + T_SEMANTIC_ROLES_OPTIONS type string value '|', + T_MODEL_METADATA type string value '|LANGUAGE|', + T_RELATION_ENTITY type string value '|', + T_RELATION_ARGUMENT type string value '|', + T_RELATIONS_RESULT type string value '|', + T_MODEL type string value '|', + T_FEATURE_SENTIMENT_RESULTS type string value '|', + T_EMOTION_SCORES type string value '|', + T_AUTHOR type string value '|', + T_FEED type string value '|', + T_FEATURES_RESULTS_METADATA type string value '|', + T_ENTITY_MENTION type string value '|', + T_DISAMBIGUATION_RESULT type string value '|', + T_ENTITIES_RESULT type string value '|', + T_TARGETED_EMOTION_RESULTS type string value '|', + T_KEYWORDS_RESULT type string value '|', + T_TARGETED_SENTIMENT_RESULTS type string value '|', + T_CATEGORIES_RELEVANT_TEXT type string value '|', + T_DOCUMENT_EMOTION_RESULTS type string value '|', + T_DOCUMENT_SENTIMENT_RESULTS type string value '|', + T_SENTIMENT_RESULT type string value '|', + T_TOKEN_RESULT type string value '|', + T_SENTENCE_RESULT type string value '|', + T_SYNTAX_RESULT type string value '|', + T_CONCEPTS_RESULT type string value '|', + T_CTGRS_RESULT_EXPLANATION type string value '|', + T_CATEGORIES_RESULT type string value '|', + T_EMOTION_RESULT type string value '|', + T_FEATURES_RESULTS type string value '|', + T_METADATA_RESULT type string value '|', + T_ERROR_RESPONSE type string value '|CODE|ERROR|', + T_EMOTION_OPTIONS type string value '|', + T_USAGE type string value '|', + T_SENTIMENT_OPTIONS type string value '|', + T_SEMANTIC_ROLES_ACTION type string value '|', + T_SYNTAX_OPTIONS_TOKENS type string value '|', + T_KEYWORDS_OPTIONS type string value '|', + T_RELATIONS_OPTIONS type string value '|', + T_ENTITIES_OPTIONS type string value '|', + T_CONCEPTS_OPTIONS type string value '|', + T_SYNTAX_OPTIONS type string value '|', + T_CATEGORIES_OPTIONS type string value '|', + T_FEATURES type string value '|', + T_ANALYSIS_RESULTS_METADATA type string value '|', + T_ANALYSIS_RESULTS_USAGE type string value '|', + T_ANALYSIS_RESULTS type string value '|', + T_SEMANTIC_ROLES_SUBJECT type string value '|', + T_LIST_MODELS_RESULTS type string value '|', + T_SEMANTIC_ROLES_OBJECT type string value '|', + T_PARAMETERS type string value '|FEATURES|', + T_MODEL_FILE_AND_METADATA type string value '|LANGUAGE|FILE|', + T_DELETE_MODEL_RESULTS type string value '|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + TEXT type string value 'text', + HTML type string value 'html', + URL type string value 'url', + FEATURES type string value 'features', + CLEAN type string value 'clean', + XPATH type string value 'xpath', + FALLBACK_TO_RAW type string value 'fallback_to_raw', + RETURN_ANALYZED_TEXT type string value 'return_analyzed_text', + LANGUAGE type string value 'language', + LIMIT_TEXT_CHARACTERS type string value 'limit_text_characters', + CONCEPTS type string value 'concepts', + EMOTION type string value 'emotion', + ENTITIES type string value 'entities', + KEYWORDS type string value 'keywords', + METADATA type string value 'metadata', + RELATIONS type string value 'relations', + SEMANTIC_ROLES type string value 'semantic_roles', + SENTIMENT type string value 'sentiment', + CATEGORIES type string value 'categories', + SYNTAX type string value 'syntax', + MODELS type string value 'models', + DELETED type string value 'deleted', + STATUS type string value 'status', + MODEL_ID type string value 'model_id', + DESCRIPTION type string value 'description', + WORKSPACE_ID type string value 'workspace_id', + VERSION type string value 'version', + VERSION_DESCRIPTION type string value 'version_description', + CREATED type string value 'created', + NAME type string value 'name', + USER_METADATA type string value 'user_metadata', + INNER type string value 'inner', + FILE type string value 'file', + ANALYZED_TEXT type string value 'analyzed_text', + RETRIEVED_URL type string value 'retrieved_url', + USAGE type string value 'usage', + SEMANTICROLES type string value 'semanticRoles', + TEXT_CHARACTERS type string value 'text_characters', + TEXT_UNITS type string value 'text_units', + RELEVANCE type string value 'relevance', + DBPEDIA_RESOURCE type string value 'dbpedia_resource', + SUBTYPE type string value 'subtype', + TYPE type string value 'type', + CONFIDENCE type string value 'confidence', + MENTIONS type string value 'mentions', + COUNT type string value 'count', + DISAMBIGUATION type string value 'disambiguation', + LOCATION type string value 'location', + LABEL type string value 'label', + SCORE type string value 'score', + EXPLANATION type string value 'explanation', + DOCUMENT type string value 'document', + TARGETS type string value 'targets', + ANGER type string value 'anger', + DISGUST type string value 'disgust', + FEAR type string value 'fear', + JOY type string value 'joy', + SADNESS type string value 'sadness', + AUTHORS type string value 'authors', + PUBLICATION_DATE type string value 'publication_date', + TITLE type string value 'title', + IMAGE type string value 'image', + FEEDS type string value 'feeds', + LINK type string value 'link', + SENTENCE type string value 'sentence', + ARGUMENTS type string value 'arguments', + SUBJECT type string value 'subject', + ACTION type string value 'action', + OBJECT type string value 'object', + NORMALIZED type string value 'normalized', + VERB type string value 'verb', + TENSE type string value 'tense', + TOKENS type string value 'tokens', + SENTENCES type string value 'sentences', + PART_OF_SPEECH type string value 'part_of_speech', + LEMMA type string value 'lemma', + LIMIT type string value 'limit', + MODEL type string value 'model', + CODE type string value 'code', + ERROR type string value 'error', + RELEVANT_TEXT type string value 'relevant_text', + RELEVANTTEXT type string value 'relevantText', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Analyze text. + "! + "! @parameter I_PARAMETERS | + "! An object containing request parameters. The `features` object and one of the + "! `text`, `html`, or `url` attributes are required. + "! @parameter E_RESPONSE | + "! Service return value of type T_ANALYSIS_RESULTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ANALYZE + importing + !I_PARAMETERS type T_PARAMETERS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ANALYSIS_RESULTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List models. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_LIST_MODELS_RESULTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_MODELS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LIST_MODELS_RESULTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete model. + "! + "! @parameter I_MODEL_ID | + "! Model ID of the model to delete. + "! @parameter E_RESPONSE | + "! Service return value of type T_DELETE_MODEL_RESULTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_MODEL + importing + !I_MODEL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_DELETE_MODEL_RESULTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_NAT_LANG_UNDRSTND_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Natural Language Understanding'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/natural-language-understanding/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092822'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->ANALYZE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_PARAMETERS TYPE T_PARAMETERS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ANALYSIS_RESULTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ANALYZE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/analyze'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_PARAMETERS ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_PARAMETERS i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'parameters' i_value = i_PARAMETERS ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_PARAMETERS to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->LIST_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LIST_MODELS_RESULTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/models'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->DELETE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_MODEL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_DELETE_MODEL_RESULTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/models/{model_id}'. + replace all occurrences of `{model_id}` in ls_request_prop-url-path with i_MODEL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_NAT_LANG_UNDRSTND_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.xml b/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.xml new file mode 100644 index 0000000..97d7dfc --- /dev/null +++ b/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_NAT_LANG_UNDRSTND_V1 + E + IBM Watson Natural Language Understanding + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_personal_insights_v3.clas.abap b/src/zcl_ibmc_personal_insights_v3.clas.abap new file mode 100644 index 0000000..c892aae --- /dev/null +++ b/src/zcl_ibmc_personal_insights_v3.clas.abap @@ -0,0 +1,825 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM Watson™ Personality Insights service enables applications to +"! derive insights from social media, enterprise data, or other digital +"! communications. The service uses linguistic analytics to infer individuals' +"! intrinsic personality characteristics, including Big Five, Needs, and Values, +"! from digital communications such as email, text messages, tweets, and forum +"! posts.
+"!
+"! The service can automatically infer, from potentially noisy social media, +"! portraits of individuals that reflect their personality characteristics. The +"! service can infer consumption preferences based on the results of its analysis +"! and, for JSON content that is timestamped, can report temporal behavior.
+"! * For information about the meaning of the models that the service uses to +"! describe personality characteristics, see [Personality +"! models](https://cloud.ibm.com/docs/services/personality-insights?topic=personal +"! ity-insights-models#models).
+"! * For information about the meaning of the consumption preferences, see +"! [Consumption +"! preferences](https://cloud.ibm.com/docs/services/personality-insights?topic=per +"! sonality-insights-preferences#preferences).
+"!
+"! **Note:** Request logging is disabled for the Personality Insights service. +"! Regardless of whether you set the `X-Watson-Learning-Opt-Out` request header, +"! the service does not log or retain data from requests and responses.
+class ZCL_IBMC_PERSONAL_INSIGHTS_V3 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! The characteristics that the service inferred from the input content. + begin of T_TRAIT, + "! 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. + TRAIT_ID type STRING, + "! The user-visible, localized name of the characteristic. + NAME type STRING, + "! The category of the characteristic: `personality` for Big Five personality + "! characteristics, `needs` for Needs, and `values` for Values. + CATEGORY type STRING, + "! 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. + PERCENTILE type DOUBLE, + "! 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. + RAW_SCORE type DOUBLE, + "! **`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. + SIGNIFICANT type BOOLEAN, + "! For `personality` (Big Five) dimensions, more detailed results for the facets of + "! each dimension as inferred from the input text. + CHILDREN type STANDARD TABLE OF DATA_REFERENCE WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAIT. + types: + "! The temporal behavior for the input content. + begin of T_BEHAVIOR, + "! The unique, non-localized identifier of the characteristic to which the results + "! pertain. IDs have the form `behavior_{value}`. + TRAIT_ID type STRING, + "! The user-visible, localized name of the characteristic. + NAME type STRING, + "! The category of the characteristic: `behavior` for temporal data. + CATEGORY type STRING, + "! 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. + PERCENTAGE type DOUBLE, + end of T_BEHAVIOR. + types: + "! A consumption preference that the service inferred from the input content. + begin of T_CONSUMPTION_PREFERENCES, + "! The unique, non-localized identifier of the consumption preference to which the + "! results pertain. IDs have the form + "! `consumption_preferences_{preference}`. + CONSUMPTION_PREFERENCE_ID type STRING, + "! The user-visible, localized name of the consumption preference. + NAME type STRING, + "! 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. + SCORE type DOUBLE, + end of T_CONSUMPTION_PREFERENCES. + types: + "! A warning message that is associated with the input content. + begin of T_WARNING, + "! The identifier of the warning message. + WARNING_ID type STRING, + "! 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. + MESSAGE type STRING, + end of T_WARNING. + types: + "! The consumption preferences that the service inferred from the input content. + begin of T_CNSMPTN_PREFERENCES_CATEGORY, + "! The unique, non-localized identifier of the consumption preferences category to + "! which the results pertain. IDs have the form + "! `consumption_preferences_{category}`. + CNSMPTN_PREFERENCE_CATEGORY_ID type STRING, + "! The user-visible name of the consumption preferences category. + NAME type STRING, + "! Detailed results inferred from the input text for the individual preferences of + "! the category. + CONSUMPTION_PREFERENCES type STANDARD TABLE OF T_CONSUMPTION_PREFERENCES WITH NON-UNIQUE DEFAULT KEY, + end of T_CNSMPTN_PREFERENCES_CATEGORY. + types: + "! The personality profile that the service generated for the input content. + begin of T_PROFILE, + "! The language model that was used to process the input. + PROCESSED_LANGUAGE type STRING, + "! The number of words from the input that were used to produce the profile. + WORD_COUNT type INTEGER, + "! 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. + WORD_COUNT_MESSAGE type STRING, + "! A recursive array of `Trait` objects that provides detailed results for the Big + "! Five personality characteristics (dimensions and facets) inferred from the + "! input text. + PERSONALITY type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + "! Detailed results for the Needs characteristics inferred from the input text. + NEEDS type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + "! Detailed results for the Values characteristics inferred from the input text. + VALUES type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + "! 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. + BEHAVIOR type STANDARD TABLE OF T_BEHAVIOR WITH NON-UNIQUE DEFAULT KEY, + "! 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. + CONSUMPTION_PREFERENCES type STANDARD TABLE OF T_CNSMPTN_PREFERENCES_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! An array of warning messages that are associated with the input text for the + "! request. The array is empty if the input generated no warnings. + WARNINGS type STANDARD TABLE OF T_WARNING WITH NON-UNIQUE DEFAULT KEY, + end of T_PROFILE. + types: + "! An input content item that the service is to analyze. + begin of T_CONTENT_ITEM, + "! The content that is to be analyzed. The service supports up to 20 MB of content + "! for all `ContentItem` objects combined. + CONTENT type STRING, + "! A unique identifier for this content item. + ID type STRING, + "! 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. + CREATED type LONG, + "! 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. + UPDATED type LONG, + "! 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. + CONTENTTYPE type STRING, + "! 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. + LANGUAGE type STRING, + "! The unique ID of the parent content item for this item. Used to identify + "! hierarchical relationships between posts/replies, messages/replies, and so on. + PARENTID type STRING, + "! Indicates whether this content item is a reply to another content item. + REPLY type BOOLEAN, + "! Indicates whether this content item is a forwarded/copied version of another + "! content item. + FORWARD type BOOLEAN, + end of T_CONTENT_ITEM. + types: + "! A CSV file that contains the results of the personality profile that the service + "! generated for the input content. + T_CSV_FILE type String. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + "! The HTTP status code. + CODE type INTEGER, + "! A service-specific error code. + SUB_CODE type STRING, + "! A description of the error. + ERROR type STRING, + "! A URL to documentation explaining the cause and possibly solutions for the + "! error. + HELP type STRING, + end of T_ERROR_MODEL. + types: + "! The full input content that the service is to analyze. + begin of T_CONTENT, + "! An array of `ContentItem` objects that provides the text that is to be analyzed. + "! + CONTENTITEMS type STANDARD TABLE OF T_CONTENT_ITEM WITH NON-UNIQUE DEFAULT KEY, + end of T_CONTENT. + +constants: + begin of C_REQUIRED_FIELDS, + T_TRAIT type string value '|TRAIT_ID|NAME|CATEGORY|PERCENTILE|', + T_BEHAVIOR type string value '|TRAIT_ID|NAME|CATEGORY|PERCENTAGE|', + T_CONSUMPTION_PREFERENCES type string value '|CONSUMPTION_PREFERENCE_ID|NAME|SCORE|', + T_WARNING type string value '|WARNING_ID|MESSAGE|', + T_CNSMPTN_PREFERENCES_CATEGORY type string value '|CNSMPTN_PREFERENCE_CATEGORY_ID|NAME|CONSUMPTION_PREFERENCES|', + T_PROFILE type string value '|PROCESSED_LANGUAGE|WORD_COUNT|PERSONALITY|NEEDS|VALUES|WARNINGS|', + T_CONTENT_ITEM type string value '|CONTENT|', + T_ERROR_MODEL type string value '|CODE|ERROR|', + T_CONTENT type string value '|CONTENTITEMS|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + PROCESSED_LANGUAGE type string value 'processed_language', + WORD_COUNT type string value 'word_count', + WORD_COUNT_MESSAGE type string value 'word_count_message', + PERSONALITY type string value 'personality', + NEEDS type string value 'needs', + VALUES type string value 'values', + BEHAVIOR type string value 'behavior', + CONSUMPTION_PREFERENCES type string value 'consumption_preferences', + CONSUMPTIONPREFERENCES type string value 'consumptionPreferences', + WARNINGS type string value 'warnings', + TRAIT_ID type string value 'trait_id', + NAME type string value 'name', + CATEGORY type string value 'category', + PERCENTILE type string value 'percentile', + RAW_SCORE type string value 'raw_score', + SIGNIFICANT type string value 'significant', + CHILDREN type string value 'children', + PERCENTAGE type string value 'percentage', + CNSMPTN_PREFERENCE_CATEGORY_ID type string value 'consumption_preference_category_id', + CONSUMPTION_PREFERENCE_ID type string value 'consumption_preference_id', + SCORE type string value 'score', + WARNING_ID type string value 'warning_id', + MESSAGE type string value 'message', + CONTENTITEMS type string value 'contentItems', + CONTENTITEM type string value 'contentItem', + CONTENT type string value 'content', + ID type string value 'id', + CREATED type string value 'created', + UPDATED type string value 'updated', + CONTENTTYPE type string value 'contenttype', + LANGUAGE type string value 'language', + PARENTID type string value 'parentid', + REPLY type string value 'reply', + FORWARD type string value 'forward', + CODE type string value 'code', + SUB_CODE type string value 'sub_code', + ERROR type string value 'error', + HELP type string value 'help', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Get profile. + "! + "! @parameter I_CONTENT | + "! A maximum of 20 MB of content to analyze, though the service requires much less + "! text; for more information, see [Providing sufficient + "! input](https://cloud.ibm.com/docs/services/personality-insights?topic=personali + "! ty-insights-input#sufficient). For JSON input, provide an object of type + "! `Content`. + "! @parameter I_CONTENT_TYPE | + "! The type of the input. For more information, see **Content types** in the method + "! description. + "! @parameter I_CONTENT_LANGUAGE | + "! 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**. + "! @parameter I_ACCEPT_LANGUAGE | + "! 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. + "! @parameter I_RAW_SCORES | + "! 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. + "! @parameter I_CSV_HEADERS | + "! Indicates whether column labels are returned with a CSV response. By default, no + "! column labels are returned. Applies only when the response type is CSV + "! (`text/csv`). + "! @parameter I_CONSUMPTION_PREFERENCES | + "! Indicates whether consumption preferences are returned with the results. By + "! default, no consumption preferences are returned. + "! @parameter E_RESPONSE | + "! Service return value of type T_PROFILE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods PROFILE + importing + !I_CONTENT type T_CONTENT + !I_CONTENT_TYPE type STRING default 'text/plain' + !I_CONTENT_LANGUAGE type STRING default 'en' + !I_ACCEPT_LANGUAGE type STRING default 'en' + !I_RAW_SCORES type BOOLEAN default c_boolean_false + !I_CSV_HEADERS type BOOLEAN default c_boolean_false + !I_CONSUMPTION_PREFERENCES type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_PROFILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get profile as csv. + "! + "! @parameter I_CONTENT | + "! A maximum of 20 MB of content to analyze, though the service requires much less + "! text; for more information, see [Providing sufficient + "! input](https://cloud.ibm.com/docs/services/personality-insights?topic=personali + "! ty-insights-input#sufficient). For JSON input, provide an object of type + "! `Content`. + "! @parameter I_CONTENT_TYPE | + "! The type of the input. For more information, see **Content types** in the method + "! description. + "! @parameter I_CONTENT_LANGUAGE | + "! 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**. + "! @parameter I_ACCEPT_LANGUAGE | + "! 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. + "! @parameter I_RAW_SCORES | + "! 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. + "! @parameter I_CSV_HEADERS | + "! Indicates whether column labels are returned with a CSV response. By default, no + "! column labels are returned. Applies only when the response type is CSV + "! (`text/csv`). + "! @parameter I_CONSUMPTION_PREFERENCES | + "! Indicates whether consumption preferences are returned with the results. By + "! default, no consumption preferences are returned. + "! @parameter E_RESPONSE | + "! Service return value of type STRING + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods PROFILE_AS_CSV + importing + !I_CONTENT type T_CONTENT + !I_CONTENT_TYPE type STRING default 'text/plain' + !I_CONTENT_LANGUAGE type STRING default 'en' + !I_ACCEPT_LANGUAGE type STRING default 'en' + !I_RAW_SCORES type BOOLEAN default c_boolean_false + !I_CSV_HEADERS type BOOLEAN default c_boolean_false + !I_CONSUMPTION_PREFERENCES type BOOLEAN default c_boolean_false + !I_accept type string default 'text/csv' + exporting + !E_RESPONSE type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_PERSONAL_INSIGHTS_V3 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Personality Insights'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/personality-insights/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092823'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->PROFILE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CONTENT TYPE T_CONTENT +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='text/plain') +* | [--->] I_CONTENT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_ACCEPT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_RAW_SCORES TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CSV_HEADERS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CONSUMPTION_PREFERENCES TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_PROFILE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method PROFILE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/profile'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_RAW_SCORES is supplied. + lv_queryparam = i_RAW_SCORES. + add_query_parameter( + exporting + i_parameter = `raw_scores` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CSV_HEADERS is supplied. + lv_queryparam = i_CSV_HEADERS. + add_query_parameter( + exporting + i_parameter = `csv_headers` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CONSUMPTION_PREFERENCES is supplied. + lv_queryparam = i_CONSUMPTION_PREFERENCES. + add_query_parameter( + exporting + i_parameter = `consumption_preferences` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + if i_CONTENT_LANGUAGE is supplied. + lv_headerparam = I_CONTENT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Content-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + if i_ACCEPT_LANGUAGE is supplied. + lv_headerparam = I_ACCEPT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Accept-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CONTENT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CONTENT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'content' i_value = i_CONTENT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CONTENT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->PROFILE_AS_CSV +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CONTENT TYPE T_CONTENT +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='text/plain') +* | [--->] I_CONTENT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_ACCEPT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_RAW_SCORES TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CSV_HEADERS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CONSUMPTION_PREFERENCES TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='text/csv') +* | [<---] E_RESPONSE TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method PROFILE_AS_CSV. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/profile'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_RAW_SCORES is supplied. + lv_queryparam = i_RAW_SCORES. + add_query_parameter( + exporting + i_parameter = `raw_scores` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CSV_HEADERS is supplied. + lv_queryparam = i_CSV_HEADERS. + add_query_parameter( + exporting + i_parameter = `csv_headers` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CONSUMPTION_PREFERENCES is supplied. + lv_queryparam = i_CONSUMPTION_PREFERENCES. + add_query_parameter( + exporting + i_parameter = `consumption_preferences` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + if i_CONTENT_LANGUAGE is supplied. + lv_headerparam = I_CONTENT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Content-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + if i_ACCEPT_LANGUAGE is supplied. + lv_headerparam = I_ACCEPT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Accept-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CONTENT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CONTENT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'content' i_value = i_CONTENT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CONTENT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve file data + e_response = get_response_string( lo_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_PERSONAL_INSIGHTS_V3->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_personal_insights_v3.clas.xml b/src/zcl_ibmc_personal_insights_v3.clas.xml new file mode 100644 index 0000000..7368b46 --- /dev/null +++ b/src/zcl_ibmc_personal_insights_v3.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_PERSONAL_INSIGHTS_V3 + E + Watson Personal Insights + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_service.clas.abap b/src/zcl_ibmc_service.clas.abap new file mode 100644 index 0000000..0767c32 --- /dev/null +++ b/src/zcl_ibmc_service.clas.abap @@ -0,0 +1,1539 @@ +* Copyright 2019,2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +class ZCL_IBMC_SERVICE definition + public + inheriting from ZCL_IBMC_SERVICE_ARCH + create public . + +public section. + + types DATA_REFERENCE type ref to DATA . + types: + FIELDNAME(30) type c . + types BOOLEAN type ZIF_IBMC_SERVICE_ARCH~BOOLEAN . + types CHAR type ZIF_IBMC_SERVICE_ARCH~CHAR . + types DATE type STRING . + types TIME type STRING . + types INTEGER type I . + types SHORT type INT2 . + types LONG type INT8 . + types FLOAT type F . + types DOUBLE type F . + types NUMBER type F . + types FILE type XSTRING . + types BINARY type XSTRING . + types JSONOBJECT type ref to DATA . + types MAP type ref to DATA . + types: + "! DateTime type, format 2018-10-23T15:18:18.914xxxZ + DATETIME(27) type c . + types TT_STRING type ZIF_IBMC_SERVICE_ARCH~TT_STRING . + types: + TT_BOOLEAN type standard table of ZIF_IBMC_SERVICE_ARCH~BOOLEAN with non-unique default key . + types: + TT_CHAR type standard table of ZIF_IBMC_SERVICE_ARCH~CHAR with non-unique default key . + types: + TT_INTEGER type standard table of INTEGER with non-unique default key . + types: + TT_SHORT type standard table of SHORT with non-unique default key . + types: + TT_LONG type standard table of LONG with non-unique default key . + types: + TT_FLOAT type standard table of FLOAT with non-unique default key . + types: + TT_DOUBLE type standard table of DOUBLE with non-unique default key . + types: + TT_NUMBER type standard table of NUMBER with non-unique default key . + types: + TT_FILE type standard table of FILE with non-unique default key . + types: + begin of TS_MAP_FILE, + KEY type STRING, + DATA type FILE, + end of TS_MAP_FILE . + types: + TT_MAP_FILE type standard table of TS_MAP_FILE with non-unique default key . + types: + begin of TS_FILE_WITH_METADATA, + FILENAME type string, + CONTENT_TYPE type string, + DATA type xstring, + end of TS_FILE_WITH_METADATA . + types: + TT_FILE_WITH_METADATA type standard table of TS_FILE_WITH_METADATA with non-unique default key . + types TS_FORM_PART type ZIF_IBMC_SERVICE_ARCH~TS_FORM_PART . + types TT_FORM_PART type ZIF_IBMC_SERVICE_ARCH~TT_FORM_PART . + + constants C_BOOLEAN_FALSE type BOOLEAN value SPACE ##NO_TEXT. + constants C_BOOLEAN_TRUE type BOOLEAN value 'X' ##NO_TEXT. + constants C_TRIBOOL_FALSE type BOOLEAN value '-' ##NO_TEXT. + constants C_DEFAULT type STRING value 'DEFAULT' ##NO_TEXT. + constants C_SUBRC_UNKNOWN type SY-SUBRC value 999999 ##NO_TEXT. + constants C_MSGID type SY-MSGID value 'ZIBMC' ##NO_TEXT. + constants C_I_ZERO type I value -2147481648 ##NO_TEXT. + constants C_I8_ZERO type INT8 value -9223372036854775608 ##NO_TEXT. + constants C_F_ZERO type F value '-2147481.648' ##NO_TEXT. + constants C_BLANK type STRING value '&#§§#&__%$X' ##NO_TEXT. + constants: + begin of C_DATATYPE, + string type char value 'g', + struct type char value 'v', + end of C_DATATYPE . + data P_REQUEST_PROP_DEFAULT type TS_REQUEST_PROP . + data P_DEBUG_MODE type CHAR value SPACE ##NO_TEXT. + data P_VERSION type STRING . + + "! Raises an exception + "! + "! @parameter I_MSGNO | Message number. + "! @parameter I_MSGV1 | Substitution for 1st placeholder in message. + "! @parameter I_MSGV2 | Substitution for 2nd placeholder in message. + "! @parameter I_MSGV3 | Substitution for 3rd placeholder in message. + "! @parameter I_MSGV4 | Substitution for 4th placeholder in message. + "! @parameter I_TEXT | Message text; specify if message number is not specified. + "! @parameter I_SUBRC | Return code being returned. + "! @parameter I_PREVIOUS | Exception that has been captured before. + "! @parameter I_HTTP_STATUS | HTTP status code if exception is triggered by HTTP error + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised. + "! + class-methods RAISE_EXCEPTION + importing + !I_MSGNO type SY-MSGNO optional + !I_MSGV1 type STRING optional + !I_MSGV2 type STRING optional + !I_MSGV3 type STRING optional + !I_MSGV4 type STRING optional + !I_TEXT type STRING optional + !I_SUBRC type SY-SUBRC default C_SUBRC_UNKNOWN + !I_PREVIOUS type ref to CX_ROOT optional + !I_HTTP_STATUS type TS_HTTP_STATUS optional + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Returns field type and length of a given parameter + "! + "! @parameter I_FIELD | Field of type that is supposed to be determined. + "! @parameter E_TECHNICAL_TYPE | Technical type (= base type) of I_FIELD. + "! @parameter E_RELATIVE_TYPE | Relative type (= data type) of I_FIELD. + "! @parameter E_LENGTH | Length of type of I_FIELD. + "! + class-methods GET_FIELD_TYPE + importing + !I_FIELD type ANY + exporting + !E_TECHNICAL_TYPE type ZIF_IBMC_SERVICE_ARCH~CHAR + !E_RELATIVE_TYPE type STRING + !E_LENGTH type I . + "! Returns component names of a given structure + "! + "! @parameter I_STRUCTURE | Structure with components. + "! @parameter E_COMPONENTS | Internal table of component names. + "! + class-methods GET_COMPONENTS + importing + !I_STRUCTURE type ANY + exporting + value(E_COMPONENTS) type ZIF_IBMC_SERVICE_ARCH~TT_STRING . + "! Parses a JSON string into an ABAP structure + "! + "! @parameter I_JSON | JSON string. + "! @parameter I_DICTIONARY | Dictionary for mapping of identifier names. + "! @parameter C_ABAP | ABAP structure to be filled + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods PARSE_JSON + importing + !I_JSON type STRING + !I_DICTIONARY type ANY optional + changing + value(C_ABAP) type ANY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Method for internal use. + "! + methods GET_REQUEST_PROP + importing + !I_AUTH_METHOD type STRING default C_DEFAULT + returning + value(E_REQUEST_PROP) type TS_REQUEST_PROP . + "! Returns data type of a given parameter + "! + "! @parameter I_FIELD | Field of type that is supposed to be determined. + "! @parameter E_DATATYPE | Technical type (= base type) of I_FIELD. + "! + class-methods GET_DATATYPE + importing + !I_FIELD type ANY + returning + value(E_DATATYPE) type ZIF_IBMC_SERVICE_ARCH~CHAR . + "! Unescape unicode codepoints to characters in a string, e.g. '\u0041 b \u0063' -> 'A b c' + "! + "! @parameter I_IN | String with unicode codepoints. + "! @parameter E_OUT | Unescaped string. + "! + class-methods UNESCAPE_UNICODE + importing + !I_IN type STRING + returning + value(E_OUT) type STRING . + "! Returns the file extension for a mime type, e.g. 'text/plain' -> 'txt' + "! + "! @parameter I_MIME_TYPE | MIME type. + "! @parameter E_EXTENSION | File extension (without leading dot). + "! + class-methods GET_FILE_EXTENSION + importing + value(I_MIME_TYPE) type STRING + returning + value(E_EXTENSION) type STRING . + "! Moves a referenced data structure to an ABAP structure + "! + "! @parameter I_DATA_REFERENCE | Reference to data object. + "! @parameter E_ABAP | ABAP structure to be filled. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods MOVE_DATA_REFERENCE_TO_ABAP + importing + !I_DATA_REFERENCE type DATA_REFERENCE + exporting + value(E_ABAP) type ANY + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Method for internal use. + "! + class-methods ADD_QUERY_PARAMETER + importing + !I_PARAMETER type STRING + !I_VALUE type STRING + !I_IS_BOOLEAN type BOOLEAN default C_BOOLEAN_FALSE + changing + !C_URL type TS_URL . + "! Method for internal use. + "! + class-methods ADD_HEADER_PARAMETER + importing + !I_PARAMETER type STRING + !I_VALUE type STRING + !I_IS_BOOLEAN type BOOLEAN default C_BOOLEAN_FALSE + changing + !C_HEADERS type ZIF_IBMC_SERVICE_ARCH~TS_REQUEST_PROP-HEADERS . + "! Method for internal use. + "! + class-methods GET_FULL_URL + importing + !I_URL type TS_URL + returning + value(E_URL) type STRING . + "! Returns the service name. + "! + "! @parameter E_APPNAME | Name of the service. + "! + methods GET_APPNAME + returning + value(E_APPNAME) type STRING . + "! Method for internal use. + "! + class-methods NORMALIZE_URL + changing + !C_URL type TS_URL . + "! Extracts a JSON string from an ABAP structure. + "! + "! @parameter I_NAME | Name of component to be extracted. + "! @parameter I_VALUE | ABAP structure to be converted to JSON string. + "! @parameter I_DICTIONARY | Dictionary to be used for mapping ABAP identifiers to JSON keys. + "! @parameter I_REQUIRED_FIELDS | + "! Dictionary of required fields.
+ "! If a field is required, an initial value appears as initial value in JSON structure. + "! Otherwise it is omitted in JSON string. + "! @parameter I_LOWER_CASE | If set to C_BOOLEAN_TRUE all keys in JSON string will be lower case. + "! @parameter E_JSON | JSON string. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods ABAP_TO_JSON + importing + !I_NAME type STRING optional + !I_VALUE type ANY + !I_DICTIONARY type ANY optional + !I_REQUIRED_FIELDS type ANY optional + !I_LOWER_CASE type BOOLEAN default C_BOOLEAN_TRUE + returning + value(E_JSON) type STRING . + methods CHECK_HTTP_RESPONSE + importing + !I_RESPONSE type TO_REST_RESPONSE optional + !I_URL type TS_URL optional + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Class constructor. + "! + "! @parameter I_URL | URL of the service. + "! @parameter I_HOST | Host of the service. I_URL and I_HOST can be used synonymously. + "! @parameter I_PROXY_HOST | Proxy server, not applicable on SAP Cloud Platform. + "! @parameter I_PROXY_PORT | Proxy server port, not applicable on SAP Cloud Platform. + "! @parameter I_USERNAME | User name to authenticate on service. + "! @parameter I_PASSWORD | User password to authenticate on service. + "! @parameter I_APIKEY | API key password to authenticate on service. + "! @parameter I_ACCESS_TOKEN | Access token to authenticate on service. + "! @parameter I_SSL_ID | ID of PSE, not applicable on SAP Cloud Platform. + "! @parameter I_DEBUG_MODE | not used. + "! + methods CONSTRUCTOR + importing + !I_URL type STRING optional + !I_HOST type STRING optional + !I_PROXY_HOST type STRING optional + !I_PROXY_PORT type STRING optional + !I_USERNAME type STRING optional + !I_PASSWORD type STRING optional + !I_APIKEY type STRING optional + !I_ACCESS_TOKEN type TS_ACCESS_TOKEN optional + !I_SSL_ID type ZIF_IBMC_SERVICE_ARCH~TY_SSL_ID optional + !I_DEBUG_MODE type CHAR default SPACE . + "! Method for internal use. + "! + methods GET_REST_CLIENT + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_CLIENT) type TS_CLIENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Method for internal use. + "! + methods GET_ACCESS_TOKEN + importing + !I_REQUEST_PROP type TS_REQUEST_PROP optional + returning + value(E_ACCESS_TOKEN) type TS_ACCESS_TOKEN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sends a HTTP DELETE request. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods HTTP_DELETE + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sets an access token explicitly. + "! + "! @parameter I_ACCESS_TOKEN | Access token. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods SET_ACCESS_TOKEN + importing + !I_ACCESS_TOKEN type TS_ACCESS_TOKEN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sends a HTTP GET request. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods HTTP_GET + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sends a HTTP POST request. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods HTTP_POST + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sends a HTTP POST request with multipart body. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter IT_FORM_PART | Internal table of form parts in request body. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods HTTP_POST_MULTIPART + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + !IT_FORM_PART type TT_FORM_PART + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Sends a HTTP PUT request. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods HTTP_PUT + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . +protected section. + + methods ADJUST_REQUEST_PROP + changing + !C_REQUEST_PROP type TS_REQUEST_PROP . + class-methods MERGE_STRUCTURE + importing + !I_ALTERNATIVE type ANY + changing + !C_BASE type ANY . + methods SET_URI_AND_AUTHORIZATION + importing + !I_CLIENT type TS_CLIENT + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_URI) type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . +private section. +ENDCLASS. + + + +CLASS ZCL_IBMC_SERVICE IMPLEMENTATION. + + + method abap_to_json. + + data: + lv_json type string, + lv_json_comp type string, + lv_json_num(24) type c, + lv_sep(1) type c, + lv_name type string, + lv_name_uc type string, + lv_type type char, + lt_compname type tt_string, + lv_name_in_dict type boolean, + lv_relative_type type string, + lv_pattern type string, + lv_str type string. + field-symbols: + type any, + type string, + type any, + type i, + type int8, + type f, + type any table, + type string, + type string. + + + get_field_type( + exporting + i_field = i_value + importing + e_technical_type = lv_type + e_relative_type = lv_relative_type ). + if lv_type eq zif_ibmc_service_arch~c_datatype-dataref or lv_type eq zif_ibmc_service_arch~c_datatype-objectref. + if i_value is initial. + return. + endif. + assign i_value->* to . + get_field_type( + exporting + i_field = + importing + e_technical_type = lv_type + e_relative_type = lv_relative_type ). + else. + assign i_value to . + endif. + + + if lv_type ne zif_ibmc_service_arch~c_datatype-struct and lv_type ne zif_ibmc_service_arch~c_datatype-struct_deep and lv_type ne zif_ibmc_service_arch~c_datatype-itab. + " simple type + + if lv_type eq 'C' or lv_type eq 'N' or lv_type eq 'g'. + lv_str = . + if lv_str eq c_blank. + " parameter is blank, not initial (i.e. null) + lv_str = ''. + else. + replace all occurrences of '"' in lv_str with '\"'. + replace all occurrences of cl_abap_char_utilities=>cr_lf in lv_str with '\n'. + replace all occurrences of cl_abap_char_utilities=>newline in lv_str with '\n'. + endif. + + " quote value unless it is a boolean + if lv_relative_type eq 'BOOLEAN'. + if lv_str eq c_boolean_true. + lv_json = `true`. + elseif lv_str eq c_boolean_false. + lv_json = `false`. + else. + lv_json = lv_str. + endif. + else. + lv_json = `"` && lv_str && `"`. + endif. + else. + do 1 times. " to allow exit command + + " special handling for optional parameters explicitly set to initial + if lv_type eq 'I'. + assign to . + if = c_i_zero. + lv_json_num = '0'. + exit. + endif. + elseif lv_type eq '8'. + assign to . + if = c_i8_zero. + lv_json_num = '0'. + exit. + endif. + elseif lv_type eq 'F'. + assign to . + if = c_f_zero. + lv_json_num = '0'. + exit. + endif. + endif. + + lv_json_num = conv #( ). + condense lv_json_num no-gaps. + enddo. + lv_json = lv_json_num. + endif. + + elseif lv_type eq zif_ibmc_service_arch~c_datatype-struct or lv_type eq zif_ibmc_service_arch~c_datatype-struct_deep. + " structure + + get_components( + exporting + i_structure = + importing + e_components = lt_compname ). + clear lv_sep. + lv_json = lv_json && `{`. + loop at lt_compname assigning . + assign component of structure to . + if sy-subrc <> 0. + continue. + endif. + + " do not add property if not required and corresponding abap field is initial + if is initial and not i_required_fields is initial. + assign component lv_relative_type of structure i_required_fields to . + if sy-subrc <> 0. + continue. + endif. + lv_pattern = `*|` && && `|*`. + if not cp lv_pattern. + continue. + endif. + endif. + + lv_name = . + + " check if key name exists in abap names dictionary + lv_name_in_dict = c_boolean_false. + try. + assign component lv_name of structure i_dictionary to . + if sy-subrc = 0. + lv_name = . + lv_name_in_dict = c_boolean_true. + endif. + catch cx_sy_assign_cast_illegal_cast cx_sy_assign_cast_unknown_type cx_sy_assign_out_of_range. + endtry. + + if lv_name_in_dict eq c_boolean_false and i_lower_case eq c_boolean_true. + " convert name to lower case + translate lv_name to lower case. + endif. + " add property (recursively) + lv_json_comp = abap_to_json( i_name = lv_name i_value = i_lower_case = i_lower_case i_dictionary = i_dictionary i_required_fields = i_required_fields ). + lv_json = lv_json && lv_sep && lv_json_comp. + lv_sep = ','. + endloop. + lv_json = lv_json && `}`. + + elseif lv_type eq zif_ibmc_service_arch~c_datatype-itab. + " internal table + + lv_json = lv_json && `[`. + clear lv_sep. + assign to . + loop at assigning . + lv_json_comp = abap_to_json( i_value = i_lower_case = i_lower_case i_dictionary = i_dictionary i_required_fields = i_required_fields ). + lv_json = lv_json && lv_sep && lv_json_comp. + lv_sep = ','. + endloop. + lv_json = lv_json && `]`. + + endif. + + if not i_name is initial. + lv_name_in_dict = c_boolean_false. + lv_name = i_name. + if not i_dictionary is initial. + assign component i_name of structure i_dictionary to . + if sy-subrc = 0. + lv_name = . + lv_name_in_dict = c_boolean_true. + endif. + endif. + if lv_name_in_dict eq c_boolean_false and i_lower_case eq c_boolean_true. + " convert name to lower case + translate lv_name to lower case. + endif. + e_json = `"` && lv_name && `": ` && lv_json. + else. + e_json = lv_json. + endif. + + endmethod. + + + method add_header_parameter. + + data: + ls_header type line of zif_ibmc_service_arch~ts_request_prop-headers, + lv_value type string. + + if i_is_boolean eq c_boolean_true. + if i_value eq c_boolean_true. + lv_value = 'true'. + else. + lv_value = 'false'. + endif. + else. + lv_value = i_value. + endif. + condense lv_value. " remove trailing spaces + + ls_header-name = i_parameter. + ls_header-value = lv_value. + append ls_header to c_headers. + + endmethod. + + + method add_query_parameter. + + data: + lv_param type string. + + if i_is_boolean eq c_boolean_true. + if i_value eq c_boolean_true. + lv_param = 'true'. + else. + lv_param = 'false'. + endif. + else. + lv_param = i_value. + endif. + condense lv_param. " remove trailing spaces + lv_param = i_parameter && `=` && lv_param. + + if c_url-querystring is initial. + c_url-querystring = lv_param. + else. + c_url-querystring = c_url-querystring && `&` && lv_param. + endif. + + endmethod. + + + method adjust_request_prop. + + data: + ls_request_prop_openapi type ts_request_prop. + + merge_structure( + exporting + i_alternative = p_request_prop_default + changing + c_base = c_request_prop ). + + " Separate protocol, host and path in url + normalize_url( + changing + c_url = c_request_prop-url ). + + " Set defaults for some unspecified properties + if c_request_prop-url-protocol is initial. + c_request_prop-url-protocol = 'http' ##NO_TEXT. + endif. + if c_request_prop-auth_headername is initial. + c_request_prop-auth_headername = 'Authorization' ##NO_TEXT. + endif. + + " Allow basic authentication with apikey + if c_request_prop-auth_basic eq c_boolean_true. + if c_request_prop-username is initial and c_request_prop-password is initial and not c_request_prop-apikey is initial. + c_request_prop-username = 'apikey' ##NO_TEXT. + c_request_prop-password = c_request_prop-apikey. + endif. + endif. + + " Correct authentication location + if ( c_request_prop-auth_basic ne c_boolean_false or + c_request_prop-auth_oauth ne c_boolean_false or + c_request_prop-auth_apikey ne c_boolean_false ) and + not ( c_request_prop-auth_header eq c_boolean_true or + c_request_prop-auth_query eq c_boolean_true or + c_request_prop-auth_body eq c_boolean_true ). + c_request_prop-auth_header = c_boolean_true. + endif. + + endmethod. + + + method check_http_response. + + data: + lv_http_status type ts_http_status, + lv_full_url type string, + ls_url type ts_url, + lv_strlen type i, + lv_code type string, + lo_service_exception type ref to zcx_ibmc_service_exception. + + lv_http_status = get_http_status( i_rest_response = i_response ). + lv_code = lv_http_status-code. + shift lv_code left deleting leading space. + if lv_code ne '200' and " ok + lv_code ne '201' and " ok with response + lv_code ne '202' and " Accepted (asynchronous function call) + lv_code ne '204'. " Deleted + + ls_url = i_url. + merge_structure( + exporting + i_alternative = p_request_prop_default-url + changing + c_base = ls_url ). + lv_full_url = get_full_url( ls_url ). + + try. + raise_exception( + i_msgno = '003' " HTTP Status: &1 (&2) + i_msgv1 = lv_code + i_msgv2 = lv_http_status-reason + i_msgv3 = lv_full_url + i_http_status = lv_http_status ). + catch zcx_ibmc_service_exception into lo_service_exception. + lo_service_exception->p_msg_json = lv_http_status-json. + endtry. + + raise exception lo_service_exception. + endif. + + endmethod. + + + method constructor. + + data: + lv_host type string. + + super->constructor( ). + + " use i_url and i_host synonymously + if not i_url is initial. + lv_host = i_url. + else. + lv_host = i_host. + endif. + + p_request_prop_default-url-host = lv_host. + p_request_prop_default-username = i_username. + p_request_prop_default-password = i_password. + p_request_prop_default-apikey = i_apikey. + p_request_prop_default-access_token = i_access_token. + + p_debug_mode = i_debug_mode. + + normalize_url( + changing + c_url = p_request_prop_default-url ). + + if not i_proxy_host is supplied. + + get_default_proxy( + exporting + i_url = p_request_prop_default-url + importing + e_proxy_host = p_request_prop_default-proxy_host + e_proxy_port = p_request_prop_default-proxy_port ). + + else. + p_request_prop_default-proxy_host = i_proxy_host. + if not i_proxy_port is initial. + p_request_prop_default-proxy_port = i_proxy_port. + else. + p_request_prop_default-proxy_port = '8080'. + endif. + endif. + + + endmethod. + + + method get_access_token. + + e_access_token = p_request_prop_default-access_token. + + endmethod. + + + method get_appname. + endmethod. + + + method get_components. + + data: + lo_abap_struc type ref to cl_abap_structdescr, + lt_comp type cl_abap_structdescr=>component_table. + + field-symbols: + type line of cl_abap_structdescr=>component_table. + + lo_abap_struc ?= cl_abap_structdescr=>describe_by_data( i_structure ). + lt_comp = lo_abap_struc->get_components( ). + + clear e_components[]. + loop at lt_comp assigning . + append -name to e_components. + endloop. + + endmethod. + + + method get_datatype. + + get_field_type( + exporting + i_field = i_field + importing + e_technical_type = e_datatype ). + + endmethod. + + + method get_field_type. + data: + lo_abap_type type ref to cl_abap_typedescr, + lo_typedescr type ref to cl_abap_typedescr. + + call method cl_abap_typedescr=>describe_by_data + exporting + p_data = i_field + receiving + p_descr_ref = lo_typedescr. + + e_technical_type = lo_typedescr->type_kind. + + if e_relative_type is requested. + if e_technical_type eq zif_ibmc_service_arch~c_datatype-objectref. + data lo_refdescr type ref to cl_abap_refdescr. + lo_refdescr ?= cl_abap_typedescr=>describe_by_data( i_field ). + lo_abap_type ?= lo_refdescr->get_referenced_type( ). + else. + lo_abap_type = cl_abap_typedescr=>describe_by_data( i_field ). + endif. + e_relative_type = lo_abap_type->get_relative_name( ). + endif. + + if e_length is requested. + if e_technical_type eq zif_ibmc_service_arch~c_datatype-c or + e_technical_type eq zif_ibmc_service_arch~c_datatype-n. + e_length = lo_typedescr->length. + else. + e_length = 0. + endif. + endif. + + endmethod. + + + method get_file_extension. + + data: + lv_mime_type type string, + lv_ext type string, + lv_len type i. + + translate i_mime_type to lower case. + + case i_mime_type. + when 'text/plain'. e_extension = 'txt'. + when 'image/jpeg'. e_extension = 'jpg'. + when 'application/octet-stream'. e_extension = 'bin'. + when others. + e_extension = 'dat'. + find regex '([^/]*)$' in i_mime_type submatches lv_ext. + if sy-subrc = 0. + lv_len = strlen( lv_ext ). + if lv_len >= 2 and lv_len <= 4. + e_extension = lv_ext. + endif. + endif. + endcase. + + endmethod. + + + method get_full_url. + + data: + lv_url type string. + + if not i_url-host cp 'http*'. + if i_url-protocol is initial. + lv_url = 'http://'. + else. + lv_url = i_url-protocol && `://`. + endif. + endif. + + lv_url = lv_url && i_url-host && i_url-path_base && i_url-path. + + if not i_url-querystring is initial. + lv_url = lv_url && `?` && i_url-querystring. + endif. + + e_url = lv_url. + + endmethod. + + + method get_request_prop. + + e_request_prop-url-protocol = 'http'. + e_request_prop-auth_headername = ''. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + e_request_prop-auth_query = c_boolean_false. + e_request_prop-auth_header = c_boolean_false. + + endmethod. + + + method get_rest_client. + + data: + ls_header type ts_header, + ls_request_prop type ts_request_prop, + lv_url type string. + + ls_request_prop = i_request_prop. + adjust_request_prop( + changing + c_request_prop = ls_request_prop ). + + " create http client instance + lv_url = ls_request_prop-url-protocol && `://` && ls_request_prop-url-host. + create_client_by_url( + exporting + i_url = lv_url + i_request_prop = ls_request_prop + importing + e_client = e_client ). + + " set URI and authorization + lv_url = set_uri_and_authorization( i_client = e_client i_request_prop = ls_request_prop ). + + " set request uri + set_request_uri( i_client = e_client i_uri = lv_url ). + + " set 'Content-Type' header + if not i_request_prop-header_content_type is initial. + set_request_header( i_client = e_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = ls_request_prop-header_content_type ). + endif. + + " set 'Accept' header + if not i_request_prop-header_accept is initial. + set_request_header( i_client = e_client i_name = zif_ibmc_service_arch~c_header_accept i_value = ls_request_prop-header_accept ). + endif. + + " set additional headers + if not ls_request_prop-headers is initial. + loop at ls_request_prop-headers into ls_header. + set_request_header( i_client = e_client i_name = ls_header-name i_value = ls_header-value ). + endloop. + endif. + + endmethod. + + + method http_delete. + + data: + lo_client type ts_client. + + " create REST client + lo_client = get_rest_client( i_request_prop = i_request_prop ). + + " execute DELETE request + e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_delete ). + + " check response + check_http_response( + i_response = e_response + i_url = i_request_prop-url ). + + endmethod. + + + method http_get. + + data: + lo_client type ts_client. + + " create REST client + lo_client = get_rest_client( i_request_prop = i_request_prop ). + + " execute GET request + e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_get ). + + " check response + check_http_response( + i_response = e_response + i_url = i_request_prop-url ). + + endmethod. + + + method http_post. + + data: + lo_client type ts_client. + + " create REST client + lo_client = get_rest_client( i_request_prop = i_request_prop ). + + " set request body + if not i_request_prop-body is initial. + set_request_body_cdata( i_client = lo_client i_data = i_request_prop-body ). + endif. + if not i_request_prop-body_bin is initial. + set_request_body_xdata( i_client = lo_client i_data = i_request_prop-body_bin ). + endif. + + " error: querystring of a POST request is not sent to server if the request body is empty + " workaround: set an empty json object for request body + if i_request_prop-body is initial and i_request_prop-body_bin is initial. + set_request_body_cdata( i_client = lo_client i_data = `{}` ). + set_request_header( i_client = lo_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = zif_ibmc_service_arch~c_mediatype-appl_json ). + endif. + + " execute POST request + e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_post ). + + " check response + check_http_response( + i_response = e_response + i_url = i_request_prop-url ). + + endmethod. + + + method HTTP_POST_MULTIPART. + + data: + lo_client type ts_client. + + " create REST client + lo_client = get_rest_client( i_request_prop = i_request_prop ). + + " set request body (multipart) + add_form_part( i_client = lo_client it_form_part = it_form_part ). + + " execute POST request + e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_post ). + + " check response + check_http_response( + i_response = e_response + i_url = i_request_prop-url ). + + endmethod. + + + method http_put. + + data: + lo_client type ts_client. + + " create REST client + lo_client = get_rest_client( i_request_prop = i_request_prop ). + + " set request body + if not i_request_prop-body is initial. + set_request_body_cdata( i_client = lo_client i_data = i_request_prop-body ). + endif. + if not i_request_prop-body_bin is initial. + set_request_body_xdata( i_client = lo_client i_data = i_request_prop-body_bin ). + endif. + + " execute PUT request + e_response = execute( i_client = lo_client i_method = zif_ibmc_service_arch~c_method_put ). + + " check response + check_http_response( + i_response = e_response + i_url = i_request_prop-url ). + + endmethod. + + + method merge_structure. + + data: + lv_type type char, + lt_compname type tt_string. + + field-symbols: + type any, + type any, + type standard table, + type standard table, + type string. + + get_components( + exporting + i_structure = c_base + importing + e_components = lt_compname ). + + loop at lt_compname assigning . + assign component of structure c_base to . + check sy-subrc = 0. + get_field_type( + exporting + i_field = + importing + e_technical_type = lv_type ). + if lv_type eq zif_ibmc_service_arch~c_datatype-struct or lv_type eq zif_ibmc_service_arch~c_datatype-struct_deep. + assign component of structure i_alternative to . + check sy-subrc = 0. + merge_structure( + exporting + i_alternative = + changing + c_base = ). + else. + if is initial. + if lv_type eq zif_ibmc_service_arch~c_datatype-itab. + assign component of structure c_base to . + check sy-subrc = 0. + assign component of structure i_alternative to . + check sy-subrc = 0. + if not is initial. + append lines of to . + endif. + else. + assign component of structure i_alternative to . + check sy-subrc = 0. + = . + endif. + endif. + endif. + endloop. + + endmethod. + + + method move_data_reference_to_abap. + + data: + lt_compname type tt_string, + lv_compname type string, + lv_index type i, + begin of ls_stack, + name type string, + ref type ref to data, + struct type ref to data, + type type char, + end of ls_stack, + ls_stack_new like ls_stack, + lt_stack like standard table of ls_stack. + field-symbols: + type data, + type any, + type any, + type ref to data, + type any. + + + clear ls_stack-name. + ls_stack-ref = i_data_reference. + ls_stack-struct = ref #( e_abap ). + get_field_type( + exporting + i_field = e_abap + importing + e_technical_type = ls_stack-type ). + append ls_stack to lt_stack. + + do. + lv_index = lines( lt_stack ). + if lv_index <= 0. exit. endif. + read table lt_stack into ls_stack index lv_index. + + assign ls_stack-ref->* to . + assign ls_stack-struct->* to . + if ls_stack-name is initial. + assign e_abap to . + else. + assign component ls_stack-name of structure to . + endif. + if ls_stack-type eq 'u' or ls_stack-type eq 'v'. " structure + get_components( + exporting + i_structure = + importing + e_components = lt_compname ). + loop at lt_compname into lv_compname. + ls_stack_new-name = lv_compname. + ls_stack_new-struct = ref #( ). + assign component lv_compname of structure to . + if sy-subrc = 0. + ls_stack_new-ref = . + assign component lv_compname of structure to . + get_field_type( + exporting + i_field = + importing + e_technical_type = ls_stack_new-type ). + append ls_stack_new to lt_stack. + endif. + endloop. + + else. + if not ls_stack-name is initial. + assign ls_stack-struct->* to . + assign component ls_stack-name of structure to . + endif. + if ls_stack-type eq 'l' or ls_stack-type eq 'r'. " reference + = ls_stack-ref. + else. + = . + endif. + endif. + + delete lt_stack index lv_index. + + enddo. + + + endmethod. + + + method normalize_url. + + check not c_url is initial. + + data(lv_protocol) = c_url-protocol. + if not lv_protocol is initial and lv_protocol np '*://'. + lv_protocol = lv_protocol && '://'. + endif. + + data(lv_host) = c_url-host. + if c_url-host cp 'http:*' or c_url-host cp 'https:*'. + clear lv_protocol. + endif. + shift lv_host right deleting trailing '/'. + if not c_url-path_base is initial. + shift c_url-path_base left deleting leading '/'. + lv_host = lv_host && '/' && c_url-path_base. + shift lv_host right deleting trailing '/'. + endif. + shift lv_host left deleting leading space. + + data(lv_path) = c_url-path. + if not lv_path is initial. + if lv_path np '/*'. + lv_path = '/' && lv_path. + endif. + endif. + + data(lv_url_full) = lv_protocol && lv_host && lv_path. + shift lv_url_full right deleting trailing '/'. + shift lv_url_full left deleting leading space. + + clear: c_url-protocol, c_url-host, c_url-path_base, c_url-path. " do not clear other components + find regex '^(http.?:\/\/)?([^\/]*)(.*)$' in lv_url_full submatches c_url-protocol c_url-host c_url-path. + + shift c_url-protocol right deleting trailing '/'. + shift c_url-protocol right deleting trailing ':'. + shift c_url-protocol left deleting leading space. + + " split path into base_path and path + if not lv_host is initial. + find lv_host in lv_url_full match offset data(lv_offset) match length data(lv_length). + if sy-subrc = 0. + data(lv_strlen_url) = strlen( lv_url_full ). + data(lv_strlen_path) = strlen( c_url-path ). + data(lv_splitpoint) = lv_strlen_path - ( lv_strlen_url - lv_offset - lv_length ). + c_url-path_base = c_url-path+0(lv_splitpoint). + c_url-path = c_url-path+lv_splitpoint. + endif. + endif. + + return. + + endmethod. + + + method PARSE_JSON. + + data: + lv_json type string, + lt_dictionary type zif_ibmc_service_arch~tt_string, + lv_dictionary type string, + lv_orgname type string, + lv_abapname type string, + lv_regex type string, + lo_json type ref to /ui2/cl_json, + lv_msg type string, + lr_exception type ref to cx_sy_move_cast_error. + field-symbols: + type string. + + if not i_json is initial. + + lv_json = i_json. + + if i_dictionary is supplied. + get_components( + exporting + i_structure = i_dictionary + importing + e_components = lt_dictionary ). + + loop at lt_dictionary into lv_dictionary. + assign component lv_dictionary of structure i_dictionary to . + lv_orgname = . + translate lv_orgname to upper case. + if lv_dictionary ne lv_orgname. + lv_regex = `"` && && `"\s*:`. + lv_abapname = `"` && lv_dictionary && `":`. + replace all occurrences of regex lv_regex in lv_json with lv_abapname. + endif. + endloop. + + endif. + + " copy code to execute /ui2/cl_json=>deserialize( exporting json = lv_json changing data = c_abap ) and catch exception + create object lo_json. + try. + lo_json->deserialize_int( exporting json = lv_json changing data = c_abap ). + catch cx_sy_move_cast_error into lr_exception. + zcl_ibmc_service=>raise_exception( + exporting + i_msgno = 20 ). + endtry. + + endif. + + endmethod. + + + method raise_exception. + + data: + ls_msg like if_t100_message=>t100key, + lv_charval(11) type c, + lo_service_exception type ref to zcx_ibmc_service_exception. + + ls_msg-msgid = c_msgid. + + if not i_msgno is initial. + ls_msg-msgno = i_msgno. + ls_msg-attr1 = i_msgv1. + ls_msg-attr2 = i_msgv2. + ls_msg-attr3 = i_msgv3. + ls_msg-attr4 = i_msgv4. + else. + if not i_text is initial. + if i_subrc <> c_subrc_unknown. + lv_charval = conv #( i_subrc ). + ls_msg-attr2 = lv_charval. + ls_msg-msgno = '001'. " &1: return code &2 + else. + ls_msg-msgno = '000'. " &1 + endif. + ls_msg-attr1 = i_text. + else. + ls_msg-msgno = '002'. " An exception has occurred, reason code &1. + lv_charval = conv #( i_subrc ). + ls_msg-attr1 = lv_charval. + endif. + endif. + + if ls_msg-attr4 is initial and not i_http_status-json is initial. + data: + begin of ls_error, + error type string, + description type string, + end of ls_error. + parse_json( + exporting + i_json = i_http_status-json + changing + c_abap = ls_error ). + if not ls_error-error is initial. + ls_msg-attr4 = unescape_unicode( ls_error-error ). + elseif not ls_error-description is initial. + ls_msg-attr4 = unescape_unicode( ls_error-description ). + else. + ls_msg-attr4 = unescape_unicode( i_http_status-json ). + endif. + endif. + + raise exception type zcx_ibmc_service_exception + message id c_msgid type 'E' number ls_msg-msgno with ls_msg-attr1 ls_msg-attr2 ls_msg-attr3 ls_msg-attr4. + + endmethod. + + + method set_access_token. + + p_request_prop_default-access_token = i_access_token. + + endmethod. + + + method set_uri_and_authorization. + + data: + ls_url type ts_url, + lv_url type string. + + ls_url = i_request_prop-url. + + " OAuth authorization + if i_request_prop-auth_oauth eq c_boolean_true. " = not ( c_boolean_false or c_tribool_false ) + data: + ls_access_token type ts_access_token, + lv_full_token type string. + ls_access_token = get_access_token( i_request_prop = i_request_prop ). + if not ls_access_token-token_type is initial. + concatenate ls_access_token-token_type ls_access_token-access_token into lv_full_token separated by space. + else. + lv_full_token = ls_access_token-access_token. + endif. + if i_request_prop-auth_header eq c_boolean_true. + set_request_header( i_client = i_client i_name = i_request_prop-auth_headername i_value = lv_full_token ). + endif. + + " Basic authentication + elseif i_request_prop-auth_basic eq c_boolean_true or i_request_prop-auth_apikey eq c_boolean_true. + data: + lv_username type string, + lv_password type string. + if i_request_prop-auth_apikey eq c_boolean_true. + lv_username = 'apikey' ##NO_TEXT. + lv_password = i_request_prop-apikey. + else. + lv_username = i_request_prop-username. + lv_password = i_request_prop-password. + endif. + if i_request_prop-auth_header eq c_boolean_true. + set_authentication_basic( i_client = i_client i_username = lv_username i_password = lv_password ). + elseif i_request_prop-auth_query eq c_boolean_true. + if i_request_prop-auth_apikey eq c_boolean_true. + add_query_parameter( + exporting + i_parameter = 'apikey' ##NO_TEXT + i_value = lv_password + changing + c_url = ls_url ). + else. + add_query_parameter( + exporting + i_parameter = 'username' ##NO_TEXT + i_value = lv_username + changing + c_url = ls_url ). + add_query_parameter( + exporting + i_parameter = 'password' ##NO_TEXT + i_value = lv_password + changing + c_url = ls_url ). + endif. + elseif i_request_prop-auth_body eq c_boolean_true. + data: + lv_body type string. + if i_request_prop-auth_apikey eq c_boolean_true. + lv_body = `{ "userid": "apikey", "password": "` && i_request_prop-apikey && `" }` ##NO_TEXT. + else. + lv_body = `{ "userid": "` && i_request_prop-username && `", "password": "` && i_request_prop-password && `" }` ##NO_TEXT. + endif. + set_request_body_cdata( i_client = i_client i_data = lv_body ). + set_request_header( i_client = i_client i_name = zif_ibmc_service_arch~c_header_content_type i_value = zif_ibmc_service_arch~c_mediatype-appl_json ). + endif. + endif. + + e_uri = get_full_url( ls_url ). + + endmethod. + + + method unescape_unicode. + + data: + lv_match type string, + lv_cp_str type string, + lv_cp_hex(4) type x, + lv_ucchar(1) type c. + + field-symbols: + like lv_ucchar. + + e_out = i_in. + + do. + find regex '(\\u[A-Fa-f0-9]{4})' in e_out ignoring case submatches lv_match ##NO_TEXT. + if sy-subrc <> 0. + exit. + endif. + + lv_cp_str = lv_match+2. + translate lv_cp_str to upper case. + lv_cp_hex = lv_cp_str. + + assign lv_cp_hex to CASTING. + lv_ucchar = . + + replace all occurrences of lv_match in e_out with lv_ucchar. + + enddo. + + endmethod. +ENDCLASS. diff --git a/src/zcl_ibmc_service.clas.xml b/src/zcl_ibmc_service.clas.xml new file mode 100644 index 0000000..ededc14 --- /dev/null +++ b/src/zcl_ibmc_service.clas.xml @@ -0,0 +1,168 @@ + + + + + + ZCL_IBMC_SERVICE + E + ABAP SDK for IBM Watson - Service Class + 1 + X + X + X + + + + ZCL_IBMC_SERVICE + ABAP_TO_JSON + E + Generates a JSON string from any ABAP structure + + + ZCL_IBMC_SERVICE + ADD_HEADER_PARAMETER + E + Adds a HTTP header parameter + + + ZCL_IBMC_SERVICE + ADD_QUERY_PARAMETER + E + Adds a REST query parameter + + + ZCL_IBMC_SERVICE + CHECK_HTTP_RESPONSE + E + Throws an exception, if HTTP response indicates an error + + + ZCL_IBMC_SERVICE + CONSTRUCTOR + E + Class constructor + + + ZCL_IBMC_SERVICE + GET_ACCESS_TOKEN + E + Reads or generates an authorization token + + + ZCL_IBMC_SERVICE + GET_APPNAME + E + Returns the API or service name, resp. + + + ZCL_IBMC_SERVICE + GET_COMPONENTS + E + Returns the component names of a given structure + + + ZCL_IBMC_SERVICE + GET_DATATYPE + E + Returns data type of a variable + + + ZCL_IBMC_SERVICE + GET_FIELD_TYPE + E + Returns the absolute type of a field + + + ZCL_IBMC_SERVICE + GET_FILE_EXTENSION + E + Returns file extension for given mime type + + + ZCL_IBMC_SERVICE + GET_FULL_URL + E + Returns complete URL string + + + ZCL_IBMC_SERVICE + GET_REQUEST_PROP + E + Returns default request properties + + + ZCL_IBMC_SERVICE + GET_REST_CLIENT + E + Creates a REST client instance + + + ZCL_IBMC_SERVICE + HTTP_DELETE + E + Performs a http DELETE request + + + ZCL_IBMC_SERVICE + HTTP_GET + E + Performs a http GET request + + + ZCL_IBMC_SERVICE + HTTP_POST + E + Performs a http POST request + + + ZCL_IBMC_SERVICE + HTTP_POST_MULTIPART + E + Performs a HTTP POST request with multipart body + + + ZCL_IBMC_SERVICE + HTTP_PUT + E + Performs a http PUT request + + + ZCL_IBMC_SERVICE + MOVE_DATA_REFERENCE_TO_ABAP + E + Moves type DATA_REFERENCE to ABAP structure + + + ZCL_IBMC_SERVICE + NORMALIZE_URL + E + Normalize URL in structure of type TS_URL + + + ZCL_IBMC_SERVICE + PARSE_JSON + E + Parses a JSON string into an ABAP structure + + + ZCL_IBMC_SERVICE + RAISE_EXCEPTION + E + Throws an exception of type ZCX_IBMC_SERVICE_EXCEPTION + + + ZCL_IBMC_SERVICE + SET_ACCESS_TOKEN + E + Sets an authorization token explicitly + + + ZCL_IBMC_SERVICE + UNESCAPE_UNICODE + E + Unescapes unicode codepoints + + + + + diff --git a/src/zcl_ibmc_service_arch.clas.abap b/src/zcl_ibmc_service_arch.clas.abap new file mode 100644 index 0000000..db0ec46 --- /dev/null +++ b/src/zcl_ibmc_service_arch.clas.abap @@ -0,0 +1,368 @@ +* Copyright 2019,2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +CLASS zcl_ibmc_service_arch DEFINITION + PUBLIC + CREATE PUBLIC . + + PUBLIC SECTION. + + INTERFACES zif_ibmc_service_arch . + + TYPES to_http_client TYPE REF TO if_web_http_client . + TYPES to_rest_request TYPE REF TO if_web_http_request . + TYPES to_rest_response TYPE REF TO if_web_http_response . + TYPES to_form_part TYPE REF TO if_web_http_request . + TYPES: + BEGIN OF ts_client, + http TYPE to_http_client, + request TYPE to_rest_request, + END OF ts_client . + TYPES: + BEGIN OF ts_http_stat, + code TYPE i, + reason TYPE string, + END OF ts_http_stat . + TYPES: + BEGIN OF ts_http_status, + code TYPE n LENGTH 3, + reason TYPE string, + json TYPE string, + END OF ts_http_status . + TYPES ts_header TYPE zif_ibmc_service_arch~ts_header . + TYPES tt_header TYPE zif_ibmc_service_arch~tt_header . + TYPES ts_url TYPE zif_ibmc_service_arch~ts_url . + TYPES ts_access_token TYPE zif_ibmc_service_arch~ts_access_token . + TYPES ts_request_prop TYPE zif_ibmc_service_arch~ts_request_prop . + + CLASS-METHODS get_timezone + RETURNING + VALUE(e_timezone) TYPE zif_ibmc_service_arch~ty_timezone . + CLASS-METHODS get_progname + RETURNING + VALUE(e_progname) TYPE string . + CLASS-METHODS base64_decode + IMPORTING + !i_base64 TYPE string + RETURNING + VALUE(e_binary) TYPE xstring + RAISING + zcx_ibmc_service_exception . + CLASS-METHODS create_client_by_url + IMPORTING + !i_url TYPE string + !i_request_prop TYPE ts_request_prop + EXPORTING + !e_client TYPE ts_client + RAISING + zcx_ibmc_service_exception . + CLASS-METHODS get_default_proxy + IMPORTING + !i_url TYPE ts_url OPTIONAL + EXPORTING + !e_proxy_host TYPE string + !e_proxy_port TYPE string . + CLASS-METHODS set_authentication_basic + IMPORTING + !i_client TYPE ts_client + !i_username TYPE string + !i_password TYPE string . + CLASS-METHODS set_request_header + IMPORTING + !i_client TYPE ts_client + !i_name TYPE string + !i_value TYPE string . + CLASS-METHODS set_request_uri + IMPORTING + !i_client TYPE ts_client + !i_uri TYPE string . + METHODS add_form_part + IMPORTING + !i_client TYPE ts_client + !it_form_part TYPE zif_ibmc_service_arch~tt_form_part + RAISING + zcx_ibmc_service_exception . + CLASS-METHODS execute + IMPORTING + !i_client TYPE ts_client + !i_method TYPE zif_ibmc_service_arch~char + RETURNING + VALUE(e_response) TYPE to_rest_response + RAISING + zcx_ibmc_service_exception . + CLASS-METHODS get_response_string + IMPORTING + !i_response TYPE REF TO if_web_http_response + RETURNING + VALUE(e_data) TYPE string . + CLASS-METHODS set_request_body_cdata + IMPORTING + !i_client TYPE ts_client + !i_data TYPE string . + CLASS-METHODS set_request_body_xdata + IMPORTING + !i_client TYPE ts_client + !i_data TYPE xstring . + CLASS-METHODS get_response_binary + IMPORTING + !i_response TYPE REF TO if_web_http_response + RETURNING + VALUE(e_data) TYPE xstring . + CLASS-METHODS get_http_status + IMPORTING + !i_rest_response TYPE REF TO if_web_http_response + RETURNING + VALUE(e_status) TYPE ts_http_status . + CLASS-METHODS convert_string_to_utf8 + IMPORTING + !i_string TYPE string + RETURNING + VALUE(e_utf8) TYPE xstring + RAISING + zcx_ibmc_service_exception . + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS zcl_ibmc_service_arch IMPLEMENTATION. + + + METHOD base64_decode. + + e_binary = cl_web_http_utility=>decode_x_base64( i_base64 ). + +* if sy-subrc <> 0. +* zcl_ibmc_service=>raise_exception( i_msgno = '030' ). " Decoding of base64 string failed +* endif. + + ENDMETHOD. + + + METHOD convert_string_to_utf8. + + CALL METHOD cl_web_http_utility=>encode_utf8 + EXPORTING + unencoded = i_string + RECEIVING + encoded = e_utf8 + EXCEPTIONS + OTHERS = 1. + IF sy-subrc <> 0. + zcl_ibmc_service=>raise_exception( i_text = 'Cannot convert string to UTF-8' ) ##NO_TEXT. + ENDIF. + + ENDMETHOD. + + + METHOD create_client_by_url. + + DATA: + lv_text TYPE string. + + TRY. + "create http destination by url + DATA(lo_http_destination) = + cl_http_destination_provider=>create_by_url( i_url ). + CATCH cx_http_dest_provider_error. + ENDTRY. + + "create HTTP client by destination + TRY. + e_client-http = cl_web_http_client_manager=>create_by_http_destination( lo_http_destination ) . + CATCH cx_web_http_client_error. + lv_text = `HTTP client cannot be created: ` && lv_text ##NO_TEXT. + zcl_ibmc_service=>raise_exception( i_text = lv_text ). + ENDTRY. + + e_client-request = e_client-http->get_http_request( ). + + ENDMETHOD. + + + METHOD execute. + + DATA: + lo_request TYPE REF TO if_web_http_request, + lv_method TYPE string, + lv_text TYPE string, + lo_exception TYPE REF TO cx_web_http_client_error. + + TRY. + CASE i_method. + WHEN zif_ibmc_service_arch~c_method_get. + lv_method = 'GET'. + e_response = i_client-http->execute( if_web_http_client=>get ). + WHEN zif_ibmc_service_arch~c_method_post. + lv_method = 'POST'. + e_response = i_client-http->execute( if_web_http_client=>post ). + WHEN zif_ibmc_service_arch~c_method_put. + lv_method = 'PUT'. + e_response = i_client-http->execute( if_web_http_client=>put ). + WHEN zif_ibmc_service_arch~c_method_delete. + lv_method = 'DELETE'. + e_response = i_client-http->execute( if_web_http_client=>delete ). + ENDCASE. + + CATCH cx_web_http_client_error INTO lo_exception. + lv_text = lo_exception->get_text( ). + lv_text = `HTTP ` && lv_method && ` request failed: ` && lv_text ##NO_TEXT. + zcl_ibmc_service=>raise_exception( i_text = lv_text i_previous = lo_exception ). + ENDTRY. + + + ENDMETHOD. + + + METHOD add_form_part. + + CONSTANTS: + lc_boundary TYPE string VALUE `--------------------------f530e26f981510ab` ##NO_TEXT. + + DATA: + ls_form_part TYPE zif_ibmc_service_arch~ts_form_part, + lx_data TYPE xstring, + lv_header TYPE string, + lx_header TYPE xstring, + lx_body TYPE xstring, + lx_crlf TYPE xstring VALUE '0D0A', + lx_dash2 TYPE xstring VALUE '2D2D'. + + DATA(lx_boundary) = convert_string_to_utf8( lc_boundary ). + + lx_body = lx_crlf. + + LOOP AT it_form_part INTO ls_form_part. + + lx_body = lx_body && lx_dash2 && lx_boundary && lx_crlf. + + IF NOT ls_form_part-content_type IS INITIAL. + lv_header = `Content-Type: ` && ls_form_part-content_type. + lx_header = convert_string_to_utf8( lv_header ). + lx_body = lx_body && lx_header && lx_crlf. + ENDIF. + IF NOT ls_form_part-content_disposition IS INITIAL. + lv_header = `Content-Disposition: ` && ls_form_part-content_disposition ##NO_TEXT. + ELSE. + lv_header = `Content-Disposition: form-data; name="unnamed"` ##NO_TEXT. + ENDIF. + lx_header = convert_string_to_utf8( lv_header ). + lx_body = lx_body && lx_header && lx_crlf && lx_crlf. + IF NOT ls_form_part-xdata IS INITIAL. + lx_body = lx_body && ls_form_part-xdata && lx_crlf. + DATA(lc_data) = cl_web_http_utility=>encode_x_base64( unencoded = ls_form_part-xdata ). + ENDIF. + IF NOT ls_form_part-cdata IS INITIAL. + lx_data = convert_string_to_utf8( ls_form_part-cdata ). + lx_body = lx_body && lx_data && lx_crlf. + ENDIF. + + ENDLOOP. + lx_body = lx_body && lx_dash2 && lx_boundary && lx_dash2 && lx_crlf. + + set_request_header( i_client = i_client i_name = `Content-Type` i_value = `multipart/form-data; boundary=` && lc_boundary && `; charset=utf-8` ) ##NO_TEXT. + set_request_body_xdata( i_client = i_client i_data = lx_body ). + + ENDMETHOD. + + + METHOD get_default_proxy. + + ENDMETHOD. + + + METHOD get_http_status. + DATA: ls_status TYPE ts_http_stat. + + ls_status = i_rest_response->get_status( ). + e_status-code = ls_status-code. + e_status-reason = ls_status-reason. + TRY. + e_status-json = i_rest_response->get_text( ). + CATCH cx_web_message_error. + " response may be binary -> ignore + e_status-json = ''. + ENDTRY. + ENDMETHOD. + + + METHOD get_progname. + +* e_progname = sy-cprog. + + ENDMETHOD. + + + METHOD get_response_binary. + + e_data = i_response->get_binary( ). + + ENDMETHOD. + + + METHOD get_response_string. + + e_data = i_response->get_text( ). + + ENDMETHOD. + + + METHOD get_timezone. + +* e_timezone = sy-zonlo. + + ENDMETHOD. + + + METHOD set_authentication_basic. + + i_client-request->set_authorization_basic( + EXPORTING + i_username = i_username + i_password = i_password + ). + + ENDMETHOD. + + + METHOD set_request_body_cdata. + + i_client-request->set_text( i_text = i_data ). + + ENDMETHOD. + + + METHOD set_request_body_xdata. + + i_client-request->set_binary( i_data = i_data ). + + ENDMETHOD. + + + METHOD set_request_header. + + i_client-request->set_header_field( i_name = i_name i_value = i_value ) . + + ENDMETHOD. + + + METHOD set_request_uri. + + DATA: + lo_request TYPE REF TO if_web_http_request. + + i_client-request->set_uri_path( i_uri_path = i_uri ). + + ENDMETHOD. +ENDCLASS. diff --git a/src/zcl_ibmc_service_arch.clas.xml b/src/zcl_ibmc_service_arch.clas.xml new file mode 100644 index 0000000..348dddf --- /dev/null +++ b/src/zcl_ibmc_service_arch.clas.xml @@ -0,0 +1,126 @@ + + + + + + ZCL_IBMC_SERVICE_ARCH + E + IBM Watson SDK Platform-specifics + 1 + X + X + X + + + + ZCL_IBMC_SERVICE_ARCH + BASE64_DECODE + E + Decodes base64 encoded data to binary + + + ZCL_IBMC_SERVICE_ARCH + CONVERT_STRING_TO_UTF8 + E + Converts STRING data to UTF8 encoded XSTRING + + + ZCL_IBMC_SERVICE_ARCH + CREATE_CLIENT_BY_URL + E + Returns a HTTP/REST client based on an URL + + + ZCL_IBMC_SERVICE_ARCH + EXECUTE + E + Executes a HTTP request (GET, POST or DELETE) + + + ZCL_IBMC_SERVICE_ARCH + GET_DEFAULT_PROXY + E + Returns the default proxy host and port + + + ZCL_IBMC_SERVICE_ARCH + GET_HTTP_STATUS + E + Returns the status of a http response + + + ZCL_IBMC_SERVICE_ARCH + GET_PROGNAME + E + Returns the ABAP program name + + + ZCL_IBMC_SERVICE_ARCH + GET_RESPONSE_BINARY + E + Reads string data from response + + + ZCL_IBMC_SERVICE_ARCH + GET_RESPONSE_STRING + E + Reads string data from response + + + ZCL_IBMC_SERVICE_ARCH + GET_REST_REQUEST + E + Returns a request object from a HTTP client object + + + ZCL_IBMC_SERVICE_ARCH + GET_TIMEZONE + E + Returns the user's time zone + + + ZCL_IBMC_SERVICE_ARCH + SET_AUTHENTICATION_BASIC + E + Sets request header for basic authentication + + + ZCL_IBMC_SERVICE_ARCH + SET_REQUEST_BODY_CDATA + E + Sets the body of a HTTP request object + + + ZCL_IBMC_SERVICE_ARCH + SET_REQUEST_BODY_XDATA + E + Sets the body of a HTTP request object + + + ZCL_IBMC_SERVICE_ARCH + SET_REQUEST_HEADER + E + Sets a HTTP header + + + ZCL_IBMC_SERVICE_ARCH + SET_REQUEST_URI + E + Sets the URI for a HTTP request + + + ZCL_IBMC_SERVICE_ARCH + TO_HTTP_CLIENT + E + HTTP Client Control Block + + + ZCL_IBMC_SERVICE_ARCH + TO_REST_CLIENT + E + REST HTTP Client + + + + + diff --git a/src/zcl_ibmc_service_ext.clas.abap b/src/zcl_ibmc_service_ext.clas.abap new file mode 100644 index 0000000..da380b1 --- /dev/null +++ b/src/zcl_ibmc_service_ext.clas.abap @@ -0,0 +1,1023 @@ +* Copyright 2019,2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +class ZCL_IBMC_SERVICE_EXT definition + public + inheriting from ZCL_IBMC_SERVICE + create public . + +public section. + + types: + ty_instance_id(32) type c . + types: + ty_servicename(30) type c . + types: + ty_image_format(3) type c . + types TY_IMAGE_CLASS type STRING . + types: + begin of ts_oauth_prop, + url type ts_url, + username type string, + password type string, + apikey type string, + end of ts_oauth_prop . + + constants C_FIELD_NONE type FIELDNAME value '###' ##NO_TEXT. + constants C_FORMAT_JPG type TY_IMAGE_FORMAT value 'jpg' ##NO_TEXT. + constants C_FORMAT_PNG type TY_IMAGE_FORMAT value 'png' ##NO_TEXT. + constants C_FORMAT_GIF type TY_IMAGE_FORMAT value 'gif' ##NO_TEXT. + constants C_FORMAT_TIF type TY_IMAGE_FORMAT value 'tif' ##NO_TEXT. + constants C_FORMAT_ZIP type TY_IMAGE_FORMAT value 'zip' ##NO_TEXT. + constants C_FORMAT_ALL type TY_IMAGE_FORMAT value '*' ##NO_TEXT. + constants C_FORMAT_UNKNOWN type TY_IMAGE_FORMAT value '###' ##NO_TEXT. + constants C_TOKEN_GENERATION_NEVER type CHAR value 'N' ##NO_TEXT. + constants C_TOKEN_GENERATION_ALWAYS type CHAR value 'A' ##NO_TEXT. + constants C_TOKEN_GENERATION_AUTO type CHAR value SPACE ##NO_TEXT. + constants C_IAM_TOKEN_HOST type STRING value 'iam.cloud.ibm.com' ##NO_TEXT. + constants C_IAM_TOKEN_PATH type STRING value '/identity/token' ##NO_TEXT. + data P_INSTANCE_ID type TY_INSTANCE_ID . + data P_SERVICENAME type TY_SERVICENAME . + + "! Sends a HTTP PUT request. + "! + "! @parameter I_REQUEST_PROP | Request properties. + "! @parameter E_RESPONSE | Response returned by service. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_BEARER_TOKEN + returning + value(E_BEARER_TOKEN) type STRING . + "! Returns the SDK built date. + "! + "! @parameter E_SDK_VERSION_DATE | Built data in format YYYYMMDD. + "! + methods GET_SDK_VERSION_DATE + returning + value(E_SDK_VERSION_DATE) type STRING . + "! Method for internal use. + "! + methods SET_BEARER_TOKEN + importing + !I_BEARER_TOKEN type STRING . + "! Retrieves a value of a configuration parameter from table ZIBMC_CONFIG. + "! + "! @parameter I_DEFUALT | Default value, if configuration parameter is not found. + "! @parameter I_PARAM | Configuration parameter name. + "! + methods GET_CONFIG_VALUE + importing + !I_DEFAULT type ZIBMC_CONFIG-VALUE optional + !I_PARAM type ZIBMC_CONFIG-PARAM + returning + value(E_VALUE) type ZIBMC_CONFIG-VALUE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Factory method to instantiate a service specific wrapper class. + "! + "! @parameter I_INSTANCE_ID | + "! Value of field INSTANCE_UID in table ZIBMC_CONFIG. + "! Service credentials are read from table ZIBMC_CONFIG with key SERVICE = Name of service wrapper class without prefix ZCL_IBMC_ and INSTANCE_UID. + "! @parameter I_URL | URL of the service. + "! @parameter I_HOST | Host of the service. I_URL and I_HOST can be used synonymously. + "! @parameter I_USERNAME | User password to authenticate on service. + "! @parameter I_PASSWORD | User password to authenticate on service. + "! @parameter I_PROXY_HOST | Proxy server, not applicable on SAP Cloud Platform. + "! @parameter I_PROXY_PORT | Proxy server port, not applicable on SAP Cloud Platform. + "! @parameter I_APIKEY | API key password to authenticate on service. + "! @parameter I_AUTH_METHOD | Authentication method. Possible values are "IAM", "ICP4D", "basicAuth", "NONE". + "! @parameter I_I_OAUTH_PROP | Credentials to generate token for OAuth authentication. + "! @parameter I_TOKEN_GENERATION | Method for access token refresh:
+ "! C_TOKEN_GENERATION_NEVER - Access token is not refreshed. + "! C_TOKEN_GENERATION_ALWAYS - Access to token is refreshed for each service call. + "! C_TOKEN_GENERATION_AUTO - Access to token is refreshed just before it expires. + "! @parameter I_REQUEST_HEADERS | List of headers sent with every request, format 'Header1=Value1;Header2=Value2'. + "! @parameter I_VERSION | Value of query parameter VERSION. + "! + class-methods GET_INSTANCE + importing + !I_INSTANCE_ID type TY_INSTANCE_ID optional + !I_URL type STRING optional + !I_HOST type STRING optional + !I_USERNAME type STRING optional + !I_PASSWORD type STRING optional + !I_PROXY_HOST type STRING optional + !I_PROXY_SERVICE type STRING optional + !I_APIKEY type STRING optional + !I_AUTH_METHOD type STRING default C_DEFAULT + !I_OAUTH_PROP type TS_OAUTH_PROP optional + !I_TOKEN_GENERATION type CHAR default C_TOKEN_GENERATION_AUTO + !I_REQUEST_HEADERS type STRING optional + !I_VERSION type STRING optional + exporting + value(EO_INSTANCE) type ANY . + "! Compresses multiple images from an internal table to a one or more xstrings in ZIP format. + "! + "! @parameter IT_EXAMPLES | Internal table of images. + "! @parameter IV_FIELD_CLASS | + "! Field in IT_EXAMPLES that contains the file class. + "! All records in IT_EXAMPLES with same class will be compress into one ZIP xstring. + "! @parameter IV_FIELD_FILENAME | Field in IT_EXAMPLES that contains the filename for the image. + "! @parameter IV_FIELD_IMAGE | Field in IT_EXAMPLES that contains the image. + "! @parameter IV_IMAGE_FORMAT | Format of the image. Possible values are + "! C_FORMAT_JPG, C_FORMAT_PNG, C_FORMAT_GIF, C_FORMAT_TIF, C_FORMAT_ALL. + "! @parameter IV_IMAGE_NAME | Name of the image. + "! @parameter ET_ZIPDATA | Internal table containing a compressed ZIP xstring for each image class. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods GET_ZIPDATA + importing + !IT_EXAMPLES type ANY TABLE + !IV_FIELD_CLASS type FIELDNAME default C_FIELD_NONE + !IV_FIELD_FILENAME type FIELDNAME optional + !IV_FIELD_IMAGE type FIELDNAME optional + !IV_IMAGE_FORMAT type TY_IMAGE_FORMAT optional + !IV_IMAGE_NAME type STRING optional + exporting + !ET_ZIPDATA type TT_MAP_FILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + methods GET_ACCESS_TOKEN + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods SET_ACCESS_TOKEN + redefinition . +protected section. +private section. + + data P_OAUTH_PROP type TS_OAUTH_PROP . + data P_TOKEN_GENERATION type CHAR . + data P_TOKEN_SAVED type ZIBMC_TOKEN . + + "! Method for internal use. + "! + class-methods ADD_CONFIG_PROP + importing + !I_SERVICENAME type TY_SERVICENAME + !I_INSTANCE_ID type TY_INSTANCE_ID optional + changing + !C_REQUEST_PROP type ANY . + "! Method for internal use. + "! + class-methods ADD_IMAGE_TO_ZIP + importing + !IS_TABLELINE type ANY + !IO_ZIP type ref to CL_ABAP_ZIP + !IV_BASE64 type BOOLEAN + !IV_FILENAME type STRING optional + !IV_FIELD_IMAGE type FIELDNAME + !IV_FIELD_FILENAME type FIELDNAME optional + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Method for internal use. + "! + class-methods GET_FIELD_DATA + importing + !IS_TABLELINE type ANY + !IV_FIELD_CLASS type FIELDNAME optional + !IV_FIELD_FILENAME type FIELDNAME optional + !IV_FIELD_IMAGE type FIELDNAME optional + exporting + !EV_FIELD_CLASS type FIELDNAME + !EV_FIELD_FILENAME type FIELDNAME + !EV_FIELD_IMAGE type FIELDNAME + !EV_FIELD_IMAGE_BASE64 type FIELDNAME + raising + ZCX_IBMC_SERVICE_EXCEPTION . +ENDCLASS. + + + +CLASS ZCL_IBMC_SERVICE_EXT IMPLEMENTATION. + + + method add_config_prop. + + data: + lt_compname type tt_string, + lv_type type char, + ls_config type zibmc_config, + lt_config type standard table of zibmc_config, + lt_ref type standard table of ref to data, + lr_data type ref to data, + lv_index type i value 0, + ls_url type ts_url value is initial. + + field-symbols: + type any, + type any, + type string, + type any. + + " read config table + if not i_instance_id is initial. + select * + from zibmc_config + where service = @i_servicename and + instance_uid = @i_instance_id + into table @lt_config. + else. + select * + from zibmc_config + where service = @i_servicename and + instance_uid = @space + into table @lt_config. + endif. + + " quit, if no relevant entry in config table exists + check sy-subrc = 0. + + " change config parameter "URL" to "HOST" + ls_config-param = 'HOST'. + modify lt_config from ls_config transporting param where param = 'URL'. + + " perform breadth-first search on c_request_prop to allow setting values on deeper levels, + " e.g. HOST -> c_request_prop-url-host + lr_data = ref #( c_request_prop ). + append lr_data to lt_ref. + + do. + lv_index = lv_index + 1. + read table lt_ref into lr_data index lv_index. + if sy-subrc <> 0. + exit. + endif. + assign lr_data->* to . + + get_components( + exporting + i_structure = + importing + e_components = lt_compname ). + + loop at lt_compname assigning . + assign component of structure to . + check sy-subrc = 0. + get_field_type( + exporting + i_field = + importing + e_technical_type = lv_type ). + if lv_type eq zif_ibmc_service_arch~c_datatype-struct or + lv_type eq zif_ibmc_service_arch~c_datatype-struct_deep. + lr_data = ref #( ). + append lr_data to lt_ref. + else. + if is initial. + read table lt_config into ls_config with key param = ##WARN_OK. + if sy-subrc = 0. + condense ls_config-value. + = ls_config-value. + endif. + endif. + endif. + endloop. + + enddo. + + endmethod. + + + method add_image_to_zip. + data: + lx_image type xstring, + lv_filename type string. + field-symbols: + type any, + type any. + + if not iv_filename is initial. + lv_filename = iv_filename. + else. + assign component iv_field_filename of structure is_tableline to . + lv_filename = conv #( ). " type conversion + if lv_filename is initial. + raise_exception( i_msgno = '056' ). + endif. + endif. + + assign component iv_field_image of structure is_tableline to . + + if iv_base64 eq c_boolean_true. + + lx_image = base64_decode( i_base64 = ). + + io_zip->add( + name = lv_filename + content = lx_image ). + + else. + + io_zip->add( + name = lv_filename + content = ). + + endif. + + endmethod. + + + method get_access_token. + data: + lo_response type to_rest_response, + lv_grand_urlencoded type string, + lv_key_urlencoded type string, + lv_json type string, + lv_seconds type i, + lv_timestamp type timestamp, + ls_token type zibmc_token value is initial, + ls_timestamp type timestamp, + begin of ls_token_classic, + token type string, + end of ls_token_classic. + + if not p_token_saved is initial. + ls_token = p_token_saved. + else. + + select single * + from zibmc_token + where service = @p_servicename and + instance_uid = @p_instance_id + into @ls_token. + + endif. + + " check if access token has expired + get time stamp field ls_timestamp. + if ls_timestamp >= ls_token-expires_ts. + clear ls_token. + endif. + + " (re)new token unless it is still valid + if ls_token-access_token is initial and p_token_generation ne c_token_generation_never. + + data: + ls_token_request_prop type ts_request_prop. + + ls_token_request_prop-url = p_oauth_prop-url. + " set to tribool_false to distinguish between false and inital + ls_token_request_prop-auth_basic = c_tribool_false. + ls_token_request_prop-auth_oauth = c_tribool_false. + ls_token_request_prop-auth_apikey = c_tribool_false. + ls_token_request_prop-header_accept = zcl_ibmc_service=>zif_ibmc_service_arch~c_mediatype-appl_json. + + + if i_request_prop-auth_name eq 'IAM' ##NO_TEXT. + + " write urlencoded parameters + if not ls_token-refresh_token is initial. + lv_grand_urlencoded = escape( val = 'refresh_token' format = cl_abap_format=>e_uri_full ) ##NO_TEXT. + lv_key_urlencoded = escape( val = ls_token-refresh_token format = cl_abap_format=>e_uri_full ). + ls_token_request_prop-body = `grant_type=` && lv_grand_urlencoded && `&refresh_token=` && lv_key_urlencoded ##NO_TEXT. + else. + if not p_oauth_prop-apikey is initial. + lv_grand_urlencoded = escape( val = 'urn:ibm:params:oauth:grant-type:apikey' format = cl_abap_format=>e_uri_full ) ##NO_TEXT. + lv_key_urlencoded = escape( val = p_oauth_prop-apikey format = cl_abap_format=>e_uri_full ). + ls_token_request_prop-body = `grant_type=` && lv_grand_urlencoded && `&apikey=` && lv_key_urlencoded ##NO_TEXT. + elseif not p_oauth_prop-password is initial. + lv_grand_urlencoded = escape( val = 'urn:ibm:params:oauth:grant-type:password' format = cl_abap_format=>e_uri_full ) ##NO_TEXT. + lv_key_urlencoded = escape( val = p_oauth_prop-password format = cl_abap_format=>e_uri_full ). + ls_token_request_prop-body = `grant_type=` && lv_grand_urlencoded && `&username=` && p_oauth_prop-username && `&password=` && p_oauth_prop-password ##NO_TEXT. + else. + ls_token_request_prop-username = p_oauth_prop-username. + ls_token_request_prop-password = p_oauth_prop-password. + ls_token_request_prop-apikey = p_oauth_prop-apikey. + endif. + endif. + ls_token_request_prop-header_content_type = zcl_ibmc_service=>zif_ibmc_service_arch~c_mediatype-appl_www_form_urlencoded. + + " execute HTTP POST request + lo_response = http_post( i_request_prop = ls_token_request_prop ). + + " receive response json + lv_json = get_response_string( lo_response ). + + " call json parser (ignore properties that do not exist in abap structure) + parse_json( + exporting + i_json = lv_json + changing + c_abap = ls_token ). + + else. + + if i_request_prop-auth_body eq c_boolean_true. + + " POST request having username/password in body (e.g. for Db2 Warehouse) + ls_token_request_prop-body = `{ "userid": "` && p_oauth_prop-username && `", "password": "` && p_oauth_prop-password && `" }` ##NO_TEXT. + ls_token_request_prop-header_content_type = zcl_ibmc_service=>zif_ibmc_service_arch~c_mediatype-appl_json. + + " execute HTTP POST request + lo_response = http_post( i_request_prop = ls_token_request_prop ). + + else. + + ls_token_request_prop-username = p_oauth_prop-username. + ls_token_request_prop-password = p_oauth_prop-password. + ls_token_request_prop-apikey = p_oauth_prop-apikey. + ls_token_request_prop-auth_basic = c_boolean_true. + + " execute HTTP GET request + lo_response = http_get( i_request_prop = ls_token_request_prop ). + + " receive response json + lv_json = get_response_string( lo_response ). + + " call json parser + parse_json( + exporting + i_json = lv_json + changing + c_abap = ls_token_classic ). + ls_token-expires_in = 3600. + ls_token-token_type = 'Bearer' ##NO_TEXT. + + endif. + + endif. + + + " calculate expiration time + if ls_token-expires_in > 0. + get time stamp field lv_timestamp. + lv_seconds = ls_token-expires_in - 300. " subtract 5 minutes to be save + ls_token-expires_ts = cl_abap_tstmp=>add( tstmp = lv_timestamp secs = lv_seconds ). + endif. + + ls_token-service = p_servicename. + ls_token-instance_uid = p_instance_id. + + if p_token_generation eq c_token_generation_auto. + modify zibmc_token from @ls_token. + commit work. + endif. + + p_token_saved = ls_token. + + endif. + + " fill returning parameter + move-corresponding ls_token to e_access_token ##ENH_OK. + + endmethod. + + + method get_bearer_token. + + data: + ls_access_token type ts_access_token. + + try. + ls_access_token = get_access_token( ). + catch zcx_ibmc_service_exception. + clear ls_access_token. + endtry. + + + if ls_access_token-token_type eq 'Bearer'. + e_bearer_token = ls_access_token-access_token. + else. + clear e_bearer_token. + endif. + + endmethod. + + + method get_config_value. + + + select single value + from zibmc_config + where param = @i_param and + service = @p_servicename and + instance_uid = @p_instance_id + into @e_value. + + if sy-subrc <> 0. + select single value + from zibmc_config + where param = @i_param and + service = @p_servicename and + instance_uid = @space + into @e_value. + + if sy-subrc <> 0. + if i_default is supplied. + e_value = i_default. + else. + raise exception type zcx_ibmc_service_exception. + endif. + endif. + + endif. + + endmethod. + + + method get_field_data. + + data: + begin of ls_comp, + name type string, + type type char, + length type i, + end of ls_comp, + lt_comp like standard table of ls_comp, + lt_compname type tt_string, + lv_msg1 type string. + field-symbols: + type any. + + get_components( + exporting + i_structure = is_tableline + importing + e_components = lt_compname ). + + loop at lt_compname into ls_comp-name. + assign component ls_comp-name of structure is_tableline to . + get_field_type( + exporting + i_field = + importing + e_technical_type = ls_comp-type + e_length = ls_comp-length ). + append ls_comp to lt_comp. + endloop. + + clear: ev_field_class, ev_field_filename, ev_field_image, ev_field_image_base64. + + if ev_field_class is requested. + if not iv_field_class is initial. + " field that contains class name is explicit specified + ev_field_class = iv_field_class. + else. + " field CLASS + read table lt_comp with key name = 'CLASS' into ls_comp. + if sy-subrc = 0 and + ( ls_comp-type eq 'C' or ls_comp-type eq 'g' or ls_comp-type eq 'N' ). " character type + ev_field_class = ls_comp-name. + else. + " first field of character type and length 6 or more contains class name + loop at lt_comp into ls_comp where ( type eq 'C' or type eq 'N' ) and length >= 6 and + name ne 'FILENAME' and name ne 'IMAGE' and name ne 'IMAGE_BASE64'. + ev_field_class = ls_comp-name. + exit. + endloop. + endif. + if ev_field_class is initial. + " first field of type string contains class name + loop at lt_comp into ls_comp where type eq 'g' and + name ne 'FILENAME' and name ne 'IMAGE' and name ne 'IMAGE_BASE64'. + ev_field_class = ls_comp-name. + exit. + endloop. + endif. + endif. + endif. + + + if ev_field_filename is requested. + if not iv_field_filename is initial. + " field that contains image name is explicit specified + ev_field_filename = iv_field_filename. + else. + read table lt_comp with key name = 'FILENAME' into ls_comp. + if sy-subrc = 0 and + ( ls_comp-type eq 'C' or ls_comp-type eq 'g' or ls_comp-type eq 'N' ). + ev_field_filename = ls_comp-name. + else. + " first field of character type and length 12 or more contains image name + loop at lt_comp into ls_comp where ( type eq 'C' or type eq 'N' ) and length >= 12 and + name ne ev_field_class and name ne 'IMAGE' and name ne 'IMAGE_BASE64'. + ev_field_filename = ls_comp-name. + exit. + endloop. + endif. + if ev_field_filename is initial. + " first field of type string contains image name + loop at lt_comp into ls_comp where type eq 'g' and name ne ev_field_class. + ev_field_filename = ls_comp-name. + exit. + endloop. + endif. + endif. + endif. + + + if ev_field_image is requested. + if not iv_field_image is initial. + " field that contains image data is explicit specified + + " check image field data type to determine encoding + read table lt_comp into ls_comp with key name = iv_field_image. + if sy-subrc <> 0. + lv_msg1 = conv #( ev_field_image ). " type conversion + raise_exception( + i_msgno = '054' " Field &1 is missing or has incompatible type. + i_msgv1 = lv_msg1 ). + endif. + if ls_comp-type eq 'g'. + " image is base64 encoded + ev_field_image_base64 = iv_field_image. + else. + " image in binary data + ev_field_image = iv_field_image. + endif. + + else. + read table lt_comp with key name = 'IMAGE' into ls_comp. + if sy-subrc <> 0. + read table lt_comp with key name = 'IMAGE_BASE64' into ls_comp. + endif. + if sy-subrc = 0 and + ( ls_comp-type eq 'y' or ls_comp-type eq 'g' ). " xstring or string + if ls_comp-type eq 'g'. + ev_field_image_base64 = ls_comp-name. + else. + ev_field_image = ls_comp-name. + endif. + else. + " first field of type xstring contains image data (binary) + loop at lt_comp into ls_comp where type eq 'y' and + name ne ev_field_class and name ne ev_field_filename. + ev_field_image = ls_comp-name. + exit. + endloop. + endif. + if ev_field_image is initial. + " first field of type string contains image data (base64 encoded) + loop at lt_comp into ls_comp where type eq 'g' and + name ne ev_field_class and name ne ev_field_filename. + ev_field_image_base64 = ls_comp-name. + exit. + endloop. + endif. + endif. + endif. + + endmethod. + + + method get_instance. + data: + lv_classname type string, + ls_request_prop type ts_request_prop, + lo_instance type ref to zcl_ibmc_service_ext, + lt_headerstr type tt_string, + lv_headerstr type string, + ls_header type ts_header. + + " instantiate object of type of exporting parameter + get_field_type( + exporting + i_field = eo_instance + importing + e_relative_type = lv_classname ). + + create object eo_instance type (lv_classname) + exporting + i_url = i_url + i_host = i_host + i_username = i_username + i_password = i_password + i_apikey = i_apikey. + + lo_instance ?= eo_instance. + + " Set service name (= class name without namespace and prefix 'CL_') + if lv_classname cp 'Z*'. + find first occurrence of regex 'ZCL_[^_]*_([^\/]*)$' in lv_classname submatches lo_instance->p_servicename. + else. + find first occurrence of regex 'CL_([^\/]*)$' in lv_classname submatches lo_instance->p_servicename. + endif. + if lo_instance->p_servicename is initial. + find first occurrence of regex '([^\/]*)$' in lv_classname submatches lo_instance->p_servicename. + if lo_instance->p_servicename is initial. + lo_instance->p_servicename = lv_classname. + endif. + endif. + + " Set default request headers + split i_request_headers at ';' into table lt_headerstr. + if sy-subrc = 0. + loop at lt_headerstr into lv_headerstr. + split lv_headerstr at '=' into ls_header-name ls_header-value. + if sy-subrc = 0. + append ls_header to lo_instance->p_request_prop_default-headers. + endif. + endloop. + endif. + + " Set instance ID + if not i_instance_id is initial. + lo_instance->p_instance_id = i_instance_id. + else. + lo_instance->p_instance_id = get_progname( ). + endif. + + " Merge properties from config table for this service and instance + add_config_prop( + exporting + i_servicename = lo_instance->p_servicename + i_instance_id = lo_instance->p_instance_id + changing + c_request_prop = lo_instance->p_request_prop_default ). + + normalize_url( changing c_url = lo_instance->p_request_prop_default-url ). + + " Merge properties from config table for this service type + add_config_prop( + exporting + i_servicename = lo_instance->p_servicename + changing + c_request_prop = lo_instance->p_request_prop_default ). + + normalize_url( changing c_url = lo_instance->p_request_prop_default-url ). + + " Get service default properties + ls_request_prop = lo_instance->get_request_prop( i_auth_method = i_auth_method ). + merge_structure( + exporting + i_alternative = ls_request_prop + changing + c_base = lo_instance->p_request_prop_default ). + + " Ensure that OAuth is set in case IAM is used. + if lo_instance->p_request_prop_default-auth_name eq 'IAM'. + lo_instance->p_request_prop_default-auth_oauth = c_boolean_true. + endif. + + " Set OAuth properties + lo_instance->p_oauth_prop = i_oauth_prop. + normalize_url( + changing + c_url = lo_instance->p_oauth_prop-url ). + if ls_request_prop-auth_name eq 'IAM' ##NO_TEXT. + if lo_instance->p_oauth_prop-url-host is initial. + lo_instance->p_oauth_prop-url-protocol = 'https' ##NO_TEXT. + lo_instance->p_oauth_prop-url-host = c_iam_token_host. + endif. + if lo_instance->p_oauth_prop-url-path_base is initial and lo_instance->p_oauth_prop-url-path is initial. + " Set path_base (not path), otherwise the default service path_base would be added, which is not correct + lo_instance->p_oauth_prop-url-path_base = c_iam_token_path. + endif. + if lo_instance->p_oauth_prop-password is initial and lo_instance->p_oauth_prop-apikey is initial. + lo_instance->p_oauth_prop-username = lo_instance->p_request_prop_default-username. + lo_instance->p_oauth_prop-password = lo_instance->p_request_prop_default-password. + lo_instance->p_oauth_prop-apikey = lo_instance->p_request_prop_default-apikey. + endif. + endif. + + lo_instance->p_token_generation = i_token_generation. + + lo_instance->p_version = i_version. + + endmethod. + + + method get_request_prop. + data: + lv_auth_method type string. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + endif. + endmethod. + + + method get_sdk_version_date. + + e_sdk_version_date = ''. + + endmethod. + + + method get_zipdata. + + constants: + c_class_all type string value '#ALL#'. + + data: + lv_field_class type fieldname, + lv_field_filename type fieldname, + lv_field_image type fieldname, + lv_field_image_base64 type fieldname, + lv_field_image_act type fieldname, + lv_base64 type boolean, + lr_data type ref to data, + ls_zipdata type ts_map_file, + lv_image_count type i, + lv_class type ty_image_class, + lt_classes type standard table of ty_image_class, + lv_filename type string, + lv_filename_suffix(4) type n value 0, + lo_zip type ref to cl_abap_zip value is initial, + lv_image_name type string, + lv_image_format type ty_image_format. + field-symbols: + type any, + type any, + type any, + type any. + + create data lr_data like line of it_examples. + assign lr_data->* to . + + " determine field with filename + if iv_field_filename is initial or iv_field_filename eq c_field_none. + if not iv_image_name is initial. + lv_field_filename = c_field_none. + lv_image_name = iv_image_name. + endif. + else. + lv_field_filename = iv_field_filename. + clear: lv_image_name, lv_image_format. + endif. + + " get field names + get_field_data( + exporting + is_tableline = + iv_field_class = iv_field_class + iv_field_filename = lv_field_filename + iv_field_image = iv_field_image + importing + ev_field_class = lv_field_class + ev_field_filename = lv_field_filename + ev_field_image = lv_field_image + ev_field_image_base64 = lv_field_image_base64 ). + + " reset field name for filename if explicitly set to 'none'. + if lv_field_filename eq c_field_none. + clear lv_field_filename. + endif. + + + if iv_field_class eq c_field_none. + " do not separate into different classes + append c_class_all to lt_classes. + else. + " compile list of different classes + loop at it_examples assigning . + assign component lv_field_class of structure to . + append to lt_classes. + endloop. + sort lt_classes. + delete adjacent duplicates from lt_classes. + endif. + + " determine default image format + if iv_image_format is initial or + iv_image_format eq c_format_all or + iv_image_format eq c_format_unknown. + lv_image_format = c_format_jpg. + else. + lv_image_format = iv_image_format. + endif. + translate lv_image_format to lower case. + + + " generate a zip data xstring per class + loop at lt_classes into lv_class. + check not lv_class is initial. + + create object lo_zip. + + lv_image_count = 0. + + loop at it_examples assigning . + if lv_class ne c_class_all. + assign component lv_field_class of structure to . + check eq lv_class. + endif. + + " determine filename + clear lv_filename. + if not lv_field_filename is initial. + assign component lv_field_filename of structure to . + if sy-subrc = 0. + " remove path from filename + find regex '([^/\\]*)$' in submatches lv_filename. + endif. + endif. + + " if valid filename was not found, use the default + if lv_filename np '*+.+++'. + if lv_filename is initial. + if lv_image_name is initial. + lv_filename = lv_class && lv_filename_suffix && `.` && lv_image_format. + else. + lv_filename = lv_image_name && lv_filename_suffix && `.` && lv_image_format. + endif. + else. + lv_filename = lv_filename && `.` && lv_image_format. + endif. + lv_filename_suffix = lv_filename_suffix + 1. + endif. + + " determine image encoding + if lv_field_image is initial. + lv_field_image_act = lv_field_image_base64. + lv_base64 = c_boolean_true. + elseif lv_field_image_base64 is initial. + lv_field_image_act = lv_field_image. + lv_base64 = c_boolean_false. + else. + assign component lv_field_image of structure to . + if not is initial. + lv_field_image_act = lv_field_image. + lv_base64 = c_boolean_false. + else. + lv_field_image_act = lv_field_image_base64. + lv_base64 = c_boolean_true. + endif. + endif. + + " add image to zip data + add_image_to_zip( + exporting + io_zip = lo_zip + is_tableline = + iv_filename = lv_filename + iv_field_image = lv_field_image_act + iv_base64 = lv_base64 ). + + lv_image_count = lv_image_count + 1. + + endloop. + + if lv_image_count > 0. + + ls_zipdata-key = lv_class. + ls_zipdata-data = lo_zip->save( ). + append ls_zipdata to et_zipdata. + + endif. + + endloop. + + endmethod. + + + method set_access_token. + + super->set_access_token( i_access_token = i_access_token ). + + clear p_token_saved. + p_token_saved-access_token = i_access_token-access_token. + p_token_saved-token_type = i_access_token-token_type. + p_token_saved-expires_ts = '99991231235959' ##LITERAL. " avoid token being refreshed by sdk + + endmethod. + + + method set_bearer_token. + + data: + ls_access_token type ts_access_token. + + ls_access_token-token_type = 'Bearer' ##NO_TEXT. + ls_access_token-access_token = i_bearer_token. + try. + set_access_token( i_access_token = ls_access_token ). + catch zcx_ibmc_service_exception ##NO_HANDLER. + endtry. + + endmethod. +ENDCLASS. diff --git a/src/zcl_ibmc_service_ext.clas.xml b/src/zcl_ibmc_service_ext.clas.xml new file mode 100644 index 0000000..b4efd87 --- /dev/null +++ b/src/zcl_ibmc_service_ext.clas.xml @@ -0,0 +1,120 @@ + + + + + + ZCL_IBMC_SERVICE_EXT + E + Extended REST API service class + 1 + X + X + X + + + + ZCL_IBMC_SERVICE_EXT + ADD_IMAGE_TO_ZIP + E + Adds an image to zip data + + + ZCL_IBMC_SERVICE_EXT + C_FIELD_NONE + E + Field Name + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_ALL + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_GIF + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_JPG + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_PNG + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_TIF + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_UNKNOWN + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + C_FORMAT_ZIP + E + Image encoding (jpg, png, ...) + + + ZCL_IBMC_SERVICE_EXT + GET_BEARER_TOKEN + E + Returns the bearer token, if available + + + ZCL_IBMC_SERVICE_EXT + GET_CONFIG_VALUE + E + Reads an individual value form table ZIBMC_CONFIG + + + ZCL_IBMC_SERVICE_EXT + GET_FIELD_DATA + E + Determines fields containing image name and image data + + + ZCL_IBMC_SERVICE_EXT + GET_INSTANCE + E + Creates an IBM Cloud service class instance + + + ZCL_IBMC_SERVICE_EXT + GET_SDK_VERSION_DATE + E + returns the build date of the method + + + ZCL_IBMC_SERVICE_EXT + GET_ZIPDATA + E + Creates or Updates a classifier + + + ZCL_IBMC_SERVICE_EXT + P_TOKEN_SAVED + E + IAM tokens + + + ZCL_IBMC_SERVICE_EXT + SET_BEARER_TOKEN + E + Sets the bearer token + + + + + diff --git a/src/zcl_ibmc_speech_to_text_v1.clas.abap b/src/zcl_ibmc_speech_to_text_v1.clas.abap new file mode 100644 index 0000000..e95d39a --- /dev/null +++ b/src/zcl_ibmc_speech_to_text_v1.clas.abap @@ -0,0 +1,5465 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM® Speech to Text service provides APIs that use IBM's +"! speech-recognition capabilities to produce transcripts of spoken audio. The +"! service can transcribe speech from various languages and audio formats. In +"! addition to basic transcription, the service can produce detailed information +"! about many different aspects of the audio. For most languages, the service +"! supports two sampling rates, broadband and narrowband. It returns all JSON +"! response content in the UTF-8 character set.
+"!
+"! For speech recognition, the service supports synchronous and asynchronous HTTP +"! Representational State Transfer (REST) interfaces. It also supports a WebSocket +"! interface that provides a full-duplex, low-latency communication channel: +"! Clients send requests and audio to the service and receive results over a +"! single connection asynchronously.
+"!
+"! The service also offers two customization interfaces. Use language model +"! customization to expand the vocabulary of a base model with domain-specific +"! terminology. Use acoustic model customization to adapt a base model for the +"! acoustic characteristics of your audio. For language model customization, the +"! service also supports grammars. A grammar is a formal language specification +"! that lets you restrict the phrases that the service can recognize.
+"!
+"! Language model customization is generally available for production use with most +"! supported languages. Acoustic model customization is beta functionality that is +"! available for all supported languages.
+class ZCL_IBMC_SPEECH_TO_TEXT_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! A warning from training of a custom language or custom acoustic model. + begin of T_TRAINING_WARNING, + "! An identifier for the type of invalid resources listed in the `description` + "! field. + CODE type STRING, + "! 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.`. + MESSAGE type STRING, + end of T_TRAINING_WARNING. + types: + "! The response from training of a custom language or custom acoustic model. + begin of T_TRAINING_RESPONSE, + "! 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`. + WARNINGS type STANDARD TABLE OF T_TRAINING_WARNING WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_RESPONSE. + types: + "! An alternative hypothesis for a word from speech recognition results. + begin of T_WORD_ALTERNATIVE_RESULT, + "! A confidence score for the word alternative hypothesis in the range of 0.0 to + "! 1.0. + CONFIDENCE type DOUBLE, + "! An alternative hypothesis for a word from the input audio. + WORD type STRING, + end of T_WORD_ALTERNATIVE_RESULT. + types: + "! Information about alternative hypotheses for words from speech recognition + "! results. + begin of T_WORD_ALTERNATIVE_RESULTS, + "! The start time in seconds of the word from the input audio that corresponds to + "! the word alternatives. + START_TIME type DOUBLE, + "! The end time in seconds of the word from the input audio that corresponds to the + "! word alternatives. + END_TIME type DOUBLE, + "! An array of alternative hypotheses for a word from the input audio. + ALTERNATIVES type STANDARD TABLE OF T_WORD_ALTERNATIVE_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_WORD_ALTERNATIVE_RESULTS. + types: + "! 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. + begin of T_AUDIO_METRICS_HISTOGRAM_BIN, + "! The lower boundary of the bin in the histogram. + BEGIN type FLOAT, + "! The upper boundary of the bin in the histogram. + END type FLOAT, + "! The number of values in the bin of the histogram. + COUNT type INTEGER, + end of T_AUDIO_METRICS_HISTOGRAM_BIN. + types: + "! Information about the speakers from speech recognition results. + begin of T_SPEAKER_LABELS_RESULT, + "! The start time of a word from the transcript. The value matches the start time + "! of a word from the `timestamps` array. + FROM type FLOAT, + "! The end time of a word from the transcript. The value matches the end time of a + "! word from the `timestamps` array. + TO type FLOAT, + "! 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. + SPEAKER type INTEGER, + "! A score that indicates the service's confidence in its identification of the + "! speaker in the range of 0.0 to 1.0. + CONFIDENCE type FLOAT, + "! 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. + FINAL type BOOLEAN, + end of T_SPEAKER_LABELS_RESULT. + types: + "! An alternative transcript from speech recognition results. + begin of T_SPCH_RECOGNITION_ALTERNATIVE, + "! A transcription of the audio. + TRANSCRIPT type STRING, + "! A score that indicates the service's confidence in the transcript in the range + "! of 0.0 to 1.0. A confidence score is returned only for the best alternative and + "! only with results marked as final. + CONFIDENCE type DOUBLE, + "! 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. + TIMESTAMPS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! A confidence score for each word of the transcript as a list of lists. Each + "! inner list consists of two elements: the word and its confidence score in the + "! range of 0.0 to 1.0, for example: `[["hello",0.95],["world",0.866]]`. + "! Confidence scores are returned only for the best alternative and only with + "! results marked as final. + WORD_CONFIDENCE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SPCH_RECOGNITION_ALTERNATIVE. + types: + "! Detailed timing information about the service's processing of the input audio. + begin of T_PROCESSED_AUDIO, + "! 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. + RECEIVED type FLOAT, + "! 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. + SEEN_BY_ENGINE type FLOAT, + "! The seconds of audio that the service has processed for speech recognition as of + "! this response. + TRANSCRIPTION type FLOAT, + "! 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. + SPEAKER_LABELS type FLOAT, + end of T_PROCESSED_AUDIO. + types: + "! If processing metrics are requested, information about the service's processing + "! of the input audio. Processing metrics are not available with the synchronous + "! **Recognize audio** method. + begin of T_PROCESSING_METRICS, + "! Detailed timing information about the service's processing of the input audio. + PROCESSED_AUDIO type T_PROCESSED_AUDIO, + "! 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. + WLL_CLCK_SNC_FRST_BYT_RECEIVED type FLOAT, + "! 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. + PERIODIC type BOOLEAN, + end of T_PROCESSING_METRICS. + types: + "! Detailed information about the signal characteristics of the input audio. + begin of T_AUDIO_METRICS_DETAILS, + "! 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. + FINAL type BOOLEAN, + "! The end time in seconds of the block of audio to which the metrics apply. + END_TIME type FLOAT, + "! 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. + SIGNAL_TO_NOISE_RATIO type FLOAT, + "! The ratio of speech to non-speech segments in the audio signal. The value lies + "! in the range of 0.0 to 1.0. + SPEECH_RATIO type FLOAT, + "! 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. + HIGH_FREQUENCY_LOSS type FLOAT, + "! An array of `AudioMetricsHistogramBin` objects that defines a histogram of the + "! cumulative direct current (DC) component of the audio signal. + DIRECT_CURRENT_OFFSET type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + "! 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. + CLIPPING_RATE type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + "! 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). + SPEECH_LEVEL type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + "! 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). + NON_SPEECH_LEVEL type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + end of T_AUDIO_METRICS_DETAILS. + types: + "! If audio metrics are requested, information about the signal characteristics of + "! the input audio. + begin of T_AUDIO_METRICS, + "! 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. + SAMPLING_INTERVAL type FLOAT, + "! Detailed information about the signal characteristics of the input audio. + ACCUMULATED type T_AUDIO_METRICS_DETAILS, + end of T_AUDIO_METRICS. + types: + "! Component results for a speech recognition request. + begin of T_SPEECH_RECOGNITION_RESULT, + "! 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. + FINAL type BOOLEAN, + "! An array of alternative transcripts. The `alternatives` array can include + "! additional requested output such as word confidence or timestamps. + ALTERNATIVES type STANDARD TABLE OF T_SPCH_RECOGNITION_ALTERNATIVE WITH NON-UNIQUE DEFAULT KEY, + "! 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. + KEYWORDS_RESULT type MAP, + "! An array of alternative hypotheses found for words of the input audio if a + "! `word_alternatives_threshold` is specified. + WORD_ALTERNATIVES type STANDARD TABLE OF T_WORD_ALTERNATIVE_RESULTS WITH NON-UNIQUE DEFAULT KEY, + "! 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. + "! + END_OF_UTTERANCE type STRING, + end of T_SPEECH_RECOGNITION_RESULT. + types: + "! The complete results for a speech recognition request. + begin of T_SPEECH_RECOGNITION_RESULTS, + "! An array of `SpeechRecognitionResult` objects that can include interim and final + "! results (interim results are returned only if supported by the method). Final + "! results are guaranteed not to change; interim results might be replaced by + "! further interim results and final results. The service periodically sends + "! updates to the results list; the `result_index` is set to the lowest index in + "! the array that has changed; it is incremented for new results. + RESULTS type STANDARD TABLE OF T_SPEECH_RECOGNITION_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! 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. + RESULT_INDEX type INTEGER, + "! 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. + SPEAKER_LABELS type STANDARD TABLE OF T_SPEAKER_LABELS_RESULT WITH NON-UNIQUE DEFAULT KEY, + "! If processing metrics are requested, information about the service's processing + "! of the input audio. Processing metrics are not available with the synchronous + "! **Recognize audio** method. + PROCESSING_METRICS type T_PROCESSING_METRICS, + "! If audio metrics are requested, information about the signal characteristics of + "! the input audio. + AUDIO_METRICS type T_AUDIO_METRICS, + "! 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. + WARNINGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SPEECH_RECOGNITION_RESULTS. + types: + "! Information about a grammar from a custom language model. + begin of T_GRAMMAR, + "! The name of the grammar. + NAME type STRING, + "! The number of OOV words in the grammar. The value is `0` while the grammar is + "! being processed. + OUT_OF_VOCABULARY_WORDS type INTEGER, + "! 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. + STATUS type STRING, + "! 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'.`. + ERROR type STRING, + end of T_GRAMMAR. + types: + "! Information about the grammars from a custom language model. + begin of T_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. + GRAMMARS type STANDARD TABLE OF T_GRAMMAR WITH NON-UNIQUE DEFAULT KEY, + end of T_GRAMMARS. + types: + "! Information about a current asynchronous speech recognition job. + begin of T_RECOGNITION_JOB, + "! The ID of the asynchronous job. + ID type STRING, + "! 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. + STATUS type STRING, + "! 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`). + CREATED type STRING, + "! 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. + UPDATED type STRING, + "! 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. + URL type STRING, + "! 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. + USER_TOKEN type STRING, + "! 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. + RESULTS type STANDARD TABLE OF T_SPEECH_RECOGNITION_RESULTS WITH NON-UNIQUE DEFAULT KEY, + "! 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. + WARNINGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_RECOGNITION_JOB. + types: + "! Information about current asynchronous speech recognition jobs. + begin of T_RECOGNITION_JOBS, + "! An array of `RecognitionJob` objects that provides the status for each of the + "! user's current jobs. The array is empty if the user has no current jobs. + RECOGNITIONS type STANDARD TABLE OF T_RECOGNITION_JOB WITH NON-UNIQUE DEFAULT KEY, + end of T_RECOGNITION_JOBS. + types: + "! Information about an audio resource from a custom acoustic model. + begin of T_AUDIO_DETAILS, + "! 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). + TYPE type STRING, + "! **For an audio-type resource,** the codec in which the audio is encoded. Omitted + "! ** for an archive-type resource. + CODEC type STRING, + "! **For an audio-type resource,** the sampling rate of the audio in Hertz (samples + "! ** per second). Omitted for an archive-type resource. + FREQUENCY type INTEGER, + "! **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. + COMPRESSION type STRING, + end of T_AUDIO_DETAILS. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + "! Description of the problem. + ERROR type STRING, + "! HTTP response code. + CODE type INTEGER, + "! Response message. + CODE_DESCRIPTION type STRING, + "! Warnings associated with the error. + WARNINGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_ERROR_MODEL. + types: + "! Information about an audio resource from a custom acoustic model. + begin of T_AUDIO_RESOURCE, + "! The total seconds of audio in the audio resource. + DURATION type INTEGER, + "! **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. + NAME type STRING, + "! An `AudioDetails` object that provides detailed information about the audio + "! resource. The object is empty until the service finishes processing the audio. + DETAILS type T_AUDIO_DETAILS, + "! 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. + STATUS type STRING, + end of T_AUDIO_RESOURCE. + types: + "! Information about an audio resource from a custom acoustic model. + begin of T_AUDIO_LISTING, + "! **For an audio-type resource,** the total seconds of audio in the resource. + "! ** Omitted for an archive-type resource. + DURATION type INTEGER, + "! **For an audio-type resource,** the user-specified name of the resource. Omitted + "! ** for an archive-type resource. + NAME type STRING, + "! **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. + DETAILS type T_AUDIO_DETAILS, + "! **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. + STATUS type STRING, + "! **For an archive-type resource,** an object of type `AudioResource` that provides + "! ** information about the resource. Omitted for an audio-type resource. + CONTAINER type T_AUDIO_RESOURCE, + "! **For an archive-type resource,** an array of `AudioResource` objects that + "! ** provides information about the audio-type resources that are contained in the + "! ** resource. Omitted for an audio-type resource. + AUDIO type STANDARD TABLE OF T_AUDIO_RESOURCE WITH NON-UNIQUE DEFAULT KEY, + end of T_AUDIO_LISTING. + types: + "! An error associated with a word from a custom language model. + begin of T_WORD_ERROR, + "! 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}'."`. + ELEMENT type STRING, + end of T_WORD_ERROR. + types: + "! Information about a word from a custom language model. + begin of T_WORD, + "! A word from the custom model's words resource. The spelling of the word is used + "! to train the model. + WORD type STRING, + "! 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. + SOUNDS_LIKE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + DISPLAY_AS type STRING, + "! 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. + COUNT type INTEGER, + "! 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`. + SOURCE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + ERROR type STANDARD TABLE OF T_WORD_ERROR WITH NON-UNIQUE DEFAULT KEY, + end of T_WORD. + types: + "! Information about the words from a custom language model. + begin of T_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. + WORDS type STANDARD TABLE OF T_WORD WITH NON-UNIQUE DEFAULT KEY, + end of T_WORDS. + types: + "! Information about a word that is to be added to a custom language model. + begin of T_CUSTOM_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 parameter for the **Add a custom word** method. + WORD type STRING, + "! 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. A pronunciation can + "! include at most 40 characters not including spaces. + SOUNDS_LIKE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! 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. + DISPLAY_AS type STRING, + end of T_CUSTOM_WORD. + types: + "! Information about the audio resources from a custom acoustic model. + begin of T_AUDIO_RESOURCES, + "! 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. + TOTAL_MINUTES_OF_AUDIO type DOUBLE, + "! 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. + AUDIO type STANDARD TABLE OF T_AUDIO_RESOURCE WITH NON-UNIQUE DEFAULT KEY, + end of T_AUDIO_RESOURCES. + types: + "! Information about a corpus from a custom language model. + begin of T_CORPUS, + "! The name of the corpus. + NAME type STRING, + "! The total number of words in the corpus. The value is `0` while the corpus is + "! being processed. + TOTAL_WORDS type INTEGER, + "! The number of OOV words in the corpus. The value is `0` while the corpus is + "! being processed. + OUT_OF_VOCABULARY_WORDS type INTEGER, + "! 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. + STATUS type STRING, + "! 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'`. + ERROR type STRING, + end of T_CORPUS. + types: + "! Information about the corpora from a custom language model. + begin of T_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. + CORPORA type STANDARD TABLE OF T_CORPUS WITH NON-UNIQUE DEFAULT KEY, + end of T_CORPORA. + types: + "! Information about an existing custom language model. + begin of T_LANGUAGE_MODEL, + "! 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. + CUSTOMIZATION_ID type STRING, + "! 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`). + CREATED type STRING, + "! 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). + UPDATED type STRING, + "! The language identifier of the custom language model (for example, `en-US`). + LANGUAGE type STRING, + "! The dialect of the language for the custom language model. For non-Spanish + "! models, the field matches the language of the base model; for example, `en-US` + "! for either of the US English language models. For Spanish models, the field + "! indicates the dialect for which the model was created:
+ "! * `es-ES` for Castilian Spanish (`es-ES` models)
+ "! * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` + "! models)
+ "! * `es-US` for Mexican (North American) Spanish (`es-MX` models)
+ "!
+ "! Dialect values are case-insensitive. + DIALECT type STRING, + "! 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. + VERSIONS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The GUID of the credentials for the instance of the service that owns the custom + "! language model. + OWNER type STRING, + "! The name of the custom language model. + NAME type STRING, + "! The description of the custom language model. + DESCRIPTION type STRING, + "! The name of the language model for which the custom language model was created. + BASE_MODEL_NAME type STRING, + "! 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. + STATUS type STRING, + "! 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. + PROGRESS type INTEGER, + "! 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. + ERROR type STRING, + "! 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. + WARNINGS type STRING, + end of T_LANGUAGE_MODEL. + types: + "! Information about existing custom language models. + begin of T_LANGUAGE_MODELS, + "! 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. + CUSTOMIZATIONS type STANDARD TABLE OF T_LANGUAGE_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_LANGUAGE_MODELS. + types: + "! Information about an existing custom acoustic model. + begin of T_ACOUSTIC_MODEL, + "! 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. + CUSTOMIZATION_ID type STRING, + "! 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`). + CREATED type STRING, + "! 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). + UPDATED type STRING, + "! The language identifier of the custom acoustic model (for example, `en-US`). + LANGUAGE type STRING, + "! 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. + VERSIONS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The GUID of the credentials for the instance of the service that owns the custom + "! acoustic model. + OWNER type STRING, + "! The name of the custom acoustic model. + NAME type STRING, + "! The description of the custom acoustic model. + DESCRIPTION type STRING, + "! The name of the language model for which the custom acoustic model was created. + BASE_MODEL_NAME type STRING, + "! 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. + STATUS type STRING, + "! 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. + PROGRESS type INTEGER, + "! 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. + WARNINGS type STRING, + end of T_ACOUSTIC_MODEL. + types: + "! Information about existing custom acoustic models. + begin of T_ACOUSTIC_MODELS, + "! 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. + CUSTOMIZATIONS type STANDARD TABLE OF T_ACOUSTIC_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_ACOUSTIC_MODELS. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! A plain text file that contains the training data for the corpus. Encode the + "! file in UTF-8 if it contains non-ASCII characters; the service assumes UTF-8 + "! encoding if it encounters non-ASCII characters.
+ "!
+ "! Make sure that you know the character encoding of the file. You must use that + "! encoding when working with the words in the custom language model. For more + "! information, see [Character + "! encoding](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-te + "! xt-corporaWords#charEncoding).
+ "!
+ "! With the `curl` command, use the `--data-binary` option to upload the file for + "! the request. + CORPUS_FILE type FILE, + end of T_INLINE_OBJECT. + types: + "! Additional service features that are supported with the model. + begin of T_SUPPORTED_FEATURES, + "! Indicates whether the customization interface can be used to create a custom + "! language model based on the language model. + CUSTOM_LANGUAGE_MODEL type BOOLEAN, + "! Indicates whether the `speaker_labels` parameter can be used with the language + "! model. + SPEAKER_LABELS type BOOLEAN, + end of T_SUPPORTED_FEATURES. + types: + "! Information about the new custom language model. + begin of T_CREATE_LANGUAGE_MODEL, + "! 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`. + NAME type STRING, + "! The name of the base language model that is to be customized by the new custom + "! language model. The new custom model can be used only with the base model that + "! it customizes.
+ "!
+ "! To determine whether a base model supports language model customization, use the + "! **Get a model** method and check that the attribute `custom_language_model` is + "! set to `true`. You can also refer to [Language support for + "! customization](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech- + "! to-text-customization#languageSupport). + BASE_MODEL_NAME type STRING, + "! The dialect of the specified language that is to be used with the custom + "! language model. For most languages, the dialect matches the language of the + "! base model by default. For example, `en-US` is used for either of the US + "! English language models.
+ "!
+ "! For a Spanish language, the service creates a custom language model that is + "! suited for speech in one of the following dialects:
+ "! * `es-ES` for Castilian Spanish (`es-ES` models)
+ "! * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE` + "! models)
+ "! * `es-US` for Mexican (North American) Spanish (`es-MX` models)
+ "!
+ "! The parameter is meaningful only for Spanish models, for which you can always + "! safely omit the parameter to have the service create the correct mapping.
+ "!
+ "! If you specify the `dialect` parameter for non-Spanish language models, its + "! value must match the language of the base model. If you specify the `dialect` + "! for Spanish language models, its value must match one of the defined mappings + "! as indicated (`es-ES`, `es-LA`, or `es-MX`). All dialect values are + "! case-insensitive. + DIALECT type STRING, + "! A description of the new custom language model. Use a localized description that + "! matches the language of the custom model. + DESCRIPTION type STRING, + end of T_CREATE_LANGUAGE_MODEL. + types: + "! Information about an available language model. + begin of T_SPEECH_MODEL, + "! The name of the model for use as an identifier in calls to the service (for + "! example, `en-US_BroadbandModel`). + NAME type STRING, + "! The language identifier of the model (for example, `en-US`). + LANGUAGE type STRING, + "! The sampling rate (minimum acceptable rate for audio) used by the model in + "! Hertz. + RATE type INTEGER, + "! The URI for the model. + URL type STRING, + "! Additional service features that are supported with the model. + SUPPORTED_FEATURES type T_SUPPORTED_FEATURES, + "! A brief description of the model. + DESCRIPTION type STRING, + end of T_SPEECH_MODEL. + types: + "! Information about the available language models. + begin of T_SPEECH_MODELS, + "! An array of `SpeechModel` objects that provides information about each available + "! model. + MODELS type STANDARD TABLE OF T_SPEECH_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_SPEECH_MODELS. + types: + "! Information about the new custom acoustic model. + begin of T_CREATE_ACOUSTIC_MODEL, + "! 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`. + NAME type STRING, + "! 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/services/speech-to-text?topic=speech- + "! to-text-customization#languageSupport). + BASE_MODEL_NAME type STRING, + "! A description of the new custom acoustic model. Use a localized description that + "! matches the language of the custom model. + DESCRIPTION type STRING, + end of T_CREATE_ACOUSTIC_MODEL. + types: + "! Information about the words that are to be added to a custom language model. + begin of T_CUSTOM_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. + WORDS type STANDARD TABLE OF T_CUSTOM_WORD WITH NON-UNIQUE DEFAULT KEY, + end of T_CUSTOM_WORDS. + types: + "! Information about a match for a keyword from speech recognition results. + begin of T_KEYWORD_RESULT, + "! A specified keyword normalized to the spoken phrase that matched in the audio + "! input. + NORMALIZED_TEXT type STRING, + "! The start time in seconds of the keyword match. + START_TIME type DOUBLE, + "! The end time in seconds of the keyword match. + END_TIME type DOUBLE, + "! A confidence score for the keyword match in the range of 0.0 to 1.0. + CONFIDENCE type DOUBLE, + end of T_KEYWORD_RESULT. + types: + "! The empty response from a request. + T_EMPTY_RESPONSE_BODY type JSONOBJECT. + types: + "! Information about a request to register a callback for asynchronous speech + "! recognition. + begin of T_REGISTER_STATUS, + "! The current status of the job:
+ "! * `created`: The service successfully white-listed the callback URL as a result + "! of the call.
+ "! * `already created`: The URL was already white-listed. + STATUS type STRING, + "! The callback URL that is successfully registered. + URL type STRING, + end of T_REGISTER_STATUS. + +constants: + begin of C_REQUIRED_FIELDS, + T_TRAINING_WARNING type string value '|CODE|MESSAGE|', + T_TRAINING_RESPONSE type string value '|', + T_WORD_ALTERNATIVE_RESULT type string value '|CONFIDENCE|WORD|', + T_WORD_ALTERNATIVE_RESULTS type string value '|START_TIME|END_TIME|ALTERNATIVES|', + T_AUDIO_METRICS_HISTOGRAM_BIN type string value '|BEGIN|END|COUNT|', + T_SPEAKER_LABELS_RESULT type string value '|FROM|TO|SPEAKER|CONFIDENCE|FINAL|', + T_SPCH_RECOGNITION_ALTERNATIVE type string value '|TRANSCRIPT|', + T_PROCESSED_AUDIO type string value '|RECEIVED|SEEN_BY_ENGINE|TRANSCRIPTION|', + T_PROCESSING_METRICS type string value '|PROCESSED_AUDIO|WLL_CLCK_SNC_FRST_BYT_RECEIVED|PERIODIC|', + T_AUDIO_METRICS_DETAILS type string value '|FINAL|END_TIME|SPEECH_RATIO|HIGH_FREQUENCY_LOSS|DIRECT_CURRENT_OFFSET|CLIPPING_RATE|SPEECH_LEVEL|NON_SPEECH_LEVEL|', + T_AUDIO_METRICS type string value '|SAMPLING_INTERVAL|ACCUMULATED|', + T_SPEECH_RECOGNITION_RESULT type string value '|FINAL|ALTERNATIVES|', + T_SPEECH_RECOGNITION_RESULTS type string value '|', + T_GRAMMAR type string value '|NAME|OUT_OF_VOCABULARY_WORDS|STATUS|', + T_GRAMMARS type string value '|GRAMMARS|', + T_RECOGNITION_JOB type string value '|ID|STATUS|CREATED|', + T_RECOGNITION_JOBS type string value '|RECOGNITIONS|', + T_AUDIO_DETAILS type string value '|', + T_ERROR_MODEL type string value '|ERROR|CODE|CODE_DESCRIPTION|', + T_AUDIO_RESOURCE type string value '|DURATION|NAME|DETAILS|STATUS|', + T_AUDIO_LISTING type string value '|', + T_WORD_ERROR type string value '|ELEMENT|', + T_WORD type string value '|WORD|SOUNDS_LIKE|DISPLAY_AS|COUNT|SOURCE|', + T_WORDS type string value '|WORDS|', + T_CUSTOM_WORD type string value '|', + T_AUDIO_RESOURCES type string value '|TOTAL_MINUTES_OF_AUDIO|AUDIO|', + T_CORPUS type string value '|NAME|TOTAL_WORDS|OUT_OF_VOCABULARY_WORDS|STATUS|', + T_CORPORA type string value '|CORPORA|', + T_LANGUAGE_MODEL type string value '|CUSTOMIZATION_ID|', + T_LANGUAGE_MODELS type string value '|CUSTOMIZATIONS|', + T_ACOUSTIC_MODEL type string value '|CUSTOMIZATION_ID|', + T_ACOUSTIC_MODELS type string value '|CUSTOMIZATIONS|', + T_INLINE_OBJECT type string value '|CORPUS_FILE|', + T_SUPPORTED_FEATURES type string value '|CUSTOM_LANGUAGE_MODEL|SPEAKER_LABELS|', + T_CREATE_LANGUAGE_MODEL type string value '|NAME|BASE_MODEL_NAME|', + T_SPEECH_MODEL type string value '|NAME|LANGUAGE|RATE|URL|SUPPORTED_FEATURES|DESCRIPTION|', + T_SPEECH_MODELS type string value '|MODELS|', + T_CREATE_ACOUSTIC_MODEL type string value '|NAME|BASE_MODEL_NAME|', + T_CUSTOM_WORDS type string value '|WORDS|', + T_KEYWORD_RESULT type string value '|NORMALIZED_TEXT|START_TIME|END_TIME|CONFIDENCE|', + T_REGISTER_STATUS type string value '|STATUS|URL|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + RECOGNITIONS type string value 'recognitions', + ID type string value 'id', + STATUS type string value 'status', + CREATED type string value 'created', + UPDATED type string value 'updated', + URL type string value 'url', + USER_TOKEN type string value 'user_token', + RESULTS type string value 'results', + WARNINGS type string value 'warnings', + RESULT_INDEX type string value 'result_index', + SPEAKER_LABELS type string value 'speaker_labels', + SPEAKERLABELS type string value 'speakerLabels', + PROCESSING_METRICS type string value 'processing_metrics', + AUDIO_METRICS type string value 'audio_metrics', + FINAL type string value 'final', + ALTERNATIVES type string value 'alternatives', + KEYWORDS_RESULT type string value 'keywords_result', + INNER type string value 'inner', + WORD_ALTERNATIVES type string value 'word_alternatives', + WORDALTERNATIVES type string value 'wordAlternatives', + END_OF_UTTERANCE type string value 'end_of_utterance', + NORMALIZED_TEXT type string value 'normalized_text', + START_TIME type string value 'start_time', + END_TIME type string value 'end_time', + CONFIDENCE type string value 'confidence', + WORD type string value 'word', + TRANSCRIPT type string value 'transcript', + TIMESTAMPS type string value 'timestamps', + WORD_CONFIDENCE type string value 'word_confidence', + WORDCONFIDENCE type string value 'wordConfidence', + FROM type string value 'from', + TO type string value 'to', + SPEAKER type string value 'speaker', + PROCESSED_AUDIO type string value 'processed_audio', + WLL_CLCK_SNC_FRST_BYT_RECEIVED type string value 'wall_clock_since_first_byte_received', + PERIODIC type string value 'periodic', + RECEIVED type string value 'received', + SEEN_BY_ENGINE type string value 'seen_by_engine', + TRANSCRIPTION type string value 'transcription', + SAMPLING_INTERVAL type string value 'sampling_interval', + ACCUMULATED type string value 'accumulated', + SIGNAL_TO_NOISE_RATIO type string value 'signal_to_noise_ratio', + SPEECH_RATIO type string value 'speech_ratio', + HIGH_FREQUENCY_LOSS type string value 'high_frequency_loss', + DIRECT_CURRENT_OFFSET type string value 'direct_current_offset', + DIRECTCURRENTOFFSET type string value 'directCurrentOffset', + CLIPPING_RATE type string value 'clipping_rate', + CLIPPINGRATE type string value 'clippingRate', + SPEECH_LEVEL type string value 'speech_level', + SPEECHLEVEL type string value 'speechLevel', + NON_SPEECH_LEVEL type string value 'non_speech_level', + NONSPEECHLEVEL type string value 'nonSpeechLevel', + BEGIN type string value 'begin', + END type string value 'end', + COUNT type string value 'count', + MODELS type string value 'models', + NAME type string value 'name', + LANGUAGE type string value 'language', + RATE type string value 'rate', + SUPPORTED_FEATURES type string value 'supported_features', + DESCRIPTION type string value 'description', + CUSTOM_LANGUAGE_MODEL type string value 'custom_language_model', + BASE_MODEL_NAME type string value 'base_model_name', + DIALECT type string value 'dialect', + CUSTOMIZATIONS type string value 'customizations', + CUSTOMIZATION_ID type string value 'customization_id', + VERSIONS type string value 'versions', + OWNER type string value 'owner', + PROGRESS type string value 'progress', + ERROR type string value 'error', + CORPORA type string value 'corpora', + TOTAL_WORDS type string value 'total_words', + OUT_OF_VOCABULARY_WORDS type string value 'out_of_vocabulary_words', + WORDS type string value 'words', + SOUNDS_LIKE type string value 'sounds_like', + SOUNDSLIKE type string value 'soundsLike', + DISPLAY_AS type string value 'display_as', + SOURCE type string value 'source', + ELEMENT type string value 'element', + GRAMMARS type string value 'grammars', + TOTAL_MINUTES_OF_AUDIO type string value 'total_minutes_of_audio', + AUDIO type string value 'audio', + DURATION type string value 'duration', + DETAILS type string value 'details', + TYPE type string value 'type', + CODEC type string value 'codec', + FREQUENCY type string value 'frequency', + COMPRESSION type string value 'compression', + CONTAINER type string value 'container', + CODE type string value 'code', + MESSAGE type string value 'message', + CODE_DESCRIPTION type string value 'code_description', + CORPUS_FILE type string value 'corpus_file', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! List models. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_SPEECH_MODELS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_MODELS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SPEECH_MODELS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a model. + "! + "! @parameter I_MODEL_ID | + "! The identifier of the model in the form of its name from the output of the **Get + "! a model** method. + "! @parameter E_RESPONSE | + "! Service return value of type T_SPEECH_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_MODEL + importing + !I_MODEL_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SPEECH_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Recognize audio. + "! + "! @parameter I_AUDIO | + "! The audio to transcribe. + "! @parameter I_CONTENT_TYPE | + "! The format (MIME type) of the audio. For more information about specifying an + "! audio format, see **Audio formats (content types)** in the method description. + "! @parameter I_MODEL | + "! The identifier of the model that is to be used for the recognition request. See + "! [Languages and + "! models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text + "! -models#models). + "! @parameter I_LANGUAGE_CUSTOMIZATION_ID | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input).
+ "!
+ "! **Note:** Use this parameter instead of the deprecated `customization_id` + "! parameter. + "! @parameter I_ACOUSTIC_CUSTOMIZATION_ID | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input). + "! @parameter I_BASE_MODEL_VERSION | + "! The version of the specified base model that is to be used with the recognition + "! request. Multiple versions of a base model can exist when a model is updated + "! for internal improvements. The parameter is intended primarily for use with + "! custom models that have been upgraded for a new base model. The default value + "! depends on whether the parameter is used with or without a custom model. See + "! [Base model + "! version](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-tex + "! t-input#version). + "! @parameter I_CUSTOMIZATION_WEIGHT | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input). + "! @parameter I_INACTIVITY_TIMEOUT | + "! 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/services/speech-to-text?topic=speech-to-tex + "! t-input#timeouts-inactivity). + "! @parameter I_KEYWORDS | + "! An array of keyword strings to spot in the audio. Each keyword string can + "! include one or more string tokens. Keywords are spotted only in the final + "! results, not in interim hypotheses. If you specify any keywords, you must also + "! specify a keywords threshold. You can spot a maximum of 1000 keywords. Omit the + "! parameter or specify an empty array if you do not need to spot keywords. See + "! [Keyword + "! spotting](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-te + "! xt-output#keyword_spotting). + "! @parameter I_KEYWORDS_THRESHOLD | + "! 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/services/speech-to-text?topic=speech-to-te + "! xt-output#keyword_spotting). + "! @parameter I_MAX_ALTERNATIVES | + "! The maximum number of alternative transcripts that the service is to return. By + "! default, the service returns a single transcript. If you specify a value of + "! `0`, the service uses the default value, `1`. See [Maximum + "! alternatives](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-t + "! o-text-output#max_alternatives). + "! @parameter I_WORD_ALTERNATIVES_THRESHOLD | + "! 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/services/speech-to-text?topic=speech-t + "! o-text-output#word_alternatives). + "! @parameter I_WORD_CONFIDENCE | + "! If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 + "! for each word. By default, the service returns no word confidence scores. See + "! [Word + "! confidence](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to- + "! text-output#word_confidence). + "! @parameter I_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/services/speech-to-text?topic=speech-to- + "! text-output#word_timestamps). + "! @parameter I_PROFANITY_FILTER | + "! If `true`, the service filters profanity from all output except for keyword + "! results by replacing inappropriate words with a series of asterisks. Set the + "! parameter to `false` to return results with no censoring. Applies to US English + "! transcription only. See [Profanity + "! filtering](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-t + "! ext-output#profanity_filter). + "! @parameter I_SMART_FORMATTING | + "! If `true`, the service converts dates, times, series of digits and numbers, + "! phone numbers, currency values, and internet addresses into more readable, + "! conventional representations in the final transcript of a recognition request. + "! For US English, the service also converts certain keyword strings to + "! punctuation symbols. By default, the service performs no smart formatting. + "!
+ "!
+ "! **Note:** Applies to US English, Japanese, and Spanish transcription only.
+ "!
+ "! See [Smart + "! formatting](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to- + "! text-output#smart_formatting). + "! @parameter I_SPEAKER_LABELS | + "! If `true`, the response includes labels that identify which words were spoken by + "! which participants in a multi-person exchange. By default, the service returns + "! no speaker labels. Setting `speaker_labels` to `true` forces the `timestamps` + "! parameter to be `true`, regardless of whether you specify `false` for the + "! parameter.
+ "!
+ "! **Note:** Applies to US English, Japanese, and Spanish (both broadband and + "! narrowband models) and UK English (narrowband model) transcription only. To + "! determine whether a language model supports speaker labels, you can also use + "! the **Get a model** method and check that the attribute `speaker_labels` is set + "! to `true`.
+ "!
+ "! See [Speaker + "! labels](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text + "! -output#speaker_labels). + "! @parameter I_CUSTOMIZATION_ID | + "! **Deprecated.** Use the `language_customization_id` parameter to specify the + "! ** customization ID (GUID) of a custom language model that is to be used with the + "! ** recognition request. Do not specify both parameters with a request. + "! @parameter I_GRAMMAR_NAME | + "! 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/services/speech-to-text?topic=speech-to-t + "! ext-input#grammars-input). + "! @parameter I_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/services/speech-to-text?topic=speech-to-t + "! ext-output#redaction). + "! @parameter I_AUDIO_METRICS | + "! If `true`, requests detailed information about the signal characteristics of the + "! input audio. The service returns audio metrics with the final transcription + "! results. By default, the service returns no audio metrics.
+ "!
+ "! See [Audio + "! metrics](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-tex + "! t-metrics#audio_metrics). + "! @parameter I_END_OF_PHRASE_SILENCE_TIME | + "! 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/services/speech-to-text?topic=speech-to-text-o + "! utput#silence_time). + "! @parameter I_SPLT_TRNSCRPT_AT_PHRASE_END | + "! 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/services/speech-to-text?topic=speech-to-text-ou + "! tput#split_transcript). + "! @parameter E_RESPONSE | + "! Service return value of type T_SPEECH_RECOGNITION_RESULTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods RECOGNIZE + importing + !I_AUDIO type FILE + !I_CONTENT_TYPE type STRING default 'application/octet-stream' + !I_MODEL type STRING default 'en-US_BroadbandModel' + !I_LANGUAGE_CUSTOMIZATION_ID type STRING optional + !I_ACOUSTIC_CUSTOMIZATION_ID type STRING optional + !I_BASE_MODEL_VERSION type STRING optional + !I_CUSTOMIZATION_WEIGHT type DOUBLE optional + !I_INACTIVITY_TIMEOUT type INTEGER optional + !I_KEYWORDS type TT_STRING optional + !I_KEYWORDS_THRESHOLD type FLOAT optional + !I_MAX_ALTERNATIVES type INTEGER optional + !I_WORD_ALTERNATIVES_THRESHOLD type FLOAT optional + !I_WORD_CONFIDENCE type BOOLEAN default c_boolean_false + !I_TIMESTAMPS type BOOLEAN default c_boolean_false + !I_PROFANITY_FILTER type BOOLEAN default c_boolean_true + !I_SMART_FORMATTING type BOOLEAN default c_boolean_false + !I_SPEAKER_LABELS type BOOLEAN default c_boolean_false + !I_CUSTOMIZATION_ID type STRING optional + !I_GRAMMAR_NAME type STRING optional + !I_REDACTION type BOOLEAN default c_boolean_false + !I_AUDIO_METRICS type BOOLEAN default c_boolean_false + !I_END_OF_PHRASE_SILENCE_TIME type DOUBLE optional + !I_SPLT_TRNSCRPT_AT_PHRASE_END type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_SPEECH_RECOGNITION_RESULTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Register a callback. + "! + "! @parameter I_CALLBACK_URL | + "! 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. + "! @parameter I_USER_SECRET | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_REGISTER_STATUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods REGISTER_CALLBACK + importing + !I_CALLBACK_URL type STRING + !I_USER_SECRET type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_REGISTER_STATUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Unregister a callback. + "! + "! @parameter I_CALLBACK_URL | + "! The callback URL that is to be unregistered. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UNREGISTER_CALLBACK + importing + !I_CALLBACK_URL type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Create a job. + "! + "! @parameter I_AUDIO | + "! The audio to transcribe. + "! @parameter I_CONTENT_TYPE | + "! The format (MIME type) of the audio. For more information about specifying an + "! audio format, see **Audio formats (content types)** in the method description. + "! @parameter I_MODEL | + "! The identifier of the model that is to be used for the recognition request. See + "! [Languages and + "! models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text + "! -models#models). + "! @parameter I_CALLBACK_URL | + "! A URL to which callback notifications are to be sent. The URL must already be + "! successfully white-listed by using the **Register a callback** method. You can + "! include the same callback URL with any number of job creation requests. Omit + "! the parameter to poll the service for job completion and results.
+ "!
+ "! Use the `user_token` parameter to specify a unique user-specified string with + "! each job to differentiate the callback notifications for the jobs. + "! @parameter I_EVENTS | + "! If the job includes a callback URL, a comma-separated list of notification + "! events to which to subscribe. Valid events are
+ "! * `recognitions.started` generates a callback notification when the service + "! begins to process the job.
+ "! * `recognitions.completed` generates a callback notification when the job is + "! complete. You must use the **Check a job** method to retrieve the results + "! before they time out or are deleted.
+ "! * `recognitions.completed_with_results` generates a callback notification when + "! the job is complete. The notification includes the results of the request.
+ "! * `recognitions.failed` generates a callback notification if the service + "! experiences an error while processing the job.
+ "!
+ "! The `recognitions.completed` and `recognitions.completed_with_results` events + "! are incompatible. You can specify only of the two events.
+ "!
+ "! If the job includes a callback URL, omit the parameter to subscribe to the + "! default events: `recognitions.started`, `recognitions.completed`, and + "! `recognitions.failed`. If the job does not include a callback URL, omit the + "! parameter. + "! @parameter I_USER_TOKEN | + "! 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. + "! @parameter I_RESULTS_TTL | + "! 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. + "! @parameter I_LANGUAGE_CUSTOMIZATION_ID | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input).
+ "!
+ "! **Note:** Use this parameter instead of the deprecated `customization_id` + "! parameter. + "! @parameter I_ACOUSTIC_CUSTOMIZATION_ID | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input). + "! @parameter I_BASE_MODEL_VERSION | + "! The version of the specified base model that is to be used with the recognition + "! request. Multiple versions of a base model can exist when a model is updated + "! for internal improvements. The parameter is intended primarily for use with + "! custom models that have been upgraded for a new base model. The default value + "! depends on whether the parameter is used with or without a custom model. See + "! [Base model + "! version](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-tex + "! t-input#version). + "! @parameter I_CUSTOMIZATION_WEIGHT | + "! 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/services/speech-to-text?topic=speech-to-text + "! -input#custom-input). + "! @parameter I_INACTIVITY_TIMEOUT | + "! 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/services/speech-to-text?topic=speech-to-tex + "! t-input#timeouts-inactivity). + "! @parameter I_KEYWORDS | + "! An array of keyword strings to spot in the audio. Each keyword string can + "! include one or more string tokens. Keywords are spotted only in the final + "! results, not in interim hypotheses. If you specify any keywords, you must also + "! specify a keywords threshold. You can spot a maximum of 1000 keywords. Omit the + "! parameter or specify an empty array if you do not need to spot keywords. See + "! [Keyword + "! spotting](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-te + "! xt-output#keyword_spotting). + "! @parameter I_KEYWORDS_THRESHOLD | + "! 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/services/speech-to-text?topic=speech-to-te + "! xt-output#keyword_spotting). + "! @parameter I_MAX_ALTERNATIVES | + "! The maximum number of alternative transcripts that the service is to return. By + "! default, the service returns a single transcript. If you specify a value of + "! `0`, the service uses the default value, `1`. See [Maximum + "! alternatives](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-t + "! o-text-output#max_alternatives). + "! @parameter I_WORD_ALTERNATIVES_THRESHOLD | + "! 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/services/speech-to-text?topic=speech-t + "! o-text-output#word_alternatives). + "! @parameter I_WORD_CONFIDENCE | + "! If `true`, the service returns a confidence measure in the range of 0.0 to 1.0 + "! for each word. By default, the service returns no word confidence scores. See + "! [Word + "! confidence](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to- + "! text-output#word_confidence). + "! @parameter I_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/services/speech-to-text?topic=speech-to- + "! text-output#word_timestamps). + "! @parameter I_PROFANITY_FILTER | + "! If `true`, the service filters profanity from all output except for keyword + "! results by replacing inappropriate words with a series of asterisks. Set the + "! parameter to `false` to return results with no censoring. Applies to US English + "! transcription only. See [Profanity + "! filtering](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-t + "! ext-output#profanity_filter). + "! @parameter I_SMART_FORMATTING | + "! If `true`, the service converts dates, times, series of digits and numbers, + "! phone numbers, currency values, and internet addresses into more readable, + "! conventional representations in the final transcript of a recognition request. + "! For US English, the service also converts certain keyword strings to + "! punctuation symbols. By default, the service performs no smart formatting. + "!
+ "!
+ "! **Note:** Applies to US English, Japanese, and Spanish transcription only.
+ "!
+ "! See [Smart + "! formatting](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to- + "! text-output#smart_formatting). + "! @parameter I_SPEAKER_LABELS | + "! If `true`, the response includes labels that identify which words were spoken by + "! which participants in a multi-person exchange. By default, the service returns + "! no speaker labels. Setting `speaker_labels` to `true` forces the `timestamps` + "! parameter to be `true`, regardless of whether you specify `false` for the + "! parameter.
+ "!
+ "! **Note:** Applies to US English, Japanese, and Spanish (both broadband and + "! narrowband models) and UK English (narrowband model) transcription only. To + "! determine whether a language model supports speaker labels, you can also use + "! the **Get a model** method and check that the attribute `speaker_labels` is set + "! to `true`.
+ "!
+ "! See [Speaker + "! labels](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text + "! -output#speaker_labels). + "! @parameter I_CUSTOMIZATION_ID | + "! **Deprecated.** Use the `language_customization_id` parameter to specify the + "! ** customization ID (GUID) of a custom language model that is to be used with the + "! ** recognition request. Do not specify both parameters with a request. + "! @parameter I_GRAMMAR_NAME | + "! 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/services/speech-to-text?topic=speech-to-t + "! ext-input#grammars-input). + "! @parameter I_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/services/speech-to-text?topic=speech-to-t + "! ext-output#redaction). + "! @parameter I_PROCESSING_METRICS | + "! If `true`, requests processing metrics about the service's transcription of the + "! input audio. The service returns processing metrics at the interval specified + "! by the `processing_metrics_interval` parameter. It also returns processing + "! metrics for transcription events, for example, for final and interim results. + "! By default, the service returns no processing metrics.
+ "!
+ "! See [Processing + "! metrics](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-tex + "! t-metrics#processing_metrics). + "! @parameter I_PROCESSING_METRICS_INTERVAL | + "! 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/services/speech-to-text?topic=speech-to-tex + "! t-metrics#processing_metrics). + "! @parameter I_AUDIO_METRICS | + "! If `true`, requests detailed information about the signal characteristics of the + "! input audio. The service returns audio metrics with the final transcription + "! results. By default, the service returns no audio metrics.
+ "!
+ "! See [Audio + "! metrics](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-tex + "! t-metrics#audio_metrics). + "! @parameter I_END_OF_PHRASE_SILENCE_TIME | + "! 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/services/speech-to-text?topic=speech-to-text-o + "! utput#silence_time). + "! @parameter I_SPLT_TRNSCRPT_AT_PHRASE_END | + "! 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/services/speech-to-text?topic=speech-to-text-ou + "! tput#split_transcript). + "! @parameter E_RESPONSE | + "! Service return value of type T_RECOGNITION_JOB + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_JOB + importing + !I_AUDIO type FILE + !I_CONTENT_TYPE type STRING default 'application/octet-stream' + !I_MODEL type STRING default 'en-US_BroadbandModel' + !I_CALLBACK_URL type STRING optional + !I_EVENTS type STRING optional + !I_USER_TOKEN type STRING optional + !I_RESULTS_TTL type INTEGER optional + !I_LANGUAGE_CUSTOMIZATION_ID type STRING optional + !I_ACOUSTIC_CUSTOMIZATION_ID type STRING optional + !I_BASE_MODEL_VERSION type STRING optional + !I_CUSTOMIZATION_WEIGHT type DOUBLE optional + !I_INACTIVITY_TIMEOUT type INTEGER optional + !I_KEYWORDS type TT_STRING optional + !I_KEYWORDS_THRESHOLD type FLOAT optional + !I_MAX_ALTERNATIVES type INTEGER optional + !I_WORD_ALTERNATIVES_THRESHOLD type FLOAT optional + !I_WORD_CONFIDENCE type BOOLEAN default c_boolean_false + !I_TIMESTAMPS type BOOLEAN default c_boolean_false + !I_PROFANITY_FILTER type BOOLEAN default c_boolean_true + !I_SMART_FORMATTING type BOOLEAN default c_boolean_false + !I_SPEAKER_LABELS type BOOLEAN default c_boolean_false + !I_CUSTOMIZATION_ID type STRING optional + !I_GRAMMAR_NAME type STRING optional + !I_REDACTION type BOOLEAN default c_boolean_false + !I_PROCESSING_METRICS type BOOLEAN default c_boolean_false + !I_PROCESSING_METRICS_INTERVAL type FLOAT optional + !I_AUDIO_METRICS type BOOLEAN default c_boolean_false + !I_END_OF_PHRASE_SILENCE_TIME type DOUBLE optional + !I_SPLT_TRNSCRPT_AT_PHRASE_END type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_RECOGNITION_JOB + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Check jobs. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_RECOGNITION_JOBS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CHECK_JOBS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_RECOGNITION_JOBS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Check a job. + "! + "! @parameter I_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. + "! @parameter E_RESPONSE | + "! Service return value of type T_RECOGNITION_JOB + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CHECK_JOB + importing + !I_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_RECOGNITION_JOB + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a job. + "! + "! @parameter I_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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_JOB + importing + !I_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a custom language model. + "! + "! @parameter I_CREATE_LANGUAGE_MODEL | + "! A `CreateLanguageModel` object that provides basic information about the new + "! custom language model. + "! @parameter E_RESPONSE | + "! Service return value of type T_LANGUAGE_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_LANGUAGE_MODEL + importing + !I_CREATE_LANGUAGE_MODEL type T_CREATE_LANGUAGE_MODEL + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LANGUAGE_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List custom language models. + "! + "! @parameter I_LANGUAGE | + "! The identifier of the language for which custom language or custom acoustic + "! models are to be returned (for example, `en-US`). Omit the parameter to see all + "! custom language or custom acoustic models that are owned by the requesting + "! credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_LANGUAGE_MODELS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_LANGUAGE_MODELS + importing + !I_LANGUAGE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LANGUAGE_MODELS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a custom language model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_LANGUAGE_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_LANGUAGE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_LANGUAGE_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom language model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_LANGUAGE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Train a custom language model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_WORD_TYPE_TO_ADD | + "! The type of words from the custom language model's words resource on which to + "! train the model:
+ "! * `all` (the default) trains the model on all new words, regardless of whether + "! they were extracted from corpora or grammars or were added or modified by the + "! user.
+ "! * `user` trains the model only on new words that were added or modified by the + "! user directly. The model is not trained on new words extracted from corpora or + "! grammars. + "! @parameter I_CUSTOMIZATION_WEIGHT | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TRAIN_LANGUAGE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD_TYPE_TO_ADD type STRING default 'all' + !I_CUSTOMIZATION_WEIGHT type DOUBLE optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Reset a custom language model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods RESET_LANGUAGE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Upgrade a custom language model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPGRADE_LANGUAGE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List corpora. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_CORPORA + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_CORPORA + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CORPORA + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add a corpus. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CORPUS_NAME | + "! 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. + "! @parameter I_CORPUS_FILE | + "! A plain text file that contains the training data for the corpus. Encode the + "! file in UTF-8 if it contains non-ASCII characters; the service assumes UTF-8 + "! encoding if it encounters non-ASCII characters.
+ "!
+ "! Make sure that you know the character encoding of the file. You must use that + "! encoding when working with the words in the custom language model. For more + "! information, see [Character + "! encoding](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-te + "! xt-corporaWords#charEncoding).
+ "!
+ "! With the `curl` command, use the `--data-binary` option to upload the file for + "! the request. + "! @parameter I_ALLOW_OVERWRITE | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_CORPUS + importing + !I_CUSTOMIZATION_ID type STRING + !I_CORPUS_NAME type STRING + !I_CORPUS_FILE type FILE + !I_ALLOW_OVERWRITE type BOOLEAN default c_boolean_false + !I_CORPUS_FILE_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a corpus. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CORPUS_NAME | + "! The name of the corpus for the custom language model. + "! @parameter E_RESPONSE | + "! Service return value of type T_CORPUS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CORPUS + importing + !I_CUSTOMIZATION_ID type STRING + !I_CORPUS_NAME type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CORPUS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a corpus. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CORPUS_NAME | + "! The name of the corpus for the custom language model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_CORPUS + importing + !I_CUSTOMIZATION_ID type STRING + !I_CORPUS_NAME type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List custom words. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_WORD_TYPE | + "! 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. + "! @parameter I_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`. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORDS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_WORDS + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD_TYPE type STRING default 'all' + !I_SORT type STRING default 'alphabetical' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORDS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add custom words. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CUSTOM_WORDS | + "! A `CustomWords` object that provides information about one or more custom words + "! that are to be added to or updated in the custom language model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_WORDS + importing + !I_CUSTOMIZATION_ID type STRING + !I_CUSTOM_WORDS type T_CUSTOM_WORDS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_WORD_NAME | + "! The custom word that is to be added to or updated in the custom language model. + "! Do not include spaces in the word. Use a `-` (dash) or `_` (underscore) to + "! connect the tokens of compound words. URL-encode the word if it includes + "! non-ASCII characters. For more information, see [Character + "! encoding](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-te + "! xt-corporaWords#charEncoding). + "! @parameter I_CUSTOM_WORD | + "! A `CustomWord` object that provides information about the specified custom word. + "! Specify an empty object to add a word with no sounds-like or display-as + "! information. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD_NAME type STRING + !I_CUSTOM_WORD type T_CUSTOM_WORD + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_WORD_NAME | + "! 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/services/speech-to-text?topic=speech-to-te + "! xt-corporaWords#charEncoding). + "! @parameter E_RESPONSE | + "! Service return value of type T_WORD + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD_NAME type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORD + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_WORD_NAME | + "! 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/services/speech-to-text?topic=speech-to-te + "! xt-corporaWords#charEncoding). + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD_NAME type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List grammars. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_GRAMMARS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_GRAMMARS + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GRAMMARS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add a grammar. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_GRAMMAR_NAME | + "! 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. + "! @parameter I_GRAMMAR_FILE | + "! 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. + "! @parameter I_CONTENT_TYPE | + "! 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. + "! @parameter I_ALLOW_OVERWRITE | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_GRAMMAR + importing + !I_CUSTOMIZATION_ID type STRING + !I_GRAMMAR_NAME type STRING + !I_GRAMMAR_FILE type STRING + !I_CONTENT_TYPE type STRING default 'application/srgs' + !I_ALLOW_OVERWRITE type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a grammar. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_GRAMMAR_NAME | + "! The name of the grammar for the custom language model. + "! @parameter E_RESPONSE | + "! Service return value of type T_GRAMMAR + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_GRAMMAR + importing + !I_CUSTOMIZATION_ID type STRING + !I_GRAMMAR_NAME type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_GRAMMAR + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a grammar. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_GRAMMAR_NAME | + "! The name of the grammar for the custom language model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_GRAMMAR + importing + !I_CUSTOMIZATION_ID type STRING + !I_GRAMMAR_NAME type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a custom acoustic model. + "! + "! @parameter I_CREATE_ACOUSTIC_MODEL | + "! A `CreateAcousticModel` object that provides basic information about the new + "! custom acoustic model. + "! @parameter E_RESPONSE | + "! Service return value of type T_ACOUSTIC_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_ACOUSTIC_MODEL + importing + !I_CREATE_ACOUSTIC_MODEL type T_CREATE_ACOUSTIC_MODEL + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ACOUSTIC_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List custom acoustic models. + "! + "! @parameter I_LANGUAGE | + "! The identifier of the language for which custom language or custom acoustic + "! models are to be returned (for example, `en-US`). Omit the parameter to see all + "! custom language or custom acoustic models that are owned by the requesting + "! credentials. + "! @parameter E_RESPONSE | + "! Service return value of type T_ACOUSTIC_MODELS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_ACOUSTIC_MODELS + importing + !I_LANGUAGE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ACOUSTIC_MODELS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a custom acoustic model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_ACOUSTIC_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_ACOUSTIC_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ACOUSTIC_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom acoustic model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_ACOUSTIC_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Train a custom acoustic model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CUSTOM_LANGUAGE_MODEL_ID | + "! The customization ID (GUID) of a custom language model that is to be used during + "! training of the custom acoustic model. Specify a custom language model that has + "! been trained with verbatim transcriptions of the audio resources or that + "! contains words that are relevant to the contents of the audio resources. The + "! custom language model must be based on the same version of the same base model + "! as the custom acoustic model. The credentials specified with the request must + "! own both custom models. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TRAIN_ACOUSTIC_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_CUSTOM_LANGUAGE_MODEL_ID type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Reset a custom acoustic model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods RESET_ACOUSTIC_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Upgrade a custom acoustic model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_CUSTOM_LANGUAGE_MODEL_ID | + "! If the custom acoustic model was trained with a custom language model, the + "! customization ID (GUID) of that custom language model. The custom language + "! model must be upgraded before the custom acoustic model can be upgraded. The + "! credentials specified with the request must own both custom models. + "! @parameter I_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/services/speech-to-text?topic=speech-to-text- + "! customUpgrade#upgradeAcoustic). + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPGRADE_ACOUSTIC_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_CUSTOM_LANGUAGE_MODEL_ID type STRING optional + !I_FORCE type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List audio resources. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_AUDIO_RESOURCES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_AUDIO + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_AUDIO_RESOURCES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add an audio resource. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_AUDIO_NAME | + "! 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. + "! @parameter I_AUDIO_RESOURCE | + "! 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. + "! @parameter I_CONTENT_TYPE | + "! 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. + "! @parameter I_CONTAINED_CONTENT_TYPE | + "! **For an archive-type resource,** specify the format of the audio files that are + "! ** contained in the archive file if they are of type `audio/alaw`, `audio/basic`, + "! ** `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and `endianness` + "! ** parameters where necessary. In this case, all audio files that are contained in + "! ** the archive file must be of the indicated type.
+ "! **
+ "! **For all other audio formats, you can omit the header. In this case, the audio + "! ** files can be of multiple types as long as they are not of the types listed in + "! ** the previous paragraph.
+ "! **
+ "! **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. + "! @parameter I_ALLOW_OVERWRITE | + "! 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. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_AUDIO + importing + !I_CUSTOMIZATION_ID type STRING + !I_AUDIO_NAME type STRING + !I_AUDIO_RESOURCE type FILE + !I_CONTENT_TYPE type STRING default 'application/zip' + !I_CONTAINED_CONTENT_TYPE type STRING optional + !I_ALLOW_OVERWRITE type BOOLEAN default c_boolean_false + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get an audio resource. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_AUDIO_NAME | + "! The name of the audio resource for the custom acoustic model. + "! @parameter E_RESPONSE | + "! Service return value of type T_AUDIO_LISTING + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_AUDIO + importing + !I_CUSTOMIZATION_ID type STRING + !I_AUDIO_NAME type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_AUDIO_LISTING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete an audio resource. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! 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. + "! @parameter I_AUDIO_NAME | + "! The name of the audio resource for the custom acoustic model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_AUDIO + importing + !I_CUSTOMIZATION_ID type STRING + !I_AUDIO_NAME type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_SPEECH_TO_TEXT_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Speech to Text'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/speech-to-text/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092825'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SPEECH_MODELS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/models'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_MODEL_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SPEECH_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/models/{model_id}'. + replace all occurrences of `{model_id}` in ls_request_prop-url-path with i_MODEL_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->RECOGNIZE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUDIO TYPE FILE +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='application/octet-stream') +* | [--->] I_MODEL TYPE STRING (default ='en-US_BroadbandModel') +* | [--->] I_LANGUAGE_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_ACOUSTIC_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_BASE_MODEL_VERSION TYPE STRING(optional) +* | [--->] I_CUSTOMIZATION_WEIGHT TYPE DOUBLE(optional) +* | [--->] I_INACTIVITY_TIMEOUT TYPE INTEGER(optional) +* | [--->] I_KEYWORDS TYPE TT_STRING(optional) +* | [--->] I_KEYWORDS_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_MAX_ALTERNATIVES TYPE INTEGER(optional) +* | [--->] I_WORD_ALTERNATIVES_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_WORD_CONFIDENCE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_TIMESTAMPS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PROFANITY_FILTER TYPE BOOLEAN (default =c_boolean_true) +* | [--->] I_SMART_FORMATTING TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_SPEAKER_LABELS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_GRAMMAR_NAME TYPE STRING(optional) +* | [--->] I_REDACTION TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_AUDIO_METRICS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_END_OF_PHRASE_SILENCE_TIME TYPE DOUBLE(optional) +* | [--->] I_SPLT_TRNSCRPT_AT_PHRASE_END TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_SPEECH_RECOGNITION_RESULTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method RECOGNIZE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/recognize'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_LANGUAGE_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_LANGUAGE_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `language_customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_ACOUSTIC_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_ACOUSTIC_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `acoustic_customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_BASE_MODEL_VERSION is supplied. + lv_queryparam = escape( val = i_BASE_MODEL_VERSION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `base_model_version` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_WEIGHT is supplied. + lv_queryparam = i_CUSTOMIZATION_WEIGHT. + add_query_parameter( + exporting + i_parameter = `customization_weight` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INACTIVITY_TIMEOUT is supplied. + lv_queryparam = i_INACTIVITY_TIMEOUT. + add_query_parameter( + exporting + i_parameter = `inactivity_timeout` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_KEYWORDS is supplied. + data: + lv_item_KEYWORDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_KEYWORDS into lv_item_KEYWORDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_KEYWORDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `keywords` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_KEYWORDS_THRESHOLD is supplied. + lv_queryparam = i_KEYWORDS_THRESHOLD. + add_query_parameter( + exporting + i_parameter = `keywords_threshold` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_MAX_ALTERNATIVES is supplied. + lv_queryparam = i_MAX_ALTERNATIVES. + add_query_parameter( + exporting + i_parameter = `max_alternatives` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_WORD_ALTERNATIVES_THRESHOLD is supplied. + lv_queryparam = i_WORD_ALTERNATIVES_THRESHOLD. + add_query_parameter( + exporting + i_parameter = `word_alternatives_threshold` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_WORD_CONFIDENCE is supplied. + lv_queryparam = i_WORD_CONFIDENCE. + add_query_parameter( + exporting + i_parameter = `word_confidence` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TIMESTAMPS is supplied. + lv_queryparam = i_TIMESTAMPS. + add_query_parameter( + exporting + i_parameter = `timestamps` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PROFANITY_FILTER is supplied. + lv_queryparam = i_PROFANITY_FILTER. + add_query_parameter( + exporting + i_parameter = `profanity_filter` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SMART_FORMATTING is supplied. + lv_queryparam = i_SMART_FORMATTING. + add_query_parameter( + exporting + i_parameter = `smart_formatting` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SPEAKER_LABELS is supplied. + lv_queryparam = i_SPEAKER_LABELS. + add_query_parameter( + exporting + i_parameter = `speaker_labels` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_GRAMMAR_NAME is supplied. + lv_queryparam = escape( val = i_GRAMMAR_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `grammar_name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_REDACTION is supplied. + lv_queryparam = i_REDACTION. + add_query_parameter( + exporting + i_parameter = `redaction` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_AUDIO_METRICS is supplied. + lv_queryparam = i_AUDIO_METRICS. + add_query_parameter( + exporting + i_parameter = `audio_metrics` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_OF_PHRASE_SILENCE_TIME is supplied. + lv_queryparam = i_END_OF_PHRASE_SILENCE_TIME. + add_query_parameter( + exporting + i_parameter = `end_of_phrase_silence_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SPLT_TRNSCRPT_AT_PHRASE_END is supplied. + lv_queryparam = i_SPLT_TRNSCRPT_AT_PHRASE_END. + add_query_parameter( + exporting + i_parameter = `split_transcript_at_phrase_end` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + + + " process body parameters + ls_request_prop-body_bin = i_AUDIO. + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->REGISTER_CALLBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CALLBACK_URL TYPE STRING +* | [--->] I_USER_SECRET TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_REGISTER_STATUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method REGISTER_CALLBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/register_callback'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CALLBACK_URL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `callback_url` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_USER_SECRET is supplied. + lv_queryparam = escape( val = i_USER_SECRET format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `user_secret` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->UNREGISTER_CALLBACK +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CALLBACK_URL TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UNREGISTER_CALLBACK. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/unregister_callback'. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CALLBACK_URL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `callback_url` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->CREATE_JOB +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUDIO TYPE FILE +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='application/octet-stream') +* | [--->] I_MODEL TYPE STRING (default ='en-US_BroadbandModel') +* | [--->] I_CALLBACK_URL TYPE STRING(optional) +* | [--->] I_EVENTS TYPE STRING(optional) +* | [--->] I_USER_TOKEN TYPE STRING(optional) +* | [--->] I_RESULTS_TTL TYPE INTEGER(optional) +* | [--->] I_LANGUAGE_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_ACOUSTIC_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_BASE_MODEL_VERSION TYPE STRING(optional) +* | [--->] I_CUSTOMIZATION_WEIGHT TYPE DOUBLE(optional) +* | [--->] I_INACTIVITY_TIMEOUT TYPE INTEGER(optional) +* | [--->] I_KEYWORDS TYPE TT_STRING(optional) +* | [--->] I_KEYWORDS_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_MAX_ALTERNATIVES TYPE INTEGER(optional) +* | [--->] I_WORD_ALTERNATIVES_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_WORD_CONFIDENCE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_TIMESTAMPS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PROFANITY_FILTER TYPE BOOLEAN (default =c_boolean_true) +* | [--->] I_SMART_FORMATTING TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_SPEAKER_LABELS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_GRAMMAR_NAME TYPE STRING(optional) +* | [--->] I_REDACTION TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PROCESSING_METRICS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_PROCESSING_METRICS_INTERVAL TYPE FLOAT(optional) +* | [--->] I_AUDIO_METRICS TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_END_OF_PHRASE_SILENCE_TIME TYPE DOUBLE(optional) +* | [--->] I_SPLT_TRNSCRPT_AT_PHRASE_END TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_RECOGNITION_JOB +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_JOB. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/recognitions'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_MODEL is supplied. + lv_queryparam = escape( val = i_MODEL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `model` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CALLBACK_URL is supplied. + lv_queryparam = escape( val = i_CALLBACK_URL format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `callback_url` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_EVENTS is supplied. + lv_queryparam = escape( val = i_EVENTS format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `events` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_USER_TOKEN is supplied. + lv_queryparam = escape( val = i_USER_TOKEN format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `user_token` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_RESULTS_TTL is supplied. + lv_queryparam = i_RESULTS_TTL. + add_query_parameter( + exporting + i_parameter = `results_ttl` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_LANGUAGE_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_LANGUAGE_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `language_customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_ACOUSTIC_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_ACOUSTIC_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `acoustic_customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_BASE_MODEL_VERSION is supplied. + lv_queryparam = escape( val = i_BASE_MODEL_VERSION format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `base_model_version` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_WEIGHT is supplied. + lv_queryparam = i_CUSTOMIZATION_WEIGHT. + add_query_parameter( + exporting + i_parameter = `customization_weight` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_INACTIVITY_TIMEOUT is supplied. + lv_queryparam = i_INACTIVITY_TIMEOUT. + add_query_parameter( + exporting + i_parameter = `inactivity_timeout` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_KEYWORDS is supplied. + data: + lv_item_KEYWORDS type STRING. + clear: lv_queryparam, lv_sep. + loop at i_KEYWORDS into lv_item_KEYWORDS. + lv_queryparam = lv_queryparam && lv_sep && lv_item_KEYWORDS. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `keywords` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_KEYWORDS_THRESHOLD is supplied. + lv_queryparam = i_KEYWORDS_THRESHOLD. + add_query_parameter( + exporting + i_parameter = `keywords_threshold` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_MAX_ALTERNATIVES is supplied. + lv_queryparam = i_MAX_ALTERNATIVES. + add_query_parameter( + exporting + i_parameter = `max_alternatives` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_WORD_ALTERNATIVES_THRESHOLD is supplied. + lv_queryparam = i_WORD_ALTERNATIVES_THRESHOLD. + add_query_parameter( + exporting + i_parameter = `word_alternatives_threshold` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_WORD_CONFIDENCE is supplied. + lv_queryparam = i_WORD_CONFIDENCE. + add_query_parameter( + exporting + i_parameter = `word_confidence` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TIMESTAMPS is supplied. + lv_queryparam = i_TIMESTAMPS. + add_query_parameter( + exporting + i_parameter = `timestamps` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PROFANITY_FILTER is supplied. + lv_queryparam = i_PROFANITY_FILTER. + add_query_parameter( + exporting + i_parameter = `profanity_filter` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SMART_FORMATTING is supplied. + lv_queryparam = i_SMART_FORMATTING. + add_query_parameter( + exporting + i_parameter = `smart_formatting` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SPEAKER_LABELS is supplied. + lv_queryparam = i_SPEAKER_LABELS. + add_query_parameter( + exporting + i_parameter = `speaker_labels` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_GRAMMAR_NAME is supplied. + lv_queryparam = escape( val = i_GRAMMAR_NAME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `grammar_name` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_REDACTION is supplied. + lv_queryparam = i_REDACTION. + add_query_parameter( + exporting + i_parameter = `redaction` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PROCESSING_METRICS is supplied. + lv_queryparam = i_PROCESSING_METRICS. + add_query_parameter( + exporting + i_parameter = `processing_metrics` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_PROCESSING_METRICS_INTERVAL is supplied. + lv_queryparam = i_PROCESSING_METRICS_INTERVAL. + add_query_parameter( + exporting + i_parameter = `processing_metrics_interval` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_AUDIO_METRICS is supplied. + lv_queryparam = i_AUDIO_METRICS. + add_query_parameter( + exporting + i_parameter = `audio_metrics` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_OF_PHRASE_SILENCE_TIME is supplied. + lv_queryparam = i_END_OF_PHRASE_SILENCE_TIME. + add_query_parameter( + exporting + i_parameter = `end_of_phrase_silence_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SPLT_TRNSCRPT_AT_PHRASE_END is supplied. + lv_queryparam = i_SPLT_TRNSCRPT_AT_PHRASE_END. + add_query_parameter( + exporting + i_parameter = `split_transcript_at_phrase_end` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + + + " process body parameters + ls_request_prop-body_bin = i_AUDIO. + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->CHECK_JOBS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_RECOGNITION_JOBS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CHECK_JOBS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/recognitions'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->CHECK_JOB +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_RECOGNITION_JOB +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CHECK_JOB. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/recognitions/{id}'. + replace all occurrences of `{id}` in ls_request_prop-url-path with i_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_JOB +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_JOB. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/recognitions/{id}'. + replace all occurrences of `{id}` in ls_request_prop-url-path with i_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->CREATE_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CREATE_LANGUAGE_MODEL TYPE T_CREATE_LANGUAGE_MODEL +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LANGUAGE_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CREATE_LANGUAGE_MODEL ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CREATE_LANGUAGE_MODEL i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'create_language_model' i_value = i_CREATE_LANGUAGE_MODEL ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CREATE_LANGUAGE_MODEL to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_LANGUAGE_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_LANGUAGE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LANGUAGE_MODELS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_LANGUAGE_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_LANGUAGE is supplied. + lv_queryparam = escape( val = i_LANGUAGE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `language` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_LANGUAGE_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->TRAIN_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD_TYPE_TO_ADD TYPE STRING (default ='all') +* | [--->] I_CUSTOMIZATION_WEIGHT TYPE DOUBLE(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TRAIN_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/train'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_WORD_TYPE_TO_ADD is supplied. + lv_queryparam = escape( val = i_WORD_TYPE_TO_ADD format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `word_type_to_add` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_WEIGHT is supplied. + lv_queryparam = i_CUSTOMIZATION_WEIGHT. + add_query_parameter( + exporting + i_parameter = `customization_weight` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->RESET_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method RESET_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/reset'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->UPGRADE_LANGUAGE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPGRADE_LANGUAGE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/upgrade_model'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_CORPORA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CORPORA +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_CORPORA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/corpora'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->ADD_CORPUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CORPUS_NAME TYPE STRING +* | [--->] I_CORPUS_FILE TYPE FILE +* | [--->] I_ALLOW_OVERWRITE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_CORPUS_FILE_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_CORPUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/corpora/{corpus_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{corpus_name}` in ls_request_prop-url-path with i_CORPUS_NAME ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_ALLOW_OVERWRITE is supplied. + lv_queryparam = i_ALLOW_OVERWRITE. + add_query_parameter( + exporting + i_parameter = `allow_overwrite` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_CORPUS_FILE is initial. + lv_extension = get_file_extension( I_CORPUS_FILE_CT ). + lv_value = `form-data; name="corpus_file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_CORPUS_FILE_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_CORPUS_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_CORPUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CORPUS_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CORPUS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CORPUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/corpora/{corpus_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{corpus_name}` in ls_request_prop-url-path with i_CORPUS_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_CORPUS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CORPUS_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_CORPUS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/corpora/{corpus_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{corpus_name}` in ls_request_prop-url-path with i_CORPUS_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_WORDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD_TYPE TYPE STRING (default ='all') +* | [--->] I_SORT TYPE STRING (default ='alphabetical') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORDS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_WORDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_WORD_TYPE is supplied. + lv_queryparam = escape( val = i_WORD_TYPE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `word_type` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_SORT is supplied. + lv_queryparam = escape( val = i_SORT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `sort` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->ADD_WORDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CUSTOM_WORDS TYPE T_CUSTOM_WORDS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_WORDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CUSTOM_WORDS ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CUSTOM_WORDS i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'custom_words' i_value = i_CUSTOM_WORDS ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CUSTOM_WORDS to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->ADD_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD_NAME TYPE STRING +* | [--->] I_CUSTOM_WORD TYPE T_CUSTOM_WORD +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word_name}` in ls_request_prop-url-path with i_WORD_NAME ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CUSTOM_WORD ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CUSTOM_WORD i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'custom_word' i_value = i_CUSTOM_WORD ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CUSTOM_WORD to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORD +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word_name}` in ls_request_prop-url-path with i_WORD_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word_name}` in ls_request_prop-url-path with i_WORD_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_GRAMMARS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GRAMMARS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_GRAMMARS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/grammars'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->ADD_GRAMMAR +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_GRAMMAR_NAME TYPE STRING +* | [--->] I_GRAMMAR_FILE TYPE STRING +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='application/srgs') +* | [--->] I_ALLOW_OVERWRITE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_GRAMMAR. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/grammars/{grammar_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{grammar_name}` in ls_request_prop-url-path with i_GRAMMAR_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_ALLOW_OVERWRITE is supplied. + lv_queryparam = i_ALLOW_OVERWRITE. + add_query_parameter( + exporting + i_parameter = `allow_overwrite` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + ls_request_prop-header_content_type = I_CONTENT_TYPE. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_GRAMMAR_FILE ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_GRAMMAR_FILE i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'grammar_file' i_value = i_GRAMMAR_FILE ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_GRAMMAR_FILE to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_GRAMMAR +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_GRAMMAR_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_GRAMMAR +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_GRAMMAR. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/grammars/{grammar_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{grammar_name}` in ls_request_prop-url-path with i_GRAMMAR_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_GRAMMAR +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_GRAMMAR_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_GRAMMAR. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/grammars/{grammar_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{grammar_name}` in ls_request_prop-url-path with i_GRAMMAR_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->CREATE_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CREATE_ACOUSTIC_MODEL TYPE T_CREATE_ACOUSTIC_MODEL +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ACOUSTIC_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CREATE_ACOUSTIC_MODEL ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CREATE_ACOUSTIC_MODEL i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'create_acoustic_model' i_value = i_CREATE_ACOUSTIC_MODEL ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CREATE_ACOUSTIC_MODEL to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_ACOUSTIC_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_LANGUAGE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ACOUSTIC_MODELS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_ACOUSTIC_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_LANGUAGE is supplied. + lv_queryparam = escape( val = i_LANGUAGE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `language` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ACOUSTIC_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->TRAIN_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CUSTOM_LANGUAGE_MODEL_ID TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TRAIN_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/train'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_CUSTOM_LANGUAGE_MODEL_ID is supplied. + lv_queryparam = escape( val = i_CUSTOM_LANGUAGE_MODEL_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `custom_language_model_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->RESET_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method RESET_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/reset'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->UPGRADE_ACOUSTIC_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CUSTOM_LANGUAGE_MODEL_ID TYPE STRING(optional) +* | [--->] I_FORCE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPGRADE_ACOUSTIC_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/upgrade_model'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_CUSTOM_LANGUAGE_MODEL_ID is supplied. + lv_queryparam = escape( val = i_CUSTOM_LANGUAGE_MODEL_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `custom_language_model_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_FORCE is supplied. + lv_queryparam = i_FORCE. + add_query_parameter( + exporting + i_parameter = `force` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->LIST_AUDIO +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_AUDIO_RESOURCES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_AUDIO. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/audio'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->ADD_AUDIO +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_AUDIO_NAME TYPE STRING +* | [--->] I_AUDIO_RESOURCE TYPE FILE +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='application/zip') +* | [--->] I_CONTAINED_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_ALLOW_OVERWRITE TYPE BOOLEAN (default =c_boolean_false) +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_AUDIO. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/audio/{audio_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{audio_name}` in ls_request_prop-url-path with i_AUDIO_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_ALLOW_OVERWRITE is supplied. + lv_queryparam = i_ALLOW_OVERWRITE. + add_query_parameter( + exporting + i_parameter = `allow_overwrite` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + if i_CONTAINED_CONTENT_TYPE is supplied. + lv_headerparam = I_CONTAINED_CONTENT_TYPE. + add_header_parameter( + exporting + i_parameter = 'Contained-Content-Type' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + ls_request_prop-body_bin = i_AUDIO_RESOURCE. + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->GET_AUDIO +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_AUDIO_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_AUDIO_LISTING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_AUDIO. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/audio/{audio_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{audio_name}` in ls_request_prop-url-path with i_AUDIO_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_AUDIO +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_AUDIO_NAME TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_AUDIO. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/acoustic_customizations/{customization_id}/audio/{audio_name}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{audio_name}` in ls_request_prop-url-path with i_AUDIO_NAME ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_SPEECH_TO_TEXT_V1->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/user_data'. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_SPEECH_TO_TEXT_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_speech_to_text_v1.clas.xml b/src/zcl_ibmc_speech_to_text_v1.clas.xml new file mode 100644 index 0000000..090dd66 --- /dev/null +++ b/src/zcl_ibmc_speech_to_text_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_SPEECH_TO_TEXT_V1 + E + IBM Watson Speech to Text + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_text_to_speech_v1.clas.abap b/src/zcl_ibmc_text_to_speech_v1.clas.abap new file mode 100644 index 0000000..480a6b3 --- /dev/null +++ b/src/zcl_ibmc_text_to_speech_v1.clas.abap @@ -0,0 +1,1627 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM® Text to Speech service provides APIs that use IBM's +"! speech-synthesis capabilities to synthesize text into natural-sounding speech +"! in a variety of languages, dialects, and voices. The service supports at least +"! one male or female voice, sometimes both, for each language. The audio is +"! streamed back to the client with minimal delay.
+"!
+"! For speech synthesis, the service supports a synchronous HTTP Representational +"! State Transfer (REST) interface. It also supports a WebSocket interface that +"! provides both plain text and SSML input, including the SSML <mark> +"! element and word timings. SSML is an XML-based markup language that provides +"! text annotation for speech-synthesis applications.
+"!
+"! The service also offers a customization interface. You can use the interface to +"! define sounds-like or phonetic translations for words. A sounds-like +"! translation consists of one or more words that, when combined, sound like the +"! word. A phonetic translation is based on the SSML phoneme format for +"! representing a word. You can specify a phonetic translation in standard +"! International Phonetic Alphabet (IPA) representation or in the proprietary IBM +"! Symbolic Phonetic Representation (SPR).
+class ZCL_IBMC_TEXT_TO_SPEECH_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Information about a word for the custom voice model. + begin of T_WORD, + "! The word for the custom voice model. + WORD type STRING, + "! 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. + TRANSLATION type STRING, + "! **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/services/text-to-speech?topic=text-to-speec + "! **h-rules#jaNotes). + PART_OF_SPEECH type STRING, + end of T_WORD. + types: + "! Information about an existing custom voice model. + begin of T_VOICE_MODEL, + "! 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. + CUSTOMIZATION_ID type STRING, + "! The name of the custom voice model. + NAME type STRING, + "! The language identifier of the custom voice model (for example, `en-US`). + LANGUAGE type STRING, + "! The GUID of the credentials for the instance of the service that owns the custom + "! voice model. + OWNER type STRING, + "! 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`). + CREATED type STRING, + "! The date and time in Coordinated Universal Time (UTC) at which the custom voice + "! model was last modified. The `created` and `updated` fields are equal when a + "! voice model is first added but has yet to be updated. The value is provided in + "! full ISO 8601 format (`YYYY-MM-DDThh:mm:ss.sTZD`). + LAST_MODIFIED type STRING, + "! The description of the custom voice model. + DESCRIPTION type STRING, + "! 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. + WORDS type STANDARD TABLE OF T_WORD WITH NON-UNIQUE DEFAULT KEY, + end of T_VOICE_MODEL. + types: + "! Additional service features that are supported with the voice. + begin of T_SUPPORTED_FEATURES, + "! If `true`, the voice can be customized; if `false`, the voice cannot be + "! customized. (Same as `customizable`.). + CUSTOM_PRONUNCIATION type BOOLEAN, + "! If `true`, the voice can be transformed by using the SSML + "! <voice-transformation> element; if `false`, the voice cannot be + "! transformed. + VOICE_TRANSFORMATION type BOOLEAN, + end of T_SUPPORTED_FEATURES. + types: + "! Information about an available voice model. + begin of T_VOICE, + "! The URI of the voice. + URL type STRING, + "! The gender of the voice: `male` or `female`. + GENDER type STRING, + "! The name of the voice. Use this as the voice identifier in all requests. + NAME type STRING, + "! The language and region of the voice (for example, `en-US`). + LANGUAGE type STRING, + "! A textual description of the voice. + DESCRIPTION type STRING, + "! If `true`, the voice can be customized; if `false`, the voice cannot be + "! customized. (Same as `custom_pronunciation`; maintained for backward + "! compatibility.). + CUSTOMIZABLE type BOOLEAN, + "! Additional service features that are supported with the voice. + SUPPORTED_FEATURES type T_SUPPORTED_FEATURES, + "! 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. + CUSTOMIZATION type T_VOICE_MODEL, + end of T_VOICE. + types: + "! Information about the new custom voice model. + begin of T_CREATE_VOICE_MODEL, + "! The name of the new custom voice model. + NAME type STRING, + "! The language of the new custom voice model. Omit the parameter to use the the + "! default language, `en-US`. + LANGUAGE type STRING, + "! A description of the new custom voice model. Specifying a description is + "! recommended. + DESCRIPTION type STRING, + end of T_CREATE_VOICE_MODEL. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + "! Description of the problem. + ERROR type STRING, + "! HTTP response code. + CODE type INTEGER, + "! Response message. + CODE_DESCRIPTION type STRING, + end of T_ERROR_MODEL. + types: + "! For the **Add custom words** method, one or more words that are to be added or + "! updated for the custom voice model and the translation for each specified word. + "!
+ "!
+ "! For the **List custom words** method, the words and their translations from the + "! custom voice model. + begin of T_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. + WORDS type STANDARD TABLE OF T_WORD WITH NON-UNIQUE DEFAULT KEY, + end of T_WORDS. + types: + "! Information about the updated custom voice model. + begin of T_UPDATE_VOICE_MODEL, + "! A new name for the custom voice model. + NAME type STRING, + "! A new description for the custom voice model. + DESCRIPTION type STRING, + "! 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. + WORDS type STANDARD TABLE OF T_WORD WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_VOICE_MODEL. + types: + "! Information about all available voice models. + begin of T_VOICES, + "! A list of available voices. + VOICES type STANDARD TABLE OF T_VOICE WITH NON-UNIQUE DEFAULT KEY, + end of T_VOICES. + types: + "! The empty response from a request. + T_EMPTY_RESPONSE_BODY type JSONOBJECT. + types: + "! Information about existing custom voice models. + begin of T_VOICE_MODELS, + "! An array of `VoiceModel` objects that provides information about each available + "! custom voice model. The array is empty if the requesting credentials own no + "! custom voice models (if no language is specified) or own no custom voice models + "! for the specified language. + CUSTOMIZATIONS type STANDARD TABLE OF T_VOICE_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_VOICE_MODELS. + types: + "! The text to synthesize. Specify either plain text or a subset of SSML. SSML is + "! an XML-based markup language that provides text annotation for speech-synthesis + "! applications. Pass a maximum of 5 KB of input text. + begin of T_TEXT, + "! The text to synthesize. + TEXT type STRING, + end of T_TEXT. + types: + "! The pronunciation of the specified text. + begin of T_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. + PRONUNCIATION type STRING, + end of T_PRONUNCIATION. + types: + "! Information about the translation for the specified text. + begin of T_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. + TRANSLATION type STRING, + "! **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/services/text-to-speech?topic=text-to-speec + "! **h-rules#jaNotes). + PART_OF_SPEECH type STRING, + end of T_TRANSLATION. + +constants: + begin of C_REQUIRED_FIELDS, + T_WORD type string value '|WORD|TRANSLATION|', + T_VOICE_MODEL type string value '|CUSTOMIZATION_ID|', + T_SUPPORTED_FEATURES type string value '|CUSTOM_PRONUNCIATION|VOICE_TRANSFORMATION|', + T_VOICE type string value '|URL|GENDER|NAME|LANGUAGE|DESCRIPTION|CUSTOMIZABLE|SUPPORTED_FEATURES|', + T_CREATE_VOICE_MODEL type string value '|NAME|', + T_ERROR_MODEL type string value '|ERROR|CODE|', + T_WORDS type string value '|WORDS|', + T_UPDATE_VOICE_MODEL type string value '|', + T_VOICES type string value '|VOICES|', + T_VOICE_MODELS type string value '|CUSTOMIZATIONS|', + T_TEXT type string value '|TEXT|', + T_PRONUNCIATION type string value '|PRONUNCIATION|', + T_TRANSLATION type string value '|TRANSLATION|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + VOICES type string value 'voices', + URL type string value 'url', + GENDER type string value 'gender', + NAME type string value 'name', + LANGUAGE type string value 'language', + DESCRIPTION type string value 'description', + CUSTOMIZABLE type string value 'customizable', + SUPPORTED_FEATURES type string value 'supported_features', + CUSTOMIZATION type string value 'customization', + CUSTOM_PRONUNCIATION type string value 'custom_pronunciation', + VOICE_TRANSFORMATION type string value 'voice_transformation', + TEXT type string value 'text', + CUSTOMIZATIONS type string value 'customizations', + CUSTOMIZATION_ID type string value 'customization_id', + OWNER type string value 'owner', + CREATED type string value 'created', + LAST_MODIFIED type string value 'last_modified', + WORDS type string value 'words', + WORD type string value 'word', + TRANSLATION type string value 'translation', + PART_OF_SPEECH type string value 'part_of_speech', + PRONUNCIATION type string value 'pronunciation', + ERROR type string value 'error', + CODE type string value 'code', + CODE_DESCRIPTION type string value 'code_description', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! List voices. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_VOICES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_VOICES + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VOICES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a voice. + "! + "! @parameter I_VOICE | + "! The voice for which information is to be returned. + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of a custom voice model for which information is to + "! be returned. You must make the request with credentials for the instance of the + "! service that owns the custom model. Omit the parameter to see information about + "! the specified voice with no customization. + "! @parameter E_RESPONSE | + "! Service return value of type T_VOICE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_VOICE + importing + !I_VOICE type STRING + !I_CUSTOMIZATION_ID type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VOICE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Synthesize audio. + "! + "! @parameter I_TEXT | + "! No documentation available. + "! @parameter I_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. + "! @parameter I_VOICE | + "! The voice to use for synthesis. + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of a custom voice model to use for the synthesis. If + "! a custom voice model is specified, it is guaranteed to work only if it matches + "! the language of the indicated voice. You must make the request with credentials + "! for the instance of the service that owns the custom model. Omit the parameter + "! to use the specified voice with no customization. + "! @parameter E_RESPONSE | + "! Service return value of type FILE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods SYNTHESIZE + importing + !I_TEXT type T_TEXT + !I_ACCEPT type STRING default 'audio/ogg;codecs=opus' + !I_VOICE type STRING default 'en-US_MichaelVoice' + !I_CUSTOMIZATION_ID type STRING optional + !I_contenttype type string default 'application/json' + exporting + !E_RESPONSE type FILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Get pronunciation. + "! + "! @parameter I_TEXT | + "! The word for which the pronunciation is requested. + "! @parameter I_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. + "! @parameter I_FORMAT | + "! The phoneme format in which to return the pronunciation. Omit the parameter to + "! obtain the pronunciation in the default format. + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of a custom voice model for which the pronunciation + "! is to be returned. The language of a specified custom model must match the + "! language of the specified voice. If the word is not defined in the specified + "! custom model, the service returns the default translation for the custom + "! model's language. You must make the request with credentials for the instance + "! of the service that owns the custom model. Omit the parameter to see the + "! translation for the specified voice with no customization. + "! @parameter E_RESPONSE | + "! Service return value of type T_PRONUNCIATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_PRONUNCIATION + importing + !I_TEXT type STRING + !I_VOICE type STRING default 'en-US_MichaelVoice' + !I_FORMAT type STRING default 'ipa' + !I_CUSTOMIZATION_ID type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_PRONUNCIATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a custom model. + "! + "! @parameter I_CREATE_VOICE_MODEL | + "! A `CreateVoiceModel` object that contains information about the new custom voice + "! model. + "! @parameter E_RESPONSE | + "! Service return value of type T_VOICE_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_VOICE_MODEL + importing + !I_CREATE_VOICE_MODEL type T_CREATE_VOICE_MODEL + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VOICE_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List custom models. + "! + "! @parameter I_LANGUAGE | + "! The language for which custom voice models that are owned by the requesting + "! credentials are to be returned. Omit the parameter to see all custom voice + "! models that are owned by the requester. + "! @parameter E_RESPONSE | + "! Service return value of type T_VOICE_MODELS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_VOICE_MODELS + importing + !I_LANGUAGE type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VOICE_MODELS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a custom model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter I_UPDATE_VOICE_MODEL | + "! An `UpdateVoiceModel` object that contains information that is to be updated for + "! the custom voice model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_VOICE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_UPDATE_VOICE_MODEL type T_UPDATE_VOICE_MODEL + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a custom model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter E_RESPONSE | + "! Service return value of type T_VOICE_MODEL + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_VOICE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_VOICE_MODEL + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom model. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_VOICE_MODEL + importing + !I_CUSTOMIZATION_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Add custom words. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter I_CUSTOM_WORDS | + "! No documentation available. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_WORDS + importing + !I_CUSTOMIZATION_ID type STRING + !I_CUSTOM_WORDS type T_WORDS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List custom words. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORDS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_WORDS + importing + !I_CUSTOMIZATION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_WORDS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter I_WORD | + "! The word that is to be added or updated for the custom voice model. + "! @parameter I_TRANSLATION | + "! The translation for the word that is to be added or updated. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD type STRING + !I_TRANSLATION type T_TRANSLATION + !I_contenttype type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter I_WORD | + "! The word that is to be queried from the custom voice model. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRANSLATION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRANSLATION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a custom word. + "! + "! @parameter I_CUSTOMIZATION_ID | + "! The customization ID (GUID) of the custom voice model. You must make the request + "! with credentials for the instance of the service that owns the custom model. + "! @parameter I_WORD | + "! The word that is to be deleted from the custom voice model. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_WORD + importing + !I_CUSTOMIZATION_ID type STRING + !I_WORD type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_TEXT_TO_SPEECH_V1 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Text to Speech'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'ICP4D'. + e_request_prop-auth_name = 'ICP4D'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/text-to-speech/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092827'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->LIST_VOICES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VOICES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_VOICES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/voices'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_VOICE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_VOICE TYPE STRING +* | [--->] I_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VOICE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_VOICE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/voices/{voice}'. + replace all occurrences of `{voice}` in ls_request_prop-url-path with i_VOICE ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->SYNTHESIZE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_TEXT TYPE T_TEXT +* | [--->] I_ACCEPT TYPE STRING (default ='audio/ogg;codecs=opus') +* | [--->] I_VOICE TYPE STRING (default ='en-US_MichaelVoice') +* | [--->] I_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE FILE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method SYNTHESIZE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/synthesize'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_VOICE is supplied. + lv_queryparam = escape( val = i_VOICE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `voice` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_ACCEPT is supplied. + lv_headerparam = I_ACCEPT. + add_header_parameter( + exporting + i_parameter = 'Accept' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_TEXT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TEXT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'text' i_value = i_TEXT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TEXT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve file data + e_response = get_response_binary( lo_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_PRONUNCIATION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_TEXT TYPE STRING +* | [--->] I_VOICE TYPE STRING (default ='en-US_MichaelVoice') +* | [--->] I_FORMAT TYPE STRING (default ='ipa') +* | [--->] I_CUSTOMIZATION_ID TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_PRONUNCIATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_PRONUNCIATION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/pronunciation'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_TEXT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `text` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + if i_VOICE is supplied. + lv_queryparam = escape( val = i_VOICE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `voice` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_FORMAT is supplied. + lv_queryparam = escape( val = i_FORMAT format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `format` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_CUSTOMIZATION_ID is supplied. + lv_queryparam = escape( val = i_CUSTOMIZATION_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customization_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->CREATE_VOICE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CREATE_VOICE_MODEL TYPE T_CREATE_VOICE_MODEL +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VOICE_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_VOICE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CREATE_VOICE_MODEL ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CREATE_VOICE_MODEL i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'create_voice_model' i_value = i_CREATE_VOICE_MODEL ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CREATE_VOICE_MODEL to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->LIST_VOICE_MODELS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_LANGUAGE TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VOICE_MODELS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_VOICE_MODELS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_LANGUAGE is supplied. + lv_queryparam = escape( val = i_LANGUAGE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `language` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->UPDATE_VOICE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_UPDATE_VOICE_MODEL TYPE T_UPDATE_VOICE_MODEL +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_VOICE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_UPDATE_VOICE_MODEL ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_UPDATE_VOICE_MODEL i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'update_voice_model' i_value = i_UPDATE_VOICE_MODEL ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_UPDATE_VOICE_MODEL to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_VOICE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_VOICE_MODEL +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_VOICE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->DELETE_VOICE_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_VOICE_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->ADD_WORDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_CUSTOM_WORDS TYPE T_WORDS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_WORDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_CUSTOM_WORDS ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_CUSTOM_WORDS i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'custom_words' i_value = i_CUSTOM_WORDS ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_CUSTOM_WORDS to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->LIST_WORDS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_WORDS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_WORDS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->ADD_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD TYPE STRING +* | [--->] I_TRANSLATION TYPE T_TRANSLATION +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word}` in ls_request_prop-url-path with i_WORD ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_TRANSLATION ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TRANSLATION i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'translation' i_value = i_TRANSLATION ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TRANSLATION to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP PUT request + lo_response = HTTP_PUT( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->GET_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRANSLATION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word}` in ls_request_prop-url-path with i_WORD ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->DELETE_WORD +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMIZATION_ID TYPE STRING +* | [--->] I_WORD TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_WORD. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/customizations/{customization_id}/words/{word}'. + replace all occurrences of `{customization_id}` in ls_request_prop-url-path with i_CUSTOMIZATION_ID ignoring case. + replace all occurrences of `{word}` in ls_request_prop-url-path with i_WORD ignoring case. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TEXT_TO_SPEECH_V1->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v1/user_data'. + + " standard headers + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_TEXT_TO_SPEECH_V1->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_text_to_speech_v1.clas.xml b/src/zcl_ibmc_text_to_speech_v1.clas.xml new file mode 100644 index 0000000..7136ceb --- /dev/null +++ b/src/zcl_ibmc_text_to_speech_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_TEXT_TO_SPEECH_V1 + E + IBM Watson Text to Speech + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_tone_analyzer_v3.clas.abap b/src/zcl_ibmc_tone_analyzer_v3.clas.abap new file mode 100644 index 0000000..3f92578 --- /dev/null +++ b/src/zcl_ibmc_tone_analyzer_v3.clas.abap @@ -0,0 +1,696 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect +"! emotional and language tones in written text. The service can analyze tone at +"! both the document and sentence levels. You can use the service to understand +"! how your written communications are perceived and then to improve the tone of +"! your communications. Businesses can use the service to learn the tone of their +"! customers' communications and to respond to each customer appropriately, or to +"! understand and improve their customer conversations.
+"!
+"! **Note:** Request logging is disabled for the Tone Analyzer service. Regardless +"! of whether you set the `X-Watson-Learning-Opt-Out` request header, the service +"! does not log or retain data from requests and responses.
+class ZCL_IBMC_TONE_ANALYZER_V3 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! The score for a tone from the input content. + begin of T_TONE_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. + SCORE type DOUBLE, + "! 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. + TONE_ID type STRING, + "! The user-visible, localized name of the tone. + TONE_NAME type STRING, + end of T_TONE_SCORE. + types: + "! The category for a tone from the input content. + begin of T_TONE_CATEGORY, + "! An array of `ToneScore` objects that provides the results for the tones of the + "! category. + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + "! 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`. + CATEGORY_ID type STRING, + "! The user-visible, localized name of the category. + CATEGORY_NAME type STRING, + end of T_TONE_CATEGORY. + types: + "! Input for the general-purpose endpoint. + begin of T_TONE_INPUT, + "! The input content that the service is to analyze. + TEXT type STRING, + end of T_TONE_INPUT. + types: + "! The score for an utterance from the input content. + begin of T_TONE_CHAT_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. + SCORE type DOUBLE, + "! The unique, non-localized identifier of the tone for the results. The service + "! returns results only for tones whose scores meet a minimum threshold of 0.5. + TONE_ID type STRING, + "! The user-visible, localized name of the tone. + TONE_NAME type STRING, + end of T_TONE_CHAT_SCORE. + types: + "! An utterance for the input of the general-purpose endpoint. + begin of T_UTTERANCE, + "! An utterance contributed by a user in the conversation that is to be analyzed. + "! The utterance can contain multiple sentences. + TEXT type STRING, + "! A string that identifies the user who contributed the utterance specified by the + "! `text` parameter. + USER type STRING, + end of T_UTTERANCE. + types: + "! Input for the customer-engagement endpoint. + begin of T_TONE_CHAT_INPUT, + "! An array of `Utterance` objects that provides the input content that the service + "! is to analyze. + UTTERANCES type STANDARD TABLE OF T_UTTERANCE WITH NON-UNIQUE DEFAULT KEY, + end of T_TONE_CHAT_INPUT. + types: + "! The results of the analysis for the individual sentences of the input content. + begin of T_SENTENCE_ANALYSIS, + "! 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. + SENTENCE_ID type INTEGER, + "! The text of the input sentence. + TEXT type STRING, + "! **`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. + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + "! **`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. + TONE_CATEGORIES type STANDARD TABLE OF T_TONE_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the first + "! ** character of the sentence in the overall input content. + INPUT_FROM type INTEGER, + "! **`2017-09-21`:** Not returned. **`2016-05-19`:** The offset of the last character + "! ** of the sentence in the overall input content. + INPUT_TO type INTEGER, + end of T_SENTENCE_ANALYSIS. + types: + "! The results of the analysis for an utterance of the input content. + begin of T_UTTERANCE_ANALYSIS, + "! The unique identifier of the utterance. The first utterance has ID 0, and the ID + "! of each subsequent utterance is incremented by one. + UTTERANCE_ID type INTEGER, + "! The text of the utterance. + UTTERANCE_TEXT type STRING, + "! 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. + TONES type STANDARD TABLE OF T_TONE_CHAT_SCORE WITH NON-UNIQUE DEFAULT KEY, + "! **`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. + ERROR type STRING, + end of T_UTTERANCE_ANALYSIS. + types: + "! The results of the analysis for the utterances of the input content. + begin of T_UTTERANCE_ANALYSES, + "! An array of `UtteranceAnalysis` objects that provides the results for each + "! utterance of the input. + UTTERANCES_TONE type STANDARD TABLE OF T_UTTERANCE_ANALYSIS WITH NON-UNIQUE DEFAULT KEY, + "! **`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. + WARNING type STRING, + end of T_UTTERANCE_ANALYSES. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + "! The HTTP status code. + CODE type INTEGER, + "! A service-specific error code. + SUB_CODE type STRING, + "! A description of the error. + ERROR type STRING, + "! A URL to documentation explaining the cause and possibly solutions for the + "! error. + HELP type STRING, + end of T_ERROR_MODEL. + types: + "! The results of the analysis for the full input content. + begin of T_DOCUMENT_ANALYSIS, + "! **`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. + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + "! **`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. + TONE_CATEGORIES type STANDARD TABLE OF T_TONE_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + "! **`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. + WARNING type STRING, + end of T_DOCUMENT_ANALYSIS. + types: + "! The tone analysis results for the input from the general-purpose endpoint. + begin of T_TONE_ANALYSIS, + "! The results of the analysis for the full input content. + DOCUMENT_TONE type T_DOCUMENT_ANALYSIS, + "! 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`. + SENTENCES_TONE type STANDARD TABLE OF T_SENTENCE_ANALYSIS WITH NON-UNIQUE DEFAULT KEY, + end of T_TONE_ANALYSIS. + +constants: + begin of C_REQUIRED_FIELDS, + T_TONE_SCORE type string value '|SCORE|TONE_ID|TONE_NAME|', + T_TONE_CATEGORY type string value '|TONES|CATEGORY_ID|CATEGORY_NAME|', + T_TONE_INPUT type string value '|TEXT|', + T_TONE_CHAT_SCORE type string value '|SCORE|TONE_ID|TONE_NAME|', + T_UTTERANCE type string value '|TEXT|', + T_TONE_CHAT_INPUT type string value '|UTTERANCES|', + T_SENTENCE_ANALYSIS type string value '|SENTENCE_ID|TEXT|', + T_UTTERANCE_ANALYSIS type string value '|UTTERANCE_ID|UTTERANCE_TEXT|TONES|', + T_UTTERANCE_ANALYSES type string value '|UTTERANCES_TONE|', + T_ERROR_MODEL type string value '|CODE|ERROR|', + T_DOCUMENT_ANALYSIS type string value '|', + T_TONE_ANALYSIS type string value '|DOCUMENT_TONE|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + TEXT type string value 'text', + UTTERANCES type string value 'utterances', + USER type string value 'user', + DOCUMENT_TONE type string value 'document_tone', + SENTENCES_TONE type string value 'sentences_tone', + SENTENCESTONE type string value 'sentencesTone', + TONES type string value 'tones', + TONE_CATEGORIES type string value 'tone_categories', + TONECATEGORIES type string value 'toneCategories', + WARNING type string value 'warning', + SENTENCE_ID type string value 'sentence_id', + INPUT_FROM type string value 'input_from', + INPUT_TO type string value 'input_to', + SCORE type string value 'score', + TONE_ID type string value 'tone_id', + TONE_NAME type string value 'tone_name', + CATEGORY_ID type string value 'category_id', + CATEGORY_NAME type string value 'category_name', + UTTERANCES_TONE type string value 'utterances_tone', + UTTERANCESTONE type string value 'utterancesTone', + UTTERANCE_ID type string value 'utterance_id', + UTTERANCE_TEXT type string value 'utterance_text', + ERROR type string value 'error', + CODE type string value 'code', + SUB_CODE type string value 'sub_code', + HELP type string value 'help', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Analyze general tone. + "! + "! @parameter I_TONE_INPUT | + "! JSON, plain text, or HTML input that contains the content to be analyzed. For + "! JSON input, provide an object of type `ToneInput`. + "! @parameter I_CONTENT_TYPE | + "! The type of the input. A character encoding can be specified by including a + "! `charset` parameter. For example, 'text/plain;charset=utf-8'. + "! @parameter I_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. + "! @parameter I_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. + "! @parameter I_CONTENT_LANGUAGE | + "! 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`. + "! @parameter I_ACCEPT_LANGUAGE | + "! 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**. + "! @parameter E_RESPONSE | + "! Service return value of type T_TONE_ANALYSIS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TONE + importing + !I_TONE_INPUT type T_TONE_INPUT + !I_CONTENT_TYPE type STRING default 'application/json' + !I_SENTENCES type BOOLEAN default c_boolean_true + !I_TONES type TT_STRING optional + !I_CONTENT_LANGUAGE type STRING default 'en' + !I_ACCEPT_LANGUAGE type STRING default 'en' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TONE_ANALYSIS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Analyze customer-engagement tone. + "! + "! @parameter I_UTTERANCES | + "! An object that contains the content to be analyzed. + "! @parameter I_CONTENT_LANGUAGE | + "! 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`. + "! @parameter I_ACCEPT_LANGUAGE | + "! 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**. + "! @parameter E_RESPONSE | + "! Service return value of type T_UTTERANCE_ANALYSES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TONE_CHAT + importing + !I_UTTERANCES type T_TONE_CHAT_INPUT + !I_CONTENT_LANGUAGE type STRING default 'en' + !I_ACCEPT_LANGUAGE type STRING default 'en' + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_UTTERANCE_ANALYSES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_TONE_ANALYZER_V3 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TONE_ANALYZER_V3->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Tone Analyzer'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_TONE_ANALYZER_V3->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + elseif lv_auth_method eq 'basicAuth'. + e_request_prop-auth_name = 'basicAuth'. + e_request_prop-auth_type = 'http'. + e_request_prop-auth_basic = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/tone-analyzer/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TONE_ANALYZER_V3->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092828'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TONE_ANALYZER_V3->TONE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_TONE_INPUT TYPE T_TONE_INPUT +* | [--->] I_CONTENT_TYPE TYPE STRING (default ='application/json') +* | [--->] I_SENTENCES TYPE BOOLEAN (default =c_boolean_true) +* | [--->] I_TONES TYPE TT_STRING(optional) +* | [--->] I_CONTENT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_ACCEPT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TONE_ANALYSIS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TONE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/tone'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_SENTENCES is supplied. + lv_queryparam = i_SENTENCES. + add_query_parameter( + exporting + i_parameter = `sentences` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_TONES is supplied. + data: + lv_item_TONES type STRING. + clear: lv_queryparam, lv_sep. + loop at i_TONES into lv_item_TONES. + lv_queryparam = lv_queryparam && lv_sep && lv_item_TONES. + lv_sep = ','. + endloop. + lv_queryparam = escape( val = lv_queryparam format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `tones` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_TYPE is supplied. + ls_request_prop-header_content_type = I_CONTENT_TYPE. + endif. + + if i_CONTENT_LANGUAGE is supplied. + lv_headerparam = I_CONTENT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Content-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + if i_ACCEPT_LANGUAGE is supplied. + lv_headerparam = I_ACCEPT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Accept-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_TONE_INPUT ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TONE_INPUT i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'tone_input' i_value = i_TONE_INPUT ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TONE_INPUT to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_TONE_ANALYZER_V3->TONE_CHAT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_UTTERANCES TYPE T_TONE_CHAT_INPUT +* | [--->] I_CONTENT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_ACCEPT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_UTTERANCE_ANALYSES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TONE_CHAT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/tone_chat'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_CONTENT_LANGUAGE is supplied. + lv_headerparam = I_CONTENT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Content-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + if i_ACCEPT_LANGUAGE is supplied. + lv_headerparam = I_ACCEPT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Accept-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_UTTERANCES ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_UTTERANCES i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'utterances' i_value = i_UTTERANCES ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_UTTERANCES to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_TONE_ANALYZER_V3->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_tone_analyzer_v3.clas.xml b/src/zcl_ibmc_tone_analyzer_v3.clas.xml new file mode 100644 index 0000000..741e3e6 --- /dev/null +++ b/src/zcl_ibmc_tone_analyzer_v3.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_TONE_ANALYZER_V3 + E + IBM Watson Tone Analyzer + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_util.clas.abap b/src/zcl_ibmc_util.clas.abap new file mode 100644 index 0000000..6f492b2 --- /dev/null +++ b/src/zcl_ibmc_util.clas.abap @@ -0,0 +1,560 @@ +* Copyright 2019,2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +class ZCL_IBMC_UTIL definition + public + final + create public . + +public section. + + + "! Converts an internal table to JSON string in table schema format. + "! E.g.: '{"fields": ["PET", "NUMBER"], "values": [["Cat",5],["Rabbit",2]]}' + "! + "! @parameter I_ITAB | Internal table to be converted. + "! @parameter I_DICTIONARY | Dictionary to be used for mapping ABAP identifiers to JSON keys. + "! @parameter I_LOWER_CASE | If set to C_BOOLEAN_TRUE all keys in JSON string will be lower case. + "! @parameter I_EXCLUDE_FIELDS | Internal table of table fields in I_ITAB that should not occur in result. + "! @parameter E_JSON | JSON string. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods ITAB_TO_TABLESCHEMA + importing + !I_ITAB type ANY TABLE + !I_DICTIONARY type ANY optional + !I_LOWER_CASE type ZCL_IBMC_SERVICE=>BOOLEAN default ZCL_IBMC_SERVICE=>C_BOOLEAN_FALSE + !IT_EXCLUDED_FIELDS type ZCL_IBMC_SERVICE=>TT_STRING optional + returning + value(E_JSON) type STRING . + "! Converts a JSON string in table schema format to an internal table. + "! E.g.: '{"tableschema_key": {"fields": ["PET", "NUMBER"], "values": [["Cat",5],["Rabbit",2]]}}' + "! + "! @parameter I_JSON | JSON string. + "! @parameter I_TABLESCHEMA_KEY | Key in JSON string that holds the table schema. + "! @parameter E_ITAB | Internal table containing converted data. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + class-methods TABLESCHEMA_TO_ITAB + importing + !I_JSON type STRING + !I_TABLESCHEMA_KEY type STRING optional + exporting + !E_ITAB type ANY TABLE . + "! Converts a timestamp in UTC to a timestamp in local time. + "! + "! @parameter IV_TIMESTAMP | Timestamp (UTC). + "! @parameter EV_LOCAL | Timestamp (local time). + "! + class-methods CONVERT_TIMESTAMP_TO_LOCAL + importing + !IV_TIMESTAMP type TIMESTAMP + returning + value(EV_LOCAL) type STRING . + "! Determine MIME type from a file name, e.g. 'docu.txt' -> 'text_/plain'. + "! + "! @parameter I_FILENAME | Filename with extension. + "! @parameter E_MIMETYPE | MIME type. + "! + class-methods GET_MIMETYPE_FROM_EXTENSION + importing + !I_FILENAME type STRING + returning + value(E_MIMETYPE) type STRING . + "! Converts a timestamp in UTC to a timestamp in another timezone. + "! + "! @parameter I_TIMESTAMP | Timestamp (UTC). + "! @parameter I_TIMEZONE | Time zone + "! @parameter E_TIMESTAMP | Timestamp in give time zone. + "! + class-methods UTC_TO_TIMEZONE + importing + !I_TIMESTAMP type TIMESTAMP + !I_TIMEZONE type ZIF_IBMC_SERVICE_ARCH=>TY_TIMEZONE optional + returning + value(E_TIMESTAMP) type TIMESTAMP . + "! Converts datetime format to a timestamp, i.e. yyyy-mm-ddThh:mm:ssZ -> YYYYMMDDHHMMSS + "! + "! @parameter I_DATETIME | Input in datetime format. + "! @parameter E_TIMESTAMP | Timestamp. + "! + class-methods CONVERT_DATETIME_TO_TIMESTAMP + importing + !I_DATETIME type ZCL_IBMC_SERVICE=>DATETIME + returning + value(E_TIMESTAMP) type TIMESTAMP . + "! Converts a timestamp to datetime format, i.e. YYYYMMDDHHMMSS -> yyyy-mm-ddThh:mm:ssZ + "! + "! @parameter I_TIMESTAMP | Timestamp. + "! @parameter E_DATATIMEP | Datetime format. + "! + class-methods CONVERT_TIMESTAMP_TO_DATETIME + importing + !I_TIMESTAMP type TIMESTAMP + returning + value(E_DATETIME) type ZCL_IBMC_SERVICE=>DATETIME . +protected section. +private section. +ENDCLASS. + + + +CLASS ZCL_IBMC_UTIL IMPLEMENTATION. + + + method CONVERT_DATETIME_TO_TIMESTAMP. + + constants: + c_zero type timestamp value '0'. " avoid conversion at runtime + + " check if input string applies to schema yyyy-mm-ddThh:mm:ssZ + if i_datetime cp '++++-++-++T++:++:++*'. + try. + e_timestamp = + i_datetime(4) * 10000000000 + i_datetime+5(2) * 100000000 + i_datetime+8(2) * 1000000 + + i_datetime+11(2) * 10000 + i_datetime+14(2) * 100 + i_datetime+17(2). + catch cx_sy_conversion_no_number. + " invalid input + e_timestamp = c_zero. + endtry. + else. + " invalid input + e_timestamp = c_zero. + endif. + + endmethod. + + + method CONVERT_TIMESTAMP_TO_DATETIME. + + data: + lv_year(4) type n, + lv_month(2) type n, + lv_day(2) type n, + lv_hour(2) type n, + lv_min(2) type n, + lv_sec(2) type n, + lv_rest type timestamp. + + lv_rest = i_timestamp. + lv_year = lv_rest div 10000000000. + lv_rest = lv_rest - ( lv_year * 10000000000 ). + lv_month = lv_rest div 100000000. + lv_rest = lv_rest - ( lv_month * 100000000 ). + lv_day = lv_rest div 1000000. + lv_rest = lv_rest - ( lv_day * 1000000 ). + lv_hour = lv_rest div 10000. + lv_rest = lv_rest - ( lv_hour * 10000 ). + lv_min = lv_rest div 100. + lv_rest = lv_rest - ( lv_min * 100 ). + lv_sec = lv_rest div 1. " type conversion + + concatenate lv_year '-' lv_month '-' lv_day 'T' lv_hour ':' lv_min ':' lv_sec 'Z' into e_datetime. + + endmethod. + + + method convert_timestamp_to_local. + + data: + lv_dats type d, + lv_tims type t, + lv_timezone type zif_ibmc_service_arch=>ty_timezone, + lv_datc(10) type c, + lv_timc(8) type c. + + " split timestamp to date and time according to time zone + lv_timezone = zcl_ibmc_service_arch=>get_timezone( ). + convert time stamp iv_timestamp time zone lv_timezone + into date lv_dats time lv_tims. + + " write date and time to string using local date/time format + lv_datc = conv #( lv_dats ). + lv_timc = conv #( lv_tims ). + concatenate lv_datc lv_timc into ev_local separated by space. + + endmethod. + + + method get_mimetype_from_extension. + data: + l_extension type string. + + if i_filename is initial. + e_mimetype = zif_ibmc_service_arch=>c_mediatype-all. + exit. + endif. + + find regex '\.([^\.]*)$' in i_filename submatches l_extension. + if sy-subrc <> 0. + l_extension = i_filename. + endif. + + translate l_extension to lower case. + + case l_extension. + when 'jpg' or 'jpeg'. e_mimetype = zif_ibmc_service_arch=>c_mediatype-image_jpeg. + when 'png'. e_mimetype = zif_ibmc_service_arch=>c_mediatype-image_png. + when 'txt'. e_mimetype = zif_ibmc_service_arch=>c_mediatype-text_plain. + when 'csv'. e_mimetype = zif_ibmc_service_arch=>c_mediatype-text_csv. + when others. e_mimetype = `application/` && l_extension ##NO_TEXT. + endcase. + + endmethod. + + + method itab_to_tableschema. + " Converts an internal table to a JSON object string with keys "fields" and "values". + " Example: I_ITAB = | PET | NUMBER | + " ------------------- + " | Cat | 5 | + " | Rabbit | 2 | + " --> E_JSON = '{"fields": ["PET", "NUMBER"], "values": [["Cat",5],["Rabbit",2]]}' + " Field names are mapped according to I_DICTIONARY. + " Example: BEGIN OF i_dictionary, + " PET type string value 'MyPet', + " END OF i_dictionary. + " --> E_JSON = '{"fields": ["MyPet", "NUMBER"], "values": [["Cat",5],["Rabbit",2]]}' + " Field names are translated to lower case, if I_LOWER_CASE = zcl_ibmc_service=>c_boolean_true. + " Field types must be elementary or table of elementary. + " Field names in table IT_EXCLUDED_FIELDS are skipped and will not appear in the JSON string. + + data: + lt_comp type cl_abap_structdescr=>component_table, + ls_comp like line of lt_comp, + lo_datadescr type ref to cl_abap_datadescr, + lo_tabledesc type ref to cl_abap_tabledescr, + lo_struct type ref to cl_abap_structdescr, + lv_fieldname type string, + lv_sep1(1) type c, + lv_sep2(1) type c, + lv_sep3(1) type c. + + field-symbols: + type any, + type any, + type any table, + type string. + + " the following data type are character-like, thus the according values must be quoted + data(lc_character_types) = + cl_abap_datadescr=>typekind_char && + cl_abap_datadescr=>typekind_clike && + cl_abap_datadescr=>typekind_csequence && + cl_abap_datadescr=>typekind_string && + cl_abap_datadescr=>typekind_date && + cl_abap_datadescr=>typekind_time && + cl_abap_datadescr=>typekind_num. + + " get internal table fields + lo_tabledesc ?= cl_abap_tabledescr=>describe_by_data( i_itab ). + lo_struct ?= lo_tabledesc->get_table_line_type( ). + lt_comp = lo_struct->get_components( ). + + " append field names to JSON string + e_json = `{"fields": [` ##NO_TEXT. + clear lv_sep1. + loop at lt_comp into ls_comp. + read table it_excluded_fields with key table_line = ls_comp-name transporting no fields. + if sy-subrc = 0. continue. endif. + lv_fieldname = ls_comp-name. + if i_dictionary is supplied. + assign component ls_comp-name of structure i_dictionary to . + if sy-subrc = 0. + lv_fieldname = . + endif. + endif. + if i_lower_case eq zcl_ibmc_service=>c_boolean_true. + translate lv_fieldname to lower case. + endif. + e_json = e_json && lv_sep1 && `"` && lv_fieldname && `"`. + lv_sep1 = `,`. + endloop. + + " append values to JSON string + e_json = e_json && `], "values": [` ##NO_TEXT. + + clear lv_sep1. + loop at i_itab assigning . " loop on itab records + clear lv_sep2. + e_json = e_json && lv_sep1 && `[`. + loop at lt_comp into ls_comp. " loop on record fields + read table it_excluded_fields with key table_line = ls_comp-name transporting no fields. + if sy-subrc = 0. continue. endif. + + if ls_comp-type->type_kind eq cl_abap_datadescr=>typekind_table. + + " field type is subtable, get line type + assign component ls_comp-name of structure to . + lo_tabledesc ?= cl_abap_tabledescr=>describe_by_data( ). + lo_datadescr = lo_tabledesc->get_table_line_type( ). + + " add field values of subtable to JSON string + clear lv_sep3. + e_json = e_json && lv_sep2 && `[`. + loop at assigning . + if lo_datadescr->type_kind ca lc_character_types. + e_json = e_json && lv_sep3 && `"` && && `"`. + else. + e_json = e_json && lv_sep3 && . + endif. + lv_sep3 = `,`. + endloop. + e_json = e_json && `]`. + + else. + + " field type is elementary, add field value to JSON string + assign component ls_comp-name of structure to . + if ls_comp-type->type_kind ca lc_character_types. + e_json = e_json && lv_sep2 && `"` && && `"`. + else. + e_json = e_json && lv_sep2 && . + endif. + + endif. + + lv_sep2 = `,`. + endloop. + + e_json = e_json && `]`. + lv_sep1 = `,`. + endloop. + + e_json = e_json && `]}` ##NO_TEXT. + + endmethod. + + + method tableschema_to_itab. + + data: + lt_comp type cl_abap_structdescr=>component_table, + ls_comp like line of lt_comp, + lv_field type string, + lt_field type standard table of string, + lv_fieldname type string, + lv_tabix type i, + lv_tableschema_key type string, + lo_structdescr type ref to cl_abap_structdescr, + lo_datadescr type ref to cl_abap_datadescr, + lo_tabledescr type ref to cl_abap_tabledescr, + lr_values type ref to data, + lr_comp type ref to data, + lr_data type ref to data, + lv_json type string. + + field-symbols: + type ref to data, + type any table, + type any, + type any, + type any table, + type any, + type any, + type ref to data, + type any table, + type any table, + type any, + type any table, + type any table. + + " dynamically create data structure: + " begin of , + " tableschema_key type ref to data, + " end of . + if i_tableschema_key is initial. + lv_json = `{ "tableschema_key": ` && i_json && ` }` ##NO_TEXT. + lv_tableschema_key = `tableschema_key` ##NO_TEXT. + else. + lv_json = i_json. + lv_tableschema_key = i_tableschema_key. + endif. + ls_comp-name = lv_tableschema_key. + ls_comp-type ?= cl_abap_datadescr=>describe_by_data( lr_data ). + append ls_comp to lt_comp. + lo_structdescr = cl_abap_structdescr=>create( lt_comp ). + create data lr_data type handle lo_structdescr. + assign lr_data->* to . + + " parse JSON + try. + zcl_ibmc_service=>parse_json( + exporting + i_json = lv_json + "i_dictionary = c_abapname_dictionary + changing + c_abap = ). + catch zcx_ibmc_service_exception. + return. + endtry. + assign component lv_tableschema_key of structure to . + assign ->* to . + + + + unassign . + assign component 'VALUES' of structure to . + + " I_JSON does not have table schema on highest level, check if any subkey has + " check all components + lo_structdescr ?= cl_abap_structdescr=>describe_by_data( ). + clear lt_comp[]. + lt_comp = lo_structdescr->get_components( ). + + loop at lt_comp into ls_comp. + assign component ls_comp-name of structure to . + lo_datadescr ?= cl_abap_datadescr=>describe_by_data_ref( ). + if lo_datadescr->type_kind eq cl_abap_datadescr=>typekind_table. + assign ->* to . + loop at assigning ##GEN_OK. + exit. + endloop. + endif. + assign ->* to . + assign component 'VALUES' of structure to . + if sy-subrc = 0. + assign to . + exit. + endif. + + endloop. + + + if not is assigned. + return. + endif. + + assign ->* to . + assign component 'FIELDS' of structure to . + if sy-subrc = 0. + assign ->* to . + loop at assigning ##GEN_OK. + assign ->* to . + append to lt_field. + endloop. + else. + data(lv_count) = lines( ). + data(lv_index) = 0. + while lv_index < lv_count. + lv_fieldname = `FIELD` && lv_index. + lv_index = lv_index + 1. + append lv_fieldname to lt_field. + endwhile. + endif. + + + " get data fields; read first values for reference + if lines( ) < 1. return. endif. + loop at into lr_data. + assign lr_data->* to . + exit. + endloop. + + clear lt_comp[]. + loop at into lr_values. + + " field name + lv_tabix = lv_tabix + 1. + read table lt_field index lv_tabix into lv_field. + if sy-subrc <> 0. + lv_field = `C` && lv_tabix. + endif. + ls_comp-name = lv_field. + + " read data type + assign lr_values->* to . + lo_datadescr ?= cl_abap_datadescr=>describe_by_data( ). + + if lo_datadescr->type_kind = cl_abap_structdescr=>typekind_table. + + " data type is internal table (of references) + " -> create new internal table layout w/o references + lo_tabledescr ?= cl_abap_tabledescr=>describe_by_data( ). + lo_datadescr = lo_tabledescr->get_table_line_type( ). + if lo_datadescr->type_kind = cl_abap_datadescr=>typekind_dref. + assign to . + loop at into lr_comp. exit. endloop. " read first table record + lo_datadescr ?= cl_abap_datadescr=>describe_by_data_ref( lr_comp ). + endif. + ls_comp-type = cl_abap_tabledescr=>create( p_line_type = lo_datadescr ). + + else. + ls_comp-type = lo_datadescr. + endif. + + append ls_comp to lt_comp. + endloop. + + " create data structure + lo_structdescr = cl_abap_structdescr=>create( lt_comp ). + create data lr_data type handle lo_structdescr. + assign lr_data->* to . + create data lr_data like table of . + assign lr_data->* to . + + + " populate data structure + loop at into lr_data. + assign lr_data->* to . + if not is assigned. + create data lr_data type handle lo_structdescr. + assign lr_data->* to . + endif. + lv_tabix = 0. + loop at into lr_values. + lv_tabix = lv_tabix + 1. + read table lt_comp index lv_tabix into ls_comp. + case ls_comp-type->type_kind. + when cl_abap_structdescr=>typekind_table. + assign component ls_comp-name of structure to . + assign lr_values->* to . + loop at into lr_data. + assign lr_data->* to . + insert into table . + endloop. + when others. + assign component ls_comp-name of structure to . + assign lr_values->* to . + = . + endcase. + endloop. + + insert into table . + unassign . " force data creation at next loop step + + endloop. + + move-corresponding to e_itab. + + endmethod. + + + method utc_to_timezone. + + data: + lv_timezone type zif_ibmc_service_arch=>ty_timezone, + lv_date type d, + lv_time type t. + + if i_timezone is initial. + lv_timezone = zcl_ibmc_service_arch=>get_timezone( ). + else. + lv_timezone = i_timezone. + endif. + + convert time stamp i_timestamp time zone lv_timezone into date lv_date time lv_time. + convert date lv_date time lv_time into time stamp e_timestamp time zone 'UTC'. + + endmethod. +ENDCLASS. diff --git a/src/zcl_ibmc_util.clas.xml b/src/zcl_ibmc_util.clas.xml new file mode 100644 index 0000000..2a1f5db --- /dev/null +++ b/src/zcl_ibmc_util.clas.xml @@ -0,0 +1,60 @@ + + + + + + ZCL_IBMC_UTIL + E + Utilities to connect to IBM Watson + 1 + X + X + X + + + + ZCL_IBMC_UTIL + CONVERT_DATETIME_TO_TIMESTAMP + E + Converts a DATETIME String to type TIMESTAMP + + + ZCL_IBMC_UTIL + CONVERT_TIMESTAMP_TO_DATETIME + E + Converts a DATETIME String to type TIMESTAMP + + + ZCL_IBMC_UTIL + CONVERT_TIMESTAMP_TO_LOCAL + E + Converts a UTF timestamp to a local timestamp + + + ZCL_IBMC_UTIL + GET_MIMETYPE_FROM_EXTENSION + E + Returns mime type for a given extension + + + ZCL_IBMC_UTIL + ITAB_TO_TABLESCHEMA + E + Converts an internal table to table schema JSON format + + + ZCL_IBMC_UTIL + TABLESCHEMA_TO_ITAB + E + Converts a JSON string in table schema format to an itab + + + ZCL_IBMC_UTIL + UTC_TO_TIMEZONE + E + Converts an UTC timestamp to the specified timezone + + + + + diff --git a/src/zcl_ibmc_visual_recognition_v3.clas.abap b/src/zcl_ibmc_visual_recognition_v3.clas.abap new file mode 100644 index 0000000..e755104 --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v3.clas.abap @@ -0,0 +1,1281 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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

+"! The IBM Watson™ Visual Recognition service uses deep learning algorithms +"! to identify scenes and objects in images that you upload to the service. You +"! can create and train a custom classifier to identify subjects that suit your +"! needs.
+class ZCL_IBMC_VISUAL_RECOGNITION_V3 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Number of images processed for the API call. + T_IMAGES_PROCESSED type Integer. + types: + "! Result of a class within a classifier. + begin of T_CLASS_RESULT, + "! Name of the class.
+ "!
+ "! Class names are translated in the language defined by the **Accept-Language** + "! request header for the build-in classifier IDs (`default`, `food`, and + "! `explicit`). Class names of custom classifiers are not translated. The response + "! might not be in the specified language when the requested language is not + "! supported or when there is no translation for the class name. + CLASS type STRING, + "! 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. + SCORE type FLOAT, + "! Knowledge graph of the property. For example, `/fruit/pome/apple/eating + "! apple/Granny Smith`. Included only if identified. + TYPE_HIERARCHY type STRING, + end of T_CLASS_RESULT. + types: + "! Classifier and score combination. + begin of T_CLASSIFIER_RESULT, + "! Name of the classifier. + NAME type STRING, + "! ID of a classifier identified in the image. + CLASSIFIER_ID type STRING, + "! Classes within the classifier. + CLASSES type STANDARD TABLE OF T_CLASS_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFIER_RESULT. + types: + "! Information about what might have caused a failure, such as an image that is too + "! large. Not returned when there is no error. + begin of T_ERROR_INFO, + "! HTTP status code. + CODE type INTEGER, + "! Human-readable error description. For example, `File size limit exceeded`. + DESCRIPTION type STRING, + "! Codified error string. For example, `limit_exceeded`. + ERROR_ID type STRING, + end of T_ERROR_INFO. + types: + "! Results for one image. + begin of T_CLASSIFIED_IMAGE, + "! Source of the image before any redirects. Not returned when the image is + "! uploaded. + SOURCE_URL type STRING, + "! Fully resolved URL of the image after redirects are followed. Not returned when + "! the image is uploaded. + RESOLVED_URL type STRING, + "! Relative path of the image file if uploaded directly. Not returned when the + "! image is passed by URL. + IMAGE type STRING, + "! Information about what might have caused a failure, such as an image that is too + "! large. Not returned when there is no error. + ERROR type T_ERROR_INFO, + "! The classifiers. + CLASSIFIERS type STANDARD TABLE OF T_CLASSIFIER_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFIED_IMAGE. + types: + "! Information about something that went wrong. + begin of T_WARNING_INFO, + "! Codified warning string, such as `limit_reached`. + WARNING_ID type STRING, + "! Information about the error. + DESCRIPTION type STRING, + end of T_WARNING_INFO. + types: + "! Results for all images. + begin of T_CLASSIFIED_IMAGES, + "! Number of custom classes identified in the images. + CUSTOM_CLASSES type INTEGER, + "! Number of images processed for the API call. + IMAGES_PROCESSED type INTEGER, + "! Classified images. + IMAGES type STANDARD TABLE OF T_CLASSIFIED_IMAGE WITH NON-UNIQUE DEFAULT KEY, + "! 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. + WARNINGS type STANDARD TABLE OF T_WARNING_INFO WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFIED_IMAGES. + types: + "! Knowledge graph of the property. For example, `/fruit/pome/apple/eating + "! apple/Granny Smith`. Included only if identified. + T_TYPE_HIERARCHY type String. + types: + "! A category within a classifier. + begin of T_CLASS, + "! The name of the class. + CLASS type STRING, + end of T_CLASS. + types: + "! Empty object. + T_EMPTY type JSONOBJECT. + types: + "! Error information. + begin of T_ERROR_RESPONSE, + "! HTTP error code. + CODE type INTEGER, + "! Human-readable error string, like 'Invalid image file'. + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! No documentation available. + begin of T_INLINE_OBJECT1, + "! The name of the new classifier. Encode special characters in UTF-8. + NAME type STRING, + "! A .zip file of images that depict the visual subject of a class in the new + "! classifier. You can include more than one positive example file in a call.
+ "!
+ "! Specify the parameter name by appending `_positive_examples` to the class name. + "! For example, `goldenretriever_positive_examples` creates the class + "! **goldenretriever**. The string cannot contain the following characters: ``$ * + "! - { } \ | / ' " ` [ ]``.
+ "!
+ "! Include at least 10 images in .jpg or .png format. The minimum recommended image + "! resolution is 32X32 pixels. The maximum number of images is 10,000 images or + "! 100 MB per .zip file.
+ "!
+ "! Encode special characters in the file name in UTF-8. + POSITIVE_EXAMPLES type FILE, + "! 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. + NEGATIVE_EXAMPLES type FILE, + end of T_INLINE_OBJECT1. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! An image file (.gif, .jpg, .png, .tif) or .zip file with images. Maximum image + "! size is 10 MB. Include no more than 20 images and limit the .zip file to 100 + "! MB. Encode the image and .zip file names in UTF-8 if they contain non-ASCII + "! characters. The service assumes UTF-8 encoding if it encounters non-ASCII + "! characters.
+ "!
+ "! You can also include an image with the **url** parameter. + IMAGES_FILE type FILE, + "! The URL of an image (.gif, .jpg, .png, .tif) to analyze. The minimum recommended + "! pixel density is 32X32 pixels, but the service tends to perform better with + "! images that are at least 224 x 224 pixels. The maximum image size is 10 + "! MB.
+ "!
+ "! You can also include images with the **images_file** parameter. + URL type STRING, + "! The minimum score a class must have to be displayed in the response. Set the + "! threshold to `0.0` to return all identified classes. + THRESHOLD type FLOAT, + "! The categories of classifiers to apply. The **classifier_ids** parameter + "! overrides **owners**, so make sure that **classifier_ids** is empty.
+ "! - Use `IBM` to classify against the `default` general classifier. You get the + "! same result if both **classifier_ids** and **owners** parameters are + "! empty.
+ "! - Use `me` to classify against all your custom classifiers. However, for better + "! performance use **classifier_ids** to specify the specific custom classifiers + "! to apply.
+ "! - Use both `IBM` and `me` to analyze the image against both classifier + "! categories. + OWNERS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Which classifiers to apply. Overrides the **owners** parameter. You can specify + "! both custom and built-in classifier IDs. The built-in `default` classifier is + "! used if both **classifier_ids** and **owners** parameters are empty.
+ "!
+ "! The following built-in classifier IDs require no training:
+ "! - `default`: Returns classes from thousands of general tags.
+ "! - `food`: Enhances specificity and accuracy for images of food items.
+ "! - `explicit`: Evaluates whether the image might be pornographic. + CLASSIFIER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_INLINE_OBJECT. + types: + "! No documentation available. + begin of T_INLINE_OBJECT2, + "! A .zip file of images that depict the visual subject of a class in the + "! classifier. The positive examples create or update classes in the classifier. + "! You can include more than one positive example file in a call.
+ "!
+ "! Specify the parameter name by appending `_positive_examples` to the class name. + "! For example, `goldenretriever_positive_examples` creates the class + "! `goldenretriever`. The string cannot contain the following characters: ``$ * - + "! { } \ | / ' " ` [ ]``.
+ "!
+ "! Include at least 10 images in .jpg or .png format. The minimum recommended image + "! resolution is 32X32 pixels. The maximum number of images is 10,000 images or + "! 100 MB per .zip file.
+ "!
+ "! Encode special characters in the file name in UTF-8. + POSITIVE_EXAMPLES type FILE, + "! 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. + NEGATIVE_EXAMPLES type FILE, + end of T_INLINE_OBJECT2. + types: + "! Information about a classifier. + begin of T_CLASSIFIER, + "! ID of a classifier identified in the image. + CLASSIFIER_ID type STRING, + "! Name of the classifier. + NAME type STRING, + "! Unique ID of the account who owns the classifier. Might not be returned by some + "! requests. + OWNER type STRING, + "! Training status of classifier. + STATUS type STRING, + "! Whether the classifier can be downloaded as a Core ML model after the training + "! status is `ready`. + CORE_ML_ENABLED type BOOLEAN, + "! If classifier training has failed, this field might explain why. + EXPLANATION type STRING, + "! Date and time in Coordinated Universal Time (UTC) that the classifier was + "! created. + CREATED type DATETIME, + "! Classes that define a classifier. + CLASSES type STANDARD TABLE OF T_CLASS WITH NON-UNIQUE DEFAULT KEY, + "! Date and time in Coordinated Universal Time (UTC) that the classifier was + "! updated. Might not be returned by some requests. Identical to `updated` and + "! retained for backward compatibility. + RETRAINED type DATETIME, + "! Date and time in Coordinated Universal Time (UTC) that the classifier was most + "! recently updated. The field matches either `retrained` or `created`. Might not + "! be returned by some requests. + UPDATED type DATETIME, + end of T_CLASSIFIER. + types: + "! Number of custom classes identified in the images. + T_CUSTOM_CLASSES_PROCESSED type Integer. + types: + "! 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. + T_CONFIDENCE_SCORE type Float. + types: + "! Relative path of the image file if uploaded directly. Not returned when the + "! image is passed by URL. + T_IMAGE_FILE type String. + types: + "! Error information. + begin of T_ERROR_HTML, + "! HTML description of the error. + ERROR1 type STRING, + end of T_ERROR_HTML. + types: + "! Source of the image before any redirects. Not returned when the image is + "! uploaded. + T_SOURCE_URL type String. + types: + "! Fully resolved URL of the image after redirects are followed. Not returned when + "! the image is uploaded. + T_RESOLVED_URL type String. + types: + "! A container for the list of classifiers. + begin of T_CLASSIFIERS, + "! List of classifiers. + CLASSIFIERS type STANDARD TABLE OF T_CLASSIFIER WITH NON-UNIQUE DEFAULT KEY, + end of T_CLASSIFIERS. + +constants: + begin of C_REQUIRED_FIELDS, + T_CLASS_RESULT type string value '|CLASS|SCORE|', + T_CLASSIFIER_RESULT type string value '|NAME|CLASSIFIER_ID|CLASSES|', + T_ERROR_INFO type string value '|CODE|DESCRIPTION|ERROR_ID|', + T_CLASSIFIED_IMAGE type string value '|CLASSIFIERS|', + T_WARNING_INFO type string value '|WARNING_ID|DESCRIPTION|', + T_CLASSIFIED_IMAGES type string value '|IMAGES|', + T_CLASS type string value '|CLASS|', + T_ERROR_RESPONSE type string value '|CODE|ERROR|', + T_INLINE_OBJECT1 type string value '|NAME|POSITIVE_EXAMPLES|', + T_INLINE_OBJECT type string value '|', + T_INLINE_OBJECT2 type string value '|', + T_CLASSIFIER type string value '|CLASSIFIER_ID|NAME|', + T_ERROR_HTML type string value '|', + T_CLASSIFIERS type string value '|CLASSIFIERS|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + WARNING_ID type string value 'warning_id', + DESCRIPTION type string value 'description', + CODE type string value 'code', + ERROR_ID type string value 'error_id', + CLASSIFIERS type string value 'classifiers', + CLASSIFIER_ID type string value 'classifier_id', + NAME type string value 'name', + OWNER type string value 'owner', + STATUS type string value 'status', + CORE_ML_ENABLED type string value 'core_ml_enabled', + EXPLANATION type string value 'explanation', + CREATED type string value 'created', + CLASSES type string value 'classes', + RETRAINED type string value 'retrained', + UPDATED type string value 'updated', + CLASS type string value 'class', + SOURCE_URL type string value 'source_url', + RESOLVED_URL type string value 'resolved_url', + IMAGE type string value 'image', + ERROR type string value 'error', + ERROR1 type string value 'Error', + SCORE type string value 'score', + TYPE_HIERARCHY type string value 'type_hierarchy', + CUSTOM_CLASSES type string value 'custom_classes', + IMAGES_PROCESSED type string value 'images_processed', + IMAGES type string value 'images', + WARNINGS type string value 'warnings', + IMAGES_FILE type string value 'images_file', + URL type string value 'url', + THRESHOLD type string value 'threshold', + OWNERS type string value 'owners', + CLASSIFIER_IDS type string value 'classifier_ids', + CLASSIFIERID type string value 'classifierId', + POSITIVE_EXAMPLES type string value 'positive_examples', + NEGATIVE_EXAMPLES type string value 'negative_examples', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Classify images. + "! + "! @parameter I_IMAGES_FILE | + "! An image file (.gif, .jpg, .png, .tif) or .zip file with images. Maximum image + "! size is 10 MB. Include no more than 20 images and limit the .zip file to 100 + "! MB. Encode the image and .zip file names in UTF-8 if they contain non-ASCII + "! characters. The service assumes UTF-8 encoding if it encounters non-ASCII + "! characters.
+ "!
+ "! You can also include an image with the **url** parameter. + "! @parameter I_IMAGES_FILENAME | + "! The filename for imagesFile. + "! @parameter I_IMAGES_FILE_CONTENT_TYPE | + "! The content type of imagesFile. + "! @parameter I_URL | + "! The URL of an image (.gif, .jpg, .png, .tif) to analyze. The minimum recommended + "! pixel density is 32X32 pixels, but the service tends to perform better with + "! images that are at least 224 x 224 pixels. The maximum image size is 10 + "! MB.
+ "!
+ "! You can also include images with the **images_file** parameter. + "! @parameter I_THRESHOLD | + "! The minimum score a class must have to be displayed in the response. Set the + "! threshold to `0.0` to return all identified classes. + "! @parameter I_OWNERS | + "! The categories of classifiers to apply. The **classifier_ids** parameter + "! overrides **owners**, so make sure that **classifier_ids** is empty.
+ "! - Use `IBM` to classify against the `default` general classifier. You get the + "! same result if both **classifier_ids** and **owners** parameters are + "! empty.
+ "! - Use `me` to classify against all your custom classifiers. However, for better + "! performance use **classifier_ids** to specify the specific custom classifiers + "! to apply.
+ "! - Use both `IBM` and `me` to analyze the image against both classifier + "! categories. + "! @parameter I_CLASSIFIER_IDS | + "! Which classifiers to apply. Overrides the **owners** parameter. You can specify + "! both custom and built-in classifier IDs. The built-in `default` classifier is + "! used if both **classifier_ids** and **owners** parameters are empty.
+ "!
+ "! The following built-in classifier IDs require no training:
+ "! - `default`: Returns classes from thousands of general tags.
+ "! - `food`: Enhances specificity and accuracy for images of food items.
+ "! - `explicit`: Evaluates whether the image might be pornographic. + "! @parameter I_ACCEPT_LANGUAGE | + "! The desired language of parts of the response. See the response for details. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIED_IMAGES + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CLASSIFY + importing + !I_IMAGES_FILE type FILE optional + !I_IMAGES_FILENAME type STRING optional + !I_IMAGES_FILE_CONTENT_TYPE type STRING optional + !I_URL type STRING optional + !I_THRESHOLD type FLOAT optional + !I_OWNERS type TT_STRING optional + !I_CLASSIFIER_IDS type TT_STRING optional + !I_ACCEPT_LANGUAGE type STRING default 'en' + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIED_IMAGES + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a classifier. + "! + "! @parameter I_NAME | + "! The name of the new classifier. Encode special characters in UTF-8. + "! @parameter I_POSITIVE_EXAMPLES | + "! A .zip file of images that depict the visual subject of a class in the new + "! classifier. You can include more than one positive example file in a call.
+ "!
+ "! Specify the parameter name by appending `_positive_examples` to the class name. + "! For example, `goldenretriever_positive_examples` creates the class + "! **goldenretriever**. The string cannot contain the following characters: ``$ * + "! - { } \ | / ' " ` [ ]``.
+ "!
+ "! Include at least 10 images in .jpg or .png format. The minimum recommended image + "! resolution is 32X32 pixels. The maximum number of images is 10,000 images or + "! 100 MB per .zip file.
+ "!
+ "! Encode special characters in the file name in UTF-8. + "! @parameter I_NEGATIVE_EXAMPLES | + "! 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. + "! @parameter I_NEGATIVE_EXAMPLES_FILENAME | + "! The filename for negativeExamples. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_CLASSIFIER + importing + !I_NAME type STRING + !I_POSITIVE_EXAMPLES type TT_MAP_FILE + !I_NEGATIVE_EXAMPLES type FILE optional + !I_NEGATIVE_EXAMPLES_FILENAME type STRING optional + !I_POSITIVE_EXAMPLES_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_NEGATIVE_EXAMPLES_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Retrieve a list of classifiers. + "! + "! @parameter I_VERBOSE | + "! Specify `true` to return details about the classifiers. Omit this parameter to + "! return a brief list of classifiers. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIERS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_CLASSIFIERS + importing + !I_VERBOSE type BOOLEAN optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIERS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Retrieve classifier details. + "! + "! @parameter I_CLASSIFIER_ID | + "! The ID of the classifier. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CLASSIFIER + importing + !I_CLASSIFIER_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a classifier. + "! + "! @parameter I_CLASSIFIER_ID | + "! The ID of the classifier. + "! @parameter I_POSITIVE_EXAMPLES | + "! A .zip file of images that depict the visual subject of a class in the + "! classifier. The positive examples create or update classes in the classifier. + "! You can include more than one positive example file in a call.
+ "!
+ "! Specify the parameter name by appending `_positive_examples` to the class name. + "! For example, `goldenretriever_positive_examples` creates the class + "! `goldenretriever`. The string cannot contain the following characters: ``$ * - + "! { } \ | / ' " ` [ ]``.
+ "!
+ "! Include at least 10 images in .jpg or .png format. The minimum recommended image + "! resolution is 32X32 pixels. The maximum number of images is 10,000 images or + "! 100 MB per .zip file.
+ "!
+ "! Encode special characters in the file name in UTF-8. + "! @parameter I_NEGATIVE_EXAMPLES | + "! 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. + "! @parameter I_NEGATIVE_EXAMPLES_FILENAME | + "! The filename for negativeExamples. + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_CLASSIFIER + importing + !I_CLASSIFIER_ID type STRING + !I_POSITIVE_EXAMPLES type TT_MAP_FILE optional + !I_NEGATIVE_EXAMPLES type FILE optional + !I_NEGATIVE_EXAMPLES_FILENAME type STRING optional + !I_POSITIVE_EXAMPLES_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_NEGATIVE_EXAMPLES_CT type STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_CLASSIFIER + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a classifier. + "! + "! @parameter I_CLASSIFIER_ID | + "! The ID of the classifier. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_CLASSIFIER + importing + !I_CLASSIFIER_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Retrieve a Core ML model of a classifier. + "! + "! @parameter I_CLASSIFIER_ID | + "! The ID of the classifier. + "! @parameter E_RESPONSE | + "! Service return value of type FILE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_CORE_ML_MODEL + importing + !I_CLASSIFIER_ID type STRING + !I_accept type string default 'application/octet-stream' + exporting + !E_RESPONSE type FILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_VISUAL_RECOGNITION_V3 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Visual Recognition'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_VISUAL_RECOGNITION_V3->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/visual-recognition/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092829'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->CLASSIFY +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_IMAGES_FILE TYPE FILE(optional) +* | [--->] I_IMAGES_FILENAME TYPE STRING(optional) +* | [--->] I_IMAGES_FILE_CONTENT_TYPE TYPE STRING(optional) +* | [--->] I_URL TYPE STRING(optional) +* | [--->] I_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_OWNERS TYPE TT_STRING(optional) +* | [--->] I_CLASSIFIER_IDS TYPE TT_STRING(optional) +* | [--->] I_ACCEPT_LANGUAGE TYPE STRING (default ='en') +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIED_IMAGES +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CLASSIFY. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classify'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + " process header parameters + data: + lv_headerparam type string ##NEEDED. + + if i_ACCEPT_LANGUAGE is supplied. + lv_headerparam = I_ACCEPT_LANGUAGE. + add_header_parameter( + exporting + i_parameter = 'Accept-Language' + i_value = lv_headerparam + changing + c_headers = ls_request_prop-headers ) ##NO_TEXT. + endif. + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_URL is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="url"' ##NO_TEXT. + lv_formdata = i_URL. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_THRESHOLD is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="threshold"' ##NO_TEXT. + lv_formdata = i_THRESHOLD. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + if not i_OWNERS is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="owners"' ##NO_TEXT. + field-symbols: + like line of i_OWNERS. + loop at i_OWNERS assigning . +* ls_form_part-cdata = . +* append ls_form_part to lt_form_part. + if ls_form_part-cdata is initial. + ls_form_part-cdata = . + else. + ls_form_part-cdata = ls_form_part-cdata && `,` && . + endif. + endloop. + append ls_form_part to lt_form_part. + endif. + + if not i_CLASSIFIER_IDS is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="classifier_ids"' ##NO_TEXT. + field-symbols: + like line of i_CLASSIFIER_IDS. + loop at i_CLASSIFIER_IDS assigning . +* ls_form_part-cdata = . +* append ls_form_part to lt_form_part. + if ls_form_part-cdata is initial. + ls_form_part-cdata = . + else. + ls_form_part-cdata = ls_form_part-cdata && `,` && . + endif. + + endloop. + append ls_form_part to lt_form_part. + + endif. + + + + if not i_IMAGES_FILE is initial. + if not I_images_filename is initial. + lv_value = `form-data; name="images_file"; filename="` && I_images_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_images_file_content_type ). + lv_value = `form-data; name="images_file"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_images_file_content_type. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_IMAGES_FILE. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->CREATE_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_NAME TYPE STRING +* | [--->] I_POSITIVE_EXAMPLES TYPE TT_MAP_FILE +* | [--->] I_NEGATIVE_EXAMPLES TYPE FILE(optional) +* | [--->] I_NEGATIVE_EXAMPLES_FILENAME TYPE STRING(optional) +* | [--->] I_POSITIVE_EXAMPLES_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_NEGATIVE_EXAMPLES_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_NAME is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="name"' ##NO_TEXT. + lv_formdata = i_NAME. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_POSITIVE_EXAMPLES is initial. + lv_extension = get_file_extension( I_POSITIVE_EXAMPLES_CT ). + field-symbols: + type line of TT_MAP_FILE. + find regex '(\{.*\})' in '{{classname}}_positive_examples' submatches lv_keypattern. + loop at i_POSITIVE_EXAMPLES assigning . + lv_base_name = '{{classname}}_positive_examples'. + replace lv_keypattern in lv_base_name with -key. + lv_value = `form-data; name="` && lv_base_name && `"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_POSITIVE_EXAMPLES_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = -data. + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_NEGATIVE_EXAMPLES is initial. + if not I_negative_examples_filename is initial. + lv_value = `form-data; name="negative_examples"; filename="` && I_negative_examples_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_NEGATIVE_EXAMPLES_CT ). + lv_value = `form-data; name="negative_examples"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_NEGATIVE_EXAMPLES_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_NEGATIVE_EXAMPLES. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->LIST_CLASSIFIERS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_VERBOSE TYPE BOOLEAN(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIERS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_CLASSIFIERS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_VERBOSE is supplied. + lv_queryparam = i_VERBOSE. + add_query_parameter( + exporting + i_parameter = `verbose` + i_value = lv_queryparam + i_is_boolean = c_boolean_true + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->GET_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers/{classifier_id}'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->UPDATE_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_POSITIVE_EXAMPLES TYPE TT_MAP_FILE(optional) +* | [--->] I_NEGATIVE_EXAMPLES TYPE FILE(optional) +* | [--->] I_NEGATIVE_EXAMPLES_FILENAME TYPE STRING(optional) +* | [--->] I_POSITIVE_EXAMPLES_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_NEGATIVE_EXAMPLES_CT TYPE STRING (default = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-all) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_CLASSIFIER +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers/{classifier_id}'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + + + if not i_POSITIVE_EXAMPLES is initial. + lv_extension = get_file_extension( I_POSITIVE_EXAMPLES_CT ). + field-symbols: + type line of TT_MAP_FILE. + find regex '(\{.*\})' in '{{classname}}_positive_examples' submatches lv_keypattern. + loop at i_POSITIVE_EXAMPLES assigning . + lv_base_name = '{{classname}}_positive_examples'. + replace lv_keypattern in lv_base_name with -key. + lv_value = `form-data; name="` && lv_base_name && `"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_POSITIVE_EXAMPLES_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = -data. + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_NEGATIVE_EXAMPLES is initial. + if not I_negative_examples_filename is initial. + lv_value = `form-data; name="negative_examples"; filename="` && I_negative_examples_filename && `"` ##NO_TEXT. + else. + lv_extension = get_file_extension( I_NEGATIVE_EXAMPLES_CT ). + lv_value = `form-data; name="negative_examples"; filename="file` && lv_index && `.` && lv_extension && `"` ##NO_TEXT. + endif. + lv_index = lv_index + 1. + clear ls_form_part. + ls_form_part-content_type = I_NEGATIVE_EXAMPLES_CT. + ls_form_part-content_disposition = lv_value. + ls_form_part-xdata = i_NEGATIVE_EXAMPLES. + append ls_form_part to lt_form_part. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->DELETE_CLASSIFIER +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_CLASSIFIER. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers/{classifier_id}'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->GET_CORE_ML_MODEL +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CLASSIFIER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/octet-stream') +* | [<---] E_RESPONSE TYPE FILE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_CORE_ML_MODEL. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/classifiers/{classifier_id}/core_ml_model'. + replace all occurrences of `{classifier_id}` in ls_request_prop-url-path with i_CLASSIFIER_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve file data + e_response = get_response_binary( lo_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V3->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v3/user_data'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_VISUAL_RECOGNITION_V3->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_visual_recognition_v3.clas.xml b/src/zcl_ibmc_visual_recognition_v3.clas.xml new file mode 100644 index 0000000..1fc323c --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v3.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_VISUAL_RECOGNITION_V3 + E + IBM Watson Visual Recognition V3 + 1 + X + X + X + + + + diff --git a/src/zcl_ibmc_visual_recognition_v4.clas.abap b/src/zcl_ibmc_visual_recognition_v4.clas.abap new file mode 100644 index 0000000..5d4cfec --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v4.clas.abap @@ -0,0 +1,2239 @@ +* Copyright 2019, 2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +"!

Visual Recognition v4

+"! Provide images to the IBM Watson™ Visual Recognition service for analysis. +"! The service detects objects based on a set of images with training data.
+class ZCL_IBMC_VISUAL_RECOGNITION_V4 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! Defines the location of the bounding box around the object. + begin of T_LOCATION, + "! Y-position of top-left pixel of the bounding box. + TOP type INTEGER, + "! X-position of top-left pixel of the bounding box. + LEFT type INTEGER, + "! Width in pixels of of the bounding box. + WIDTH type INTEGER, + "! Height in pixels of the bounding box. + HEIGHT type INTEGER, + end of T_LOCATION. + types: + "! Training status for the objects in the collection. + begin of T_OBJECT_TRAINING_STATUS, + "! Whether you can analyze images in the collection with the **objects** feature. + READY type BOOLEAN, + "! Whether training is in progress. + IN_PROGRESS type BOOLEAN, + "! Whether there are changes to the training data since the most recent training. + DATA_CHANGED type BOOLEAN, + "! Whether the most recent training failed. + LATEST_FAILED type BOOLEAN, + "! Details about the training. If training is in progress, includes information + "! about the status. If training is not in progress, includes a success message or + "! information about why training failed. + DESCRIPTION type STRING, + end of T_OBJECT_TRAINING_STATUS. + types: + "! Training status information for the collection. + begin of T_TRAINING_STATUS, + "! Training status for the objects in the collection. + OBJECTS type T_OBJECT_TRAINING_STATUS, + end of T_TRAINING_STATUS. + types: + "! Basic information about an object. + begin of T_OBJECT_METADATA, + "! The name of the object. + OBJECT type STRING, + "! Number of bounding boxes with this object name in the collection. + COUNT type INTEGER, + end of T_OBJECT_METADATA. + types: + "! The source type of the image. + begin of T_IMAGE_SOURCE, + "! The source type of the image. + TYPE type STRING, + "! Name of the image file if uploaded. Not returned when the image is passed by + "! URL. + FILENAME type STRING, + "! Name of the .zip file of images if uploaded. Not returned when the image is + "! passed directly or by URL. + ARCHIVE_FILENAME type STRING, + "! Source of the image before any redirects. Not returned when the image is + "! uploaded. + SOURCE_URL type STRING, + "! Fully resolved URL of the image after redirects are followed. Not returned when + "! the image is uploaded. + RESOLVED_URL type STRING, + end of T_IMAGE_SOURCE. + types: + "! Details about the training data. + begin of T_TRAINING_DATA_OBJECT, + "! The name of the object. + OBJECT type STRING, + "! Defines the location of the bounding box around the object. + LOCATION type T_LOCATION, + end of T_TRAINING_DATA_OBJECT. + types: + "! Training data for all objects. + begin of T_TRAINING_DATA_OBJECTS, + "! Training data for specific objects. + OBJECTS type STANDARD TABLE OF T_TRAINING_DATA_OBJECT WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_DATA_OBJECTS. + types: + "! Details about a collection. + begin of T_COLLECTION, + "! The identifier of the collection. + COLLECTION_ID type STRING, + "! The name of the collection. + NAME type STRING, + "! The description of the collection. + DESCRIPTION type STRING, + "! Date and time in Coordinated Universal Time (UTC) that the collection was + "! created. + CREATED type DATETIME, + "! Date and time in Coordinated Universal Time (UTC) that the collection was most + "! recently updated. + UPDATED type DATETIME, + "! Number of images in the collection. + IMAGE_COUNT type INTEGER, + "! Training status information for the collection. + TRAINING_STATUS type T_TRAINING_STATUS, + end of T_COLLECTION. + types: + "! Height and width of an image. + begin of T_IMAGE_DIMENSIONS, + "! Height in pixels of the image. + HEIGHT type INTEGER, + "! Width in pixels of the image. + WIDTH type INTEGER, + end of T_IMAGE_DIMENSIONS. + types: + "! Details about the specific area of the problem. + begin of T_ERROR_TARGET, + "! The parameter or property that is the focus of the problem. + TYPE type STRING, + "! The property that is identified with the problem. + NAME type STRING, + end of T_ERROR_TARGET. + types: + "! Details about an error. + begin of T_ERROR, + "! Identifier of the problem. + CODE type STRING, + "! An explanation of the problem with possible solutions. + MESSAGE type STRING, + "! A URL for more information about the solution. + MORE_INFO type STRING, + "! Details about the specific area of the problem. + TARGET type T_ERROR_TARGET, + end of T_ERROR. + types: + "! A container for the list of request-level problems. + begin of T_ERROR_RESPONSE, + "! A container for the problems in the request. + ERRORS type STANDARD TABLE OF T_ERROR WITH NON-UNIQUE DEFAULT KEY, + "! A unique identifier of the request. + TRACE type STRING, + end of T_ERROR_RESPONSE. + types: + "! Details about an object and its location. + begin of T_BASE_OBJECT, + "! The name of the object. The name can contain alphanumeric, underscore, hyphen, + "! space, and dot characters. It cannot begin with the reserved prefix `sys-`. + OBJECT type STRING, + "! Defines the location of the bounding box around the object. + LOCATION type T_LOCATION, + end of T_BASE_OBJECT. + types: + "! No documentation available. + begin of T_INLINE_OBJECT, + "! The IDs of the collections to analyze. + COLLECTION_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The features to analyze. + FEATURES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! An array of image files (.jpg or .png) or .zip files with images.
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit the .zip file to 100 MB.
+ "! - Limit each image file to 10 MB.
+ "!
+ "! You can also include an image with the **image_url** parameter. + IMAGES_FILE type STANDARD TABLE OF FILE WITH NON-UNIQUE DEFAULT KEY, + "! An array of URLs of image files (.jpg or .png).
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit each image file to 10 MB.
+ "! - Minimum width and height is 30 pixels, but the service tends to perform better + "! with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for + "! either height or width.
+ "!
+ "! You can also include images with the **images_file** parameter. + IMAGE_URL type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! The minimum score a feature must have to be returned. + THRESHOLD type FLOAT, + end of T_INLINE_OBJECT. + types: + "! Details about an object in the collection. + begin of T_OBJECT_DETAIL, + "! The label for the object. + OBJECT type STRING, + "! Defines the location of the bounding box around the object. + LOCATION type T_LOCATION, + "! Confidence score for the object in the range of 0 to 1. A higher score indicates + "! greater likelihood that the object is depicted at this location in the image. + SCORE type FLOAT, + end of T_OBJECT_DETAIL. + types: + "! The objects in a collection that are detected in an image. + begin of T_COLLECTION_OBJECTS, + "! The identifier of the collection. + COLLECTION_ID type STRING, + "! The identified objects in a collection. + OBJECTS type STANDARD TABLE OF T_OBJECT_DETAIL WITH NON-UNIQUE DEFAULT KEY, + end of T_COLLECTION_OBJECTS. + types: + "! Container for the list of collections that have objects detected in an image. + begin of T_DETECTED_OBJECTS, + "! The collections with identified objects. + COLLECTIONS type STANDARD TABLE OF T_COLLECTION_OBJECTS WITH NON-UNIQUE DEFAULT KEY, + end of T_DETECTED_OBJECTS. + types: + "! A file returned in the response. + T_JPEG_IMAGE type FILE. + types: + "! A container for the list of collections. + begin of T_COLLECTIONS_LIST, + "! The collections in this service instance. + COLLECTIONS type STANDARD TABLE OF T_COLLECTION WITH NON-UNIQUE DEFAULT KEY, + end of T_COLLECTIONS_LIST. + types: + "! Details about the training event. + begin of T_TRAINING_EVENT, + "! Trained object type. Only `objects` is currently supported. + TYPE type STRING, + "! Identifier of the trained collection. + COLLECTION_ID type STRING, + "! Date and time in Coordinated Universal Time (UTC) that training on the + "! collection finished. + COMPLETION_TIME type DATETIME, + "! Training status of the training event. + STATUS type STRING, + "! The total number of images that were used in training for this training event. + IMAGE_COUNT type INTEGER, + end of T_TRAINING_EVENT. + types: + "! Details about the training events. + begin of T_TRAINING_EVENTS, + "! The starting day for the returned training events in Coordinated Universal Time + "! (UTC). If not specified in the request, it identifies the earliest training + "! event. + START_TIME type DATETIME, + "! The ending day for the returned training events in Coordinated Universal Time + "! (UTC). If not specified in the request, it lists the current time. + END_TIME type DATETIME, + "! The total number of training events in the response for the start and end times. + "! + COMPLETED_EVENTS type INTEGER, + "! The total number of images that were used in training for the start and end + "! times. + TRAINED_IMAGES type INTEGER, + "! The completed training events for the start and end time. + EVENTS type STANDARD TABLE OF T_TRAINING_EVENT WITH NON-UNIQUE DEFAULT KEY, + end of T_TRAINING_EVENTS. + types: + "! Details about an image. + begin of T_IMAGE_DETAILS, + "! The identifier of the image. + IMAGE_ID type STRING, + "! Date and time in Coordinated Universal Time (UTC) that the image was most + "! recently updated. + UPDATED type DATETIME, + "! Date and time in Coordinated Universal Time (UTC) that the image was created. + CREATED type DATETIME, + "! The source type of the image. + SOURCE type T_IMAGE_SOURCE, + "! Height and width of an image. + DIMENSIONS type T_IMAGE_DIMENSIONS, + "! No documentation available. + ERRORS type STANDARD TABLE OF T_ERROR WITH NON-UNIQUE DEFAULT KEY, + "! Training data for all objects. + TRAINING_DATA type T_TRAINING_DATA_OBJECTS, + end of T_IMAGE_DETAILS. + types: + "! Details about a problem. + begin of T_WARNING, + "! Identifier of the problem. + CODE type STRING, + "! An explanation of the problem with possible solutions. + MESSAGE type STRING, + "! A URL for more information about the solution. + MORE_INFO type STRING, + end of T_WARNING. + types: + "! List of information about the images. + begin of T_IMAGE_DETAILS_LIST, + "! The images in the collection. + IMAGES type STANDARD TABLE OF T_IMAGE_DETAILS WITH NON-UNIQUE DEFAULT KEY, + "! Information about what might cause less than optimal output. + WARNINGS type STANDARD TABLE OF T_WARNING WITH NON-UNIQUE DEFAULT KEY, + "! A unique identifier of the request. Included only when an error or warning is + "! returned. + TRACE type STRING, + end of T_IMAGE_DETAILS_LIST. + types: + "! Empty response. + T_EMPTY type JSONOBJECT. + types: + "! Basic information about an image. + begin of T_IMAGE_SUMMARY, + "! The identifier of the image. + IMAGE_ID type STRING, + "! Date and time in Coordinated Universal Time (UTC) that the image was most + "! recently updated. + UPDATED type DATETIME, + end of T_IMAGE_SUMMARY. + types: + "! Container for the training data. + begin of T_BASE_TRAINING_DATA_OBJECTS, + "! Training data for specific objects. + OBJECTS type STANDARD TABLE OF T_TRAINING_DATA_OBJECT WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_TRAINING_DATA_OBJECTS. + types: + "! No documentation available. + begin of T_INLINE_OBJECT1, + "! An array of image files (.jpg or .png) or .zip files with images.
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit the .zip file to 100 MB.
+ "! - Limit each image file to 10 MB.
+ "!
+ "! You can also include an image with the **image_url** parameter. + IMAGES_FILE type STANDARD TABLE OF FILE WITH NON-UNIQUE DEFAULT KEY, + "! The array of URLs of image files (.jpg or .png).
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit each image file to 10 MB.
+ "! - Minimum width and height is 30 pixels, but the service tends to perform better + "! with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for + "! either height or width.
+ "!
+ "! You can also include images with the **images_file** parameter. + IMAGE_URL type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + "! Training data for a single image. Include training data only if you add one + "! image with the request.
+ "!
+ "! The `object` property can contain alphanumeric, underscore, hyphen, space, and + "! dot characters. It cannot begin with the reserved prefix `sys-` and must be no + "! longer than 32 characters. + TRAINING_DATA type STRING, + end of T_INLINE_OBJECT1. + types: + "! List of images. + begin of T_IMAGE_SUMMARY_LIST, + "! The images in the collection. + IMAGES type STANDARD TABLE OF T_IMAGE_SUMMARY WITH NON-UNIQUE DEFAULT KEY, + end of T_IMAGE_SUMMARY_LIST. + types: + "! Details about an image. + begin of T_IMAGE, + "! The source type of the image. + SOURCE type T_IMAGE_SOURCE, + "! Height and width of an image. + DIMENSIONS type T_IMAGE_DIMENSIONS, + "! Container for the list of collections that have objects detected in an image. + OBJECTS type T_DETECTED_OBJECTS, + "! A container for the problems in the request. + ERRORS type STANDARD TABLE OF T_ERROR WITH NON-UNIQUE DEFAULT KEY, + end of T_IMAGE. + types: + "! Results for all images. + begin of T_ANALYZE_RESPONSE, + "! Analyzed images. + IMAGES type STANDARD TABLE OF T_IMAGE WITH NON-UNIQUE DEFAULT KEY, + "! Information about what might cause less than optimal output. + WARNINGS type STANDARD TABLE OF T_WARNING WITH NON-UNIQUE DEFAULT KEY, + "! A unique identifier of the request. Included only when an error or warning is + "! returned. + TRACE type STRING, + end of T_ANALYZE_RESPONSE. + types: + "! Base details about a collection. + begin of T_BASE_COLLECTION, + "! The identifier of the collection. + COLLECTION_ID type STRING, + "! The name of the collection. The name can contain alphanumeric, underscore, + "! hyphen, and dot characters. It cannot begin with the reserved prefix `sys-`. + NAME type STRING, + "! The description of the collection. + DESCRIPTION type STRING, + "! Date and time in Coordinated Universal Time (UTC) that the collection was + "! created. + CREATED type DATETIME, + "! Date and time in Coordinated Universal Time (UTC) that the collection was most + "! recently updated. + UPDATED type DATETIME, + "! Number of images in the collection. + IMAGE_COUNT type INTEGER, + "! Training status information for the collection. + TRAINING_STATUS type T_TRAINING_STATUS, + end of T_BASE_COLLECTION. + types: + "! Basic information about an updated object. + begin of T_UPDATE_OBJECT_METADATA, + "! The updated name of the object. The name can contain alphanumeric, underscore, + "! hyphen, space, and dot characters. It cannot begin with the reserved prefix + "! `sys-`. + OBJECT type STRING, + "! Number of bounding boxes in the collection with the updated object name. + COUNT type INTEGER, + end of T_UPDATE_OBJECT_METADATA. + types: + "! List of objects. + begin of T_OBJECT_METADATA_LIST, + "! Number of unique named objects in the collection. + OBJECT_COUNT type INTEGER, + "! The objects in the collection. + OBJECTS type STANDARD TABLE OF T_OBJECT_METADATA WITH NON-UNIQUE DEFAULT KEY, + end of T_OBJECT_METADATA_LIST. + +constants: + begin of C_REQUIRED_FIELDS, + T_LOCATION type string value '|TOP|LEFT|WIDTH|HEIGHT|', + T_OBJECT_TRAINING_STATUS type string value '|READY|IN_PROGRESS|DATA_CHANGED|LATEST_FAILED|DESCRIPTION|', + T_TRAINING_STATUS type string value '|OBJECTS|', + T_OBJECT_METADATA type string value '|', + T_IMAGE_SOURCE type string value '|TYPE|', + T_TRAINING_DATA_OBJECT type string value '|', + T_TRAINING_DATA_OBJECTS type string value '|', + T_COLLECTION type string value '|COLLECTION_ID|NAME|DESCRIPTION|CREATED|UPDATED|IMAGE_COUNT|TRAINING_STATUS|', + T_IMAGE_DIMENSIONS type string value '|', + T_ERROR_TARGET type string value '|TYPE|NAME|', + T_ERROR type string value '|CODE|MESSAGE|', + T_ERROR_RESPONSE type string value '|ERRORS|TRACE|', + T_BASE_OBJECT type string value '|', + T_INLINE_OBJECT type string value '|COLLECTION_IDS|FEATURES|', + T_OBJECT_DETAIL type string value '|OBJECT|LOCATION|SCORE|', + T_COLLECTION_OBJECTS type string value '|COLLECTION_ID|OBJECTS|', + T_DETECTED_OBJECTS type string value '|', + T_COLLECTIONS_LIST type string value '|COLLECTIONS|', + T_TRAINING_EVENT type string value '|', + T_TRAINING_EVENTS type string value '|', + T_IMAGE_DETAILS type string value '|SOURCE|', + T_WARNING type string value '|CODE|MESSAGE|', + T_IMAGE_DETAILS_LIST type string value '|', + T_IMAGE_SUMMARY type string value '|', + T_BASE_TRAINING_DATA_OBJECTS type string value '|', + T_INLINE_OBJECT1 type string value '|', + T_IMAGE_SUMMARY_LIST type string value '|IMAGES|', + T_IMAGE type string value '|SOURCE|DIMENSIONS|OBJECTS|', + T_ANALYZE_RESPONSE type string value '|IMAGES|', + T_BASE_COLLECTION type string value '|', + T_UPDATE_OBJECT_METADATA type string value '|', + T_OBJECT_METADATA_LIST type string value '|OBJECT_COUNT|', + __DUMMY type string value SPACE, + end of C_REQUIRED_FIELDS . + +constants: + begin of C_ABAPNAME_DICTIONARY, + CODE type string value 'code', + MESSAGE type string value 'message', + MORE_INFO type string value 'more_info', + TARGET type string value 'target', + TYPE type string value 'type', + NAME type string value 'name', + ERRORS type string value 'errors', + TRACE type string value 'trace', + IMAGES type string value 'images', + WARNINGS type string value 'warnings', + COLLECTION_ID type string value 'collection_id', + DESCRIPTION type string value 'description', + CREATED type string value 'created', + UPDATED type string value 'updated', + IMAGE_COUNT type string value 'image_count', + TRAINING_STATUS type string value 'training_status', + COLLECTIONS type string value 'collections', + START_TIME type string value 'start_time', + END_TIME type string value 'end_time', + COMPLETED_EVENTS type string value 'completed_events', + TRAINED_IMAGES type string value 'trained_images', + EVENTS type string value 'events', + COMPLETION_TIME type string value 'completion_time', + STATUS type string value 'status', + OBJECTS type string value 'objects', + OBJECT_COUNT type string value 'object_count', + OBJECT type string value 'object', + COUNT type string value 'count', + READY type string value 'ready', + IN_PROGRESS type string value 'in_progress', + DATA_CHANGED type string value 'data_changed', + LATEST_FAILED type string value 'latest_failed', + IMAGE_ID type string value 'image_id', + SOURCE type string value 'source', + DIMENSIONS type string value 'dimensions', + TRAINING_DATA type string value 'training_data', + HEIGHT type string value 'height', + WIDTH type string value 'width', + LOCATION type string value 'location', + FILENAME type string value 'filename', + ARCHIVE_FILENAME type string value 'archive_filename', + SOURCE_URL type string value 'source_url', + RESOLVED_URL type string value 'resolved_url', + SCORE type string value 'score', + TOP type string value 'top', + LEFT type string value 'left', + COLLECTION_IDS type string value 'collection_ids', + COLLECTIONIDS type string value 'collectionIds', + FEATURES type string value 'features', + IMAGES_FILE type string value 'images_file', + IMAGESFILE type string value 'imagesFile', + IMAGE_URL type string value 'image_url', + IMAGEURL type string value 'imageUrl', + THRESHOLD type string value 'threshold', + end of C_ABAPNAME_DICTIONARY . + + + methods GET_APPNAME + redefinition . + methods GET_REQUEST_PROP + redefinition . + methods GET_SDK_VERSION_DATE + redefinition . + + + "! Analyze images. + "! + "! @parameter I_COLLECTION_IDS | + "! The IDs of the collections to analyze. + "! @parameter I_FEATURES | + "! The features to analyze. + "! @parameter I_IMAGES_FILE | + "! An array of image files (.jpg or .png) or .zip files with images.
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit the .zip file to 100 MB.
+ "! - Limit each image file to 10 MB.
+ "!
+ "! You can also include an image with the **image_url** parameter. + "! @parameter I_IMAGE_URL | + "! An array of URLs of image files (.jpg or .png).
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit each image file to 10 MB.
+ "! - Minimum width and height is 30 pixels, but the service tends to perform better + "! with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for + "! either height or width.
+ "!
+ "! You can also include images with the **images_file** parameter. + "! @parameter I_THRESHOLD | + "! The minimum score a feature must have to be returned. + "! @parameter E_RESPONSE | + "! Service return value of type T_ANALYZE_RESPONSE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ANALYZE + importing + !I_COLLECTION_IDS type TT_STRING + !I_FEATURES type TT_STRING + !I_IMAGES_FILE type TT_FILE_WITH_METADATA optional + !I_IMAGE_URL type TT_STRING optional + !I_THRESHOLD type FLOAT optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_ANALYZE_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Create a collection. + "! + "! @parameter I_COLLECTION_INFO | + "! The new collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods CREATE_COLLECTION + importing + !I_COLLECTION_INFO type T_BASE_COLLECTION + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List collections. + "! + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTIONS_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_COLLECTIONS + importing + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTIONS_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get collection details. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_COLLECTION + importing + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update a collection. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_COLLECTION_INFO | + "! The updated collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_COLLECTION + importing + !I_COLLECTION_ID type STRING + !I_COLLECTION_INFO type T_BASE_COLLECTION optional + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete a collection. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_COLLECTION + importing + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Add images. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_IMAGES_FILE | + "! An array of image files (.jpg or .png) or .zip files with images.
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit the .zip file to 100 MB.
+ "! - Limit each image file to 10 MB.
+ "!
+ "! You can also include an image with the **image_url** parameter. + "! @parameter I_IMAGE_URL | + "! The array of URLs of image files (.jpg or .png).
+ "! - Include a maximum of 20 images in a request.
+ "! - Limit each image file to 10 MB.
+ "! - Minimum width and height is 30 pixels, but the service tends to perform better + "! with images that are at least 300 x 300 pixels. Maximum is 5400 pixels for + "! either height or width.
+ "!
+ "! You can also include images with the **images_file** parameter. + "! @parameter I_TRAINING_DATA | + "! Training data for a single image. Include training data only if you add one + "! image with the request.
+ "!
+ "! The `object` property can contain alphanumeric, underscore, hyphen, space, and + "! dot characters. It cannot begin with the reserved prefix `sys-` and must be no + "! longer than 32 characters. + "! @parameter E_RESPONSE | + "! Service return value of type T_IMAGE_DETAILS_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_IMAGES + importing + !I_COLLECTION_ID type STRING + !I_IMAGES_FILE type TT_FILE_WITH_METADATA optional + !I_IMAGE_URL type TT_STRING optional + !I_TRAINING_DATA type STRING optional + !I_contenttype type string default 'multipart/form-data' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_IMAGE_DETAILS_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! List images. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_IMAGE_SUMMARY_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_IMAGES + importing + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_IMAGE_SUMMARY_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get image details. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_IMAGE_ID | + "! The identifier of the image. + "! @parameter E_RESPONSE | + "! Service return value of type T_IMAGE_DETAILS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_IMAGE_DETAILS + importing + !I_COLLECTION_ID type STRING + !I_IMAGE_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_IMAGE_DETAILS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete an image. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_IMAGE_ID | + "! The identifier of the image. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_IMAGE + importing + !I_COLLECTION_ID type STRING + !I_IMAGE_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get a JPEG file of an image. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_IMAGE_ID | + "! The identifier of the image. + "! @parameter I_SIZE | + "! The image size. Specify `thumbnail` to return a version that maintains the + "! original aspect ratio but is no larger than 200 pixels in the larger dimension. + "! For example, an original 800 x 1000 image is resized to 160 x 200 pixels. + "! @parameter E_RESPONSE | + "! Service return value of type FILE + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_JPEG_IMAGE + importing + !I_COLLECTION_ID type STRING + !I_IMAGE_ID type STRING + !I_SIZE type STRING default 'full' + !I_accept type string default 'image/jpeg' + exporting + !E_RESPONSE type FILE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! List object metadata. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_OBJECT_METADATA_LIST + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods LIST_OBJECT_METADATA + importing + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_OBJECT_METADATA_LIST + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Update an object name. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_OBJECT | + "! The name of the object. + "! @parameter I_UPDATEOBJECTMETADATA | + "! No documentation available. + "! @parameter E_RESPONSE | + "! Service return value of type T_UPDATE_OBJECT_METADATA + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods UPDATE_OBJECT_METADATA + importing + !I_COLLECTION_ID type STRING + !I_OBJECT type STRING + !I_UPDATEOBJECTMETADATA type T_UPDATE_OBJECT_METADATA optional + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_UPDATE_OBJECT_METADATA + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get object metadata. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_OBJECT | + "! The name of the object. + "! @parameter E_RESPONSE | + "! Service return value of type T_OBJECT_METADATA + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_OBJECT_METADATA + importing + !I_COLLECTION_ID type STRING + !I_OBJECT type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_OBJECT_METADATA + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Delete an object. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_OBJECT | + "! The name of the object. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_OBJECT + importing + !I_COLLECTION_ID type STRING + !I_OBJECT type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Train a collection. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods TRAIN + importing + !I_COLLECTION_ID type STRING + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_COLLECTION + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Add training data to an image. + "! + "! @parameter I_COLLECTION_ID | + "! The identifier of the collection. + "! @parameter I_IMAGE_ID | + "! The identifier of the image. + "! @parameter I_TRAINING_DATA | + "! Training data. Elements in the request replace the existing elements. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_DATA_OBJECTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods ADD_IMAGE_TRAINING_DATA + importing + !I_COLLECTION_ID type STRING + !I_IMAGE_ID type STRING + !I_TRAINING_DATA type T_BASE_TRAINING_DATA_OBJECTS + !I_contenttype type string default 'application/json' + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_DATA_OBJECTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + "! Get training usage. + "! + "! @parameter I_START_TIME | + "! The earliest day to include training events. Specify dates in YYYY-MM-DD format. + "! If empty or not specified, the earliest training event is included. + "! @parameter I_END_TIME | + "! The most recent day to include training events. Specify dates in YYYY-MM-DD + "! format. All events for the day are included. If empty or not specified, the + "! current day is used. Specify the same value as `start_time` to request events + "! for a single day. + "! @parameter E_RESPONSE | + "! Service return value of type T_TRAINING_EVENTS + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods GET_TRAINING_USAGE + importing + !I_START_TIME type STRING optional + !I_END_TIME type STRING optional + !I_accept type string default 'application/json' + exporting + !E_RESPONSE type T_TRAINING_EVENTS + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + "! Delete labeled data. + "! + "! @parameter I_CUSTOMER_ID | + "! The customer ID for which all data is to be deleted. + "! @raising ZCX_IBMC_SERVICE_EXCEPTION | Exception being raised in case of an error. + "! + methods DELETE_USER_DATA + importing + !I_CUSTOMER_ID type STRING + !I_accept type string default 'application/json' + raising + ZCX_IBMC_SERVICE_EXCEPTION . + + +protected section. + +private section. + + methods SET_DEFAULT_QUERY_PARAMETERS + changing + !C_URL type TS_URL . + +ENDCLASS. + +class ZCL_IBMC_VISUAL_RECOGNITION_V4 IMPLEMENTATION. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_APPNAME +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_APPNAME TYPE STRING +* +-------------------------------------------------------------------------------------- + method GET_APPNAME. + + e_appname = 'Visual Recognition v4'. + + endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Protected Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_REQUEST_PROP +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_AUTH_METHOD TYPE STRING (default =C_DEFAULT) +* | [<-()] E_REQUEST_PROP TYPE TS_REQUEST_PROP +* +-------------------------------------------------------------------------------------- +method GET_REQUEST_PROP. + + data: + lv_auth_method type string ##NEEDED. + + e_request_prop = super->get_request_prop( i_auth_method = i_auth_method ). + + lv_auth_method = i_auth_method. + if lv_auth_method eq c_default. + lv_auth_method = 'IAM'. + endif. + if lv_auth_method is initial. + e_request_prop-auth_basic = c_boolean_false. + e_request_prop-auth_oauth = c_boolean_false. + e_request_prop-auth_apikey = c_boolean_false. + elseif lv_auth_method eq 'IAM'. + e_request_prop-auth_name = 'IAM'. + e_request_prop-auth_type = 'apiKey'. + e_request_prop-auth_headername = 'Authorization'. + e_request_prop-auth_header = c_boolean_true. + else. + endif. + + e_request_prop-url-protocol = 'http'. + e_request_prop-url-host = 'localhost'. + e_request_prop-url-path_base = '/visual-recognition/api'. + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_SDK_VERSION_DATE +* +-------------------------------------------------------------------------------------------------+ +* | [<-()] E_SDK_VERSION_DATE TYPE STRING +* +-------------------------------------------------------------------------------------- + method get_sdk_version_date. + + e_sdk_version_date = '20200210092831'. + + endmethod. + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->ANALYZE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_IDS TYPE TT_STRING +* | [--->] I_FEATURES TYPE TT_STRING +* | [--->] I_IMAGES_FILE TYPE TT_FILE_WITH_METADATA(optional) +* | [--->] I_IMAGE_URL TYPE TT_STRING(optional) +* | [--->] I_THRESHOLD TYPE FLOAT(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_ANALYZE_RESPONSE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ANALYZE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/analyze'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_COLLECTION_IDS is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="collection_ids"' ##NO_TEXT. + field-symbols: + like line of i_COLLECTION_IDS. + loop at i_COLLECTION_IDS assigning . + ls_form_part-cdata = . + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_FEATURES is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="features"' ##NO_TEXT. + field-symbols: + like line of i_FEATURES. + loop at i_FEATURES assigning . + ls_form_part-cdata = . + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_IMAGE_URL is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="image_url"' ##NO_TEXT. + field-symbols: + like line of i_IMAGE_URL. + loop at i_IMAGE_URL assigning . + ls_form_part-cdata = . + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_THRESHOLD is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="threshold"' ##NO_TEXT. + lv_formdata = i_THRESHOLD. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_IMAGES_FILE is initial. + data: + lv_filename type string, + lv_content_type type string. + field-symbols: + like line of i_IMAGES_FILE. + loop at i_IMAGES_FILE assigning . + if not -content_type is initial. + lv_content_type = -content_type. + else. + lv_content_type = 'application/octet-stream' ##NO_TEXT. + endif. + if not -filename is initial. + lv_filename = -filename. + else. + lv_extension = get_file_extension( lv_content_type ). + lv_filename = `file` && lv_index && `.` && lv_extension ##NO_TEXT. + lv_index = lv_index + 1. + endif. + clear ls_form_part. + ls_form_part-content_type = lv_content_type. + ls_form_part-content_disposition = `form-data; name="images_file"; filename="` && lv_filename && `"` ##NO_TEXT. + ls_form_part-xdata = -data. + append ls_form_part to lt_form_part. + endloop. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->CREATE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_INFO TYPE T_BASE_COLLECTION +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method CREATE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections'. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_COLLECTION_INFO ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_COLLECTION_INFO i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'collection_info' i_value = i_COLLECTION_INFO ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_COLLECTION_INFO to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->LIST_COLLECTIONS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTIONS_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_COLLECTIONS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->UPDATE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_COLLECTION_INFO TYPE T_BASE_COLLECTION(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_COLLECTION_INFO is initial. + lv_datatype = get_datatype( i_COLLECTION_INFO ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_COLLECTION_INFO i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'collection_info' i_value = i_COLLECTION_INFO ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_COLLECTION_INFO to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->DELETE_COLLECTION +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_COLLECTION. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->ADD_IMAGES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_IMAGES_FILE TYPE TT_FILE_WITH_METADATA(optional) +* | [--->] I_IMAGE_URL TYPE TT_STRING(optional) +* | [--->] I_TRAINING_DATA TYPE STRING(optional) +* | [--->] I_contenttype TYPE string (default ='multipart/form-data') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_IMAGE_DETAILS_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_IMAGES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + " process form parameters + data: + ls_form_part type ts_form_part, + lt_form_part type tt_form_part, + lv_formdata type string value is initial ##NEEDED, + lv_value type string ##NEEDED, + lv_index(3) type n value '000' ##NEEDED, + lv_keypattern type string ##NEEDED, + lv_base_name type string ##NEEDED, + lv_extension type string ##NEEDED. + + + if not i_IMAGE_URL is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="image_url"' ##NO_TEXT. + field-symbols: + like line of i_IMAGE_URL. + loop at i_IMAGE_URL assigning . + ls_form_part-cdata = . + append ls_form_part to lt_form_part. + endloop. + endif. + + if not i_TRAINING_DATA is initial. + clear ls_form_part. + ls_form_part-content_type = ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-TEXT_PLAIN. + ls_form_part-content_disposition = 'form-data; name="training_data"' ##NO_TEXT. + lv_formdata = i_TRAINING_DATA. + ls_form_part-cdata = lv_formdata. + append ls_form_part to lt_form_part. + endif. + + + + if not i_IMAGES_FILE is initial. + data: + lv_filename type string, + lv_content_type type string. + field-symbols: + like line of i_IMAGES_FILE. + loop at i_IMAGES_FILE assigning . + if not -content_type is initial. + lv_content_type = -content_type. + else. + lv_content_type = 'application/octet-stream' ##NO_TEXT. + endif. + if not -filename is initial. + lv_filename = -filename. + else. + lv_extension = get_file_extension( lv_content_type ). + lv_filename = `file` && lv_index && `.` && lv_extension ##NO_TEXT. + lv_index = lv_index + 1. + endif. + clear ls_form_part. + ls_form_part-content_type = lv_content_type. + ls_form_part-content_disposition = `form-data; name="images_file"; filename="` && lv_filename && `"` ##NO_TEXT. + ls_form_part-xdata = -data. + append ls_form_part to lt_form_part. + endloop. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST_MULTIPART( i_request_prop = ls_request_prop it_form_part = lt_form_part ). + + + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->LIST_IMAGES +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_IMAGE_SUMMARY_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_IMAGES. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_IMAGE_DETAILS +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_IMAGE_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_IMAGE_DETAILS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_IMAGE_DETAILS. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images/{image_id}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{image_id}` in ls_request_prop-url-path with i_IMAGE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->DELETE_IMAGE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_IMAGE_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_IMAGE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images/{image_id}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{image_id}` in ls_request_prop-url-path with i_IMAGE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_JPEG_IMAGE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_IMAGE_ID TYPE STRING +* | [--->] I_SIZE TYPE STRING (default ='full') +* | [--->] I_accept TYPE string (default ='image/jpeg') +* | [<---] E_RESPONSE TYPE FILE +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_JPEG_IMAGE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images/{image_id}/jpeg'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{image_id}` in ls_request_prop-url-path with i_IMAGE_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_SIZE is supplied. + lv_queryparam = escape( val = i_SIZE format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `size` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve file data + e_response = get_response_binary( lo_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->LIST_OBJECT_METADATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_OBJECT_METADATA_LIST +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method LIST_OBJECT_METADATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/objects'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->UPDATE_OBJECT_METADATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_OBJECT TYPE STRING +* | [--->] I_UPDATEOBJECTMETADATA TYPE T_UPDATE_OBJECT_METADATA(optional) +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_UPDATE_OBJECT_METADATA +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method UPDATE_OBJECT_METADATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/objects/{object}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{object}` in ls_request_prop-url-path with i_OBJECT ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + if not i_UPDATEOBJECTMETADATA is initial. + lv_datatype = get_datatype( i_UPDATEOBJECTMETADATA ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_UPDATEOBJECTMETADATA i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'UpdateObjectMetadata' i_value = i_UPDATEOBJECTMETADATA ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_UPDATEOBJECTMETADATA to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_OBJECT_METADATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_OBJECT TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_OBJECT_METADATA +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_OBJECT_METADATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/objects/{object}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{object}` in ls_request_prop-url-path with i_OBJECT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->DELETE_OBJECT +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_OBJECT TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_OBJECT. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/objects/{object}'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{object}` in ls_request_prop-url-path with i_OBJECT ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->TRAIN +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_COLLECTION +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method TRAIN. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/train'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->ADD_IMAGE_TRAINING_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_COLLECTION_ID TYPE STRING +* | [--->] I_IMAGE_ID TYPE STRING +* | [--->] I_TRAINING_DATA TYPE T_BASE_TRAINING_DATA_OBJECTS +* | [--->] I_contenttype TYPE string (default ='application/json') +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_DATA_OBJECTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method ADD_IMAGE_TRAINING_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/collections/{collection_id}/images/{image_id}/training_data'. + replace all occurrences of `{collection_id}` in ls_request_prop-url-path with i_COLLECTION_ID ignoring case. + replace all occurrences of `{image_id}` in ls_request_prop-url-path with i_IMAGE_ID ignoring case. + + " standard headers + ls_request_prop-header_content_type = I_contenttype. + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + + + + + + " process body parameters + data: + lv_body type string, + lv_bodyparam type string, + lv_datatype type char. + field-symbols: + type any. + lv_separator = ''. + lv_datatype = get_datatype( i_TRAINING_DATA ). + + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep or + ls_request_prop-header_content_type cp '*json*'. + if lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct or + lv_datatype eq ZIF_IBMC_SERVICE_ARCH~c_datatype-struct_deep. + lv_bodyparam = abap_to_json( i_value = i_TRAINING_DATA i_dictionary = c_abapname_dictionary i_required_fields = c_required_fields ). + else. + lv_bodyparam = abap_to_json( i_name = 'training_data' i_value = i_TRAINING_DATA ). + endif. + lv_body = lv_body && lv_separator && lv_bodyparam. + else. + assign i_TRAINING_DATA to . + lv_bodyparam = . + concatenate lv_body lv_bodyparam into lv_body. + endif. + if ls_request_prop-header_content_type cp '*json*' and lv_body(1) ne '{'. + lv_body = `{` && lv_body && `}`. + endif. + + if ls_request_prop-header_content_type cp '*charset=utf-8*'. + ls_request_prop-body_bin = convert_string_to_utf8( i_string = lv_body ). + replace all occurrences of regex ';\s*charset=utf-8' in ls_request_prop-header_content_type with '' ignoring case. + else. + ls_request_prop-body = lv_body. + endif. + + + " execute HTTP POST request + lo_response = HTTP_POST( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->GET_TRAINING_USAGE +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_START_TIME TYPE STRING(optional) +* | [--->] I_END_TIME TYPE STRING(optional) +* | [--->] I_accept TYPE string (default ='application/json') +* | [<---] E_RESPONSE TYPE T_TRAINING_EVENTS +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method GET_TRAINING_USAGE. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/training_usage'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + if i_START_TIME is supplied. + lv_queryparam = escape( val = i_START_TIME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `start_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + if i_END_TIME is supplied. + lv_queryparam = escape( val = i_END_TIME format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `end_time` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + endif. + + + + + + + " execute HTTP GET request + lo_response = HTTP_GET( i_request_prop = ls_request_prop ). + + + " retrieve JSON data + lv_json = get_response_string( lo_response ). + parse_json( + exporting + i_json = lv_json + i_dictionary = c_abapname_dictionary + changing + c_abap = e_response ). + +endmethod. + + +* ---------------------------------------------------------------------------------------+ +* | Instance Public Method ZCL_IBMC_VISUAL_RECOGNITION_V4->DELETE_USER_DATA +* +-------------------------------------------------------------------------------------------------+ +* | [--->] I_CUSTOMER_ID TYPE STRING +* | [--->] I_accept TYPE string (default ='application/json') +* | [!CX!] ZCX_IBMC_SERVICE_EXCEPTION +* +-------------------------------------------------------------------------------------- +method DELETE_USER_DATA. + + data: + ls_request_prop type ts_request_prop, + lv_separator(1) type c ##NEEDED, + lv_sep(1) type c ##NEEDED, + lo_response type to_rest_response, + lv_json type string ##NEEDED. + + ls_request_prop-url-path = '/v4/user_data'. + + " standard headers + ls_request_prop-header_accept = I_accept. + set_default_query_parameters( + changing + c_url = ls_request_prop-url ). + + " process query parameters + data: + lv_queryparam type string. + + lv_queryparam = escape( val = i_CUSTOMER_ID format = cl_abap_format=>e_uri_full ). + add_query_parameter( + exporting + i_parameter = `customer_id` + i_value = lv_queryparam + changing + c_url = ls_request_prop-url ) ##NO_TEXT. + + + + + + + " execute HTTP DELETE request + lo_response = HTTP_DELETE( i_request_prop = ls_request_prop ). + + + +endmethod. + + + + +* ---------------------------------------------------------------------------------------+ +* | Instance Private Method ZCL_IBMC_VISUAL_RECOGNITION_V4->SET_DEFAULT_QUERY_PARAMETERS +* +-------------------------------------------------------------------------------------------------+ +* | [<-->] C_URL TYPE TS_URL +* +-------------------------------------------------------------------------------------- + method set_default_query_parameters. + if not p_version is initial. + add_query_parameter( + exporting + i_parameter = `version` + i_value = p_version + changing + c_url = c_url ). + endif. + endmethod. + +ENDCLASS. diff --git a/src/zcl_ibmc_visual_recognition_v4.clas.xml b/src/zcl_ibmc_visual_recognition_v4.clas.xml new file mode 100644 index 0000000..690b950 --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v4.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_VISUAL_RECOGNITION_V4 + E + IBM Watson Visual Recognition V4 + 1 + X + X + X + + + + diff --git a/src/zcx_ibmc_service_exception.clas.abap b/src/zcx_ibmc_service_exception.clas.abap new file mode 100644 index 0000000..165fdd7 --- /dev/null +++ b/src/zcx_ibmc_service_exception.clas.abap @@ -0,0 +1,68 @@ +class ZCX_IBMC_SERVICE_EXCEPTION definition + public + inheriting from CX_STATIC_CHECK + final + create public . + +public section. + + interfaces IF_T100_DYN_MSG . + interfaces IF_T100_MESSAGE . + + data P_MSG_JSON type STRING . + data P_HTTP_STATUS type STRING . + data P_HTTP_REASON type STRING . + + methods CONSTRUCTOR + importing + !TEXTID like IF_T100_MESSAGE=>T100KEY optional + !PREVIOUS like PREVIOUS optional + !P_MSG_JSON type STRING optional + !P_HTTP_STATUS type STRING optional + !P_HTTP_REASON type STRING optional . + + methods IF_MESSAGE~GET_LONGTEXT + redefinition . + methods IF_MESSAGE~GET_TEXT + redefinition . +protected section. +private section. +ENDCLASS. + + + +CLASS ZCX_IBMC_SERVICE_EXCEPTION IMPLEMENTATION. + + + method CONSTRUCTOR. +CALL METHOD SUPER->CONSTRUCTOR +EXPORTING +PREVIOUS = PREVIOUS +. +me->P_MSG_JSON = P_MSG_JSON . +me->P_HTTP_STATUS = P_HTTP_STATUS . +me->P_HTTP_REASON = P_HTTP_REASON . +clear me->textid. +if textid is initial. + IF_T100_MESSAGE~T100KEY = IF_T100_MESSAGE=>DEFAULT_TEXTID. +else. + IF_T100_MESSAGE~T100KEY = TEXTID. +endif. + endmethod. + + + method if_message~get_longtext. + call method super->if_message~get_longtext + exporting + preserve_newlines = preserve_newlines + receiving + result = result. + endmethod. + + + method if_message~get_text. + call method super->if_message~get_text + receiving + result = result. + endmethod. +ENDCLASS. diff --git a/src/zcx_ibmc_service_exception.clas.xml b/src/zcx_ibmc_service_exception.clas.xml new file mode 100644 index 0000000..14c7bcb --- /dev/null +++ b/src/zcx_ibmc_service_exception.clas.xml @@ -0,0 +1,25 @@ + + + + + + ZCX_IBMC_SERVICE_EXCEPTION + E + IBM Cloud Service Exception + 40 + 1 + X + X + X + + + + ZCX_IBMC_SERVICE_EXCEPTION + CONSTRUCTOR + E + CONSTRUCTOR + + + + + diff --git a/src/zibmc.msag.xml b/src/zibmc.msag.xml new file mode 100644 index 0000000..b67a5d7 --- /dev/null +++ b/src/zibmc.msag.xml @@ -0,0 +1,416 @@ + + + + + + ZIBMC + E + + + + E + ZIBMC + 000 + &1 + + + E + ZIBMC + 001 + &1: return code &2 + + + E + ZIBMC + 002 + An exception has occurred, reason code &1. + + + E + ZIBMC + 003 + HTTP Status: &1 (&2) + + + E + ZIBMC + 004 + Malformated url: &1 + + + E + ZIBMC + 005 + HTTP &1 request failed: &2 + + + E + ZIBMC + 006 + HTTP client cannot be created, return code &1. + + + E + ZIBMC + 007 + Parameter &1 not set + + + E + ZIBMC + 008 + Either parameter &1 or parameter &2 must be specified. + + + E + ZIBMC + 020 + Cannot parse JSON string, see short dump. + + + E + ZIBMC + 030 + Decoding of base64 string failed. + + + E + ZIBMC + 040 + &1 + + + E + ZIBMC + 050 + Missing field &1 in input structure. + + + E + ZIBMC + 051 + Input image is missing or ambiguous. + + + E + ZIBMC + 052 + base64 decoding of image &1 failed with return code &2. + + + E + ZIBMC + 053 + Classifier &1 has status &2. Operation terminated. + + + E + ZIBMC + 054 + Field &1 is missing or has incompatible type. + + + E + ZIBMC + 055 + Input structure meta data is not available. + + + E + ZIBMC + 056 + Cannot add image to ZIP file without filename. + + + + + + NA + ZIBMC003 + E + E + 0018 + X + 00005 + + + DOKU + ZIBMC003 + NA + E + S_DOCU_SHOW + S_DOCUS1 + 00018 + 072 + + + + AS + The HTTP Request received status "&V1&": "&V2&" + + + U1 + &SYSTEM_RESPONSE& + + + AS + Access point: &V3& + + + AS + Detailed Information reported by the service: + + + AS + &V4& + + + U1 + &WHAT_TO_DO& + + + AS + ,,Correct the error and restart the process. + + + + + + NA + ZIBMC004 + E + E + 0002 + X + 00004 + + + DOKU + ZIBMC004 + NA + E + S_DOCU_SHOW + S_DOCUS1 + 00002 + 072 + + + + U1 + &CAUSE& + + + AS + The format of URL "&V1&" is not correct. + + + U1 + &SYSTEM_RESPONSE& + + + AS + The request has been terminated. + + + U1 + &WHAT_TO_DO& + + + AS + Correct the URL. Format of the URL must comply with schema http(s):// + + + = + <host>/<api path> + + + U1 + &SYS_ADMIN& + + + AS + + + + + + NA + ZIBMC040 + E + E + 0004 + X + 00004 + + + DOKU + ZIBMC040 + NA + E + S_DOCU_SHOW + S_DOCUS1 + 00004 + 072 + + + + U1 + &CAUSE& + + + AS + Error + + + U1 + &SYSTEM_RESPONSE& + + + AS + JSON comes here. + + + AS + <(>&<)>1 + + + AS + &V1& + + + U1 + &WHAT_TO_DO& + + + AS + + + U1 + &SYS_ADMIN& + + + AS + + + + + + NA + ZIBMC050 + E + E + 0003 + X + 00004 + + + DOKU + ZIBMC050 + NA + E + S_DOCU_SHOW + S_DOCUS1 + 00003 + 072 + + + + U1 + &CAUSE& + + + AS + The Watson Machine Learning scoring endpoint requires input field &V1& + + + which is not present in the input structure. + + + U1 + &SYSTEM_RESPONSE& + + + AS + Watson Machine Learning refuses the scoring request. + + + U1 + &WHAT_TO_DO& + + + AS + Add field &V1& to the input structure. + + + U1 + &SYS_ADMIN& + + + AS + + + + + + NA + ZIBMC051 + E + E + 0001 + X + 00005 + + + DOKU + ZIBMC051 + NA + E + S_DOCU_SHOW + S_DOCUS1 + 00001 + 072 + + + + U1 + &CAUSE& + + + AS + The image to be classified is not specified or its specification is + + + ambiguous. + + + U1 + &SYSTEM_RESPONSE& + + + AS + The image is not being classified. + + + U1 + &WHAT_TO_DO& + + + AS + Specify the image either as binary data (type XSTRING) or as base64 + + + encoded character data (type STRING), but not both. + + + U1 + &SYS_ADMIN& + + + AS + + + + + + + diff --git a/src/zibmc_config.tabl.xml b/src/zibmc_config.tabl.xml new file mode 100644 index 0000000..fdd45e8 --- /dev/null +++ b/src/zibmc_config.tabl.xml @@ -0,0 +1,87 @@ + + + + + + ZIBMC_CONFIG + E + TRANSP + X + IBM Cloud Service Integration - Configuration + X + C + 1 + + + ZIBMC_CONFIG + A + 2 + APPL2 + X + X + + + + ZIBMC_CONFIG + CLIENT + E + 0001 + X + 0 + C + 000006 + X + CLNT + 000003 + CLNT + + + ZIBMC_CONFIG + SERVICE + E + 0002 + X + 0 + C + 000060 + X + CHAR + 000030 + CHAR + + + ZIBMC_CONFIG + INSTANCE_UID + 0003 + X + ZIBMC_TY_INSTANCE_UID + 0 + X + E + + + ZIBMC_CONFIG + PARAM + E + 0004 + X + 0 + C + 000064 + X + CHAR + 000032 + CHAR + + + ZIBMC_CONFIG + VALUE + 0005 + ZIBMC_TY_STRINGVALUE + 0 + E + + + + + diff --git a/src/zibmc_dom_stringvalue.doma.xml b/src/zibmc_dom_stringvalue.doma.xml new file mode 100644 index 0000000..3fef5e1 --- /dev/null +++ b/src/zibmc_dom_stringvalue.doma.xml @@ -0,0 +1,14 @@ + + + + + + ZIBMC_DOM_STRINGVALUE + E + STRG + X + Case-sensitive string value + + + + diff --git a/src/zibmc_token.tabl.xml b/src/zibmc_token.tabl.xml new file mode 100644 index 0000000..f651218 --- /dev/null +++ b/src/zibmc_token.tabl.xml @@ -0,0 +1,140 @@ + + + + + + ZIBMC_TOKEN + E + TRANSP + X + IAM tokens + X + L + 4 + + + ZIBMC_TOKEN + A + 4 + APPL2 + N + + + + ZIBMC_TOKEN + CLIENT + E + 0001 + X + 0 + C + 000006 + X + CLNT + 000003 + CLNT + + + ZIBMC_TOKEN + SERVICE + E + 0002 + X + 0 + C + 000060 + X + CHAR + 000030 + CHAR + + + ZIBMC_TOKEN + INSTANCE_UID + 0003 + X + ZIBMC_TY_INSTANCE_UID + 0 + X + E + + + ZIBMC_TOKEN + ACCESS_TOKEN + E + 0004 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + REFRESH_TOKEN + E + 0005 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + TOKEN_TYPE + E + 0006 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + EXPIRES_IN + E + 0007 + 0 + X + 000004 + INT4 + 000010 + INT4 + + + ZIBMC_TOKEN + EXPIRES_TS + 0008 + TIMESTAMP + 0 + E + + + ZIBMC_TOKEN + EXPIRATION + E + 0009 + 0 + X + 000004 + INT4 + 000010 + INT4 + + + ZIBMC_TOKEN + SCOPE + E + 0010 + 0 + g + 000008 + STRG + STRG + + + + + diff --git a/src/zibmc_ty_instance_uid.dtel.xml b/src/zibmc_ty_instance_uid.dtel.xml new file mode 100644 index 0000000..97d11b8 --- /dev/null +++ b/src/zibmc_ty_instance_uid.dtel.xml @@ -0,0 +1,24 @@ + + + + + + ZIBMC_TY_INSTANCE_UID + E + 55 + 10 + 20 + 40 + Instance GUI + Instance UID + Instance + Instance UID + Instance UID + E + CHAR + 000032 + 000032 + + + + diff --git a/src/zibmc_ty_stringvalue.dtel.xml b/src/zibmc_ty_stringvalue.dtel.xml new file mode 100644 index 0000000..9dc30d9 --- /dev/null +++ b/src/zibmc_ty_stringvalue.dtel.xml @@ -0,0 +1,23 @@ + + + + + + ZIBMC_TY_STRINGVALUE + E + ZIBMC_DOM_STRINGVALUE + 55 + 10 + 20 + 40 + Case-sensitive string value + Value + Value + Value + Value + E + D + + + + diff --git a/src/zif_ibmc_service_arch.intf.abap b/src/zif_ibmc_service_arch.intf.abap new file mode 100644 index 0000000..7acc531 --- /dev/null +++ b/src/zif_ibmc_service_arch.intf.abap @@ -0,0 +1,151 @@ +* Copyright 2019,2020 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +interface ZIF_IBMC_SERVICE_ARCH + public . + + + types: + boolean(1) type c . + types: + char(1) type c . + types: + begin of ts_http_status, + code type string, + reason type string, + json type string, + end of ts_http_status . + types: + begin of ts_header, + name type string, + value type string, + end of ts_header . + types: + tt_header type standard table of ts_header with non-unique default key . + types: + begin of ts_url, + protocol type string, + host type string, + path_base type string, + path type string, + querystring type string, + end of ts_url . + types: + begin of ts_access_token, + access_token type string, + token_type(32) type c, + end of ts_access_token . + types: + ty_timezone(6) type c . + types: + ty_ssl_id(6) type c . + types: + begin of ts_request_prop, + url type ts_url, + proxy_host type string, + proxy_port type string, + auth_name type string, + auth_type type string, + auth_headername type string, + auth_basic type boolean, + auth_oauth type boolean, + auth_apikey type boolean, + auth_query type boolean, + auth_header type boolean, + auth_body type boolean, + header_accept type string, + header_content_type type string, + headers type tt_header, + body type string, + body_bin type xstring, + username type string, + password type string, + apikey type string, + access_token type ts_access_token, + ssl_id type ty_ssl_id, + end of ts_request_prop . + types: + tt_string type standard table of string with non-unique default key . + types: + begin of TS_FORM_PART, + CONTENT_TYPE type STRING, + CONTENT_DISPOSITION type STRING, + CDATA type STRING, + XDATA type XSTRING, + end of TS_FORM_PART . + types: + TT_FORM_PART type standard table of TS_FORM_PART with non-unique default key . + + + constants C_METHOD_GET type CHAR value 'g' ##NO_TEXT. + constants C_METHOD_POST type CHAR value 'p' ##NO_TEXT. + constants C_METHOD_CREATE type CHAR value 'c' ##NO_TEXT. + constants C_METHOD_PUT type CHAR value 'u' ##NO_TEXT. + constants C_METHOD_DELETE type CHAR value 'd' ##NO_TEXT. + constants C_HEADER_CONTENT_TYPE type STRING value 'Content-Type' ##NO_TEXT. + constants C_HEADER_ACCEPT type STRING value 'Accept' ##NO_TEXT. + constants C_HEADER_CONTENT_DISPOSITION type STRING value 'Content-Disposition' ##NO_TEXT. + constants: + begin of c_mediatype, + all type string value '*/*', + appl_gzip type string value 'application/gzip', + appl_html type string value 'application/html', + appl_json type string value 'application/json', + appl_octet_stream type string value 'application/octet-stream', + appl_pdf type string value 'application/pdf', + appl_www_form_urlencoded type string value 'application/x-www-form-urlencoded', + appl_xml type string value 'application/xml', + appl_xhtml_xml type string value 'application/xhtml+xml', + atom_xml type string value 'application/atom+xml', + appl_zip type string value 'application/zip', + audio_all type string value 'audio/*', + audio_mpeg type string value 'audio/mpeg', + audio_ogg type string value 'audio/ogg', + audio_wav type string value 'audio/wav', + image_all type string value 'image/*', + image_bmp type string value 'image/bmp', + image_gif type string value 'image/gif', + image_jpeg type string value 'image/jpeg', + image_png type string value 'image/png', + image_tiff type string value 'image/tiff', + multipart_all type string value 'multipart/*', + multipart_form_data type string value 'multipart/form-data', + multipart_mixed type string value 'multipart/mixed', + text_all type string value 'text/*', + text_css type string value 'text/css', + text_csv type string value 'text/csv', + text_html type string value 'text/html', + text_javascript type string value 'text/javascript', + text_plain type string value 'text/plain', + video_all type string value 'video/*', + video_mp4 type string value 'video/mp4', + video_mpeg type string value 'video/mpeg', + end of c_mediatype . + constants: + begin of c_datatype, + i type char value 'I', + int8 type char value '8', + p type char value 'P', + f type char value 'F', + c type char value 'C', + n type char value 'N', + string type char value 'g', + x type char value 'X', + xstring type char value 'y', + dataref type char value 'l', + objectref type char value 'r', + struct type char value 'u', + struct_deep type char value 'v', + itab type char value 'h', + end of c_datatype . +endinterface. diff --git a/src/zif_ibmc_service_arch.intf.xml b/src/zif_ibmc_service_arch.intf.xml new file mode 100644 index 0000000..6555753 --- /dev/null +++ b/src/zif_ibmc_service_arch.intf.xml @@ -0,0 +1,15 @@ + + + + + + ZIF_IBMC_SERVICE_ARCH + E + IBM Watson SDK Platform-specifics + 2 + 1 + X + + + +