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 new file mode 100644 index 0000000..4947287 --- /dev/null +++ b/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index 3aaef13..f0cb1d7 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,462 @@ -# abap-sdk-nwas -ABAP code for using IBM Watson Developer Services with SAP NetWeaver Application Server, imported via abapGit +[![CLA assistant](https://cla-assistant.io/readme/badge/watson-developer-cloud/abap-sdk-nwas)](https://cla-assistant.io/watson-developer-cloud/abap-sdk-nwas) + +# ABAP SDK for IBM Watson, using SAP NetWeaver + +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 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. + +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** | [abap-sdk-scp](https://github.com/watson-developer-cloud/abap-sdk-scp) | +|---|---| +| for SAP NetWeaver AS ABAP 7.50+ | for SAP Cloud Platform ABAP Environment 1911+ | +| tested on SAP ECC and SAP S/4HANA | | +| `this repository` | | + +--- + +
+ Table of Contents + + * [Before you begin](#before-you-begin) + * [Installation](#installation) + * [SAP System Configuration](#sap-system-configuration) + * [SAP Profile Parameters](#sap-profile-parameters) + * [Proxy configuration](#proxy-configuration) + * [SSL Certificates](#ssl-certificates) + * [Credentials](#credentials) + * [Configuration table](#configuration-table) + * [IAM Authentication](#iam-reference) + * [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 [abapGit][abapgit], using the [abapGit Docs][abapgit_docs] +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. + +## SAP System Configuration + +### SAP Profile Parameters +The following SAP profile parameter settings are recommended. +``` +icm/HTTPS/client_sni_enabled = TRUE +ssl/ciphersuites = 135:PFS:HIGH::EC_P256:EC_HIGH +ssl/client_ciphersuites = 150:PFS:HIGH::EC_P256:EC_HIGH +wdisp/ssl_ignore_host_mismatch = TRUE +``` + +### Proxy configuration +The client library respects the ABAP proxy settings. If you are using a central proxy server that is not already configured in your SAP system, proceed as follows. +1. Logon to the SAP system and call transaction SICF. +2. Click *Execute* (or press F8). +3. Select menu item *Client* → *Proxy Settings*. +4. On tab *Global Settings*: Select *Proxy Setting is Active* and *No Proxy Setting for Local Server*. +5. On tabs *HTTP Log* and *HTTPS Log* specify the proxy *Host Name* and *Port*. If the proxy server requires logon credentials, also specify *User Name* and *Password*. +6. Click *Execute (F8)* and *OK*. + + +### 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 on the SAP application server in the Personal Security Environment (PSE). Transaction STRUST is used to maintain the PSE. + +#### Determine required certificate +If a call to an IBM Cloud service failed due to a missing SSL certificate, check the ICM trace file to find the required certificate. To do so, call transaction SMICM and select menu item *Goto* → *Trace File* → *Display End*. Alternatively, call transaction AL11 and navigate to file DIR_HOME/dev_icm. +Find last entry in trace file that indicates error *SSSLERR_PEER_CERT_UNTRUSTED*, as shown in the example below. +``` +[Thr nn] Peer not trusted +[Thr nn] Certificate: +[Thr nn] Certificate: +[Thr nn] Subject: CN=*.watsonplatform.net, O=INTERNATIONAL BUSINESS MACHINES CORPORATION, L=Armonk, SP=New York, C=US +[Thr nn] Issuer: CN=GeoTrust RSA CA 2018, OU=www.digicert.com, O=DigiCert Inc, C=US +[Thr nn] Serial Number: 05:1C:46:1B:6E:C2:29:48:BD:F0:03:B3:A6:87:1A:5B +[Thr nn] Verification result: +[...] +[Thr nn] SignerCert: +[Thr nn] Certificate: +[Thr nn] Subject: CN=GeoTrust RSA CA 2018, OU=www.digicert.com, O=DigiCert Inc, C=US +[Thr nn] Issuer: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +[Thr nn] Serial Number: 05:46:FE:18:23:F7:E1:94:1D:A3:9F:CE:14:C4:61:73 +[Thr nn] Verification result: +[...] +[Thr nn] SignerCert: +[Thr nn] Certificate: +[Thr nn] Subject: CN=DigiCert Global Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US +[...] +[Thr nn] << ---------- End of Secu-SSL Errorstack ---------- +[Thr nn] Target Hostname="stream.watsonplatform.net" +[Thr nn] SSL NI-hdl 463: local=9.152.20.145:56542 peer=169.48.115.62:443 +[Thr nn] <<- ERROR: SapSSLSessionStartNB(sssl_hdl=3fef0000c70)==SSSLERR_PEER_CERT_UNTRUSTED +[Thr nn] *** ERROR => SSL handshake with stream.watsonplatform.net:443 failed: SSSLERR_PEER_CERT_UNTRUSTED (-102) +[Thr nn] The peer's X.509 Certificate (chain) is untrusted +``` +The SSL error stack shows the SSL certificate chain, which in the example above looks like follows: + +| Certificate Authority Type | Certificate Authority (CA) | +|:--------------------------:|:-------------------------- | +| end-user | *.watsonplatform.net | +| intermediate | GeoTrust RSA CA 2018 | +| root | DigiCert Global Root CA | + +You can install any of these SSL certificates. However, it is recommended to install the root CA certificate.
+Download the appropriate SSL certificate from the provider's website, for example https://www.digicert.com/digicert-root-certificates.htm. Store the certificate file on your computer. + + +#### Add an SSL certificate to the PSE + +Proceed as follows to add the downloaded SSL certificate to your SAP system's *Standard SSL Client PSE*. +1. Logon to the SAP system and call transaction STRUST. +2. Switch to edit mode (press according tool bar icon). +3. If a local PSE file does not exist already, create it by right-clicking on `SSL client SSL Client (Standard)` and selecting *Create* from context menu. Keep all default settings in next popup dialog. +4. In *Certificate* section, click *Import* (alternatively select menu item *Certificate* → *Import*). Choose the certificate file that you have downloaded and import the certificate. +5. Click button *Add to Certificate List*. +6. Click *Save (F3)*. + + +#### Restart the ICM (Internet Communication Manager) + +It is recommended to restart the ICM after a new SSL certificate has been applied to the PSE. To do so, proceed as follows. +1. Logon to the SAP system and call transaction SMICM. +2. Select menu item *Administration* → *ICM* → *Restart* → *Yes*. + +## 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 dashboard and need to be provided as parameters `i_apikey` and `i_host` 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 | +|:----------------- |:----------------- |:--------------------------------------------------------------------------- | +| HOST | service-dependent | Watson service endpoint host, e.g. https://gateway-lon.watsonplatform.net | +| USERNAME | | Watson service user name | +| PASSWORD | | Watson service password | +| APIKEY | | Watson service API keys | +| PROXY_HOST | | Proxy server | +| PROXY_PORT | | Proxy server port | +| AUTH_NAME | service-dependent | Authorization, `IAM` or `basicAuth` | +| SSL_ID | CLIENT | SSL Identity, defines PSE for SSL certificates: `CLIENT` or `ANONYM` | + +
+ + +## 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 username / password or apikey are provided for method `zcl_ibmc_service_ext=>get_instance()`, the ABAP SDK under the cover generates a bearer-token when needed and refreshes it when it is about to expire.
+If neither username / password nor apikey are 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: +``` + 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`. +``` + data: + lo_service_class type . + + zcl_ibmc_service_ext=>get_instance( + exporting + i_host = + i_apikey = +... + importing + eo_instance = lo_service_class ). +``` + +2. Call the Watson service API endpoint by invoking the corresponding class method. +``` + 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 + +``` +* 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_host = 'https://gateway-lon.watsonplatform.net' + 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. + + " print voices + loop at lt_voices-voices into ls_voice. + write: / ls_voice-name. + endloop. +``` + +
+ +
+ Natural Language Understanding Example + +``` +* 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_host = 'https://gateway-lon.watsonplatform.net' + 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 + +``` +* 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_host = 'https://gateway-lon.watsonplatform.net' + 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 + +``` +* 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_host = 'https://gateway-lon.watsonplatform.net' + 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 + +If you have questions about the IBM Watson services or are having difficulties using the APIs, please ask a question at [dW Answers](https://developer.ibm.com/answers/questions/ask/?topics=watson) or [Stack Overflow](http://stackoverflow.com/questions/ask?tags=ibm-watson-cognitive). + +## License + +This library is licensed under the [Apache 2.0 license][license]. + +--- + +## Contributors + +* Christian Bartels +* Joachim Rese +* Jochen Röhrig +* Aleksandar Debelic + +## Acknowledgements + +* Bradley Knapp (Sponsor) +* Devraj Bardhan (Sponsor) +* Sean Freeman (Sponsor) + +In addition, we would like to thank the [abapGit][abapgit] contributors and the SAP Mentors of this team. + +[wdc]: http://www.ibm.com/watson/developercloud/ +[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_docs]: https://docs.abapgit.org/ diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v1.html new file mode 100644 index 0000000..b135b88 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v1.html @@ -0,0 +1,611 @@ +Class ZCL_IBMC_ASSISTANT_V1

Class ZCL_IBMC_ASSISTANT_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_audit_properties (structured type) 
publict_base_counterexample (structured type) 
publict_base_dialog_node (structured type) 
publict_base_entity (structured type) 
publict_base_example (structured type) 
publict_base_intent (structured type) 
publict_base_message (structured type) 
publict_base_output (structured type) An output object that includes the response to the user, the dialog nodes that + were triggered, and messages from the log.
publict_base_synonym (structured type) 
publict_base_value (structured type) 
publict_base_workspace (structured type) 
publict_capture_group (structured type) A recognized capture group for a pattern-based entity.
publict_context (structured type) State information for the conversation. To maintain state, include the context + from the previous response.
publict_counterexample (structured type) 
publict_counterexample_collection (structured type) 
publict_create_entity (structured type) 
publict_create_intent (structured type) 
publict_create_value (structured type) 
publict_create_workspace (structured type) 
publict_dialog_node (structured type) 
publict_dialog_node_action (structured type) 
publict_dialog_node_collection (structured type) An array of dialog nodes.
publict_dialog_node_next_step (structured type) The next step to execute following this dialog node.
publict_dialog_node_output (structured type) The output of the dialog node. For more information about how to specify dialog + node output, see the + [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-d + ialog-overview#dialog-overview-responses).
publict_dialog_node_output_generic (structured type) 
publict_dialog_node_output_modifiers (structured type) Options that modify how specified output is handled.
publict_dialog_node_visited_details (structured type) 
publict_dialog_suggestion (structured type) 
publict_dialog_suggestion_output (structured type) The dialog output that will be returned from the Watson Assistant service if the + user selects the corresponding option.
publict_dialog_suggestion_value (structured type) 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.
publict_dia_nd_otpt_resp_type_pause (structured type) 
publict_dia_nd_otpt_resp_typ_cnnct_1 (structured type) 
publict_dia_nd_otpt_resp_typ_srch_s1 (structured type) 
publict_dia_nd_otpt_text_values_elem (structured type) 
publict_dia_nd_output_opt_elem_value (structured type) An object defining the message input to be sent to the Watson Assistant service + if the user selects the corresponding option.
publict_dia_nd_output_resp_type_img (structured type) 
publict_dia_nd_output_resp_type_opt (structured type) 
publict_dia_nd_output_resp_type_text (structured type) 
publict_dia_node_output_opt_element (structured type) 
publict_dia_suggestion_resp_generic (structured type) 
publict_empty_response type JSONOBJECT 
publict_entity (structured type) 
publict_entity_collection (structured type) An array of objects describing the entities for the workspace.
publict_entity_mention (structured type) An object describing a contextual entity mention.
publict_entity_mention_collection (structured type) 
publict_error_detail (structured type) 
publict_error_response (structured type) 
publict_example (structured type) 
publict_example_collection (structured type) 
publict_intent (structured type) 
publict_intent_collection (structured type) 
publict_log (structured type) 
publict_log_collection (structured type) 
publict_log_message (structured type) Log message details.
publict_log_pagination (structured type) The pagination data for the returned objects.
publict_mention (structured type) A mention of a contextual entity.
publict_message_context_metadata (structured type) Metadata related to the message.
publict_message_input (structured type) An input object that includes the input text.
publict_message_request (structured type) A request sent to the workspace, including the user input and context.
publict_message_response (structured type) The response sent by the workspace, including the output text, detected intents + and entities, and context.
publict_output_data (structured type) An output object that includes the response to the user, the dialog nodes that + were triggered, and messages from the log.
publict_pagination (structured type) The pagination data for the returned objects.
publict_rt_entity_interpretation (structured type) 
publict_rt_entty_intrprttn_sys_date (structured type) 
publict_rt_entty_intrprttn_sys_num (structured type) 
publict_rt_entty_intrprttn_sys_time (structured type) 
publict_rt_response_type_suggestion (structured type) 
publict_rt_resp_typ_connect_to_agent (structured type) 
publict_runtime_entity (structured type) A term from the request that was identified as an entity.
publict_runtime_entity_alternative (structured type) An alternative value for the recognized entity.
publict_runtime_entity_role (structured type) 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 part of the new system entities, which are a beta feature.
publict_runtime_intent (structured type) An intent identified in the user input.
publict_runtime_response_generic (structured type) 
publict_runtime_response_type_image (structured type) 
publict_runtime_response_type_option (structured type) 
publict_runtime_response_type_pause (structured type) 
publict_runtime_response_type_text (structured type) 
publict_synonym (structured type) 
publict_synonym_collection (structured type) 
publict_system_response type MAP For internal use only.
publict_update_counterexample (structured type) 
publict_update_dialog_node (structured type) 
publict_update_entity (structured type) 
publict_update_example (structured type) 
publict_update_intent (structured type) 
publict_update_synonym (structured type) 
publict_update_value (structured type) 
publict_update_workspace (structured type) 
publict_value (structured type) 
publict_value_collection (structured type) 
publict_workspace (structured type) 
publict_workspace_collection (structured type) 
publict_workspace_system_settings (structured type) Global settings for the workspace.
publict_ws_system_settings_tooling (structured type) Workspace settings related to the Watson Assistant user interface.
publict_ws_systm_sttngs_dsmbgtn (structured type) Workspace settings related to the disambiguation feature. + + **Note:** This feature is available only to Premium users.
publict_ws_systm_sttngs_systm_entts (structured type) Workspace settings related to the behavior of system entities.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
create_counterexample
importingi_workspace_idtype STRING
i_bodytype T_COUNTEREXAMPLE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COUNTEREXAMPLE
raisingzcx_ibmc_service_exception
Create counterexample. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_body + The content of the new counterexample. +
e_response + Service return value of type T_COUNTEREXAMPLE +
public instance
create_dialog_node
importingi_workspace_idtype STRING
i_bodytype T_DIALOG_NODE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DIALOG_NODE
raisingzcx_ibmc_service_exception
Create dialog node. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_body + A CreateDialogNode object defining the content of the new dialog node. +
e_response + Service return value of type T_DIALOG_NODE +
public instance
create_entity
importingi_workspace_idtype STRING
i_bodytype T_CREATE_ENTITY
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENTITY
raisingzcx_ibmc_service_exception
Create entity. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_body + The content of the new entity. +
e_response + Service return value of type T_ENTITY +
public instance
create_example
importingi_workspace_idtype STRING
i_intenttype STRING
i_bodytype T_EXAMPLE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXAMPLE
raisingzcx_ibmc_service_exception
Create user input example. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
i_body + The content of the new user input example. +
e_response + Service return value of type T_EXAMPLE +
public instance
create_intent
importingi_workspace_idtype STRING
i_bodytype T_CREATE_INTENT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_INTENT
raisingzcx_ibmc_service_exception
Create intent. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_body + The content of the new intent. +
e_response + Service return value of type T_INTENT +
public instance
create_synonym
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_bodytype T_SYNONYM
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SYNONYM
raisingzcx_ibmc_service_exception
Create entity value synonym. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
i_body + The new synonym. +
e_response + Service return value of type T_SYNONYM +
public instance
create_value
importingi_workspace_idtype STRING
i_entitytype STRING
i_bodytype T_CREATE_VALUE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VALUE
raisingzcx_ibmc_service_exception
Create entity value. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_body + The new entity value. +
e_response + Service return value of type T_VALUE +
public instance
create_workspace
importingi_bodytype T_CREATE_WORKSPACE optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORKSPACE
raisingzcx_ibmc_service_exception
Create workspace. + +
Parameters
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. +
e_response + Service return value of type T_WORKSPACE +
public instance
delete_counterexample
importingi_workspace_idtype STRING
i_texttype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete counterexample. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_text + The text of a user input counterexample (for example, `What are you wearing?`). +
public instance
delete_dialog_node
importingi_workspace_idtype STRING
i_dialog_nodetype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete dialog node. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_dialog_node + The dialog node ID (for example, `get_order`). +
public instance
delete_entity
importingi_workspace_idtype STRING
i_entitytype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete entity. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
public instance
delete_example
importingi_workspace_idtype STRING
i_intenttype STRING
i_texttype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete user input example. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
i_text + The text of the user input example. +
public instance
delete_intent
importingi_workspace_idtype STRING
i_intenttype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete intent. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
public instance
delete_synonym
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_synonymtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete entity value synonym. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
i_synonym + The text of the synonym. +
public instance
delete_user_data
importingi_customer_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instance
delete_value
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete entity value. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
public instance
delete_workspace
importingi_workspace_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete workspace. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
public instanceget_appname redefinition 
public instance
get_counterexample
importingi_workspace_idtype STRING
i_texttype STRING
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COUNTEREXAMPLE
raisingzcx_ibmc_service_exception
Get counterexample. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_text + The text of a user input counterexample (for example, `What are you wearing?`). +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_COUNTEREXAMPLE +
public instance
get_dialog_node
importingi_workspace_idtype STRING
i_dialog_nodetype STRING
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DIALOG_NODE
raisingzcx_ibmc_service_exception
Get dialog node. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_dialog_node + The dialog node ID (for example, `get_order`). +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_DIALOG_NODE +
public instance
get_entity
importingi_workspace_idtype STRING
i_entitytype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENTITY
raisingzcx_ibmc_service_exception
Get entity. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
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. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_ENTITY +
public instance
get_example
importingi_workspace_idtype STRING
i_intenttype STRING
i_texttype STRING
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXAMPLE
raisingzcx_ibmc_service_exception
Get user input example. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
i_text + The text of the user input example. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_EXAMPLE +
public instance
get_intent
importingi_workspace_idtype STRING
i_intenttype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_INTENT
raisingzcx_ibmc_service_exception
Get intent. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
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. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_INTENT +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
get_synonym
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_synonymtype STRING
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SYNONYM
raisingzcx_ibmc_service_exception
Get entity value synonym. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
i_synonym + The text of the synonym. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_SYNONYM +
public instance
get_value
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VALUE
raisingzcx_ibmc_service_exception
Get entity value. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
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. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_VALUE +
public instance
get_workspace
importingi_workspace_idtype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_sorttype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORKSPACE
raisingzcx_ibmc_service_exception
Get information about a workspace. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
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. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
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. +
e_response + Service return value of type T_WORKSPACE +
public instance
list_all_logs
importingi_filtertype STRING
i_sorttype STRING optional
i_page_limittype INTEGER optional
i_cursortype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LOG_COLLECTION
raisingzcx_ibmc_service_exception
List log events in all workspaces. + +
Parameters
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 `workspace_id` or `request.context.metadata.deployment`. + For more information, see the + [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-f + ilter-reference#filter-reference). +
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 (`-`). +
i_page_limit + The number of records to return in each page of results. +
i_cursor + A token identifying the page of results to retrieve. +
e_response + Service return value of type T_LOG_COLLECTION +
public instance
list_counterexamples
importingi_workspace_idtype STRING
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COUNTEREXAMPLE_COLLECTION
raisingzcx_ibmc_service_exception
List counterexamples. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned counterexamples will be sorted. To reverse the + sort order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_COUNTEREXAMPLE_COLLECTION +
public instance
list_dialog_nodes
importingi_workspace_idtype STRING
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DIALOG_NODE_COLLECTION
raisingzcx_ibmc_service_exception
List dialog nodes. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned dialog nodes will be sorted. To reverse the sort + order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_DIALOG_NODE_COLLECTION +
public instance
list_entities
importingi_workspace_idtype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENTITY_COLLECTION
raisingzcx_ibmc_service_exception
List entities. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
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. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned entities will be sorted. To reverse the sort + order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_ENTITY_COLLECTION +
public instance
list_examples
importingi_workspace_idtype STRING
i_intenttype STRING
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXAMPLE_COLLECTION
raisingzcx_ibmc_service_exception
List user input examples. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned examples will be sorted. To reverse the sort + order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_EXAMPLE_COLLECTION +
public instance
list_intents
importingi_workspace_idtype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_INTENT_COLLECTION
raisingzcx_ibmc_service_exception
List intents. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
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. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned intents will be sorted. To reverse the sort + order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_INTENT_COLLECTION +
public instance
list_logs
importingi_workspace_idtype STRING
i_sorttype STRING optional
i_filtertype STRING optional
i_page_limittype INTEGER optional
i_cursortype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LOG_COLLECTION
raisingzcx_ibmc_service_exception
List log events in a workspace. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
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 (`-`). +
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/services/assistant?topic=assistant-f + ilter-reference#filter-reference). +
i_page_limit + The number of records to return in each page of results. +
i_cursor + A token identifying the page of results to retrieve. +
e_response + Service return value of type T_LOG_COLLECTION +
public instance
list_mentions
importingi_workspace_idtype STRING
i_entitytype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENTITY_MENTION_COLLECTION
raisingzcx_ibmc_service_exception
List entity mentions. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
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. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_ENTITY_MENTION_COLLECTION +
public instance
list_synonyms
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SYNONYM_COLLECTION
raisingzcx_ibmc_service_exception
List entity value synonyms. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
i_page_limit + The number of records to return in each page of results. +
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 (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_SYNONYM_COLLECTION +
public instance
list_values
importingi_workspace_idtype STRING
i_entitytype STRING
i_exporttype BOOLEAN default C_BOOLEAN_FALSE
i_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VALUE_COLLECTION
raisingzcx_ibmc_service_exception
List entity values. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
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. +
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned entity values will be sorted. To reverse the + sort order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_VALUE_COLLECTION +
public instance
list_workspaces
importingi_page_limittype INTEGER optional
i_sorttype STRING optional
i_cursortype STRING optional
i_include_audittype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORKSPACE_COLLECTION
raisingzcx_ibmc_service_exception
List workspaces. + +
Parameters
i_page_limit + The number of records to return in each page of results. +
i_sort + The attribute by which returned workspaces will be sorted. To reverse the sort + order, prefix the value with a minus sign (`-`). +
i_cursor + A token identifying the page of results to retrieve. +
i_include_audit + Whether to include the audit properties (`created` and `updated` timestamps) in + the response. +
e_response + Service return value of type T_WORKSPACE_COLLECTION +
public instance
message
importingi_workspace_idtype STRING
i_bodytype T_MESSAGE_REQUEST optional
i_nodes_visited_detailstype BOOLEAN default C_BOOLEAN_FALSE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_MESSAGE_RESPONSE
raisingzcx_ibmc_service_exception
Get response to user input. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_body + The message to be sent. This includes the user's input, along with optional + intents, entities, and context from the last response. +
i_nodes_visited_details + Whether to include additional diagnostic information about the dialog nodes that + were visited during processing of the message. +
e_response + Service return value of type T_MESSAGE_RESPONSE +
public instance
update_counterexample
importingi_workspace_idtype STRING
i_texttype STRING
i_bodytype T_UPDATE_COUNTEREXAMPLE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COUNTEREXAMPLE
raisingzcx_ibmc_service_exception
Update counterexample. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_text + The text of a user input counterexample (for example, `What are you wearing?`). +
i_body + The text of the counterexample. +
e_response + Service return value of type T_COUNTEREXAMPLE +
public instance
update_dialog_node
importingi_workspace_idtype STRING
i_dialog_nodetype STRING
i_bodytype T_UPDATE_DIALOG_NODE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DIALOG_NODE
raisingzcx_ibmc_service_exception
Update dialog node. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_dialog_node + The dialog node ID (for example, `get_order`). +
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. +
e_response + Service return value of type T_DIALOG_NODE +
public instance
update_entity
importingi_workspace_idtype STRING
i_entitytype STRING
i_bodytype T_UPDATE_ENTITY
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENTITY
raisingzcx_ibmc_service_exception
Update entity. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
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. +
e_response + Service return value of type T_ENTITY +
public instance
update_example
importingi_workspace_idtype STRING
i_intenttype STRING
i_texttype STRING
i_bodytype T_UPDATE_EXAMPLE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXAMPLE
raisingzcx_ibmc_service_exception
Update user input example. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
i_text + The text of the user input example. +
i_body + The new text of the user input example. +
e_response + Service return value of type T_EXAMPLE +
public instance
update_intent
importingi_workspace_idtype STRING
i_intenttype STRING
i_bodytype T_UPDATE_INTENT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_INTENT
raisingzcx_ibmc_service_exception
Update intent. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_intent + The intent name. +
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. +
e_response + Service return value of type T_INTENT +
public instance
update_synonym
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_synonymtype STRING
i_bodytype T_UPDATE_SYNONYM
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SYNONYM
raisingzcx_ibmc_service_exception
Update entity value synonym. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
i_synonym + The text of the synonym. +
i_body + The updated entity value synonym. +
e_response + Service return value of type T_SYNONYM +
public instance
update_value
importingi_workspace_idtype STRING
i_entitytype STRING
i_valuetype STRING
i_bodytype T_UPDATE_VALUE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VALUE
raisingzcx_ibmc_service_exception
Update entity value. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
i_entity + The name of the entity. +
i_value + The text of the entity value. +
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. +
e_response + Service return value of type T_VALUE +
public instance
update_workspace
importingi_workspace_idtype STRING
i_bodytype T_UPDATE_WORKSPACE optional
i_appendtype BOOLEAN default C_BOOLEAN_FALSE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORKSPACE
raisingzcx_ibmc_service_exception
Update workspace. + +
Parameters
i_workspace_id + Unique identifier of the workspace. +
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. +
i_append + Whether the new data is to be appended to the existing data in the workspace. If + **append**=`false`, elements included in the new data completely replace the + corresponding existing elements, including all subelements. For example, if the + new data includes **entities** and **append**=`false`, all existing entities in + the workspace are discarded and replaced with the new entities. + + If **append**=`true`, existing elements are preserved, and the new elements are + added. If any elements in the new data collide with existing elements, the + update request fails. +
e_response + Service return value of type T_WORKSPACE +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v2.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v2.html new file mode 100644 index 0000000..31492cb --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_assistant_v2.html @@ -0,0 +1,59 @@ +Class ZCL_IBMC_ASSISTANT_V2

Class ZCL_IBMC_ASSISTANT_V2

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_capture_group (structured type) 
publict_dialog_log_message (structured type) Dialog log message details.
publict_dialog_nodes_visited (structured type) 
publict_dialog_node_action (structured type) 
publict_dialog_suggestion (structured type) 
publict_dialog_suggestion_value (structured type) An object defining the message input to be sent to the assistant if the user + selects the corresponding disambiguation option.
publict_dia_nd_output_opt_elem_value (structured type) An object defining the message input to be sent to the assistant if the user + selects the corresponding option.
publict_dia_node_output_opt_element (structured type) 
publict_empty_response type JSONOBJECT 
publict_error_detail (structured type) 
publict_error_response (structured type) 
publict_message_context (structured type) 
publict_message_context_global (structured type) Information that is shared by all skills used by the Assistant.
publict_message_context_skill (structured type) Contains information specific to a particular skill used by the Assistant.
publict_message_context_skills type MAP 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.
publict_message_input (structured type) An input object that includes the input text.
publict_message_input_options (structured type) Optional properties that control how the assistant responds.
publict_message_output (structured type) Assistant output to be rendered or processed by the client.
publict_message_output_debug (structured type) Additional detailed information about a message response and how it was + generated.
publict_message_request (structured type) A request formatted for the Watson Assistant service.
publict_message_response (structured type) A response from the Watson Assistant service.
publict_mssg_context_global_system (structured type) Built-in system properties that apply to all skills used by the assistant.
publict_rt_entity_interpretation (structured type) 
publict_rt_entty_intrprttn_sys_date (structured type) 
publict_rt_entty_intrprttn_sys_num (structured type) 
publict_rt_entty_intrprttn_sys_time (structured type) 
publict_rt_response_type_suggestion (structured type) 
publict_rt_resp_typ_connect_to_agent (structured type) 
publict_runtime_entity (structured type) The entity value that was recognized in the user input.
publict_runtime_entity_alternative (structured type) An alternative value for the recognized entity.
publict_runtime_entity_role (structured type) 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 part of the new system entities, which are a beta feature.
publict_runtime_intent (structured type) An intent identified in the user input.
publict_runtime_response_generic (structured type) 
publict_runtime_response_type_image (structured type) 
publict_runtime_response_type_option (structured type) 
publict_runtime_response_type_pause (structured type) 
publict_runtime_response_type_search (structured type) 
publict_runtime_response_type_text (structured type) 
publict_search_result (structured type) 
publict_search_result_highlight (structured type) An object containing segments of text from search results with query-matching + text highlighted using HTML tags.
publict_search_result_metadata (structured type) An object containing search result metadata from the Discovery service.
publict_session_response (structured type) 

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
create_session
importingi_assistant_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SESSION_RESPONSE
raisingzcx_ibmc_service_exception
Create a session. + +
Parameters
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/services/assistant?topic=assistant-a + ssistant-add#assistant-add-task). + + **Note:** Currently, the v2 API does not support creating assistants. +
e_response + Service return value of type T_SESSION_RESPONSE +
public instance
delete_session
importingi_assistant_idtype STRING
i_session_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete session. + +
Parameters
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/services/assistant?topic=assistant-a + ssistant-add#assistant-add-task). + + **Note:** Currently, the v2 API does not support creating assistants. +
i_session_id + Unique identifier of the session. +
public instanceget_appname redefinition 
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
message
importingi_assistant_idtype STRING
i_session_idtype STRING
i_requesttype T_MESSAGE_REQUEST optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_MESSAGE_RESPONSE
raisingzcx_ibmc_service_exception
Send user input to assistant. + +
Parameters
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/services/assistant?topic=assistant-a + ssistant-add#assistant-add-task). + + **Note:** Currently, the v2 API does not support creating assistants. +
i_session_id + Unique identifier of the session. +
i_request + The message to be sent. This includes the user's input, along with optional + content such as intents and entities. +
e_response + Service return value of type T_MESSAGE_RESPONSE +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_compare_comply_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_compare_comply_v1.html new file mode 100644 index 0000000..8d493d5 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_compare_comply_v1.html @@ -0,0 +1,239 @@ +Class ZCL_IBMC_COMPARE_COMPLY_V1

Class ZCL_IBMC_COMPARE_COMPLY_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

Compare and Comply

+ IBM Watson™ Compare and Comply analyzes governing documents to provide + details about critical aspects of the documents.

Types

Visibility and LevelNameDocumentation
publict_address (structured type) A party's address.
publict_aligned_element (structured type) 
publict_attribute (structured type) List of document attributes.
publict_batches (structured type) The results of a successful **List Batches** request.
publict_batch_status (structured type) The batch-request status.
publict_body_cells (structured type) Cells that are not table header, column header, or row header cells.
publict_category (structured type) Information defining an element's subject matter.
publict_category_comparison (structured type) Information defining an element's subject matter.
publict_classify_return (structured type) The analysis of objects returned by the **Element classification** method.
publict_column_headers (structured type) Column-level cells, each applicable as a header to other cells in the same + column as itself, of the current table.
publict_column_header_ids type TT_STRING An array that contains the `id` value of a column header that is applicable to + the current cell.
publict_column_header_texts type TT_STRING An array that contains the `text` value of a column header that is applicable to + the current cell.
publict_column_header_texts_norm type TT_STRING 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`.
publict_compare_return (structured type) The comparison of the two submitted documents.
publict_contact (structured type) A contact.
publict_contexts (structured type) Text that is related to the contents of the table and that precedes or follows + the current table.
publict_contract_amts (structured type) A monetary amount identified in the input document.
publict_contract_currencies (structured type) The contract currencies that are declared in the document.
publict_contract_terms (structured type) The duration or durations of the contract.
publict_contract_types (structured type) The contract type identified in the input document.
publict_document (structured type) Basic information about the input document.
publict_doc_counts (structured type) Document counts.
publict_doc_info (structured type) Information about the parsed input document.
publict_doc_structure (structured type) The structure of the input document.
publict_effective_dates (structured type) An effective date.
publict_element (structured type) A component part of the document.
publict_element_locations (structured type) A list of `begin` and `end` indexes that indicate the locations of the elements + in the input document.
publict_element_pair (structured type) Details of semantically aligned elements.
publict_error_response (structured type) 
publict_feedback_data_input (structured type) Feedback data for submission.
publict_feedback_data_output (structured type) Information returned from the **Add Feedback** method.
publict_feedback_deleted (structured type) The status and message of the deletion request.
publict_feedback_input (structured type) The feedback to be added to an element in the document.
publict_feedback_list (structured type) The results of a successful **List Feedback** request for all feedback.
publict_feedback_return (structured type) Information about the document and the submitted feedback.
publict_get_feedback (structured type) The results of a successful **Get Feedback** request for a single feedback + entry.
publict_htmlreturn (structured type) The HTML converted from an input document.
publict_inline_object (structured type) 
publict_inline_object1 (structured type) 
publict_inline_object2 (structured type) 
publict_inline_object3 (structured type) 
publict_inline_object4 (structured type) 
publict_interpretation (structured type) The details of the normalized text, if applicable. This element is optional; it + is returned only if normalized text exists.
publict_key (structured type) A key in a key-value pair.
publict_key_value_pair (structured type) Key-value pairs detected across cell boundaries.
publict_label (structured type) 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.
publict_leading_sentence (structured type) The leading sentences in a section or subsection of the input document.
publict_location (structured type) The numeric location of the identified element in the document, represented with + two integers labeled `begin` and `end`.
publict_mention (structured type) A mention of a party.
publict_original_labels_in (structured type) The original labeling from the input document, without the submitted feedback.
publict_original_labels_out (structured type) The original labeling from the input document, without the submitted feedback.
publict_pagination (structured type) Pagination details, if required by the length of the output.
publict_paragraphs (structured type) The locations of each paragraph in the input document.
publict_parties (structured type) A party and its corresponding role, including address and contact information if + identified.
publict_payment_terms (structured type) The document's payment duration or durations.
publict_row_headers (structured type) Row-level cells, each applicable as a header to other cells in the same row as + itself, of the current table.
publict_row_header_ids type TT_STRING An array that contains the `id` value of a row header that is applicable to this + body cell.
publict_row_header_texts type TT_STRING An array that contains the `text` value of a row header that is applicable to + this body cell.
publict_row_header_texts_normalized type TT_STRING 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`.
publict_section_title (structured type) The table's section title, if identified.
publict_section_titles (structured type) 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.
publict_short_doc (structured type) Brief information about the input document.
publict_tables (structured type) The contents of the tables extracted from a document.
publict_table_headers (structured type) The contents of the current table's header.
publict_table_return (structured type) The analysis of the document's tables.
publict_table_title (structured type) 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.
publict_termination_dates (structured type) Termination dates identified in the input document.
publict_type_label (structured type) Identification of a specific type.
publict_type_label_comparison (structured type) Identification of a specific type.
publict_unaligned_element (structured type) Element that does not align semantically between two compared documents.
publict_updated_labels_in (structured type) The updated labeling from the input document, accounting for the submitted + feedback.
publict_updated_labels_out (structured type) The updated labeling from the input document, accounting for the submitted + feedback.
publict_value (structured type) A value in a key-value pair.
publict_values TYPE STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY A list of values in a key-value pair.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
add_feedback
importingi_feedback_datatype T_FEEDBACK_INPUT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_FEEDBACK_RETURN
raisingzcx_ibmc_service_exception
Add feedback. + +
Parameters
i_feedback_data + An object that defines the feedback to be submitted. +
e_response + Service return value of type T_FEEDBACK_RETURN +
public instance
classify_elements
importingi_filetype FILE
i_file_content_typetype STRING optional
i_modeltype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFY_RETURN
raisingzcx_ibmc_service_exception
Classify the elements of a document. + +
Parameters
i_file + The document to classify. +
i_file_content_type + The content type of file. +
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. + +
e_response + Service return value of type T_CLASSIFY_RETURN +
public instance
compare_documents
importingi_file_1type FILE
i_file_2type FILE
i_file_1_content_typetype STRING optional
i_file_2_content_typetype STRING optional
i_file_1_labeltype STRING default 'file_1'
i_file_2_labeltype STRING default 'file_2'
i_modeltype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COMPARE_RETURN
raisingzcx_ibmc_service_exception
Compare two documents. + +
Parameters
i_file_1 + The first document to compare. +
i_file_2 + The second document to compare. +
i_file_1_content_type + The content type of file1. +
i_file_2_content_type + The content type of file2. +
i_file_1_label + A text label for the first document. +
i_file_2_label + A text label for the second document. +
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. + +
e_response + Service return value of type T_COMPARE_RETURN +
public instance
convert_to_html
importingi_filetype FILE
i_file_content_typetype STRING optional
i_modeltype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_HTMLRETURN
raisingzcx_ibmc_service_exception
Convert document to HTML. + +
Parameters
i_file + The document to convert. +
i_file_content_type + The content type of file. +
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. + +
e_response + Service return value of type T_HTMLRETURN +
public instance
create_batch
importingi_functiontype STRING
i_input_credentials_filetype FILE
i_input_bucket_locationtype STRING
i_input_bucket_nametype STRING
i_output_credentials_filetype FILE
i_output_bucket_locationtype STRING
i_output_bucket_nametype STRING
i_modeltype STRING optional
i_input_credentials_file_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_output_credentials_file_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_BATCH_STATUS
raisingzcx_ibmc_service_exception
Submit a batch-processing request. + +
Parameters
i_function + The Compare and Comply method to run across the submitted input documents. +
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. +
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`. +
i_input_bucket_name + The name of the Cloud Object Storage input bucket. +
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. +
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`. +
i_output_bucket_name + The name of the Cloud Object Storage output bucket. +
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. + +
e_response + Service return value of type T_BATCH_STATUS +
public instance
delete_feedback
importingi_feedback_idtype STRING
i_modeltype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_FEEDBACK_DELETED
raisingzcx_ibmc_service_exception
Delete a specified feedback entry. + +
Parameters
i_feedback_id + A string that specifies the feedback entry to be deleted from the document. +
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. + +
e_response + Service return value of type T_FEEDBACK_DELETED +
public instance
extract_tables
importingi_filetype FILE
i_file_content_typetype STRING optional
i_modeltype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TABLE_RETURN
raisingzcx_ibmc_service_exception
Extract a document's tables. + +
Parameters
i_file + The document on which to run table extraction. +
i_file_content_type + The content type of file. +
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. + +
e_response + Service return value of type T_TABLE_RETURN +
public instanceget_appname redefinition 
public instance
get_batch
importingi_batch_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_BATCH_STATUS
raisingzcx_ibmc_service_exception
Get information about a specific batch-processing job. + +
Parameters
i_batch_id + The ID of the batch-processing job whose information you want to retrieve. +
e_response + Service return value of type T_BATCH_STATUS +
public instance
get_feedback
importingi_feedback_idtype STRING
i_modeltype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GET_FEEDBACK
raisingzcx_ibmc_service_exception
Get a specified feedback entry. + +
Parameters
i_feedback_id + A string that specifies the feedback entry to be included in the output. +
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. + +
e_response + Service return value of type T_GET_FEEDBACK +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
list_batches
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_BATCHES
raisingzcx_ibmc_service_exception
List submitted batch-processing jobs. + +
Parameters
e_response + Service return value of type T_BATCHES +
public instance
list_feedback
importingi_feedback_typetype STRING optional
i_beforetype DATE optional
i_aftertype DATE optional
i_document_titletype STRING optional
i_model_idtype STRING optional
i_model_versiontype STRING optional
i_category_removedtype STRING optional
i_category_addedtype STRING optional
i_category_not_changedtype STRING optional
i_type_removedtype STRING optional
i_type_addedtype STRING optional
i_type_not_changedtype STRING optional
i_page_limittype INTEGER optional
i_cursortype STRING optional
i_sorttype STRING optional
i_include_totaltype BOOLEAN optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_FEEDBACK_LIST
raisingzcx_ibmc_service_exception
List the feedback in a document. + +
Parameters
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`. +
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. +
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. +
i_document_title + An optional string that filters the output to include only feedback from the + document with the specified `document_title`. +
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`. +
i_model_version + An optional string that filters the output to include only feedback with the + specified `model_version`. +
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. +
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. +
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. +
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. +
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. +
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. +
i_page_limit + An optional integer specifying the number of documents that you want the service + to return. +
i_cursor + An optional string that returns the set of documents after the previous set. Use + this parameter with the `page_limit` 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`. +
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. +
e_response + Service return value of type T_FEEDBACK_LIST +
public instance
update_batch
importingi_batch_idtype STRING
i_actiontype STRING
i_modeltype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_BATCH_STATUS
raisingzcx_ibmc_service_exception
Update a pending or active batch-processing job. + +
Parameters
i_batch_id + The ID of the batch-processing job you want to update. +
i_action + The action you want to perform on the specified batch-processing job. +
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. + +
e_response + Service return value of type T_BATCH_STATUS +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_discovery_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_discovery_v1.html new file mode 100644 index 0000000..14945b0 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_discovery_v1.html @@ -0,0 +1,774 @@ +Class ZCL_IBMC_DISCOVERY_V1

Class ZCL_IBMC_DISCOVERY_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_aggregation_result (structured type) Aggregation results for the specified query.
publict_calculation (structured type) 
publict_collection (structured type) A collection for storing documents.
publict_collection_crawl_status (structured type) Object containing information about the crawl status of this collection.
publict_collection_disk_usage (structured type) Summary of the disk usage statistics for this collection.
publict_collection_usage (structured type) Summary of the collection usage in the environment.
publict_coll_query_large (structured type) Object that describes a long query.
publict_completions (structured type) An object containing an array of autocompletion suggestions.
publict_configuration (structured type) A custom configuration for the environment.
publict_conversions (structured type) Document conversion settings.
publict_create_collection_request (structured type) Object containing specification for a new collection.
publict_create_environment_request (structured type) Object containing information about a new environment.
publict_create_event_object (structured type) An object defining the event being created.
publict_create_event_response (structured type) An object defining the event being created.
publict_credentials (structured type) Object containing credential information.
publict_credentials_list (structured type) Object containing array of credential definitions.
publict_credential_details (structured type) Object containing details of the stored credentials. + + Obtain credentials for your source from the administrator of the source.
publict_delete_collection_response (structured type) Response object returned when deleting a colleciton.
publict_delete_credentials (structured type) Object returned after credentials are deleted.
publict_delete_document_response (structured type) Information returned when a document is deleted.
publict_delete_environment_response (structured type) Response object returned when deleting an environment.
publict_del_configuration_response (structured type) Information returned when a configuration is deleted.
publict_disk_usage (structured type) Summary of the disk usage statistics for the environment.
publict_document_accepted (structured type) Information returned after an uploaded document is accepted.
publict_document_counts (structured type) Object containing collection document count information.
publict_document_status (structured type) Status information about a submitted document.
publict_elements_enrichment_options (structured type) An object representing the configuration options to use for the `elements` + enrichment.
publict_enrichment (structured type) 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.
publict_enrichments TYPE STANDARD TABLE OF T_ENRICHMENT WITH NON-UNIQUE DEFAULT KEY An array of document enrichment settings for the configuration.
publict_enrichment_options (structured type) Options which are specific to a particular enrichment.
publict_environment (structured type) Details about an environment.
publict_environment_documents (structured type) Summary of the document usage statistics for the environment.
publict_error_response (structured type) An error response object.
publict_event_data (structured type) Query event data object.
publict_expansion (structured type) 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.
publict_expansions (structured type) The query expansion definitions for the specified collection.
publict_fed_query_large (structured type) Object that describes a long query.
publict_field (structured type) Object containing field details.
publict_filter (structured type) 
publict_font_setting (structured type) Font matching configuration.
publict_font_settings TYPE STANDARD TABLE OF T_FONT_SETTING WITH NON-UNIQUE DEFAULT KEY Array of font matching configurations.
publict_gateway (structured type) Object describing a specific gateway.
publict_gateway_delete (structured type) Gatway deletion confirmation.
publict_gateway_list (structured type) Object containing gateways array.
publict_gateway_name (structured type) Object containing user-defined name.
publict_histogram (structured type) 
publict_html_settings (structured type) A list of HTML conversion settings.
publict_index_capacity (structured type) Details about the resource usage and capacity of the environment.
publict_inline_object (structured type) 
publict_list_collections_response (structured type) Response object containing an array of collection details.
publict_list_configurations_response (structured type) Object containing an array of available configurations.
publict_list_environments_response (structured type) Response object containing an array of configured environments.
publict_log_qry_resp_rslt_docs_rslt (structured type) Each object in the **results** array corresponds to an individual document + returned by the original query.
publict_log_query_response (structured type) Object containing results that match the requested **logs** query.
publict_log_query_response_result (structured type) 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.
publict_log_query_resp_result_docs (structured type) Object containing result information that was returned by the query used to + create this log entry. Only returned with logs of type `query`.
publict_lst_collection_fields_resp (structured type) 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`).
publict_metric_aggregation (structured type) An aggregation analyzing log information for queries and events.
publict_metric_aggregation_result (structured type) Aggregation result data for the requested metric.
publict_metric_response (structured type) The response generated from a call to a **metrics** method.
publict_metric_token_aggregation (structured type) An aggregation analyzing log information for queries and events.
publict_metric_token_aggr_result (structured type) Aggregation result data for the requested metric.
publict_metric_token_response (structured type) The response generated from a call to a **metrics** method that evaluates + tokens.
publict_nested (structured type) 
publict_new_training_query (structured type) Training query to add.
publict_nlu_enrichment_categories type MAP An object that indicates the Categories enrichment will be applied to the + specified field.
publict_nlu_enrichment_concepts (structured type) An object specifiying the concepts enrichment and related parameters.
publict_nlu_enrichment_emotion (structured type) An object specifying the emotion detection enrichment and related parameters.
publict_nlu_enrichment_entities (structured type) An object speficying the Entities enrichment and related parameters.
publict_nlu_enrichment_features (structured type) Object containing Natural Language Understanding features to be used.
publict_nlu_enrichment_keywords (structured type) An object specifying the Keyword enrichment and related parameters.
publict_nlu_enrichment_options (structured type) An object representing the configuration options to use for the + `natural_language_understanding` enrichments.
publict_nlu_enrichment_relations (structured type) An object specifying the relations enrichment and related parameters.
publict_nlu_enrichment_sentiment (structured type) An object specifying the sentiment extraction enrichment and related parameters. +
publict_nl_enrichment_semantic_roles (structured type) An object specifiying the semantic roles enrichment and related parameters.
publict_normalizations TYPE STANDARD TABLE OF T_NORMALIZATION_OPERATION 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.
publict_normalization_operation (structured type) Object containing normalization operations.
publict_notice (structured type) A notice produced for the collection.
publict_pdf_heading_detection (structured type) Object containing heading detection conversion settings for PDF documents.
publict_pdf_settings (structured type) A list of PDF conversion settings.
publict_query_aggregation (structured type) An aggregation produced by Discovery to analyze the input provided.
publict_query_large (structured type) Object that describes a long query.
publict_query_notices_response (structured type) Object containing notice query results.
publict_query_notices_result (structured type) Query result object.
publict_query_passages (structured type) A passage query result.
publict_query_response (structured type) A response containing the documents and aggregations for the query.
publict_query_result (structured type) Query result object.
publict_query_result_metadata (structured type) Metadata of a query result.
publict_retrieval_details (structured type) An object contain retrieval type information.
publict_sdu_status (structured type) Object containing smart document understanding information for this collection.
publict_sdu_status_custom_fields (structured type) Information about custom smart document understanding fields that exist in this + collection.
publict_search_status (structured type) Information about the Continuous Relevancy Training for this environment.
publict_segment_settings (structured type) A list of Document Segmentation settings.
publict_source (structured type) Object containing source parameters for the configuration.
publict_source_options (structured type) The **options** object defines which items to crawl from the source system.
publict_source_options_buckets (structured type) Object defining a cloud object store bucket to crawl.
publict_source_options_folder (structured type) Object that defines a box folder to crawl with this configuration.
publict_source_options_object (structured type) Object that defines a Salesforce document object type crawl with this + configuration.
publict_source_options_site_coll (structured type) Object that defines a Microsoft SharePoint site collection to crawl with this + configuration.
publict_source_options_web_crawl (structured type) Object defining which URL to crawl and how to crawl it.
publict_source_schedule (structured type) Object containing the schedule information for the source.
publict_source_status (structured type) Object containing source crawl status information.
publict_term (structured type) 
publict_timeslice (structured type) 
publict_token_dict (structured type) Tokenization dictionary describing how words are tokenized during ingestion and + at query time.
publict_token_dict_rule (structured type) An object defining a single tokenizaion rule.
publict_token_dict_status_response (structured type) Object describing the current status of the wordlist.
publict_top_hits (structured type) 
publict_top_hits_results (structured type) Top hit information for this query.
publict_training_data_set (structured type) Training information for a specific collection.
publict_training_example (structured type) Training example details.
publict_training_example_list (structured type) Object containing an array of training examples.
publict_training_example_patch (structured type) Training example to add.
publict_training_query (structured type) Training query details.
publict_training_status (structured type) Training status details.
publict_update_collection_request (structured type) Object containing collection update information.
publict_update_environment_request (structured type) Object containing environment update information.
publict_word_heading_detection (structured type) Object containing heading detection conversion settings for Microsoft Word + documents.
publict_word_settings (structured type) A list of Word conversion settings.
publict_word_style (structured type) Microsoft Word styles to convert into a specified HTML head level.
publict_word_styles TYPE STANDARD TABLE OF T_WORD_STYLE WITH NON-UNIQUE DEFAULT KEY Array of Microsoft Word styles to convert.
publict_xpath_patterns (structured type) Object containing an array of XPaths.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
add_document
importingi_environment_idtype STRING
i_collection_idtype STRING
i_filetype FILE optional
i_filenametype STRING optional
i_file_content_typetype STRING optional
i_metadatatype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_ACCEPTED
raisingzcx_ibmc_service_exception
Add a document. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
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 confiruration is 1 megabyte. Files larger than the supported + size are rejected. +
i_filename + The filename for file. +
i_file_content_type + The content type of file. +
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" + } ```. +
e_response + Service return value of type T_DOCUMENT_ACCEPTED +
public instance
add_training_data
importingi_environment_idtype STRING
i_collection_idtype STRING
i_bodytype T_NEW_TRAINING_QUERY
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_QUERY
raisingzcx_ibmc_service_exception
Add query to training data. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_body + The body of the training data query that is to be added to the collection's + training data. +
e_response + Service return value of type T_TRAINING_QUERY +
public instance
create_collection
importingi_environment_idtype STRING
i_bodytype T_CREATE_COLLECTION_REQUEST
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Create a collection. + +
Parameters
i_environment_id + The ID of the environment. +
i_body + Input an object that allows you to add a collection. +
e_response + Service return value of type T_COLLECTION +
public instance
create_configuration
importingi_environment_idtype STRING
i_configurationtype T_CONFIGURATION
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CONFIGURATION
raisingzcx_ibmc_service_exception
Add configuration. + +
Parameters
i_environment_id + The ID of the environment. +
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. +
e_response + Service return value of type T_CONFIGURATION +
public instance
create_credentials
importingi_environment_idtype STRING
i_credentials_parametertype T_CREDENTIALS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CREDENTIALS
raisingzcx_ibmc_service_exception
Create credentials. + +
Parameters
i_environment_id + The ID of the environment. +
i_credentials_parameter + An object that defines an individual set of source credentials. +
e_response + Service return value of type T_CREDENTIALS +
public instance
create_environment
importingi_bodytype T_CREATE_ENVIRONMENT_REQUEST
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENVIRONMENT
raisingzcx_ibmc_service_exception
Create an environment. + +
Parameters
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. +
e_response + Service return value of type T_ENVIRONMENT +
public instance
create_event
importingi_query_eventtype T_CREATE_EVENT_OBJECT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CREATE_EVENT_RESPONSE
raisingzcx_ibmc_service_exception
Create event. + +
Parameters
i_query_event + An object that defines a query event to be added to the log. +
e_response + Service return value of type T_CREATE_EVENT_RESPONSE +
public instance
create_expansions
importingi_environment_idtype STRING
i_collection_idtype STRING
i_bodytype T_EXPANSIONS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXPANSIONS
raisingzcx_ibmc_service_exception
Create or update expansion list. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_body + An object that defines the expansion list. +
e_response + Service return value of type T_EXPANSIONS +
public instance
create_gateway
importingi_environment_idtype STRING
i_gateway_nametype T_GATEWAY_NAME optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GATEWAY
raisingzcx_ibmc_service_exception
Create Gateway. + +
Parameters
i_environment_id + The ID of the environment. +
i_gateway_name + The name of the gateway to created. +
e_response + Service return value of type T_GATEWAY +
public instance
create_stopword_list
importingi_environment_idtype STRING
i_collection_idtype STRING
i_stopword_filetype FILE
i_stopword_filenametype STRING
i_stopword_file_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TOKEN_DICT_STATUS_RESPONSE
raisingzcx_ibmc_service_exception
Create stopword list. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_stopword_file + The content of the stopword list to ingest. +
i_stopword_filename + The filename for stopwordFile. +
e_response + Service return value of type T_TOKEN_DICT_STATUS_RESPONSE +
public instance
create_tokenization_dictionary
importingi_environment_idtype STRING
i_collection_idtype STRING
i_tokenization_dictionarytype T_TOKEN_DICT optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TOKEN_DICT_STATUS_RESPONSE
raisingzcx_ibmc_service_exception
Create tokenization dictionary. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_tokenization_dictionary + An object that represents the tokenization dictionary to be uploaded. +
e_response + Service return value of type T_TOKEN_DICT_STATUS_RESPONSE +
public instance
create_training_example
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_bodytype T_TRAINING_EXAMPLE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_EXAMPLE
raisingzcx_ibmc_service_exception
Add example to training data query. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
i_body + The body of the example that is to be added to the specified query. +
e_response + Service return value of type T_TRAINING_EXAMPLE +
public instance
delete_all_training_data
importingi_environment_idtype STRING
i_collection_idtype STRING
raisingzcx_ibmc_service_exception
Delete all training data. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
public instance
delete_collection
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_COLLECTION_RESPONSE
raisingzcx_ibmc_service_exception
Delete a collection. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_DELETE_COLLECTION_RESPONSE +
public instance
delete_configuration
importingi_environment_idtype STRING
i_configuration_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DEL_CONFIGURATION_RESPONSE
raisingzcx_ibmc_service_exception
Delete a configuration. + +
Parameters
i_environment_id + The ID of the environment. +
i_configuration_id + The ID of the configuration. +
e_response + Service return value of type T_DEL_CONFIGURATION_RESPONSE +
public instance
delete_credentials
importingi_environment_idtype STRING
i_credential_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_CREDENTIALS
raisingzcx_ibmc_service_exception
Delete credentials. + +
Parameters
i_environment_id + The ID of the environment. +
i_credential_id + The unique identifier for a set of source credentials. +
e_response + Service return value of type T_DELETE_CREDENTIALS +
public instance
delete_document
importingi_environment_idtype STRING
i_collection_idtype STRING
i_document_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_DOCUMENT_RESPONSE
raisingzcx_ibmc_service_exception
Delete a document. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_document_id + The ID of the document. +
e_response + Service return value of type T_DELETE_DOCUMENT_RESPONSE +
public instance
delete_environment
importingi_environment_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_ENVIRONMENT_RESPONSE
raisingzcx_ibmc_service_exception
Delete environment. + +
Parameters
i_environment_id + The ID of the environment. +
e_response + Service return value of type T_DELETE_ENVIRONMENT_RESPONSE +
public instance
delete_expansions
importingi_environment_idtype STRING
i_collection_idtype STRING
raisingzcx_ibmc_service_exception
Delete the expansion list. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
public instance
delete_gateway
importingi_environment_idtype STRING
i_gateway_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GATEWAY_DELETE
raisingzcx_ibmc_service_exception
Delete Gateway. + +
Parameters
i_environment_id + The ID of the environment. +
i_gateway_id + The requested gateway ID. +
e_response + Service return value of type T_GATEWAY_DELETE +
public instance
delete_stopword_list
importingi_environment_idtype STRING
i_collection_idtype STRING
raisingzcx_ibmc_service_exception
Delete a custom stopword list. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
public instance
delete_tokenization_dictionary
importingi_environment_idtype STRING
i_collection_idtype STRING
raisingzcx_ibmc_service_exception
Delete tokenization dictionary. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
public instance
delete_training_data
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
raisingzcx_ibmc_service_exception
Delete a training data query. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
public instance
delete_training_example
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_example_idtype STRING
raisingzcx_ibmc_service_exception
Delete example for training data query. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
i_example_id + The ID of the document as it is indexed. +
public instance
delete_user_data
importingi_customer_idtype STRING
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instance
federated_query
importingi_environment_idtype STRING
i_query_longtype T_FED_QUERY_LARGE optional
i_x_watson_logging_opt_outtype BOOLEAN default C_BOOLEAN_FALSE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_QUERY_RESPONSE
raisingzcx_ibmc_service_exception
Query multiple collections. + +
Parameters
i_environment_id + The ID of the environment. +
i_query_long + +
i_x_watson_logging_opt_out + If `true`, queries are not stored in the Discovery **Logs** endpoint. +
e_response + Service return value of type T_QUERY_RESPONSE +
public instance
federated_query_notices
importingi_environment_idtype STRING
i_collection_idstype TT_STRING
i_filtertype STRING optional
i_querytype STRING optional
i_natural_language_querytype STRING optional
i_aggregationtype STRING optional
i_counttype INTEGER optional
i_returntype TT_STRING optional
i_offsettype INTEGER optional
i_sorttype TT_STRING optional
i_highlighttype BOOLEAN default C_BOOLEAN_FALSE
i_deduplicate_fieldtype STRING optional
i_similartype BOOLEAN default C_BOOLEAN_FALSE
i_similar_document_idstype TT_STRING optional
i_similar_fieldstype TT_STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_QUERY_NOTICES_RESPONSE
raisingzcx_ibmc_service_exception
Query multiple collection system notices. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_ids + A comma-separated list of collection IDs to be queried against. +
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. +
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. +
i_natural_language_query + A natural language query that returns relevant documents by utilizing training + data and natural language understanding. +
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. +
i_count + Number of results to return. The maximum for the **count** and **offset** values + together in any one query is **10000**. +
i_return + A comma-separated list of the portion of the document hierarchy to return. +
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**. +
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. +
i_highlight + When true, a highlight field is returned for each result which contains the + fields which match the query with `` tags around the matching query + terms. +
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. +
i_similar + When `true`, results are returned based on their similarity to the document IDs + specified in the **similar.document_ids** 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. +
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. +
e_response + Service return value of type T_QUERY_NOTICES_RESPONSE +
public instanceget_appname redefinition 
public instance
get_autocompletion
importingi_environment_idtype STRING
i_collection_idtype STRING
i_fieldtype STRING optional
i_prefixtype STRING optional
i_counttype INTEGER optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COMPLETIONS
raisingzcx_ibmc_service_exception
Get Autocomplete Suggestions. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_field + The field in the result documents that autocompletion suggestions are identified + from. +
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. +
i_count + The number of autocompletion suggestions to return. +
e_response + Service return value of type T_COMPLETIONS +
public instance
get_collection
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Get collection details. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_COLLECTION +
public instance
get_configuration
importingi_environment_idtype STRING
i_configuration_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CONFIGURATION
raisingzcx_ibmc_service_exception
Get configuration details. + +
Parameters
i_environment_id + The ID of the environment. +
i_configuration_id + The ID of the configuration. +
e_response + Service return value of type T_CONFIGURATION +
public instance
get_credentials
importingi_environment_idtype STRING
i_credential_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CREDENTIALS
raisingzcx_ibmc_service_exception
View Credentials. + +
Parameters
i_environment_id + The ID of the environment. +
i_credential_id + The unique identifier for a set of source credentials. +
e_response + Service return value of type T_CREDENTIALS +
public instance
get_document_status
importingi_environment_idtype STRING
i_collection_idtype STRING
i_document_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_STATUS
raisingzcx_ibmc_service_exception
Get document details. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_document_id + The ID of the document. +
e_response + Service return value of type T_DOCUMENT_STATUS +
public instance
get_environment
importingi_environment_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENVIRONMENT
raisingzcx_ibmc_service_exception
Get environment info. + +
Parameters
i_environment_id + The ID of the environment. +
e_response + Service return value of type T_ENVIRONMENT +
public instance
get_gateway
importingi_environment_idtype STRING
i_gateway_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GATEWAY
raisingzcx_ibmc_service_exception
List Gateway Details. + +
Parameters
i_environment_id + The ID of the environment. +
i_gateway_id + The requested gateway ID. +
e_response + Service return value of type T_GATEWAY +
public instance
get_metrics_event_rate
importingi_start_timetype DATETIME optional
i_end_timetype DATETIME optional
i_result_typetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_METRIC_RESPONSE
raisingzcx_ibmc_service_exception
Percentage of queries with an associated event. + +
Parameters
i_start_time + Metric is computed from data recorded after this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_end_time + Metric is computed from data recorded before this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_result_type + The type of result to consider when calculating the metric. +
e_response + Service return value of type T_METRIC_RESPONSE +
public instance
get_metrics_query
importingi_start_timetype DATETIME optional
i_end_timetype DATETIME optional
i_result_typetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_METRIC_RESPONSE
raisingzcx_ibmc_service_exception
Number of queries over time. + +
Parameters
i_start_time + Metric is computed from data recorded after this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_end_time + Metric is computed from data recorded before this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_result_type + The type of result to consider when calculating the metric. +
e_response + Service return value of type T_METRIC_RESPONSE +
public instance
get_metrics_query_event
importingi_start_timetype DATETIME optional
i_end_timetype DATETIME optional
i_result_typetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_METRIC_RESPONSE
raisingzcx_ibmc_service_exception
Number of queries with an event over time. + +
Parameters
i_start_time + Metric is computed from data recorded after this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_end_time + Metric is computed from data recorded before this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_result_type + The type of result to consider when calculating the metric. +
e_response + Service return value of type T_METRIC_RESPONSE +
public instance
get_metrics_query_no_results
importingi_start_timetype DATETIME optional
i_end_timetype DATETIME optional
i_result_typetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_METRIC_RESPONSE
raisingzcx_ibmc_service_exception
Number of queries with no search results over time. + +
Parameters
i_start_time + Metric is computed from data recorded after this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_end_time + Metric is computed from data recorded before this timestamp; must be in + `YYYY-MM-DDThh:mm:ssZ` format. +
i_result_type + The type of result to consider when calculating the metric. +
e_response + Service return value of type T_METRIC_RESPONSE +
public instance
get_metrics_query_token_event
importingi_counttype INTEGER optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_METRIC_TOKEN_RESPONSE
raisingzcx_ibmc_service_exception
Most frequent query tokens with an event. + +
Parameters
i_count + Number of results to return. The maximum for the **count** and **offset** values + together in any one query is **10000**. +
e_response + Service return value of type T_METRIC_TOKEN_RESPONSE +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
get_stopword_list_status
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TOKEN_DICT_STATUS_RESPONSE
raisingzcx_ibmc_service_exception
Get stopword list status. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_TOKEN_DICT_STATUS_RESPONSE +
public instance
get_tokenization_dict_status
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TOKEN_DICT_STATUS_RESPONSE
raisingzcx_ibmc_service_exception
Get tokenization dictionary status. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_TOKEN_DICT_STATUS_RESPONSE +
public instance
get_training_data
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_QUERY
raisingzcx_ibmc_service_exception
Get details about a query. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
e_response + Service return value of type T_TRAINING_QUERY +
public instance
get_training_example
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_example_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_EXAMPLE
raisingzcx_ibmc_service_exception
Get details for training data example. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
i_example_id + The ID of the document as it is indexed. +
e_response + Service return value of type T_TRAINING_EXAMPLE +
public instance
list_collections
importingi_environment_idtype STRING
i_nametype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LIST_COLLECTIONS_RESPONSE
raisingzcx_ibmc_service_exception
List collections. + +
Parameters
i_environment_id + The ID of the environment. +
i_name + Find collections with the given name. +
e_response + Service return value of type T_LIST_COLLECTIONS_RESPONSE +
public instance
list_collection_fields
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LST_COLLECTION_FIELDS_RESP
raisingzcx_ibmc_service_exception
List collection fields. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_LST_COLLECTION_FIELDS_RESP +
public instance
list_configurations
importingi_environment_idtype STRING
i_nametype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LIST_CONFIGURATIONS_RESPONSE
raisingzcx_ibmc_service_exception
List configurations. + +
Parameters
i_environment_id + The ID of the environment. +
i_name + Find configurations with the given name. +
e_response + Service return value of type T_LIST_CONFIGURATIONS_RESPONSE +
public instance
list_credentials
importingi_environment_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CREDENTIALS_LIST
raisingzcx_ibmc_service_exception
List credentials. + +
Parameters
i_environment_id + The ID of the environment. +
e_response + Service return value of type T_CREDENTIALS_LIST +
public instance
list_environments
importingi_nametype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LIST_ENVIRONMENTS_RESPONSE
raisingzcx_ibmc_service_exception
List environments. + +
Parameters
i_name + Show only the environment with the given name. +
e_response + Service return value of type T_LIST_ENVIRONMENTS_RESPONSE +
public instance
list_expansions
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_EXPANSIONS
raisingzcx_ibmc_service_exception
Get the expansion list. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_EXPANSIONS +
public instance
list_fields
importingi_environment_idtype STRING
i_collection_idstype TT_STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LST_COLLECTION_FIELDS_RESP
raisingzcx_ibmc_service_exception
List fields across collections. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_ids + A comma-separated list of collection IDs to be queried against. +
e_response + Service return value of type T_LST_COLLECTION_FIELDS_RESP +
public instance
list_gateways
importingi_environment_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GATEWAY_LIST
raisingzcx_ibmc_service_exception
List Gateways. + +
Parameters
i_environment_id + The ID of the environment. +
e_response + Service return value of type T_GATEWAY_LIST +
public instance
list_training_data
importingi_environment_idtype STRING
i_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_DATA_SET
raisingzcx_ibmc_service_exception
List training data. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
e_response + Service return value of type T_TRAINING_DATA_SET +
public instance
list_training_examples
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_EXAMPLE_LIST
raisingzcx_ibmc_service_exception
List examples for a training data query. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
e_response + Service return value of type T_TRAINING_EXAMPLE_LIST +
public instance
query
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_longtype T_COLL_QUERY_LARGE optional
i_x_watson_logging_opt_outtype BOOLEAN default C_BOOLEAN_FALSE
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_QUERY_RESPONSE
raisingzcx_ibmc_service_exception
Query a collection. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_long + An object that represents the query to be submitted. +
i_x_watson_logging_opt_out + If `true`, queries are not stored in the Discovery **Logs** endpoint. +
e_response + Service return value of type T_QUERY_RESPONSE +
public instance
query_log
importingi_filtertype STRING optional
i_querytype STRING optional
i_counttype INTEGER optional
i_offsettype INTEGER optional
i_sorttype TT_STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LOG_QUERY_RESPONSE
raisingzcx_ibmc_service_exception
Search the query and event log. + +
Parameters
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. +
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. +
i_count + Number of results to return. The maximum for the **count** and **offset** values + together in any one query is **10000**. +
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**. +
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. +
e_response + Service return value of type T_LOG_QUERY_RESPONSE +
public instance
query_notices
importingi_environment_idtype STRING
i_collection_idtype STRING
i_filtertype STRING optional
i_querytype STRING optional
i_natural_language_querytype STRING optional
i_passagestype BOOLEAN optional
i_aggregationtype STRING optional
i_counttype INTEGER optional
i_returntype TT_STRING optional
i_offsettype INTEGER optional
i_sorttype TT_STRING optional
i_highlighttype BOOLEAN default C_BOOLEAN_FALSE
i_passages_fieldstype TT_STRING optional
i_passages_counttype INTEGER optional
i_passages_characterstype INTEGER optional
i_deduplicate_fieldtype STRING optional
i_similartype BOOLEAN default C_BOOLEAN_FALSE
i_similar_document_idstype TT_STRING optional
i_similar_fieldstype TT_STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_QUERY_NOTICES_RESPONSE
raisingzcx_ibmc_service_exception
Query system notices. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
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. +
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. +
i_natural_language_query + A natural language query that returns relevant documents by utilizing training + data and natural language understanding. +
i_passages + A passages query that returns the most relevant passages from the results. +
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. +
i_count + Number of results to return. The maximum for the **count** and **offset** values + together in any one query is **10000**. +
i_return + A comma-separated list of the portion of the document hierarchy to return. +
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**. +
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. +
i_highlight + When true, a highlight field is returned for each result which contains the + fields which match the query with `` tags around the matching query + terms. +
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. +
i_passages_count + The maximum number of passages to return. The search returns fewer passages if + the requested total is not found. +
i_passages_characters + The approximate number of characters that any one passage will have. +
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. +
i_similar + When `true`, results are returned based on their similarity to the document IDs + specified in the **similar.document_ids** 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. +
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. +
e_response + Service return value of type T_QUERY_NOTICES_RESPONSE +
public instance
update_collection
importingi_environment_idtype STRING
i_collection_idtype STRING
i_bodytype T_UPDATE_COLLECTION_REQUEST optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Update a collection. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_body + Input an object that allows you to update a collection. +
e_response + Service return value of type T_COLLECTION +
public instance
update_configuration
importingi_environment_idtype STRING
i_configuration_idtype STRING
i_configurationtype T_CONFIGURATION
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CONFIGURATION
raisingzcx_ibmc_service_exception
Update a configuration. + +
Parameters
i_environment_id + The ID of the environment. +
i_configuration_id + The ID of the configuration. +
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. +
e_response + Service return value of type T_CONFIGURATION +
public instance
update_credentials
importingi_environment_idtype STRING
i_credential_idtype STRING
i_credentials_parametertype T_CREDENTIALS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CREDENTIALS
raisingzcx_ibmc_service_exception
Update credentials. + +
Parameters
i_environment_id + The ID of the environment. +
i_credential_id + The unique identifier for a set of source credentials. +
i_credentials_parameter + An object that defines an individual set of source credentials. +
e_response + Service return value of type T_CREDENTIALS +
public instance
update_document
importingi_environment_idtype STRING
i_collection_idtype STRING
i_document_idtype STRING
i_filetype FILE optional
i_filenametype STRING optional
i_file_content_typetype STRING optional
i_metadatatype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_ACCEPTED
raisingzcx_ibmc_service_exception
Update a document. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_document_id + The ID of the document. +
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 confiruration is 1 megabyte. Files larger than the supported + size are rejected. +
i_filename + The filename for file. +
i_file_content_type + The content type of file. +
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" + } ```. +
e_response + Service return value of type T_DOCUMENT_ACCEPTED +
public instance
update_environment
importingi_environment_idtype STRING
i_bodytype T_UPDATE_ENVIRONMENT_REQUEST
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ENVIRONMENT
raisingzcx_ibmc_service_exception
Update an environment. + +
Parameters
i_environment_id + The ID of the environment. +
i_body + An object that defines the environment's name and, optionally, description. +
e_response + Service return value of type T_ENVIRONMENT +
public instance
update_training_example
importingi_environment_idtype STRING
i_collection_idtype STRING
i_query_idtype STRING
i_example_idtype STRING
i_bodytype T_TRAINING_EXAMPLE_PATCH
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_EXAMPLE
raisingzcx_ibmc_service_exception
Change label or cross reference for example. + +
Parameters
i_environment_id + The ID of the environment. +
i_collection_id + The ID of the collection. +
i_query_id + The ID of the query used for training. +
i_example_id + The ID of the document as it is indexed. +
i_body + The body of the example that is to be added to the specified query. +
e_response + Service return value of type T_TRAINING_EXAMPLE +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_lang_translator_v3.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_lang_translator_v3.html new file mode 100644 index 0000000..a14399f --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_lang_translator_v3.html @@ -0,0 +1,136 @@ +Class ZCL_IBMC_LANG_TRANSLATOR_V3

Class ZCL_IBMC_LANG_TRANSLATOR_V3

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_base_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.
publict_delete_model_result (structured type) 
publict_document_id type STRING System generated ID identifying a document being translated using one specific + translation model.
publict_document_list (structured type) 
publict_document_status (structured type) Document information, including translation status.
publict_error_response (structured type) 
publict_identifiable_language (structured type) 
publict_identifiable_languages (structured type) 
publict_identified_language (structured type) 
publict_identified_languages (structured type) 
publict_inline_object (structured type) 
publict_inline_object1 (structured type) 
publict_model_id type STRING A globally unique string that identifies the underlying model that is used for + translation.
publict_source type STRING Translation source language code.
publict_target type STRING Translation target language code.
publict_translate_request (structured type) 
publict_translation (structured type) 
publict_translation_model (structured type) Response payload for models.
publict_translation_models (structured type) The response type for listing existing translation models.
publict_translation_result (structured type) 
publict_translation_status type STRING The status of the translation job associated with a submitted document.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
create_model
importingi_base_model_idtype STRING
i_forced_glossarytype FILE optional
i_parallel_corpustype FILE optional
i_nametype STRING optional
i_forced_glossary_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_parallel_corpus_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRANSLATION_MODEL
raisingzcx_ibmc_service_exception
Create model. + +
Parameters
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. +
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. +
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. +
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. +
e_response + Service return value of type T_TRANSLATION_MODEL +
public instance
delete_document
importingi_document_idtype STRING
raisingzcx_ibmc_service_exception
Delete document. + +
Parameters
i_document_id + Document ID of the document to delete. +
public instance
delete_model
importingi_model_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_MODEL_RESULT
raisingzcx_ibmc_service_exception
Delete model. + +
Parameters
i_model_id + Model ID of the model to delete. +
e_response + Service return value of type T_DELETE_MODEL_RESULT +
public instanceget_appname redefinition 
public instance
get_document_status
importingi_document_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_STATUS
raisingzcx_ibmc_service_exception
Get document status. + +
Parameters
i_document_id + The document ID of the document. +
e_response + Service return value of type T_DOCUMENT_STATUS +
public instance
get_model
importingi_model_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRANSLATION_MODEL
raisingzcx_ibmc_service_exception
Get model details. + +
Parameters
i_model_id + Model ID of the model to get. +
e_response + Service return value of type T_TRANSLATION_MODEL +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
get_translated_document
importingi_document_idtype STRING
i_accepttype STRING optional
exportinge_responsetype FILE
raisingzcx_ibmc_service_exception
Get translated document. + +
Parameters
i_document_id + The document ID of the document that was submitted for translation. +
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'. +
e_response + Service return value of type FILE +
public instance
identify
importingi_texttype STRING
i_contenttypetype STRING default 'text/plain'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_IDENTIFIED_LANGUAGES
raisingzcx_ibmc_service_exception
Identify language. + +
Parameters
i_text + Input text in UTF-8 format. +
e_response + Service return value of type T_IDENTIFIED_LANGUAGES +
public instance
list_documents
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_LIST
raisingzcx_ibmc_service_exception
List documents. + +
Parameters
e_response + Service return value of type T_DOCUMENT_LIST +
public instance
list_identifiable_languages
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_IDENTIFIABLE_LANGUAGES
raisingzcx_ibmc_service_exception
List identifiable languages. + +
Parameters
e_response + Service return value of type T_IDENTIFIABLE_LANGUAGES +
public instance
list_models
importingi_sourcetype STRING optional
i_targettype STRING optional
i_defaulttype BOOLEAN optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRANSLATION_MODELS
raisingzcx_ibmc_service_exception
List models. + +
Parameters
i_source + Specify a language code to filter results by source language. +
i_target + Specify a language code to filter results by target language. +
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. +
e_response + Service return value of type T_TRANSLATION_MODELS +
public instance
translate
importingi_requesttype T_TRANSLATE_REQUEST
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRANSLATION_RESULT
raisingzcx_ibmc_service_exception
Translate. + +
Parameters
i_request + The translate request containing the text, and either a model ID or source and + target language pair. +
e_response + Service return value of type T_TRANSLATION_RESULT +
public instance
translate_document
importingi_filetype FILE
i_filenametype STRING
i_file_content_typetype STRING optional
i_model_idtype STRING optional
i_sourcetype STRING optional
i_targettype STRING optional
i_document_idtype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DOCUMENT_STATUS
raisingzcx_ibmc_service_exception
Translate document. + +
Parameters
i_file + 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**. +
i_filename + The filename for file. +
i_file_content_type + The content type of file. +
i_model_id + The model to use for translation. `model_id` or both `source` and `target` are + required. +
i_source + Language code that specifies the language of the source document. +
i_target + Language code that specifies the target language for translation. +
i_document_id + To use a previously submitted document as the source for a new translation, + enter the `document_id` of the document. +
e_response + Service return value of type T_DOCUMENT_STATUS +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_class_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_class_v1.html new file mode 100644 index 0000000..16a7506 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_class_v1.html @@ -0,0 +1,52 @@ +Class ZCL_IBMC_NAT_LANG_CLASS_V1

Class ZCL_IBMC_NAT_LANG_CLASS_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_classification (structured type) Response from the classifier for a phrase.
publict_classification_collection (structured type) Response from the classifier for multiple phrases.
publict_classified_class (structured type) Class and confidence.
publict_classifier (structured type) A classifier for natural language phrases.
publict_classifier_list (structured type) List of available classifiers.
publict_classify_collection_input (structured type) Request payload to classify.
publict_classify_input (structured type) Request payload to classify.
publict_collection_item (structured type) Response from the classifier for a phrase in a collection.
publict_empty type JSONOBJECT 
publict_error_cloud (structured type) Response payload for Cloud errors.
publict_error_response (structured type) Response payload for HTTP errors.
publict_inline_object (structured type) 

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
classify
importingi_classifier_idtype STRING
i_bodytype T_CLASSIFY_INPUT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFICATION
raisingzcx_ibmc_service_exception
Classify a phrase. + +
Parameters
i_classifier_id + Classifier ID to use. +
i_body + Phrase to classify. +
e_response + Service return value of type T_CLASSIFICATION +
public instance
classify_collection
importingi_classifier_idtype STRING
i_bodytype T_CLASSIFY_COLLECTION_INPUT
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFICATION_COLLECTION
raisingzcx_ibmc_service_exception
Classify multiple phrases. + +
Parameters
i_classifier_id + Classifier ID to use. +
i_body + Phrase to classify. You can submit up to 30 text phrases in a request. +
e_response + Service return value of type T_CLASSIFICATION_COLLECTION +
public instance
create_classifier
importingi_training_metadatatype FILE
i_training_datatype FILE
i_training_metadata_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_training_data_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER
raisingzcx_ibmc_service_exception
Create classifier. + +
Parameters
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`). +
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/services/natural-language-classifier?to + pic=natural-language-classifier-using-your-data). +
e_response + Service return value of type T_CLASSIFIER +
public instance
delete_classifier
importingi_classifier_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete classifier. + +
Parameters
i_classifier_id + Classifier ID to delete. +
public instanceget_appname redefinition 
public instance
get_classifier
importingi_classifier_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER
raisingzcx_ibmc_service_exception
Get information about a classifier. + +
Parameters
i_classifier_id + Classifier ID to query. +
e_response + Service return value of type T_CLASSIFIER +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
list_classifiers
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER_LIST
raisingzcx_ibmc_service_exception
List classifiers. + +
Parameters
e_response + Service return value of type T_CLASSIFIER_LIST +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_undrstnd_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_undrstnd_v1.html new file mode 100644 index 0000000..27d563a --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_nat_lang_undrstnd_v1.html @@ -0,0 +1,74 @@ +Class ZCL_IBMC_NAT_LANG_UNDRSTND_V1

Class ZCL_IBMC_NAT_LANG_UNDRSTND_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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, relations, and categories in Natural Language + Understanding.

Types

Visibility and LevelNameDocumentation
publict_analysis_results (structured type) Results of the analysis, organized by feature.
publict_analysis_results_metadata (structured type) Webpage metadata, such as the author and the title of the page.
publict_analysis_results_usage (structured type) API usage information for the request.
publict_author (structured type) The author of the analyzed content.
publict_categories_options (structured type) 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.
publict_categories_relevant_text (structured type) Relevant text that contributed to the categorization.
publict_categories_result (structured type) A categorization of the analyzed text.
publict_concepts_options (structured type) 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.
publict_concepts_result (structured type) The general concepts referenced or alluded to in the analyzed text.
publict_ctgrs_result_explanation (structured type) Information that helps to explain what contributed to the categories result.
publict_dbpedia_resource type STRING Link to the corresponding DBpedia resource.
publict_delete_model_results (structured type) Delete model results.
publict_disambiguation_result (structured type) Disambiguation information for the entity.
publict_document_emotion_results (structured type) Emotion results for the document as a whole.
publict_document_sentiment_results (structured type) 
publict_emotion_options (structured type) 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.
publict_emotion_result (structured type) 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.
publict_emotion_scores (structured type) 
publict_entities_options (structured type) 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.
publict_entities_result (structured type) The important people, places, geopolitical entities and other types of entities + in your content.
publict_entity_mention (structured type) 
publict_error_response (structured type) 
publict_features (structured type) Analysis features and options.
publict_features_results (structured type) Analysis results for each requested feature.
publict_features_results_metadata (structured type) Webpage metadata, such as the author and the title of the page.
publict_feature_sentiment_results (structured type) 
publict_feed (structured type) RSS or ATOM feed found on the webpage.
publict_keywords_options (structured type) Returns important keywords in the content. + + Supported languages: English, French, German, Italian, Japanese, Korean, + Portuguese, Russian, Spanish, Swedish.
publict_keywords_result (structured type) The important keywords in the content, organized by relevance.
publict_list_models_results (structured type) Custom models that are available for entities and relations.
publict_metadata_options type JSONOBJECT 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.
publict_metadata_result (structured type) The authors, publication date, title, prominent page image, and RSS/ATOM feeds + of the webpage. Supports URL and HTML input types.
publict_model (structured type) 
publict_parameters (structured type) An object containing request parameters.
publict_relations_options (structured type) 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.
publict_relations_result (structured type) The relations between entities found in the content.
publict_relation_argument (structured type) 
publict_relation_entity (structured type) An entity that corresponds with an argument in a relation.
publict_semantic_roles_action (structured type) 
publict_semantic_roles_entity (structured type) 
publict_semantic_roles_keyword (structured type) 
publict_semantic_roles_object (structured type) 
publict_semantic_roles_options (structured type) Parses sentences into subject, action, and object form. + + Supported languages: English, German, Japanese, Korean, Spanish.
publict_semantic_roles_result (structured type) The object containing the actions and the objects the actions act upon.
publict_semantic_roles_result_action (structured type) The extracted action from the sentence.
publict_semantic_roles_result_object (structured type) The extracted object from the sentence.
publict_semantic_roles_subject (structured type) 
publict_semantic_roles_verb (structured type) 
publict_sentence_result (structured type) 
publict_sentiment_options (structured type) 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.
publict_sentiment_result (structured type) The sentiment of the content.
publict_smntc_roles_result_subject (structured type) The extracted subject from the sentence.
publict_syntax_options (structured type) Returns tokens and sentences from the input text.
publict_syntax_options_tokens (structured type) Tokenization options.
publict_syntax_result (structured type) Tokens and sentences returned from syntax analysis.
publict_targeted_emotion_results (structured type) Emotion results for a specified target.
publict_targeted_sentiment_results (structured type) 
publict_token_result (structured type) 
publict_usage (structured type) Usage information.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
analyze
importingi_parameterstype T_PARAMETERS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ANALYSIS_RESULTS
raisingzcx_ibmc_service_exception
Analyze text. + +
Parameters
i_parameters + An object containing request parameters. The `features` object and one of the + `text`, `html`, or `url` attributes are required. +
e_response + Service return value of type T_ANALYSIS_RESULTS +
public instance
delete_model
importingi_model_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_DELETE_MODEL_RESULTS
raisingzcx_ibmc_service_exception
Delete model. + +
Parameters
i_model_id + Model ID of the model to delete. +
e_response + Service return value of type T_DELETE_MODEL_RESULTS +
public instanceget_appname redefinition 
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
list_models
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_LIST_MODELS_RESULTS
raisingzcx_ibmc_service_exception
List models. + +
Parameters
e_response + Service return value of type T_LIST_MODELS_RESULTS +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_personal_insights_v3.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_personal_insights_v3.html new file mode 100644 index 0000000..7267aee --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_personal_insights_v3.html @@ -0,0 +1,109 @@ +Class ZCL_IBMC_PERSONAL_INSIGHTS_V3

Class ZCL_IBMC_PERSONAL_INSIGHTS_V3

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_behavior (structured type) The temporal behavior for the input content.
publict_cnsmptn_preferences_category (structured type) The consumption preferences that the service inferred from the input content.
publict_consumption_preferences (structured type) A consumption preference that the service inferred from the input content.
publict_content (structured type) The full input content that the service is to analyze.
publict_content_item (structured type) An input content item that the service is to analyze.
publict_csv_file type STRING A CSV file that contains the results of the personality profile that the service + generated for the input content.
publict_error_model (structured type) The error response from a failed request.
publict_profile (structured type) The personality profile that the service generated for the input content.
publict_trait (structured type) The characteristics that the service inferred from the input content.
publict_warning (structured type) A warning message that is associated with the input content.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instanceget_appname redefinition 
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
profile
importingi_contenttype T_CONTENT
i_content_typetype STRING default 'text/plain'
i_content_languagetype STRING default 'en'
i_accept_languagetype STRING default 'en'
i_raw_scorestype BOOLEAN default C_BOOLEAN_FALSE
i_csv_headerstype BOOLEAN default C_BOOLEAN_FALSE
i_consumption_preferencestype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_PROFILE
raisingzcx_ibmc_service_exception
Get profile. + +
Parameters
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`. +
i_content_type + The type of the input. For more information, see **Content types** in the method + description. +
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**. +
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. +
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. +
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`). +
i_consumption_preferences + Indicates whether consumption preferences are returned with the results. By + default, no consumption preferences are returned. +
e_response + Service return value of type T_PROFILE +
public instance
profile_as_csv
importingi_contenttype T_CONTENT
i_content_typetype STRING default 'text/plain'
i_content_languagetype STRING default 'en'
i_accept_languagetype STRING default 'en'
i_raw_scorestype BOOLEAN default C_BOOLEAN_FALSE
i_csv_headerstype BOOLEAN default C_BOOLEAN_FALSE
i_consumption_preferencestype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'text/csv'
raisingzcx_ibmc_service_exception
Get profile as csv. + +
Parameters
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`. +
i_content_type + The type of the input. For more information, see **Content types** in the method + description. +
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**. +
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. +
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. +
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`). +
i_consumption_preferences + Indicates whether consumption preferences are returned with the results. By + default, no consumption preferences are returned. +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service.html new file mode 100644 index 0000000..de7c2ae --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service.html @@ -0,0 +1 @@ +Class ZCL_IBMC_SERVICE

Class ZCL_IBMC_SERVICE

public inheriting from ZCL_IBMC_SERVICE_ARCH create public

Documentation

IBM Watson ABAP SDK - Service Class

Types

Visibility and LevelNameDocumentation
publicbinary type XSTRING 
publicboolean type ZIF_IBMC_SERVICE_ARCH~BOOLEAN 
publicchar type ZIF_IBMC_SERVICE_ARCH~CHAR 
publicdata_reference type ref to DATA 
publicdate type STRING 
publicdatetime (typing) 
publicdouble type F 
publicfieldname (typing) 
publicfile type XSTRING 
publicfloat type F 
publicinteger type I 
publicjsonobject type ref to DATA 
publiclong type INT8 
publicmap type ref to DATA 
publicnumber type F 
publicshort type INT2 
publictime type STRING 
publicts_file_with_metadata (structured type) 
publicts_form_part (structured type) 
publicts_map_file (structured type) 
publictt_boolean TYPE standard table of ZIF_IBMC_SERVICE_ARCH~BOOLEAN with non-unique default key 
publictt_char TYPE standard table of ZIF_IBMC_SERVICE_ARCH~CHAR with non-unique default key 
publictt_double TYPE standard table of DOUBLE with non-unique default key 
publictt_file TYPE standard table of FILE with non-unique default key 
publictt_file_with_metadata TYPE standard table of TS_FILE_WITH_METADATA with non-unique default key 
publictt_float TYPE standard table of FLOAT with non-unique default key 
publictt_form_part TYPE standard table of TS_FORM_PART 
publictt_integer TYPE standard table of INTEGER with non-unique default key 
publictt_long TYPE standard table of LONG with non-unique default key 
publictt_map_file TYPE standard table of TS_MAP_FILE with non-unique default key 
publictt_number TYPE standard table of NUMBER with non-unique default key 
publictt_short TYPE standard table of SHORT with non-unique default key 
publictt_string type ZIF_IBMC_SERVICE_ARCH~TT_STRING 

Constants

Visibility and LevelNameDocumentation
public staticc_blank type STRING value '&#§§#&__%$X' 
public staticc_boolean_false type BOOLEAN value SPACE 
public staticc_boolean_true type BOOLEAN value 'X' 
public staticc_datatype (structured type)  
public staticc_default type STRING value 'DEFAULT' 
public staticc_f_zero type F value '-2147481.648' 
public staticc_i8_zero type INT8 value -9223372036854775608 
public staticc_i_zero type I value -2147481648 
public staticc_msgid type SY-MSGID value 'ZIBMC' 
public staticc_subrc_unknown type SY-SUBRC value 999999 
public staticc_tribool_false type BOOLEAN value '-' 

Attributes

Visibility and LevelNameDocumentation
public instancep_debug_mode type CHAR value SPACE 
public instancep_request_prop_default type TS_REQUEST_PROP  
public instancep_version type STRING  

Methods

Visibility and LevelNameDocumentation
public static
abap_to_json
importingi_nametype STRING optional
i_valuetype ANY
i_dictionarytype ANY optional
i_required_fieldstype ANY optional
i_lower_casetype BOOLEAN default C_BOOLEAN_TRUE
returningvalue(e_json)type STRING
 
public static
add_header_parameter
importingi_parametertype STRING
i_valuetype STRING
i_is_booleantype BOOLEAN default C_BOOLEAN_FALSE
changingc_headerstype ZIF_IBMC_SERVICE_ARCH~TS_REQUEST_PROP-HEADERS
 
public static
add_query_parameter
importingi_parametertype STRING
i_valuetype STRING
i_is_booleantype BOOLEAN default C_BOOLEAN_FALSE
changingc_urltype TS_URL
 
public static
get_datatype
importingi_fieldtype ANY
returningvalue(e_datatype)type ZIF_IBMC_SERVICE_ARCH~CHAR
Returns data type of a variable
public static
get_file_extension
importingvalue(i_mime_type)type STRING
returningvalue(e_extension)type STRING
Returns file extension for given mime type
public static
get_full_url
importingi_urltype TS_URL
returningvalue(e_url)type STRING
 
public static
move_data_reference_to_abap
importingi_data_referencetype DATA_REFERENCE
exportingvalue(e_abap)type ANY
raisingzcx_ibmc_service_exception
moves type DATA_REFERENCE to ABAP structure
Class-based Exceptions
zcx_ibmc_service_exceptionIBM Cloud Service Exception
public static
normalize_url
changingc_urltype TS_URL
 
public static
raise_exception
importingi_msgnotype SY-MSGNO optional
i_msgv1type STRING optional
i_msgv2type STRING optional
i_msgv3type STRING optional
i_msgv4type STRING optional
i_texttype STRING optional
i_subrctype SY-SUBRC default C_SUBRC_UNKNOWN
i_previoustype ref to CX_ROOT optional
i_http_statustype TS_HTTP_STATUS optional
raisingzcx_ibmc_service_exception
 
public static
unescape_unicode
importingi_intype STRING
returningvalue(e_out)type STRING
Unescapes unicode codepoints
public instance
add_form_part
importingi_clienttype TS_CLIENT
it_form_parttype TT_FORM_PART
raisingzcx_ibmc_service_exception
 
public instance
check_http_response
importingi_responsetype TO_REST_RESPONSE optional
i_urltype TS_URL optional
raisingzcx_ibmc_service_exception
 
public instance
constructor
importingi_hosttype STRING optional
i_proxy_hosttype STRING optional
i_proxy_porttype STRING optional
i_usernametype STRING optional
i_passwordtype STRING optional
i_apikeytype STRING optional
i_access_tokentype TS_ACCESS_TOKEN optional
i_ssl_idtype ZIF_IBMC_SERVICE_ARCH~TY_SSL_ID optional
i_debug_modetype CHAR default SPACE
 
public instance
get_access_token
importingi_request_proptype TS_REQUEST_PROP optional
returningvalue(e_access_token)type TS_ACCESS_TOKEN
raisingzcx_ibmc_service_exception
 
public instance
get_appname
returningvalue(e_appname)type STRING
 
public instance
get_request_prop
importingi_auth_methodtype STRING default C_DEFAULT
returningvalue(e_request_prop)type TS_REQUEST_PROP
 
public instance
get_rest_client
importingi_request_proptype TS_REQUEST_PROP
returningvalue(e_client)type TS_CLIENT
raisingzcx_ibmc_service_exception
 
public instance
http_delete
importingi_request_proptype TS_REQUEST_PROP
returningvalue(e_response)type TO_REST_RESPONSE
raisingzcx_ibmc_service_exception
 
public instance
http_get
importingi_request_proptype TS_REQUEST_PROP
returningvalue(e_response)type TO_REST_RESPONSE
raisingzcx_ibmc_service_exception
 
public instance
http_post
importingi_request_proptype TS_REQUEST_PROP
returningvalue(e_response)type TO_REST_RESPONSE
raisingzcx_ibmc_service_exception
 
public instance
http_post_multipart
importingi_request_proptype TS_REQUEST_PROP
it_form_parttype TT_FORM_PART
returningvalue(e_response)type TO_REST_RESPONSE
raisingzcx_ibmc_service_exception
 
public instance
http_put
importingi_request_proptype TS_REQUEST_PROP
returningvalue(e_response)type TO_REST_RESPONSE
raisingzcx_ibmc_service_exception
 
public instance
set_access_token
importingi_access_tokentype TS_ACCESS_TOKEN
raisingzcx_ibmc_service_exception
 
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service_ext.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service_ext.html new file mode 100644 index 0000000..dcc4502 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_service_ext.html @@ -0,0 +1 @@ +Class ZCL_IBMC_SERVICE_EXT

Class ZCL_IBMC_SERVICE_EXT

public inheriting from ZCL_IBMC_SERVICE create public

Documentation

Extended REST API service class

Types

Visibility and LevelNameDocumentation
publicts_oauth_prop (structured type) 
publicty_image_class type STRING 
publicty_image_format (typing) 
publicty_instance_id (typing) 
publicty_servicename (typing) 

Constants

Visibility and LevelNameDocumentation
public staticc_field_none type FIELDNAME value '###'Field Name
public staticc_format_all type TY_IMAGE_FORMAT value '*'Image encoding (jpg, png, ...)
public staticc_format_gif type TY_IMAGE_FORMAT value 'gif'Image encoding (jpg, png, ...)
public staticc_format_jpg type TY_IMAGE_FORMAT value 'jpg'Image encoding (jpg, png, ...)
public staticc_format_png type TY_IMAGE_FORMAT value 'png'Image encoding (jpg, png, ...)
public staticc_format_tif type TY_IMAGE_FORMAT value 'tif'Image encoding (jpg, png, ...)
public staticc_format_unknown type TY_IMAGE_FORMAT value '###'Image encoding (jpg, png, ...)
public staticc_format_zip type TY_IMAGE_FORMAT value 'zip'Image encoding (jpg, png, ...)
public staticc_token_generation_always type CHAR value 'A' 
public staticc_token_generation_auto type CHAR value SPACE 
public staticc_token_generation_never type CHAR value 'N' 

Attributes

Visibility and LevelNameDocumentation
public instancep_instance_id type TY_INSTANCE_ID  
public instancep_servicename type TY_SERVICENAME  

Methods

Visibility and LevelNameDocumentation
public static
get_instance
importingi_instance_idtype TY_INSTANCE_ID optional
i_hosttype STRING optional
i_usernametype STRING optional
i_passwordtype STRING optional
i_proxy_hosttype STRING optional
i_proxy_servicetype STRING optional
i_apikeytype STRING optional
i_auth_methodtype STRING default C_DEFAULT
i_oauth_proptype TS_OAUTH_PROP optional
i_token_generationtype CHAR default C_TOKEN_GENERATION_AUTO
i_request_headerstype STRING optional
i_versiontype STRING optional
exportingvalue(eo_instance)type ANY
Creates an IBM Cloud service class instance
Parameters
i_instance_idInstance GUI
eo_instanceExtended REST API service class
public static
get_zipdata
importingit_examplestype ANY TABLE
iv_field_classtype FIELDNAME default C_FIELD_NONE
iv_field_filenametype FIELDNAME optional
iv_field_imagetype FIELDNAME optional
iv_image_formattype TY_IMAGE_FORMAT optional
iv_image_nametype STRING optional
exportinget_zipdatatype TT_MAP_FILE
raisingzcx_ibmc_service_exception
Creates or Updates a classifier
Parameters
iv_field_classField Name
iv_field_filenameField Name
iv_field_imageField Name
public instanceget_access_token redefinition 
public instance
get_bearer_token
returningvalue(e_bearer_token)type STRING
Returns the bearer token, if available
public instance
get_config_value
importingi_defaulttype ZIBMC_CONFIG-VALUE optional
i_paramtype ZIBMC_CONFIG-PARAM
returningvalue(e_value)type ZIBMC_CONFIG-VALUE
raisingzcx_ibmc_service_exception
Reads an individual value form table ZIBMC_CONFIG
Parameters
i_defaultCase-sensitive string value
e_valueCase-sensitive string value
Class-based Exceptions
zcx_ibmc_service_exceptionIBM Cloud Service Exception
public instance
get_sdk_version_date
returningvalue(e_sdk_version_date)type STRING
returns the build date of the method
public instanceset_access_token redefinition 
public instance
set_bearer_token
importingi_bearer_tokentype STRING
Sets the bearer token
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_speech_to_text_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_speech_to_text_v1.html new file mode 100644 index 0000000..7686e51 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_speech_to_text_v1.html @@ -0,0 +1,939 @@ +Class ZCL_IBMC_SPEECH_TO_TEXT_V1

Class ZCL_IBMC_SPEECH_TO_TEXT_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_acoustic_model (structured type) Information about an existing custom acoustic model.
publict_acoustic_models (structured type) Information about existing custom acoustic models.
publict_audio_details (structured type) Information about an audio resource from a custom acoustic model.
publict_audio_listing (structured type) Information about an audio resource from a custom acoustic model.
publict_audio_metrics (structured type) If audio metrics are requested, information about the signal characteristics of + the input audio.
publict_audio_metrics_details (structured type) Detailed information about the signal characteristics of the input audio.
publict_audio_metrics_histogram_bin (structured type) 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.
publict_audio_resource (structured type) Information about an audio resource from a custom acoustic model.
publict_audio_resources (structured type) Information about the audio resources from a custom acoustic model.
publict_corpora (structured type) Information about the corpora from a custom language model.
publict_corpus (structured type) Information about a corpus from a custom language model.
publict_create_acoustic_model (structured type) Information about the new custom acoustic model.
publict_create_language_model (structured type) Information about the new custom language model.
publict_custom_word (structured type) Information about a word that is to be added to a custom language model.
publict_custom_words (structured type) Information about the words that are to be added to a custom language model.
publict_empty_response_body type JSONOBJECT The empty response from a request.
publict_error_model (structured type) The error response from a failed request.
publict_grammar (structured type) Information about a grammar from a custom language model.
publict_grammars (structured type) Information about the grammars from a custom language model.
publict_inline_object (structured type) 
publict_keyword_result (structured type) Information about a match for a keyword from speech recognition results.
publict_language_model (structured type) Information about an existing custom language model.
publict_language_models (structured type) Information about existing custom language models.
publict_processed_audio (structured type) Detailed timing information about the service's processing of the input audio.
publict_processing_metrics (structured type) 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.
publict_recognition_job (structured type) Information about a current asynchronous speech recognition job.
publict_recognition_jobs (structured type) Information about current asynchronous speech recognition jobs.
publict_register_status (structured type) Information about a request to register a callback for asynchronous speech + recognition.
publict_spch_recognition_alternative (structured type) An alternative transcript from speech recognition results.
publict_speaker_labels_result (structured type) Information about the speakers from speech recognition results.
publict_speech_model (structured type) Information about an available language model.
publict_speech_models (structured type) Information about the available language models.
publict_speech_recognition_result (structured type) Component results for a speech recognition request.
publict_speech_recognition_results (structured type) The complete results for a speech recognition request.
publict_supported_features (structured type) Additional service features that are supported with the model.
publict_training_response (structured type) The response from training of a custom language or custom acoustic model.
publict_training_warning (structured type) A warning from training of a custom language or custom acoustic model.
publict_word (structured type) Information about a word from a custom language model.
publict_words (structured type) Information about the words from a custom language model.
publict_word_alternative_result (structured type) An alternative hypothesis for a word from speech recognition results.
publict_word_alternative_results (structured type) Information about alternative hypotheses for words from speech recognition + results.
publict_word_error (structured type) An error associated with a word from a custom language model.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
add_audio
importingi_customization_idtype STRING
i_audio_nametype STRING
i_audio_resourcetype FILE
i_content_typetype STRING default 'application/zip'
i_contained_content_typetype STRING optional
i_allow_overwritetype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add an audio resource. + +
Parameters
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. +
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. +
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. +
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. +
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. +
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. +
public instance
add_corpus
importingi_customization_idtype STRING
i_corpus_nametype STRING
i_corpus_filetype FILE
i_allow_overwritetype BOOLEAN default C_BOOLEAN_FALSE
i_corpus_file_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add a corpus. + +
Parameters
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. +
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. +
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. +
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. +
public instance
add_grammar
importingi_customization_idtype STRING
i_grammar_nametype STRING
i_grammar_filetype STRING
i_content_typetype STRING default 'application/srgs'
i_allow_overwritetype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add a grammar. + +
Parameters
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. +
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. +
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. +
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. +
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. +
public instance
add_word
importingi_customization_idtype STRING
i_word_nametype STRING
i_custom_wordtype T_CUSTOM_WORD
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add a custom word. + +
Parameters
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. +
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). +
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. +
public instance
add_words
importingi_customization_idtype STRING
i_custom_wordstype T_CUSTOM_WORDS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add custom words. + +
Parameters
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. +
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. +
public instance
check_job
importingi_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_RECOGNITION_JOB
raisingzcx_ibmc_service_exception
Check a job. + +
Parameters
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. +
e_response + Service return value of type T_RECOGNITION_JOB +
public instance
check_jobs
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_RECOGNITION_JOBS
raisingzcx_ibmc_service_exception
Check jobs. + +
Parameters
e_response + Service return value of type T_RECOGNITION_JOBS +
public instance
create_acoustic_model
importingi_create_acoustic_modeltype T_CREATE_ACOUSTIC_MODEL
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ACOUSTIC_MODEL
raisingzcx_ibmc_service_exception
Create a custom acoustic model. + +
Parameters
i_create_acoustic_model + A `CreateAcousticModel` object that provides basic information about the new + custom acoustic model. +
e_response + Service return value of type T_ACOUSTIC_MODEL +
public instance
create_job
importingi_audiotype FILE
i_content_typetype STRING default 'application/octet-stream'
i_modeltype STRING default 'en-US_BroadbandModel'
i_callback_urltype STRING optional
i_eventstype STRING optional
i_user_tokentype STRING optional
i_results_ttltype INTEGER optional
i_language_customization_idtype STRING optional
i_acoustic_customization_idtype STRING optional
i_base_model_versiontype STRING optional
i_customization_weighttype DOUBLE optional
i_inactivity_timeouttype INTEGER optional
i_keywordstype TT_STRING optional
i_keywords_thresholdtype FLOAT optional
i_max_alternativestype INTEGER optional
i_word_alternatives_thresholdtype FLOAT optional
i_word_confidencetype BOOLEAN default C_BOOLEAN_FALSE
i_timestampstype BOOLEAN default C_BOOLEAN_FALSE
i_profanity_filtertype BOOLEAN default C_BOOLEAN_TRUE
i_smart_formattingtype BOOLEAN default C_BOOLEAN_FALSE
i_speaker_labelstype BOOLEAN default C_BOOLEAN_FALSE
i_customization_idtype STRING optional
i_grammar_nametype STRING optional
i_redactiontype BOOLEAN default C_BOOLEAN_FALSE
i_processing_metricstype BOOLEAN default C_BOOLEAN_FALSE
i_processing_metrics_intervaltype FLOAT optional
i_audio_metricstype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_RECOGNITION_JOB
raisingzcx_ibmc_service_exception
Create a job. + +
Parameters
i_audio + The audio to transcribe. +
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. +
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). +
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. +
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. +
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. +
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. +
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. +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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. +
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). +
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). +
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. +
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. +
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. +
e_response + Service return value of type T_RECOGNITION_JOB +
public instance
create_language_model
importingi_create_language_modeltype T_CREATE_LANGUAGE_MODEL
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LANGUAGE_MODEL
raisingzcx_ibmc_service_exception
Create a custom language model. + +
Parameters
i_create_language_model + A `CreateLanguageModel` object that provides basic information about the new + custom language model. +
e_response + Service return value of type T_LANGUAGE_MODEL +
public instance
delete_acoustic_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a custom acoustic model. + +
Parameters
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. +
public instance
delete_audio
importingi_customization_idtype STRING
i_audio_nametype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete an audio resource. + +
Parameters
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. +
i_audio_name + The name of the audio resource for the custom acoustic model. +
public instance
delete_corpus
importingi_customization_idtype STRING
i_corpus_nametype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a corpus. + +
Parameters
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. +
i_corpus_name + The name of the corpus for the custom language model. +
public instance
delete_grammar
importingi_customization_idtype STRING
i_grammar_nametype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a grammar. + +
Parameters
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. +
i_grammar_name + The name of the grammar for the custom language model. +
public instance
delete_job
importingi_idtype STRING
raisingzcx_ibmc_service_exception
Delete a job. + +
Parameters
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. +
public instance
delete_language_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a custom language model. + +
Parameters
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. +
public instance
delete_user_data
importingi_customer_idtype STRING
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instance
delete_word
importingi_customization_idtype STRING
i_word_nametype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a custom word. + +
Parameters
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. +
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). +
public instance
get_acoustic_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ACOUSTIC_MODEL
raisingzcx_ibmc_service_exception
Get a custom acoustic model. + +
Parameters
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. +
e_response + Service return value of type T_ACOUSTIC_MODEL +
public instanceget_appname redefinition 
public instance
get_audio
importingi_customization_idtype STRING
i_audio_nametype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_AUDIO_LISTING
raisingzcx_ibmc_service_exception
Get an audio resource. + +
Parameters
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. +
i_audio_name + The name of the audio resource for the custom acoustic model. +
e_response + Service return value of type T_AUDIO_LISTING +
public instance
get_corpus
importingi_customization_idtype STRING
i_corpus_nametype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CORPUS
raisingzcx_ibmc_service_exception
Get a corpus. + +
Parameters
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. +
i_corpus_name + The name of the corpus for the custom language model. +
e_response + Service return value of type T_CORPUS +
public instance
get_grammar
importingi_customization_idtype STRING
i_grammar_nametype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GRAMMAR
raisingzcx_ibmc_service_exception
Get a grammar. + +
Parameters
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. +
i_grammar_name + The name of the grammar for the custom language model. +
e_response + Service return value of type T_GRAMMAR +
public instance
get_language_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LANGUAGE_MODEL
raisingzcx_ibmc_service_exception
Get a custom language model. + +
Parameters
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. +
e_response + Service return value of type T_LANGUAGE_MODEL +
public instance
get_model
importingi_model_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SPEECH_MODEL
raisingzcx_ibmc_service_exception
Get a model. + +
Parameters
i_model_id + The identifier of the model in the form of its name from the output of the **Get + a model** method. +
e_response + Service return value of type T_SPEECH_MODEL +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
get_word
importingi_customization_idtype STRING
i_word_nametype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORD
raisingzcx_ibmc_service_exception
Get a custom word. + +
Parameters
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. +
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). +
e_response + Service return value of type T_WORD +
public instance
list_acoustic_models
importingi_languagetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ACOUSTIC_MODELS
raisingzcx_ibmc_service_exception
List custom acoustic models. + +
Parameters
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. +
e_response + Service return value of type T_ACOUSTIC_MODELS +
public instance
list_audio
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_AUDIO_RESOURCES
raisingzcx_ibmc_service_exception
List audio resources. + +
Parameters
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. +
e_response + Service return value of type T_AUDIO_RESOURCES +
public instance
list_corpora
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CORPORA
raisingzcx_ibmc_service_exception
List corpora. + +
Parameters
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. +
e_response + Service return value of type T_CORPORA +
public instance
list_grammars
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_GRAMMARS
raisingzcx_ibmc_service_exception
List grammars. + +
Parameters
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. +
e_response + Service return value of type T_GRAMMARS +
public instance
list_language_models
importingi_languagetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_LANGUAGE_MODELS
raisingzcx_ibmc_service_exception
List custom language models. + +
Parameters
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. +
e_response + Service return value of type T_LANGUAGE_MODELS +
public instance
list_models
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_SPEECH_MODELS
raisingzcx_ibmc_service_exception
List models. + +
Parameters
e_response + Service return value of type T_SPEECH_MODELS +
public instance
list_words
importingi_customization_idtype STRING
i_word_typetype STRING default 'all'
i_sorttype STRING default 'alphabetical'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORDS
raisingzcx_ibmc_service_exception
List custom words. + +
Parameters
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. +
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. +
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`. +
e_response + Service return value of type T_WORDS +
public instance
recognize
importingi_audiotype FILE
i_content_typetype STRING default 'application/octet-stream'
i_modeltype STRING default 'en-US_BroadbandModel'
i_language_customization_idtype STRING optional
i_acoustic_customization_idtype STRING optional
i_base_model_versiontype STRING optional
i_customization_weighttype DOUBLE optional
i_inactivity_timeouttype INTEGER optional
i_keywordstype TT_STRING optional
i_keywords_thresholdtype FLOAT optional
i_max_alternativestype INTEGER optional
i_word_alternatives_thresholdtype FLOAT optional
i_word_confidencetype BOOLEAN default C_BOOLEAN_FALSE
i_timestampstype BOOLEAN default C_BOOLEAN_FALSE
i_profanity_filtertype BOOLEAN default C_BOOLEAN_TRUE
i_smart_formattingtype BOOLEAN default C_BOOLEAN_FALSE
i_speaker_labelstype BOOLEAN default C_BOOLEAN_FALSE
i_customization_idtype STRING optional
i_grammar_nametype STRING optional
i_redactiontype BOOLEAN default C_BOOLEAN_FALSE
i_audio_metricstype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
exportinge_responsetype T_SPEECH_RECOGNITION_RESULTS
raisingzcx_ibmc_service_exception
Recognize audio. + +
Parameters
i_audio + The audio to transcribe. +
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. +
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). +
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. +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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). +
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. +
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). +
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). +
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. +
e_response + Service return value of type T_SPEECH_RECOGNITION_RESULTS +
public instance
register_callback
importingi_callback_urltype STRING
i_user_secrettype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_REGISTER_STATUS
raisingzcx_ibmc_service_exception
Register a callback. + +
Parameters
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. +
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. +
e_response + Service return value of type T_REGISTER_STATUS +
public instance
reset_acoustic_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Reset a custom acoustic model. + +
Parameters
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. +
public instance
reset_language_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Reset a custom language model. + +
Parameters
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. +
public instance
train_acoustic_model
importingi_customization_idtype STRING
i_custom_language_model_idtype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_RESPONSE
raisingzcx_ibmc_service_exception
Train a custom acoustic model. + +
Parameters
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. +
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. +
e_response + Service return value of type T_TRAINING_RESPONSE +
public instance
train_language_model
importingi_customization_idtype STRING
i_word_type_to_addtype STRING default 'all'
i_customization_weighttype DOUBLE optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_RESPONSE
raisingzcx_ibmc_service_exception
Train a custom language model. + +
Parameters
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. +
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. +
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. +
e_response + Service return value of type T_TRAINING_RESPONSE +
public instance
unregister_callback
importingi_callback_urltype STRING
raisingzcx_ibmc_service_exception
Unregister a callback. + +
Parameters
i_callback_url + The callback URL that is to be unregistered. +
public instance
upgrade_acoustic_model
importingi_customization_idtype STRING
i_custom_language_model_idtype STRING optional
i_forcetype BOOLEAN default C_BOOLEAN_FALSE
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Upgrade a custom acoustic model. + +
Parameters
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. +
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. +
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). +
public instance
upgrade_language_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Upgrade a custom language model. + +
Parameters
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. +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_text_to_speech_v1.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_text_to_speech_v1.html new file mode 100644 index 0000000..9f2ce66 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_text_to_speech_v1.html @@ -0,0 +1,160 @@ +Class ZCL_IBMC_TEXT_TO_SPEECH_V1

Class ZCL_IBMC_TEXT_TO_SPEECH_V1

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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).

Types

Visibility and LevelNameDocumentation
publict_create_voice_model (structured type) Information about the new custom voice model.
publict_empty_response_body type JSONOBJECT The empty response from a request.
publict_error_model (structured type) The error response from a failed request.
publict_pronunciation (structured type) The pronunciation of the specified text.
publict_supported_features (structured type) Additional service features that are supported with the voice.
publict_text (structured type) 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.
publict_translation (structured type) Information about the translation for the specified text.
publict_update_voice_model (structured type) Information about the updated custom voice model.
publict_voice (structured type) Information about an available voice model.
publict_voices (structured type) Information about all available voice models.
publict_voice_model (structured type) Information about an existing custom voice model.
publict_voice_models (structured type) Information about existing custom voice models.
publict_word (structured type) Information about a word for the custom voice model.
publict_words (structured type) 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.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
add_word
importingi_customization_idtype STRING
i_wordtype STRING
i_translationtype T_TRANSLATION
i_contenttypetype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add a custom word. + +
Parameters
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. +
i_word + The word that is to be added or updated for the custom voice model. +
i_translation + The translation for the word that is to be added or updated. +
public instance
add_words
importingi_customization_idtype STRING
i_custom_wordstype T_WORDS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Add custom words. + +
Parameters
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. +
i_custom_words + +
public instance
create_voice_model
importingi_create_voice_modeltype T_CREATE_VOICE_MODEL
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VOICE_MODEL
raisingzcx_ibmc_service_exception
Create a custom model. + +
Parameters
i_create_voice_model + A `CreateVoiceModel` object that contains information about the new custom voice + model. +
e_response + Service return value of type T_VOICE_MODEL +
public instance
delete_user_data
importingi_customer_idtype STRING
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instance
delete_voice_model
importingi_customization_idtype STRING
raisingzcx_ibmc_service_exception
Delete a custom model. + +
Parameters
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. +
public instance
delete_word
importingi_customization_idtype STRING
i_wordtype STRING
raisingzcx_ibmc_service_exception
Delete a custom word. + +
Parameters
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. +
i_word + The word that is to be deleted from the custom voice model. +
public instanceget_appname redefinition 
public instance
get_pronunciation
importingi_texttype STRING
i_voicetype STRING default 'en-US_MichaelVoice'
i_formattype STRING default 'ipa'
i_customization_idtype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_PRONUNCIATION
raisingzcx_ibmc_service_exception
Get pronunciation. + +
Parameters
i_text + The word for which the pronunciation is requested. +
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. +
i_format + The phoneme format in which to return the pronunciation. Omit the parameter to + obtain the pronunciation in the default format. +
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. +
e_response + Service return value of type T_PRONUNCIATION +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
get_voice
importingi_voicetype STRING
i_customization_idtype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VOICE
raisingzcx_ibmc_service_exception
Get a voice. + +
Parameters
i_voice + The voice for which information is to be returned. +
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. +
e_response + Service return value of type T_VOICE +
public instance
get_voice_model
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VOICE_MODEL
raisingzcx_ibmc_service_exception
Get a custom model. + +
Parameters
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. +
e_response + Service return value of type T_VOICE_MODEL +
public instance
get_word
importingi_customization_idtype STRING
i_wordtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRANSLATION
raisingzcx_ibmc_service_exception
Get a custom word. + +
Parameters
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. +
i_word + The word that is to be queried from the custom voice model. +
e_response + Service return value of type T_TRANSLATION +
public instance
list_voices
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_VOICES
raisingzcx_ibmc_service_exception
List voices. + +
Parameters
e_response + Service return value of type T_VOICES +
public instance
list_voice_models
importingi_languagetype STRING optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_VOICE_MODELS
raisingzcx_ibmc_service_exception
List custom models. + +
Parameters
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. +
e_response + Service return value of type T_VOICE_MODELS +
public instance
list_words
importingi_customization_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_WORDS
raisingzcx_ibmc_service_exception
List custom words. + +
Parameters
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. +
e_response + Service return value of type T_WORDS +
public instance
synthesize
importingi_texttype T_TEXT
i_accepttype STRING default 'audio/ogg;codecs=opus'
i_voicetype STRING default 'en-US_MichaelVoice'
i_customization_idtype STRING optional
i_contenttypetype STRING default 'application/json'
exportinge_responsetype FILE
raisingzcx_ibmc_service_exception
Synthesize audio. + +
Parameters
i_text + +
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. +
i_voice + The voice to use for synthesis. +
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. +
e_response + Service return value of type FILE +
public instance
update_voice_model
importingi_customization_idtype STRING
i_update_voice_modeltype T_UPDATE_VOICE_MODEL
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Update a custom model. + +
Parameters
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. +
i_update_voice_model + An `UpdateVoiceModel` object that contains information that is to be updated for + the custom voice model. +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_tone_analyzer_v3.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_tone_analyzer_v3.html new file mode 100644 index 0000000..47ecec1 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_tone_analyzer_v3.html @@ -0,0 +1,67 @@ +Class ZCL_IBMC_TONE_ANALYZER_V3

Class ZCL_IBMC_TONE_ANALYZER_V3

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_document_analysis (structured type) The results of the analysis for the full input content.
publict_error_model (structured type) The error response from a failed request.
publict_sentence_analysis (structured type) The results of the analysis for the individual sentences of the input content.
publict_tone_analysis (structured type) The tone analysis results for the input from the general-purpose endpoint.
publict_tone_category (structured type) The category for a tone from the input content.
publict_tone_chat_input (structured type) Input for the customer-engagement endpoint.
publict_tone_chat_score (structured type) The score for an utterance from the input content.
publict_tone_input (structured type) Input for the general-purpose endpoint.
publict_tone_score (structured type) The score for a tone from the input content.
publict_utterance (structured type) An utterance for the input of the general-purpose endpoint.
publict_utterance_analyses (structured type) The results of the analysis for the utterances of the input content.
publict_utterance_analysis (structured type) The results of the analysis for an utterance of the input content.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instanceget_appname redefinition 
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
tone
importingi_tone_inputtype T_TONE_INPUT
i_content_typetype STRING default 'application/json'
i_sentencestype BOOLEAN default C_BOOLEAN_TRUE
i_tonestype TT_STRING optional
i_content_languagetype STRING default 'en'
i_accept_languagetype STRING default 'en'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TONE_ANALYSIS
raisingzcx_ibmc_service_exception
Analyze general tone. + +
Parameters
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`. +
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'. +
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. +
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. +
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`. +
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**. +
e_response + Service return value of type T_TONE_ANALYSIS +
public instance
tone_chat
importingi_utterancestype T_TONE_CHAT_INPUT
i_content_languagetype STRING default 'en'
i_accept_languagetype STRING default 'en'
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_UTTERANCE_ANALYSES
raisingzcx_ibmc_service_exception
Analyze customer-engagement tone. + +
Parameters
i_utterances + An object that contains the content to be analyzed. +
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`. +
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**. +
e_response + Service return value of type T_UTTERANCE_ANALYSES +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_util.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_util.html new file mode 100644 index 0000000..808bb12 --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_util.html @@ -0,0 +1 @@ +Class ZCL_IBMC_UTIL

Class ZCL_IBMC_UTIL

public final create public

Documentation

Utilities to connect to IBM Watson

Methods

Visibility and LevelNameDocumentation
public static
convert_datetime_to_timestamp
importingi_datetimetype ZCL_IBMC_SERVICE=>DATETIME
returningvalue(e_timestamp)type TIMESTAMP
Converts a DATETIME String to type TIMESTAMP
Parameters
e_timestampUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
public static
convert_timestamp_to_datetime
importingi_timestamptype TIMESTAMP
returningvalue(e_datetime)type ZCL_IBMC_SERVICE=>DATETIME
Converts a DATETIME String to type TIMESTAMP
Parameters
i_timestampUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
e_datetimeUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
public static
convert_timestamp_to_local
importingiv_timestamptype TIMESTAMP
returningvalue(ev_local)type STRING
Converts a UTF timestamp to a local timestamp
Parameters
iv_timestampUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
public static
get_mimetype_from_extension
importingi_filenametype STRING
returningvalue(e_mimetype)type STRING
Returns mime type for a given extension
Parameters
i_filenameCharacter field of length 40
public static
utc_to_timezone
importingi_timestamptype TIMESTAMP
i_timezonetype ZIF_IBMC_SERVICE_ARCH=>TY_TIMEZONE optional
returningvalue(e_timestamp)type TIMESTAMP
Converts an UTC timestamp to the specified timezone
Parameters
i_timestampUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
i_timezoneTime Zone
e_timestampUTC Time Stamp in Short Form (YYYYMMDDhhmmss)
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v3.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v3.html new file mode 100644 index 0000000..6b0cd9f --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v3.html @@ -0,0 +1,138 @@ +Class ZCL_IBMC_VISUAL_RECOGNITION_V3

Class ZCL_IBMC_VISUAL_RECOGNITION_V3

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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.

Types

Visibility and LevelNameDocumentation
publict_class (structured type) A category within a classifier.
publict_classified_image (structured type) Results for one image.
publict_classified_images (structured type) Results for all images.
publict_classifier (structured type) Information about a classifier.
publict_classifiers (structured type) A container for the list of classifiers.
publict_classifier_result (structured type) Classifier and score combination.
publict_class_result (structured type) Result of a class within a classifier.
publict_confidence_score type FLOAT 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.
publict_custom_classes_processed type INTEGER Number of custom classes identified in the images.
publict_empty type JSONOBJECT Empty object.
publict_error_html (structured type) Error information.
publict_error_info (structured type) Information about what might have caused a failure, such as an image that is too + large. Not returned when there is no error.
publict_error_response (structured type) Error information.
publict_images_processed type INTEGER Number of images processed for the API call.
publict_image_file type STRING Relative path of the image file if uploaded directly. Not returned when the + image is passed by URL.
publict_inline_object (structured type) 
publict_inline_object1 (structured type) 
publict_inline_object2 (structured type) 
publict_resolved_url type STRING Fully resolved URL of the image after redirects are followed. Not returned when + the image is uploaded.
publict_source_url type STRING Source of the image before any redirects. Not returned when the image is + uploaded.
publict_type_hierarchy type STRING Knowledge graph of the property. For example, `/fruit/pome/apple/eating + apple/Granny Smith`. Included only if identified.
publict_warning_info (structured type) Information about something that went wrong.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
classify
importingi_images_filetype FILE optional
i_images_filenametype STRING optional
i_images_file_content_typetype STRING optional
i_urltype STRING optional
i_thresholdtype FLOAT optional
i_ownerstype TT_STRING optional
i_classifier_idstype TT_STRING optional
i_accept_languagetype STRING default 'en'
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIED_IMAGES
raisingzcx_ibmc_service_exception
Classify images. + +
Parameters
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. +
i_images_filename + The filename for imagesFile. +
i_images_file_content_type + The content type of imagesFile. +
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. +
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. +
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. +
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. +
i_accept_language + The desired language of parts of the response. See the response for details. +
e_response + Service return value of type T_CLASSIFIED_IMAGES +
public instance
create_classifier
importingi_nametype STRING
i_positive_examplestype TT_MAP_FILE
i_negative_examplestype FILE optional
i_negative_examples_filenametype STRING optional
i_positive_examples_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_negative_examples_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER
raisingzcx_ibmc_service_exception
Create a classifier. + +
Parameters
i_name + The name of the new classifier. Encode special characters in UTF-8. +
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**. + + 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. +
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. +
i_negative_examples_filename + The filename for negativeExamples. +
e_response + Service return value of type T_CLASSIFIER +
public instance
delete_classifier
importingi_classifier_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a classifier. + +
Parameters
i_classifier_id + The ID of the classifier. +
public instance
delete_user_data
importingi_customer_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instanceget_appname redefinition 
public instance
get_classifier
importingi_classifier_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER
raisingzcx_ibmc_service_exception
Retrieve classifier details. + +
Parameters
i_classifier_id + The ID of the classifier. +
e_response + Service return value of type T_CLASSIFIER +
public instance
get_core_ml_model
importingi_classifier_idtype STRING
i_accepttype STRING default 'application/octet-stream'
exportinge_responsetype FILE
raisingzcx_ibmc_service_exception
Retrieve a Core ML model of a classifier. + +
Parameters
i_classifier_id + The ID of the classifier. +
e_response + Service return value of type FILE +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
list_classifiers
importingi_verbosetype BOOLEAN optional
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIERS
raisingzcx_ibmc_service_exception
Retrieve a list of classifiers. + +
Parameters
i_verbose + Specify `true` to return details about the classifiers. Omit this parameter to + return a brief list of classifiers. +
e_response + Service return value of type T_CLASSIFIERS +
public instance
update_classifier
importingi_classifier_idtype STRING
i_positive_examplestype TT_MAP_FILE optional
i_negative_examplestype FILE optional
i_negative_examples_filenametype STRING optional
i_positive_examples_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_negative_examples_cttype STRING default ZIF_IBMC_SERVICE_ARCH~C_MEDIATYPE-ALL
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_CLASSIFIER
raisingzcx_ibmc_service_exception
Update a classifier. + +
Parameters
i_classifier_id + The ID of the classifier. +
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`. + + 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. +
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. +
i_negative_examples_filename + The filename for negativeExamples. +
e_response + Service return value of type T_CLASSIFIER +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v4.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v4.html new file mode 100644 index 0000000..ce353ca --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcl_ibmc_visual_recognition_v4.html @@ -0,0 +1,142 @@ +Class ZCL_IBMC_VISUAL_RECOGNITION_V4

Class ZCL_IBMC_VISUAL_RECOGNITION_V4

public inheriting from ZCL_IBMC_SERVICE_EXT create public

Documentation

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. + + **Beta:** The Visual Recognition v4 API and Object Detection model are beta + features. For more information about beta features, see the [Release + notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-reco + gnition-release-notes#beta). + {: important}

Types

Visibility and LevelNameDocumentation
publict_analyze_response (structured type) Results for all images.
publict_base_collection (structured type) Base details about a collection.
publict_base_object (structured type) Details about an object and its location.
publict_base_training_data_objects (structured type) Container for the training data.
publict_collection (structured type) Details about a collection.
publict_collections_list (structured type) A container for the list of collections.
publict_collection_objects (structured type) The objects in a collection that are detected in an image.
publict_detected_objects (structured type) Container for the list of collections that have objects detected in an image.
publict_empty type JSONOBJECT Empty response.
publict_error (structured type) Details about an error.
publict_error_response (structured type) A container for the list of request-level problems.
publict_error_target (structured type) Details about the specific area of the problem.
publict_image (structured type) Details about an image.
publict_image_details (structured type) Details about an image.
publict_image_details_list (structured type) List of information about the images.
publict_image_dimensions (structured type) Height and width of an image.
publict_image_source (structured type) The source type of the image.
publict_image_summary (structured type) Basic information about an image.
publict_image_summary_list (structured type) List of images.
publict_inline_object (structured type) 
publict_inline_object1 (structured type) 
publict_jpeg_image type FILE A file returned in the response.
publict_location (structured type) Defines the location of the bounding box around the object.
publict_object_detail (structured type) Details about an object in the collection.
publict_object_training_status (structured type) Training status for the objects in the collection.
publict_training_data_object (structured type) Details about the training data.
publict_training_data_objects (structured type) Training data for all objects.
publict_training_status (structured type) Training status information for the collection.
publict_warning (structured type) Details about a problem.

Constants

Visibility and LevelNameDocumentation
public staticc_abapname_dictionary (structured type)  
public staticc_required_fields (structured type)  

Methods

Visibility and LevelNameDocumentation
public instance
add_images
importingi_collection_idtype STRING
i_images_filetype TT_FILE_WITH_METADATA optional
i_image_urltype TT_STRING optional
i_training_datatype STRING optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_IMAGE_DETAILS_LIST
raisingzcx_ibmc_service_exception
Add images. + +
Parameters
i_collection_id + The identifier of the collection. +
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. +
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. +
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. +
e_response + Service return value of type T_IMAGE_DETAILS_LIST +
public instance
add_image_training_data
importingi_collection_idtype STRING
i_image_idtype STRING
i_training_datatype T_BASE_TRAINING_DATA_OBJECTS
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_TRAINING_DATA_OBJECTS
raisingzcx_ibmc_service_exception
Add training data to an image. + +
Parameters
i_collection_id + The identifier of the collection. +
i_image_id + The identifier of the image. +
i_training_data + Training data. Elements in the request replace the existing elements. +
e_response + Service return value of type T_TRAINING_DATA_OBJECTS +
public instance
analyze
importingi_collection_idstype TT_STRING
i_featurestype TT_STRING
i_images_filetype TT_FILE_WITH_METADATA optional
i_image_urltype TT_STRING optional
i_thresholdtype FLOAT optional
i_contenttypetype STRING default 'multipart/form-data'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_ANALYZE_RESPONSE
raisingzcx_ibmc_service_exception
Analyze images. + +
Parameters
i_collection_ids + The IDs of the collections to analyze. +
i_features + The features to analyze. +
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. +
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. +
i_threshold + The minimum score a feature must have to be returned. +
e_response + Service return value of type T_ANALYZE_RESPONSE +
public instance
create_collection
importingi_collection_infotype T_BASE_COLLECTION
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Create a collection. + +
Parameters
i_collection_info + The new collection. +
e_response + Service return value of type T_COLLECTION +
public instance
delete_collection
importingi_collection_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete a collection. + +
Parameters
i_collection_id + The identifier of the collection. +
public instance
delete_image
importingi_collection_idtype STRING
i_image_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete an image. + +
Parameters
i_collection_id + The identifier of the collection. +
i_image_id + The identifier of the image. +
public instance
delete_user_data
importingi_customer_idtype STRING
i_accepttype STRING default 'application/json'
raisingzcx_ibmc_service_exception
Delete labeled data. + +
Parameters
i_customer_id + The customer ID for which all data is to be deleted. +
public instanceget_appname redefinition 
public instance
get_collection
importingi_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Get collection details. + +
Parameters
i_collection_id + The identifier of the collection. +
e_response + Service return value of type T_COLLECTION +
public instance
get_image_details
importingi_collection_idtype STRING
i_image_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_IMAGE_DETAILS
raisingzcx_ibmc_service_exception
Get image details. + +
Parameters
i_collection_id + The identifier of the collection. +
i_image_id + The identifier of the image. +
e_response + Service return value of type T_IMAGE_DETAILS +
public instance
get_jpeg_image
importingi_collection_idtype STRING
i_image_idtype STRING
i_sizetype STRING default 'full'
i_accepttype STRING default 'image/jpeg'
exportinge_responsetype FILE
raisingzcx_ibmc_service_exception
Get a JPEG file of an image. + +
Parameters
i_collection_id + The identifier of the collection. +
i_image_id + The identifier of the image. +
i_size + Specify the image size. +
e_response + Service return value of type FILE +
public instanceget_request_prop redefinition 
public instanceget_sdk_version_date redefinition 
public instance
list_collections
importingi_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTIONS_LIST
raisingzcx_ibmc_service_exception
List collections. + +
Parameters
e_response + Service return value of type T_COLLECTIONS_LIST +
public instance
list_images
importingi_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_IMAGE_SUMMARY_LIST
raisingzcx_ibmc_service_exception
List images. + +
Parameters
i_collection_id + The identifier of the collection. +
e_response + Service return value of type T_IMAGE_SUMMARY_LIST +
public instance
train
importingi_collection_idtype STRING
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Train a collection. + +
Parameters
i_collection_id + The identifier of the collection. +
e_response + Service return value of type T_COLLECTION +
public instance
update_collection
importingi_collection_idtype STRING
i_collection_infotype T_BASE_COLLECTION optional
i_contenttypetype STRING default 'application/json'
i_accepttype STRING default 'application/json'
exportinge_responsetype T_COLLECTION
raisingzcx_ibmc_service_exception
Update a collection. + +
Parameters
i_collection_id + The identifier of the collection. +
i_collection_info + The updated collection. +
e_response + Service return value of type T_COLLECTION +
\ No newline at end of file diff --git a/docs/ABAPDoc/abapdoc/zibmc/classes/zcx_ibmc_service_exception.html b/docs/ABAPDoc/abapdoc/zibmc/classes/zcx_ibmc_service_exception.html new file mode 100644 index 0000000..8f525ff --- /dev/null +++ b/docs/ABAPDoc/abapdoc/zibmc/classes/zcx_ibmc_service_exception.html @@ -0,0 +1 @@ +Class ZCX_IBMC_SERVICE_EXCEPTION

Class ZCX_IBMC_SERVICE_EXCEPTION

public inheriting from CX_STATIC_CHECK final create public

Documentation

IBM Cloud Service Exception

Interfaces

if_t100_dyn_msg
if_t100_message

Attributes

Visibility and LevelNameDocumentation
public instancep_http_reason type STRING  
public instancep_http_status type STRING  
public instancep_msg_json type STRING  

Methods

Visibility and LevelNameDocumentation
public instance
constructor
importingtextidlike IF_T100_MESSAGE=>T100KEY optional
previouslike PREVIOUS optional
p_msg_jsontype STRING optional
p_http_statustype STRING optional
p_http_reasontype STRING optional
CONSTRUCTOR
public instanceif_message~get_longtext redefinition 
public instanceif_message~get_text redefinition 
\ No newline at end of file diff --git a/docs/ABAPDoc/htmldesign/stylesheet.css b/docs/ABAPDoc/htmldesign/stylesheet.css new file mode 100644 index 0000000..30680b5 --- /dev/null +++ b/docs/ABAPDoc/htmldesign/stylesheet.css @@ -0,0 +1,30 @@ +body { font-family:arial; font-size:13px; background-color: white; margin: 0px; } +table { border: 1px solid black; border-spacing: 0px; border-collapse: collapse; text-align: left; vertical-align: top; width: 100%; } +tr { vertical-align: top; } +th { border: 1px solid black; padding: 4px; background-color: #EBEBEB; text-align: left; } +td { border: 1px solid black; padding: 3px; } +h2 { font-size: 22px; } +h4 { font-size: 18px; } +h5 { font-size: 13px; font-weight: bold; margin-bottom: 5px; } +a { color: black; } +#header { border-bottom: 3px solid grey; background-color: ghostwhite; width: 100%; padding: 4px; padding-left: 8px; } +#headerTitle { padding: 5px; font-size: 22px } +#content { margin: 8px; } +#footer { font-size: 11px; padding-bottom: 8px; padding-left: 8px; } +.identifier { font-weight: bold; text-transform: lowercase; } +.methodSignature { border: 0px; margin: 1px; width: auto; } +.methodSignature tr { text-align: left; vertical-align: top; } +.methodSignature td { border: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 5px; } +.methodParametersDocumentation { border: 0px; margin-left: 5px; width: auto; } +.methodParametersDocumentation td { border: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 5px; } +.parametersTable { border: 0px; } +.fieldName {} +.methodName {} +.parameterName {} +.exceptionName {} +.objectName { text-transform: uppercase; } +.interfaceName { font-weight: normal; } +.exceptions { border: 0px; width: auto; } +.exceptions td { border: 0px; padding: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 5px; } +.abapDocComment p { margin-top: 0px; } +.shorttext { margin-top: 0px; } \ No newline at end of file diff --git a/docs/ABAPDoc/readme.txt b/docs/ABAPDoc/readme.txt new file mode 100644 index 0000000..78253c2 --- /dev/null +++ b/docs/ABAPDoc/readme.txt @@ -0,0 +1,15 @@ +Content of this folder: + +./abapdoc/ + +Contains the exported documentation for the selected classes and interfaces. Each object is stored in its ABAP package e.g. + ++---package + \---subpackage + \---classes + \---cl_abap_class + + +./htmldesign/ + +Contains the html stylesheet. It can be used to change the design of the generated documentation. \ No newline at end of file diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..5ca7b8b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,31 @@ + + + Reference ABAP SDK for IBM Watson + + + +

ABAP SDK for IBM Watson: API Reference

+
+
The ABAP SDK is used to consume IBM Watson cognitive services with the SAP Business Suite and S/4HANA.
+
It wraps the IBM Watson service REST API into regular ABAP classes and delivers ABAP data types that exactly fit the IBM Watson interface.
+

+ The table below provides an overview on the supported IBM Watson services. Click the ABAP class name to navigate to the corresponding methods and data types reference. +

+ + + + + + + + + + + + + + + +
Watson serviceVersionABAP Class Name
Watson AssistantV1ZCL_IBMC_ASSISTANT_V1
Watson AssistantV2ZCL_IBMC_ASSISTANT_V2
Compare and ComplyV1ZCL_IBMC_COMPARE_COMPLY_V1
DiscoveryV1ZCL_IBMC_DISCOVERY_V1
Language TranslatorV3ZCL_IBMC_LANG_TRANSLATOR_V3
Natural Language ClassifierV1ZCL_IBMC_NAT_LANG_CLASS_V1
Natural Language UnderstandingV1ZCL_IBMC_NAT_LANG_UNDRSTND_V1
Personality InsightsV3ZCL_IBMC_PERSONAL_INSIGHTS_V3
Speech to TextV1ZCL_IBMC_SPEECH_TO_TEXT_V1
Text to SpeechV1ZCL_IBMC_TEXT_TO_SPEECH_V1
Tone AnalyzerV3ZCL_IBMC_TONE_ANALYZER_V3
Visual RecognitionV3ZCL_IBMC_VISUAL_RECOGNITION_V3
Visual RecognitionV4ZCL_IBMC_VISUAL_RECOGNITION_V4
+ + 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..ac37d14 --- /dev/null +++ b/src/zcl_ibmc_assistant_v1.clas.abap @@ -0,0 +1,5944 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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: + "! + begin of T_DIA_ND_OTPT_TEXT_VALUES_ELEM, + TEXT type STRING, + end of T_DIA_ND_OTPT_TEXT_VALUES_ELEM. + types: + "! A mention of a contextual entity. + begin of T_MENTION, + ENTITY type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_MENTION. + types: + "! + begin of T_EXAMPLE, + TEXT type STRING, + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_EXAMPLE. + types: + "! + begin of T_INTENT, + INTENT type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_INTENT. + types: + "! + begin of T_DIALOG_NODE_ACTION, + NAME type STRING, + TYPE type STRING, + PARAMETERS type MAP, + RESULT_VARIABLE type STRING, + CREDENTIALS type STRING, + end of T_DIALOG_NODE_ACTION. + types: + "! Workspace settings related to the disambiguation feature. + "! + "! **Note:** This feature is available only to Premium users. + begin of T_WS_SYSTM_STTNGS_DSMBGTN, + PROMPT type STRING, + NONE_OF_THE_ABOVE_PROMPT type STRING, + ENABLED type BOOLEAN, + SENSITIVITY 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, + 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, + BEHAVIOR type STRING, + DIALOG_NODE type STRING, + SELECTOR type STRING, + end of T_DIALOG_NODE_NEXT_STEP. + types: + "! An input object that includes the input text. + begin of T_MESSAGE_INPUT, + TEXT type STRING, + end of T_MESSAGE_INPUT. + types: + "! A recognized capture group for a pattern-based entity. + begin of T_CAPTURE_GROUP, + GROUP type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_CAPTURE_GROUP. + types: + "! A term from the request that was identified as an entity. + begin of T_RUNTIME_ENTITY, + ENTITY type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + VALUE type STRING, + CONFIDENCE type NUMBER, + METADATA type MAP, + GROUPS type STANDARD TABLE OF T_CAPTURE_GROUP WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_ENTITY. + types: + "! An intent identified in the user input. + begin of T_RUNTIME_INTENT, + INTENT type STRING, + 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, + INPUT type T_MESSAGE_INPUT, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + end of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE. + types: + "! + begin of T_DIA_NODE_OUTPUT_OPT_ELEMENT, + LABEL type STRING, + VALUE type T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + end of T_DIA_NODE_OUTPUT_OPT_ELEMENT. + types: + "! + begin of T_DIALOG_NODE_OUTPUT_GENERIC, + RESPONSE_TYPE type STRING, + VALUES type STANDARD TABLE OF T_DIA_ND_OTPT_TEXT_VALUES_ELEM WITH NON-UNIQUE DEFAULT KEY, + SELECTION_POLICY type STRING, + DELIMITER type STRING, + TIME type INTEGER, + TYPING type BOOLEAN, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + MESSAGE_TO_HUMAN_AGENT type STRING, + QUERY type STRING, + QUERY_TYPE type STRING, + FILTER type STRING, + 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/services/assistant?topic=assistant-d + "! ialog-overview#dialog-overview-responses). + begin of T_DIALOG_NODE_OUTPUT, + GENERIC type STANDARD TABLE OF T_DIALOG_NODE_OUTPUT_GENERIC WITH NON-UNIQUE DEFAULT KEY, + MODIFIERS type T_DIALOG_NODE_OUTPUT_MODIFIERS, + end of T_DIALOG_NODE_OUTPUT. + types: + "! Workspace settings related to the Watson Assistant user interface. + begin of T_WS_SYSTEM_SETTINGS_TOOLING, + STORE_GENERIC_RESPONSES type BOOLEAN, + end of T_WS_SYSTEM_SETTINGS_TOOLING. + types: + "! Global settings for the workspace. + begin of T_WORKSPACE_SYSTEM_SETTINGS, + TOOLING type T_WS_SYSTEM_SETTINGS_TOOLING, + DISAMBIGUATION type T_WS_SYSTM_STTNGS_DSMBGTN, + HUMAN_AGENT_ASSIST type MAP, + end of T_WORKSPACE_SYSTEM_SETTINGS. + types: + "! + begin of T_DIALOG_NODE, + DIALOG_NODE type STRING, + DESCRIPTION type STRING, + CONDITIONS type STRING, + PARENT type STRING, + PREVIOUS_SIBLING type STRING, + OUTPUT type T_DIALOG_NODE_OUTPUT, + CONTEXT type MAP, + METADATA type MAP, + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + TITLE type STRING, + TYPE type STRING, + EVENT_NAME type STRING, + VARIABLE type STRING, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + DIGRESS_IN type STRING, + DIGRESS_OUT type STRING, + DIGRESS_OUT_SLOTS type STRING, + USER_LABEL type STRING, + DISABLED type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_DIALOG_NODE. + types: + "! + begin of T_VALUE, + VALUE type STRING, + METADATA type MAP, + TYPE type STRING, + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_VALUE. + types: + "! + begin of T_COUNTEREXAMPLE, + TEXT type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_COUNTEREXAMPLE. + types: + "! + begin of T_ENTITY, + ENTITY type STRING, + DESCRIPTION type STRING, + METADATA type MAP, + FUZZY_MATCH type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + VALUES type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_ENTITY. + types: + "! + begin of T_WORKSPACE, + NAME type STRING, + DESCRIPTION type STRING, + LANGUAGE type STRING, + METADATA type MAP, + LEARNING_OPT_OUT type BOOLEAN, + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + WORKSPACE_ID type STRING, + STATUS type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + INTENTS type STANDARD TABLE OF T_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_ENTITY WITH NON-UNIQUE DEFAULT KEY, + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_WORKSPACE. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_NUM, + NUMERIC_VALUE type NUMBER, + RANGE_LINK type STRING, + SUBTYPE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_NUM. + types: + "! + begin of T_UPDATE_COUNTEREXAMPLE, + TEXT type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_UPDATE_COUNTEREXAMPLE. + types: + "! + begin of T_SYNONYM, + SYNONYM type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_SYNONYM. + types: + "! The pagination data for the returned objects. + begin of T_PAGINATION, + REFRESH_URL type STRING, + NEXT_URL type STRING, + TOTAL type INTEGER, + MATCHED type INTEGER, + REFRESH_CURSOR type STRING, + NEXT_CURSOR type STRING, + end of T_PAGINATION. + types: + "! + begin of T_SYNONYM_COLLECTION, + SYNONYMS type STANDARD TABLE OF T_SYNONYM WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_SYNONYM_COLLECTION. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_OPTION, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_OPTION. + types: + "! Log message details. + begin of T_LOG_MESSAGE, + LEVEL type STRING, + MSG type STRING, + end of T_LOG_MESSAGE. + types: + "! An array of objects describing the entities for the workspace. + begin of T_ENTITY_COLLECTION, + ENTITIES type STANDARD TABLE OF T_ENTITY WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_ENTITY_COLLECTION. + types: + "! + begin of T_DIA_ND_OUTPUT_RESP_TYPE_TEXT, + VALUES type STANDARD TABLE OF T_DIA_ND_OTPT_TEXT_VALUES_ELEM WITH NON-UNIQUE DEFAULT KEY, + SELECTION_POLICY type STRING, + DELIMITER type STRING, + end of T_DIA_ND_OUTPUT_RESP_TYPE_TEXT. + types: + "! + begin of T_INTENT_COLLECTION, + INTENTS type STANDARD TABLE OF T_INTENT WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_INTENT_COLLECTION. + types: + "! + begin of T_DIA_ND_OTPT_RESP_TYPE_PAUSE, + TIME type INTEGER, + TYPING type BOOLEAN, + end of T_DIA_ND_OTPT_RESP_TYPE_PAUSE. + types: + "! + begin of T_BASE_WORKSPACE, + NAME type STRING, + DESCRIPTION type STRING, + LANGUAGE type STRING, + METADATA type MAP, + LEARNING_OPT_OUT type BOOLEAN, + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + WORKSPACE_ID type STRING, + STATUS type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_WORKSPACE. + types: + "! + begin of T_DIA_SUGGESTION_RESP_GENERIC, + RESPONSE_TYPE type STRING, + TEXT type STRING, + TIME type INTEGER, + TYPING type BOOLEAN, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + MESSAGE_TO_HUMAN_AGENT type STRING, + TOPIC type STRING, + DIALOG_NODE type STRING, + end of T_DIA_SUGGESTION_RESP_GENERIC. + types: + "! + begin of T_DIA_ND_OUTPUT_RESP_TYPE_IMG, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + end of T_DIA_ND_OUTPUT_RESP_TYPE_IMG. + types: + "! + begin of T_ERROR_DETAIL, + MESSAGE type STRING, + PATH type STRING, + end of T_ERROR_DETAIL. + types: + "! + begin of T_ERROR_RESPONSE, + ERROR type STRING, + ERRORS type STANDARD TABLE OF T_ERROR_DETAIL WITH NON-UNIQUE DEFAULT KEY, + CODE type INTEGER, + end of T_ERROR_RESPONSE. + types: + "! Workspace settings related to the behavior of system entities. + begin of T_WS_SYSTM_STTNGS_SYSTM_ENTTS, + ENABLED type BOOLEAN, + end of T_WS_SYSTM_STTNGS_SYSTM_ENTTS. + types: + "! + begin of T_RT_ENTITY_INTERPRETATION, + CALENDAR_TYPE type STRING, + DATETIME_LINK type STRING, + FESTIVAL type STRING, + GRANULARITY type STRING, + RANGE_LINK type STRING, + RANGE_MODIFIER type STRING, + RELATIVE_DAY type NUMBER, + RELATIVE_MONTH type NUMBER, + RELATIVE_WEEK type NUMBER, + RELATIVE_WEEKEND type NUMBER, + RELATIVE_YEAR type NUMBER, + SPECIFIC_DAY type NUMBER, + SPECIFIC_DAY_OF_WEEK type STRING, + SPECIFIC_MONTH type NUMBER, + SPECIFIC_QUARTER type NUMBER, + SPECIFIC_YEAR type NUMBER, + NUMERIC_VALUE type NUMBER, + SUBTYPE type STRING, + PART_OF_DAY type STRING, + RELATIVE_HOUR type NUMBER, + RELATIVE_MINUTE type NUMBER, + RELATIVE_SECOND type NUMBER, + SPECIFIC_HOUR type NUMBER, + SPECIFIC_MINUTE type NUMBER, + SPECIFIC_SECOND type NUMBER, + TIMEZONE type STRING, + end of T_RT_ENTITY_INTERPRETATION. + 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, + INPUT type T_MESSAGE_INPUT, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + end of T_DIALOG_SUGGESTION_VALUE. + types: + "! + begin of T_DIALOG_NODE_VISITED_DETAILS, + DIALOG_NODE type STRING, + TITLE type STRING, + CONDITIONS type STRING, + end of T_DIALOG_NODE_VISITED_DETAILS. + 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, + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + GENERIC type STANDARD TABLE OF T_DIA_SUGGESTION_RESP_GENERIC WITH NON-UNIQUE DEFAULT KEY, + end of T_DIALOG_SUGGESTION_OUTPUT. + types: + "! + begin of T_BASE_ENTITY, + ENTITY type STRING, + DESCRIPTION type STRING, + METADATA type MAP, + FUZZY_MATCH type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_ENTITY. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_TEXT, + TEXT type STRING, + end of T_RUNTIME_RESPONSE_TYPE_TEXT. + types: + "! For internal use only. + T_SYSTEM_RESPONSE type MAP. + types: + "! Metadata related to the message. + begin of T_MESSAGE_CONTEXT_METADATA, + DEPLOYMENT type STRING, + 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, + CONVERSATION_ID type STRING, + SYSTEM type T_SYSTEM_RESPONSE, + METADATA type T_MESSAGE_CONTEXT_METADATA, + end of T_CONTEXT. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_TIME, + DATETIME_LINK type STRING, + GRANULARITY type STRING, + PART_OF_DAY type STRING, + RANGE_LINK type STRING, + RELATIVE_HOUR type NUMBER, + RELATIVE_MINUTE type NUMBER, + RELATIVE_SECOND type NUMBER, + SPECIFIC_HOUR type NUMBER, + SPECIFIC_MINUTE type NUMBER, + SPECIFIC_SECOND type NUMBER, + TIMEZONE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_TIME. + types: + "! + begin of T_UPDATE_EXAMPLE, + TEXT type STRING, + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_UPDATE_EXAMPLE. + types: + "! + begin of T_DIALOG_SUGGESTION, + LABEL type STRING, + VALUE type T_DIALOG_SUGGESTION_VALUE, + OUTPUT type T_DIALOG_SUGGESTION_OUTPUT, + DIALOG_NODE type STRING, + end of T_DIALOG_SUGGESTION. + types: + "! + begin of T_RUNTIME_RESPONSE_GENERIC, + RESPONSE_TYPE type STRING, + TEXT type STRING, + TIME type INTEGER, + TYPING type BOOLEAN, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + MESSAGE_TO_HUMAN_AGENT type STRING, + TOPIC type STRING, + DIALOG_NODE type STRING, + 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, + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + LOG_MESSAGES type STANDARD TABLE OF T_LOG_MESSAGE WITH NON-UNIQUE DEFAULT KEY, + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + GENERIC type STANDARD TABLE OF T_RUNTIME_RESPONSE_GENERIC WITH NON-UNIQUE DEFAULT KEY, + end of T_OUTPUT_DATA. + types: + "! + begin of T_BASE_MESSAGE, + INPUT type T_MESSAGE_INPUT, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + ALTERNATE_INTENTS type BOOLEAN, + CONTEXT type T_CONTEXT, + OUTPUT type T_OUTPUT_DATA, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_MESSAGE. + types: + "! An object describing a contextual entity mention. + begin of T_ENTITY_MENTION, + TEXT type STRING, + INTENT type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + end of T_ENTITY_MENTION. + types: + "! + begin of T_RT_RESPONSE_TYPE_SUGGESTION, + TITLE type STRING, + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + end of T_RT_RESPONSE_TYPE_SUGGESTION. + types: + "! + begin of T_ENTITY_MENTION_COLLECTION, + EXAMPLES type STANDARD TABLE OF T_ENTITY_MENTION WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_ENTITY_MENTION_COLLECTION. + types: + "! + begin of T_UPDATE_SYNONYM, + SYNONYM type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_UPDATE_SYNONYM. + types: + "! + begin of T_DIA_ND_OTPT_RESP_TYP_SRCH_S1, + QUERY type STRING, + QUERY_TYPE type STRING, + FILTER type STRING, + DISCOVERY_VERSION type STRING, + end of T_DIA_ND_OTPT_RESP_TYP_SRCH_S1. + types: + "! + begin of T_EXAMPLE_COLLECTION, + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_EXAMPLE_COLLECTION. + types: + "! The pagination data for the returned objects. + begin of T_LOG_PAGINATION, + NEXT_URL type STRING, + MATCHED type INTEGER, + NEXT_CURSOR type STRING, + end of T_LOG_PAGINATION. + types: + "! + begin of T_RT_RESP_TYP_CONNECT_TO_AGENT, + MESSAGE_TO_HUMAN_AGENT type STRING, + TOPIC type STRING, + DIALOG_NODE type STRING, + end of T_RT_RESP_TYP_CONNECT_TO_AGENT. + types: + "! + begin of T_CREATE_VALUE, + VALUE type STRING, + METADATA type MAP, + TYPE type STRING, + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_CREATE_VALUE. + types: + "! + begin of T_BASE_INTENT, + INTENT type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_INTENT. + types: + "! + T_EMPTY_RESPONSE type JSONOBJECT. + types: + "! + begin of T_UPDATE_VALUE, + VALUE type STRING, + METADATA type MAP, + TYPE type STRING, + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_UPDATE_VALUE. + types: + "! An alternative value for the recognized entity. + begin of T_RUNTIME_ENTITY_ALTERNATIVE, + VALUE type STRING, + CONFIDENCE type NUMBER, + end of T_RUNTIME_ENTITY_ALTERNATIVE. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_DATE, + CALENDAR_TYPE type STRING, + DATETIME_LINK type STRING, + FESTIVAL type STRING, + GRANULARITY type STRING, + RANGE_LINK type STRING, + RANGE_MODIFIER type STRING, + RELATIVE_DAY type NUMBER, + RELATIVE_MONTH type NUMBER, + RELATIVE_WEEK type NUMBER, + RELATIVE_WEEKEND type NUMBER, + RELATIVE_YEAR type NUMBER, + SPECIFIC_DAY type NUMBER, + SPECIFIC_DAY_OF_WEEK type STRING, + SPECIFIC_MONTH type NUMBER, + SPECIFIC_QUARTER type NUMBER, + SPECIFIC_YEAR type NUMBER, + end of T_RT_ENTTY_INTRPRTTN_SYS_DATE. + types: + "! + begin of T_UPDATE_INTENT, + INTENT type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_INTENT. + types: + "! + begin of T_VALUE_COLLECTION, + VALUES type STANDARD TABLE OF T_VALUE WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_VALUE_COLLECTION. + 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 part of the new system entities, which are a beta feature. + begin of T_RUNTIME_ENTITY_ROLE, + TYPE type STRING, + end of T_RUNTIME_ENTITY_ROLE. + types: + "! + begin of T_DIA_ND_OUTPUT_RESP_TYPE_OPT, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + 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: + "! + begin of T_BASE_COUNTEREXAMPLE, + TEXT type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_COUNTEREXAMPLE. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_IMAGE, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + end of T_RUNTIME_RESPONSE_TYPE_IMAGE. + types: + "! + begin of T_CREATE_INTENT, + INTENT type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + EXAMPLES type STANDARD TABLE OF T_EXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_INTENT. + types: + "! + begin of T_CREATE_ENTITY, + ENTITY type STRING, + DESCRIPTION type STRING, + METADATA type MAP, + FUZZY_MATCH type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + VALUES type STANDARD TABLE OF T_CREATE_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_ENTITY. + types: + "! + begin of T_UPDATE_WORKSPACE, + NAME type STRING, + DESCRIPTION type STRING, + LANGUAGE type STRING, + METADATA type MAP, + LEARNING_OPT_OUT type BOOLEAN, + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + WORKSPACE_ID type STRING, + STATUS type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + INTENTS type STANDARD TABLE OF T_CREATE_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_CREATE_ENTITY WITH NON-UNIQUE DEFAULT KEY, + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_WORKSPACE. + types: + "! An array of dialog nodes. + begin of T_DIALOG_NODE_COLLECTION, + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_DIALOG_NODE_COLLECTION. + types: + "! + begin of T_BASE_DIALOG_NODE, + DIALOG_NODE type STRING, + DESCRIPTION type STRING, + CONDITIONS type STRING, + PARENT type STRING, + PREVIOUS_SIBLING type STRING, + OUTPUT type T_DIALOG_NODE_OUTPUT, + CONTEXT type MAP, + METADATA type MAP, + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + TITLE type STRING, + TYPE type STRING, + EVENT_NAME type STRING, + VARIABLE type STRING, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + DIGRESS_IN type STRING, + DIGRESS_OUT type STRING, + DIGRESS_OUT_SLOTS type STRING, + USER_LABEL type STRING, + DISABLED type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_DIALOG_NODE. + types: + "! The response sent by the workspace, including the output text, detected intents + "! and entities, and context. + begin of T_MESSAGE_RESPONSE, + INPUT type T_MESSAGE_INPUT, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + ALTERNATE_INTENTS type BOOLEAN, + CONTEXT type T_CONTEXT, + OUTPUT type T_OUTPUT_DATA, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_MESSAGE_RESPONSE. + types: + "! + begin of T_BASE_VALUE, + VALUE type STRING, + METADATA type MAP, + TYPE type STRING, + SYNONYMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + PATTERNS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_VALUE. + types: + "! A request sent to the workspace, including the user input and context. + begin of T_MESSAGE_REQUEST, + INPUT type T_MESSAGE_INPUT, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + ALTERNATE_INTENTS type BOOLEAN, + CONTEXT type T_CONTEXT, + OUTPUT type T_OUTPUT_DATA, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + end of T_MESSAGE_REQUEST. + types: + "! + begin of T_LOG, + REQUEST type T_MESSAGE_REQUEST, + RESPONSE type T_MESSAGE_RESPONSE, + LOG_ID type STRING, + REQUEST_TIMESTAMP type STRING, + RESPONSE_TIMESTAMP type STRING, + WORKSPACE_ID type STRING, + LANGUAGE type STRING, + end of T_LOG. + types: + "! + begin of T_UPDATE_ENTITY, + ENTITY type STRING, + DESCRIPTION type STRING, + METADATA type MAP, + FUZZY_MATCH type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + VALUES type STANDARD TABLE OF T_CREATE_VALUE WITH NON-UNIQUE DEFAULT KEY, + end of T_UPDATE_ENTITY. + 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, + NODES_VISITED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + NODES_VISITED_DETAILS type STANDARD TABLE OF T_DIALOG_NODE_VISITED_DETAILS WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_OUTPUT. + types: + "! + begin of T_UPDATE_DIALOG_NODE, + DIALOG_NODE type STRING, + DESCRIPTION type STRING, + CONDITIONS type STRING, + PARENT type STRING, + PREVIOUS_SIBLING type STRING, + OUTPUT type T_DIALOG_NODE_OUTPUT, + CONTEXT type MAP, + METADATA type MAP, + NEXT_STEP type T_DIALOG_NODE_NEXT_STEP, + TITLE type STRING, + TYPE type STRING, + EVENT_NAME type STRING, + VARIABLE type STRING, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + DIGRESS_IN type STRING, + DIGRESS_OUT type STRING, + DIGRESS_OUT_SLOTS type STRING, + USER_LABEL type STRING, + DISABLED type BOOLEAN, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_UPDATE_DIALOG_NODE. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_PAUSE, + TIME type INTEGER, + TYPING type BOOLEAN, + end of T_RUNTIME_RESPONSE_TYPE_PAUSE. + types: + "! + begin of T_LOG_COLLECTION, + LOGS type STANDARD TABLE OF T_LOG WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_LOG_PAGINATION, + end of T_LOG_COLLECTION. + types: + "! + begin of T_DIA_ND_OTPT_RESP_TYP_CNNCT_1, + MESSAGE_TO_HUMAN_AGENT type STRING, + end of T_DIA_ND_OTPT_RESP_TYP_CNNCT_1. + types: + "! + begin of T_AUDIT_PROPERTIES, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_AUDIT_PROPERTIES. + types: + "! + begin of T_CREATE_WORKSPACE, + NAME type STRING, + DESCRIPTION type STRING, + LANGUAGE type STRING, + METADATA type MAP, + LEARNING_OPT_OUT type BOOLEAN, + SYSTEM_SETTINGS type T_WORKSPACE_SYSTEM_SETTINGS, + WORKSPACE_ID type STRING, + STATUS type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + INTENTS type STANDARD TABLE OF T_CREATE_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_CREATE_ENTITY WITH NON-UNIQUE DEFAULT KEY, + DIALOG_NODES type STANDARD TABLE OF T_DIALOG_NODE WITH NON-UNIQUE DEFAULT KEY, + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + end of T_CREATE_WORKSPACE. + types: + "! + begin of T_COUNTEREXAMPLE_COLLECTION, + COUNTEREXAMPLES type STANDARD TABLE OF T_COUNTEREXAMPLE WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_COUNTEREXAMPLE_COLLECTION. + types: + "! + begin of T_WORKSPACE_COLLECTION, + WORKSPACES type STANDARD TABLE OF T_WORKSPACE WITH NON-UNIQUE DEFAULT KEY, + PAGINATION type T_PAGINATION, + end of T_WORKSPACE_COLLECTION. + types: + "! + begin of T_BASE_SYNONYM, + SYNONYM type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_SYNONYM. + types: + "! + begin of T_BASE_EXAMPLE, + TEXT type STRING, + MENTIONS type STANDARD TABLE OF T_MENTION WITH NON-UNIQUE DEFAULT KEY, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BASE_EXAMPLE. + +constants: + begin of C_REQUIRED_FIELDS, + T_DIA_ND_OTPT_TEXT_VALUES_ELEM type string value '|', + T_MENTION type string value '|ENTITY|LOCATION|', + T_EXAMPLE type string value '|TEXT|', + T_INTENT type string value '|INTENT|', + 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 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_DIALOG_NODE_OUTPUT_GENERIC type string value '|RESPONSE_TYPE|', + T_DIALOG_NODE_OUTPUT type string value '|', + T_WS_SYSTEM_SETTINGS_TOOLING type string value '|', + T_WORKSPACE_SYSTEM_SETTINGS type string value '|', + T_DIALOG_NODE type string value '|DIALOG_NODE|', + T_VALUE type string value '|VALUE|TYPE|', + 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_RT_ENTTY_INTRPRTTN_SYS_NUM type string value '|', + T_UPDATE_COUNTEREXAMPLE type string value '|', + 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_LOG_MESSAGE type string value '|LEVEL|MSG|', + T_ENTITY_COLLECTION type string value '|ENTITIES|PAGINATION|', + T_DIA_ND_OUTPUT_RESP_TYPE_TEXT type string value '|', + T_INTENT_COLLECTION type string value '|INTENTS|PAGINATION|', + T_DIA_ND_OTPT_RESP_TYPE_PAUSE type string value '|', + T_BASE_WORKSPACE type string value '|', + T_DIA_SUGGESTION_RESP_GENERIC type string value '|RESPONSE_TYPE|', + T_DIA_ND_OUTPUT_RESP_TYPE_IMG type string value '|', + T_ERROR_DETAIL type string value '|MESSAGE|', + T_ERROR_RESPONSE type string value '|ERROR|CODE|', + T_WS_SYSTM_STTNGS_SYSTM_ENTTS type string value '|', + T_RT_ENTITY_INTERPRETATION type string value '|', + T_DIALOG_SUGGESTION_VALUE type string value '|', + T_DIALOG_NODE_VISITED_DETAILS type string value '|', + T_DIALOG_SUGGESTION_OUTPUT type string value '|TEXT|', + T_BASE_ENTITY type string value '|', + T_RUNTIME_RESPONSE_TYPE_TEXT type string value '|', + T_MESSAGE_CONTEXT_METADATA type string value '|', + T_CONTEXT type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_TIME type string value '|', + T_UPDATE_EXAMPLE type string value '|', + T_DIALOG_SUGGESTION type string value '|LABEL|VALUE|', + T_RUNTIME_RESPONSE_GENERIC type string value '|RESPONSE_TYPE|', + T_OUTPUT_DATA type string value '|LOG_MESSAGES|TEXT|', + T_BASE_MESSAGE type string value '|', + T_ENTITY_MENTION type string value '|TEXT|INTENT|LOCATION|', + T_RT_RESPONSE_TYPE_SUGGESTION type string value '|', + T_ENTITY_MENTION_COLLECTION type string value '|EXAMPLES|PAGINATION|', + T_UPDATE_SYNONYM type string value '|', + 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_BASE_INTENT type string value '|', + T_UPDATE_VALUE type string value '|', + T_RUNTIME_ENTITY_ALTERNATIVE type string value '|', + T_RT_ENTTY_INTRPRTTN_SYS_DATE type string value '|', + T_UPDATE_INTENT type string value '|', + T_VALUE_COLLECTION type string value '|VALUES|PAGINATION|', + T_RUNTIME_ENTITY_ROLE 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_CREATE_INTENT type string value '|INTENT|', + T_CREATE_ENTITY type string value '|ENTITY|', + T_UPDATE_WORKSPACE type string value '|', + T_DIALOG_NODE_COLLECTION type string value '|DIALOG_NODES|PAGINATION|', + T_BASE_DIALOG_NODE type string value '|', + T_MESSAGE_RESPONSE type string value '|INPUT|INTENTS|ENTITIES|CONTEXT|OUTPUT|', + T_BASE_VALUE 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_UPDATE_ENTITY type string value '|', + T_BASE_OUTPUT type string value '|', + T_UPDATE_DIALOG_NODE type string value '|', + T_RUNTIME_RESPONSE_TYPE_PAUSE type string value '|', + T_LOG_COLLECTION type string value '|LOGS|PAGINATION|', + T_DIA_ND_OTPT_RESP_TYP_CNNCT_1 type string value '|', + T_AUDIT_PROPERTIES type string value '|', + T_CREATE_WORKSPACE type string value '|', + T_COUNTEREXAMPLE_COLLECTION type string value '|COUNTEREXAMPLES|PAGINATION|', + T_WORKSPACE_COLLECTION type string value '|WORKSPACES|PAGINATION|', + T_BASE_SYNONYM type string value '|', + T_BASE_EXAMPLE 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', + 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', + 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', + PARAMETERS type string value 'parameters', + RESULT_VARIABLE type string value 'result_variable', + CREDENTIALS type string value 'credentials', + GENERIC type string value 'generic', + MODIFIERS type string value 'modifiers', + OVERWRITE type string value 'overwrite', + 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', + TOPIC type string value 'topic', + SUGGESTIONS type string value 'suggestions', + LABEL type string value 'label', + 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', + DIALOGNODES type string value 'dialogNodes', + BEHAVIOR type string value 'behavior', + SELECTOR type string value 'selector', + 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', + LOGS type string value 'logs', + LEVEL type string value 'level', + MSG type string value 'msg', + 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', + 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', + 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', + TOOLING type string value 'tooling', + DISAMBIGUATION type string value 'disambiguation', + HUMAN_AGENT_ASSIST type string value 'human_agent_assist', + ENABLED type string value 'enabled', + STORE_GENERIC_RESPONSES type string value 'store_generic_responses', + PROMPT type string value 'prompt', + NONE_OF_THE_ABOVE_PROMPT type string value 'none_of_the_above_prompt', + SENSITIVITY type string value 'sensitivity', + WORKSPACES type string value 'workspaces', + 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 + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_WORKSPACE + "! + methods CREATE_WORKSPACE + importing + !I_body type T_CREATE_WORKSPACE optional + !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 + "! + 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 workspace. If + "! **append**=`false`, elements included in the new data completely replace the + "! corresponding existing elements, including all subelements. For example, if the + "! new data includes **entities** and **append**=`false`, all existing entities in + "! the workspace are discarded and replaced with the new entities. + "! + "! If **append**=`true`, existing elements are preserved, and the new elements are + "! added. If any elements in the new data collide with existing elements, the + "! update request fails. + "! @parameter E_RESPONSE | + "! Service return value of type T_WORKSPACE + "! + 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_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. + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_INTENT + "! + methods CREATE_INTENT + importing + !I_workspace_id type STRING + !I_body type T_CREATE_INTENT + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_INTENT + "! + methods UPDATE_INTENT + importing + !I_workspace_id type STRING + !I_intent type STRING + !I_body type T_UPDATE_INTENT + !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. + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_EXAMPLE + "! + methods CREATE_EXAMPLE + importing + !I_workspace_id type STRING + !I_intent type STRING + !I_body type T_EXAMPLE + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_EXAMPLE + "! + methods UPDATE_EXAMPLE + importing + !I_workspace_id type STRING + !I_intent type STRING + !I_text type STRING + !I_body type T_UPDATE_EXAMPLE + !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. + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE + "! + methods CREATE_COUNTEREXAMPLE + importing + !I_workspace_id type STRING + !I_body type T_COUNTEREXAMPLE + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_COUNTEREXAMPLE + "! + methods UPDATE_COUNTEREXAMPLE + importing + !I_workspace_id type STRING + !I_text type STRING + !I_body type T_UPDATE_COUNTEREXAMPLE + !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?`). + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_ENTITY + "! + methods CREATE_ENTITY + importing + !I_workspace_id type STRING + !I_body type T_CREATE_ENTITY + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_ENTITY + "! + methods UPDATE_ENTITY + importing + !I_workspace_id type STRING + !I_entity type STRING + !I_body type T_UPDATE_ENTITY + !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. + "! + 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 + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_VALUE + "! + methods CREATE_VALUE + importing + !I_workspace_id type STRING + !I_entity type STRING + !I_body type T_CREATE_VALUE + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_VALUE + "! + methods UPDATE_VALUE + importing + !I_workspace_id type STRING + !I_entity type STRING + !I_value type STRING + !I_body type T_UPDATE_VALUE + !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. + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_SYNONYM + "! + methods CREATE_SYNONYM + importing + !I_workspace_id type STRING + !I_entity type STRING + !I_value type STRING + !I_body type T_SYNONYM + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_SYNONYM + "! + 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_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. + "! + 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 + "! + 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 E_RESPONSE | + "! Service return value of type T_DIALOG_NODE + "! + methods CREATE_DIALOG_NODE + importing + !I_workspace_id type STRING + !I_body type T_DIALOG_NODE + !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 + "! + 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 E_RESPONSE | + "! Service return value of type T_DIALOG_NODE + "! + methods UPDATE_DIALOG_NODE + importing + !I_workspace_id type STRING + !I_dialog_node type STRING + !I_body type T_UPDATE_DIALOG_NODE + !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`). + "! + 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/services/assistant?topic=assistant-f + "! ilter-reference#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 + "! + 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 `workspace_id` or `request.context.metadata.deployment`. + "! For more information, see the + "! [documentation](https://cloud.ibm.com/docs/services/assistant?topic=assistant-f + "! ilter-reference#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 + "! + 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. + "! + 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( ). + + 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 = '20191002122834'. + + 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_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 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_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. + + + + + " 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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_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 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..da00af5 --- /dev/null +++ b/src/zcl_ibmc_assistant_v2.clas.abap @@ -0,0 +1,876 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + LEVEL type STRING, + MESSAGE type STRING, + end of T_DIALOG_LOG_MESSAGE. + types: + "! + begin of T_DIALOG_NODES_VISITED, + DIALOG_NODE type STRING, + TITLE type STRING, + 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, + NODES_VISITED type STANDARD TABLE OF T_DIALOG_NODES_VISITED WITH NON-UNIQUE DEFAULT KEY, + LOG_MESSAGES type STANDARD TABLE OF T_DIALOG_LOG_MESSAGE WITH NON-UNIQUE DEFAULT KEY, + BRANCH_EXITED type BOOLEAN, + BRANCH_EXITED_REASON type STRING, + end of T_MESSAGE_OUTPUT_DEBUG. + types: + "! + T_EMPTY_RESPONSE type JSONOBJECT. + types: + "! + begin of T_SESSION_RESPONSE, + SESSION_ID type STRING, + end of T_SESSION_RESPONSE. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_NUM, + NUMERIC_VALUE type NUMBER, + RANGE_LINK type STRING, + 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, + VALUE type STRING, + CONFIDENCE type NUMBER, + end of T_RUNTIME_ENTITY_ALTERNATIVE. + types: + "! Optional properties that control how the assistant responds. + begin of T_MESSAGE_INPUT_OPTIONS, + DEBUG type BOOLEAN, + RESTART type BOOLEAN, + ALTERNATE_INTENTS type BOOLEAN, + RETURN_CONTEXT type BOOLEAN, + end of T_MESSAGE_INPUT_OPTIONS. + types: + "! An intent identified in the user input. + begin of T_RUNTIME_INTENT, + INTENT type STRING, + CONFIDENCE type DOUBLE, + end of T_RUNTIME_INTENT. + types: + "! + begin of T_CAPTURE_GROUP, + GROUP type STRING, + 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, + ENTITY type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + VALUE type STRING, + CONFIDENCE type NUMBER, + METADATA type MAP, + GROUPS type STANDARD TABLE OF T_CAPTURE_GROUP WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_ENTITY. + types: + "! An input object that includes the input text. + begin of T_MESSAGE_INPUT, + MESSAGE_TYPE type STRING, + TEXT type STRING, + OPTIONS type T_MESSAGE_INPUT_OPTIONS, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + 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, + INPUT type T_MESSAGE_INPUT, + end of T_DIA_ND_OUTPUT_OPT_ELEM_VALUE. + types: + "! + begin of T_DIA_NODE_OUTPUT_OPT_ELEMENT, + LABEL type STRING, + VALUE type T_DIA_ND_OUTPUT_OPT_ELEM_VALUE, + end of T_DIA_NODE_OUTPUT_OPT_ELEMENT. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_OPTION, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_OPTION. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_DATE, + CALENDAR_TYPE type STRING, + DATETIME_LINK type STRING, + FESTIVAL type STRING, + GRANULARITY type STRING, + RANGE_LINK type STRING, + RANGE_MODIFIER type STRING, + RELATIVE_DAY type NUMBER, + RELATIVE_MONTH type NUMBER, + RELATIVE_WEEK type NUMBER, + RELATIVE_WEEKEND type NUMBER, + RELATIVE_YEAR type NUMBER, + SPECIFIC_DAY type NUMBER, + SPECIFIC_DAY_OF_WEEK type STRING, + SPECIFIC_MONTH type NUMBER, + SPECIFIC_QUARTER type NUMBER, + 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 tags. + begin of T_SEARCH_RESULT_HIGHLIGHT, + BODY type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + TITLE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + 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, + CONFIDENCE type DOUBLE, + SCORE type DOUBLE, + end of T_SEARCH_RESULT_METADATA. + types: + "! + begin of T_SEARCH_RESULT, + ID type STRING, + RESULT_METADATA type T_SEARCH_RESULT_METADATA, + BODY type STRING, + TITLE type STRING, + URL type STRING, + HIGHLIGHT type T_SEARCH_RESULT_HIGHLIGHT, + end of T_SEARCH_RESULT. + types: + "! + begin of T_DIALOG_SUGGESTION, + LABEL type STRING, + VALUE type T_DIALOG_SUGGESTION_VALUE, + OUTPUT type MAP, + end of T_DIALOG_SUGGESTION. + types: + "! + begin of T_RUNTIME_RESPONSE_GENERIC, + RESPONSE_TYPE type STRING, + TEXT type STRING, + TIME type INTEGER, + TYPING type BOOLEAN, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + PREFERENCE type STRING, + OPTIONS type STANDARD TABLE OF T_DIA_NODE_OUTPUT_OPT_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + MESSAGE_TO_HUMAN_AGENT type STRING, + TOPIC type STRING, + SUGGESTIONS type STANDARD TABLE OF T_DIALOG_SUGGESTION WITH NON-UNIQUE DEFAULT KEY, + HEADER type STRING, + RESULTS type STANDARD TABLE OF T_SEARCH_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_GENERIC. + 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 part of the new system entities, which are a beta feature. + begin of T_RUNTIME_ENTITY_ROLE, + TYPE type STRING, + end of T_RUNTIME_ENTITY_ROLE. + types: + "! + begin of T_ERROR_DETAIL, + MESSAGE type STRING, + PATH type STRING, + end of T_ERROR_DETAIL. + types: + "! + begin of T_ERROR_RESPONSE, + ERROR type STRING, + ERRORS type STANDARD TABLE OF T_ERROR_DETAIL WITH NON-UNIQUE DEFAULT KEY, + CODE type INTEGER, + end of T_ERROR_RESPONSE. + types: + "! + begin of T_RT_ENTITY_INTERPRETATION, + CALENDAR_TYPE type STRING, + DATETIME_LINK type STRING, + FESTIVAL type STRING, + GRANULARITY type STRING, + RANGE_LINK type STRING, + RANGE_MODIFIER type STRING, + RELATIVE_DAY type NUMBER, + RELATIVE_MONTH type NUMBER, + RELATIVE_WEEK type NUMBER, + RELATIVE_WEEKEND type NUMBER, + RELATIVE_YEAR type NUMBER, + SPECIFIC_DAY type NUMBER, + SPECIFIC_DAY_OF_WEEK type STRING, + SPECIFIC_MONTH type NUMBER, + SPECIFIC_QUARTER type NUMBER, + SPECIFIC_YEAR type NUMBER, + NUMERIC_VALUE type NUMBER, + SUBTYPE type STRING, + PART_OF_DAY type STRING, + RELATIVE_HOUR type NUMBER, + RELATIVE_MINUTE type NUMBER, + RELATIVE_SECOND type NUMBER, + SPECIFIC_HOUR type NUMBER, + SPECIFIC_MINUTE type NUMBER, + SPECIFIC_SECOND type NUMBER, + TIMEZONE type STRING, + end of T_RT_ENTITY_INTERPRETATION. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_IMAGE, + SOURCE type STRING, + TITLE type STRING, + DESCRIPTION type STRING, + end of T_RUNTIME_RESPONSE_TYPE_IMAGE. + types: + "! + begin of T_DIALOG_NODE_ACTION, + NAME type STRING, + TYPE type STRING, + PARAMETERS type MAP, + RESULT_VARIABLE type STRING, + 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, + TIMEZONE type STRING, + USER_ID type STRING, + TURN_COUNT type INTEGER, + 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, + 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: + "! + begin of T_MESSAGE_CONTEXT, + GLOBAL type T_MESSAGE_CONTEXT_GLOBAL, + 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, + GENERIC type STANDARD TABLE OF T_RUNTIME_RESPONSE_GENERIC WITH NON-UNIQUE DEFAULT KEY, + INTENTS type STANDARD TABLE OF T_RUNTIME_INTENT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_RUNTIME_ENTITY WITH NON-UNIQUE DEFAULT KEY, + ACTIONS type STANDARD TABLE OF T_DIALOG_NODE_ACTION WITH NON-UNIQUE DEFAULT KEY, + DEBUG type T_MESSAGE_OUTPUT_DEBUG, + USER_DEFINED type MAP, + end of T_MESSAGE_OUTPUT. + types: + "! A response from the Watson Assistant service. + begin of T_MESSAGE_RESPONSE, + OUTPUT type T_MESSAGE_OUTPUT, + CONTEXT type T_MESSAGE_CONTEXT, + end of T_MESSAGE_RESPONSE. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_TEXT, + TEXT type STRING, + end of T_RUNTIME_RESPONSE_TYPE_TEXT. + types: + "! + begin of T_RT_ENTTY_INTRPRTTN_SYS_TIME, + DATETIME_LINK type STRING, + GRANULARITY type STRING, + PART_OF_DAY type STRING, + RANGE_LINK type STRING, + RELATIVE_HOUR type NUMBER, + RELATIVE_MINUTE type NUMBER, + RELATIVE_SECOND type NUMBER, + SPECIFIC_HOUR type NUMBER, + SPECIFIC_MINUTE type NUMBER, + SPECIFIC_SECOND type NUMBER, + TIMEZONE type STRING, + end of T_RT_ENTTY_INTRPRTTN_SYS_TIME. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_PAUSE, + TIME type INTEGER, + TYPING type BOOLEAN, + end of T_RUNTIME_RESPONSE_TYPE_PAUSE. + types: + "! + begin of T_RUNTIME_RESPONSE_TYPE_SEARCH, + HEADER type STRING, + RESULTS type STANDARD TABLE OF T_SEARCH_RESULT WITH NON-UNIQUE DEFAULT KEY, + end of T_RUNTIME_RESPONSE_TYPE_SEARCH. + types: + "! + begin of T_RT_RESPONSE_TYPE_SUGGESTION, + TITLE type STRING, + 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, + USER_DEFINED type MAP, + end of T_MESSAGE_CONTEXT_SKILL. + types: + "! + begin of T_RT_RESP_TYP_CONNECT_TO_AGENT, + MESSAGE_TO_HUMAN_AGENT type STRING, + 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, + INPUT type T_MESSAGE_INPUT, + 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_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_RUNTIME_ENTITY_ROLE type string value '|', + T_ERROR_DETAIL type string value '|MESSAGE|', + T_ERROR_RESPONSE type string value '|ERROR|CODE|', + T_RT_ENTITY_INTERPRETATION type string value '|', + 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', + 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', + 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/services/assistant?topic=assistant-a + "! ssistant-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 + "! + 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/services/assistant?topic=assistant-a + "! ssistant-add#assistant-add-task). + "! + "! **Note:** Currently, the v2 API does not support creating assistants. + "! @parameter I_session_id | + "! Unique identifier of the session. + "! + 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/services/assistant?topic=assistant-a + "! ssistant-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 + "! + 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( ). + + 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 = '20191002122836'. + + 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..aaa9802 --- /dev/null +++ b/src/zcl_ibmc_compare_comply_v1.clas.abap @@ -0,0 +1,2441 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + BEGIN type LONG, + 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, + NATURE type STRING, + PARTY type STRING, + end of T_LABEL. + types: + "! Identification of a specific type. + begin of T_TYPE_LABEL_COMPARISON, + LABEL type T_LABEL, + end of T_TYPE_LABEL_COMPARISON. + types: + "! The locations of each paragraph in the input document. + begin of T_PARAGRAPHS, + LOCATION type T_LOCATION, + end of T_PARAGRAPHS. + types: + "! Document counts. + begin of T_DOC_COUNTS, + TOTAL type INTEGER, + PENDING type INTEGER, + SUCCESSFUL type INTEGER, + FAILED type INTEGER, + end of T_DOC_COUNTS. + types: + "! Identification of a specific type. + begin of T_TYPE_LABEL, + LABEL type T_LABEL, + 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, + TITLE type STRING, + HASH type STRING, + end of T_SHORT_DOC. + types: + "! Information defining an element's subject matter. + begin of T_CATEGORY, + LABEL type STRING, + 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, + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + 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, + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + MODIFICATION type STRING, + end of T_UPDATED_LABELS_OUT. + types: + "! Pagination details, if required by the length of the output. + begin of T_PAGINATION, + REFRESH_CURSOR type STRING, + NEXT_CURSOR type STRING, + REFRESH_URL type STRING, + NEXT_URL type STRING, + TOTAL type LONG, + end of T_PAGINATION. + types: + "! Information returned from the **Add Feedback** method. + begin of T_FEEDBACK_DATA_OUTPUT, + FEEDBACK_TYPE type STRING, + DOCUMENT type T_SHORT_DOC, + MODEL_ID type STRING, + MODEL_VERSION type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + ORIGINAL_LABELS type T_ORIGINAL_LABELS_OUT, + UPDATED_LABELS type T_UPDATED_LABELS_OUT, + PAGINATION type T_PAGINATION, + end of T_FEEDBACK_DATA_OUTPUT. + types: + "! List of document attributes. + begin of T_ATTRIBUTE, + TYPE type STRING, + TEXT type STRING, + LOCATION type T_LOCATION, + end of T_ATTRIBUTE. + types: + "! Information defining an element's subject matter. + begin of T_CATEGORY_COMPARISON, + LABEL type STRING, + end of T_CATEGORY_COMPARISON. + types: + "! Element that does not align semantically between two compared documents. + begin of T_UNALIGNED_ELEMENT, + DOCUMENT_LABEL type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + TYPES type STANDARD TABLE OF T_TYPE_LABEL_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORY_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + 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, + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + 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, + BEGIN type INTEGER, + 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, + TEXT type STRING, + LOCATION type T_LOCATION, + 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, + TEXT type STRING, + LOCATION type T_LOCATION, + LEVEL type INTEGER, + 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, + SECTION_TITLES type STANDARD TABLE OF T_SECTION_TITLES WITH NON-UNIQUE DEFAULT KEY, + LEADING_SENTENCES type STANDARD TABLE OF T_LEADING_SENTENCE WITH NON-UNIQUE DEFAULT KEY, + 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: + "! + begin of T_ERROR_RESPONSE, + CODE type INTEGER, + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! A contact. + begin of T_CONTACT, + NAME type STRING, + ROLE type STRING, + end of T_CONTACT. + types: + "! The table's section title, if identified. + begin of T_SECTION_TITLE, + TEXT type STRING, + 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, + CELL_ID type STRING, + LOCATION type JSONOBJECT, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + ROW_INDEX_BEGIN type LONG, + ROW_INDEX_END type LONG, + COLUMN_INDEX_BEGIN type LONG, + 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, + TEXT type STRING, + 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, + LOCATION type T_LOCATION, + 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, + CELL_ID type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + ROW_INDEX_BEGIN type LONG, + ROW_INDEX_END type LONG, + COLUMN_INDEX_BEGIN type LONG, + COLUMN_INDEX_END type LONG, + ROW_HEADER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + ROW_HEADER_TEXTS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + ROW_HEADER_TEXTS_NORMALIZED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + COLUMN_HEADER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + COLUMN_HEADER_TEXTS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + COLUMN_HEADER_TEXTS_NORMALIZED type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + CELL_ID type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + end of T_KEY. + types: + "! A value in a key-value pair. + begin of T_VALUE, + CELL_ID type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + end of T_VALUE. + types: + "! Key-value pairs detected across cell boundaries. + begin of T_KEY_VALUE_PAIR, + KEY type T_KEY, + 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, + CELL_ID type STRING, + LOCATION type JSONOBJECT, + TEXT type STRING, + ROW_INDEX_BEGIN type LONG, + ROW_INDEX_END type LONG, + COLUMN_INDEX_BEGIN type LONG, + 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, + CELL_ID type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + ROW_INDEX_BEGIN type LONG, + ROW_INDEX_END type LONG, + COLUMN_INDEX_BEGIN type LONG, + COLUMN_INDEX_END type LONG, + end of T_ROW_HEADERS. + types: + "! The contents of the tables extracted from a document. + begin of T_TABLES, + LOCATION type T_LOCATION, + TEXT type STRING, + SECTION_TITLE type T_SECTION_TITLE, + TITLE type T_TABLE_TITLE, + TABLE_HEADERS type STANDARD TABLE OF T_TABLE_HEADERS WITH NON-UNIQUE DEFAULT KEY, + ROW_HEADERS type STANDARD TABLE OF T_ROW_HEADERS WITH NON-UNIQUE DEFAULT KEY, + COLUMN_HEADERS type STANDARD TABLE OF T_COLUMN_HEADERS WITH NON-UNIQUE DEFAULT KEY, + BODY_CELLS type STANDARD TABLE OF T_BODY_CELLS WITH NON-UNIQUE DEFAULT KEY, + CONTEXTS type STANDARD TABLE OF T_CONTEXTS WITH NON-UNIQUE DEFAULT KEY, + 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, + HTML type STRING, + TITLE type STRING, + HASH type STRING, + end of T_DOC_INFO. + types: + "! The analysis of the document's tables. + begin of T_TABLE_RETURN, + DOCUMENT type T_DOC_INFO, + MODEL_ID type STRING, + MODEL_VERSION type STRING, + 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, + FEEDBACK_ID type STRING, + USER_ID type STRING, + COMMENT type STRING, + CREATED type DATETIME, + 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, + VALUE type STRING, + NUMERIC_VALUE type NUMBER, + UNIT type STRING, + end of T_INTERPRETATION. + types: + "! A monetary amount identified in the input document. + begin of T_CONTRACT_AMTS, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + INTERPRETATION type T_INTERPRETATION, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_CONTRACT_AMTS. + types: + "! The contract currencies that are declared in the document. + begin of T_CONTRACT_CURRENCIES, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_CONTRACT_CURRENCIES. + types: + "! The document's payment duration or durations. + begin of T_PAYMENT_TERMS, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + INTERPRETATION type T_INTERPRETATION, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_PAYMENT_TERMS. + types: + "! A component part of the document. + begin of T_ELEMENT, + LOCATION type T_LOCATION, + TEXT type STRING, + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + 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, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_TERMINATION_DATES. + types: + "! The contract type identified in the input document. + begin of T_CONTRACT_TYPES, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_CONTRACT_TYPES. + types: + "! An effective date. + begin of T_EFFECTIVE_DATES, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + LOCATION type T_LOCATION, + end of T_EFFECTIVE_DATES. + types: + "! A mention of a party. + begin of T_MENTION, + TEXT type STRING, + LOCATION type T_LOCATION, + end of T_MENTION. + types: + "! A party's address. + begin of T_ADDRESS, + TEXT type STRING, + 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, + PARTY type STRING, + ROLE type STRING, + IMPORTANCE type STRING, + ADDRESSES type STANDARD TABLE OF T_ADDRESS WITH NON-UNIQUE DEFAULT KEY, + CONTACTS type STANDARD TABLE OF T_CONTACT WITH NON-UNIQUE DEFAULT KEY, + 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, + TITLE type STRING, + HTML type STRING, + HASH type STRING, + LABEL type STRING, + end of T_DOCUMENT. + types: + "! The duration or durations of the contract. + begin of T_CONTRACT_TERMS, + CONFIDENCE_LEVEL type STRING, + TEXT type STRING, + TEXT_NORMALIZED type STRING, + INTERPRETATION type T_INTERPRETATION, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + DOCUMENT type T_DOCUMENT, + MODEL_ID type STRING, + MODEL_VERSION type STRING, + ELEMENTS type STANDARD TABLE OF T_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + EFFECTIVE_DATES type STANDARD TABLE OF T_EFFECTIVE_DATES WITH NON-UNIQUE DEFAULT KEY, + CONTRACT_AMOUNTS type STANDARD TABLE OF T_CONTRACT_AMTS WITH NON-UNIQUE DEFAULT KEY, + TERMINATION_DATES type STANDARD TABLE OF T_TERMINATION_DATES WITH NON-UNIQUE DEFAULT KEY, + CONTRACT_TYPES type STANDARD TABLE OF T_CONTRACT_TYPES WITH NON-UNIQUE DEFAULT KEY, + CONTRACT_TERMS type STANDARD TABLE OF T_CONTRACT_TERMS WITH NON-UNIQUE DEFAULT KEY, + PAYMENT_TERMS type STANDARD TABLE OF T_PAYMENT_TERMS WITH NON-UNIQUE DEFAULT KEY, + CONTRACT_CURRENCIES type STANDARD TABLE OF T_CONTRACT_CURRENCIES WITH NON-UNIQUE DEFAULT KEY, + TABLES type STANDARD TABLE OF T_TABLES WITH NON-UNIQUE DEFAULT KEY, + DOCUMENT_STRUCTURE type T_DOC_STRUCTURE, + 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, + TYPES type STANDARD TABLE OF T_TYPE_LABEL WITH NON-UNIQUE DEFAULT KEY, + 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, + DOCUMENT_LABEL type STRING, + TEXT type STRING, + LOCATION type T_LOCATION, + TYPES type STANDARD TABLE OF T_TYPE_LABEL_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORY_COMPARISON WITH NON-UNIQUE DEFAULT KEY, + ATTRIBUTES type STANDARD TABLE OF T_ATTRIBUTE WITH NON-UNIQUE DEFAULT KEY, + end of T_ELEMENT_PAIR. + types: + "! + begin of T_ALIGNED_ELEMENT, + ELEMENT_PAIR type STANDARD TABLE OF T_ELEMENT_PAIR WITH NON-UNIQUE DEFAULT KEY, + IDENTICAL_TEXT type BOOLEAN, + PROVENANCE_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + SIGNIFICANT_ELEMENTS type BOOLEAN, + end of T_ALIGNED_ELEMENT. + types: + "! The comparison of the two submitted documents. + begin of T_COMPARE_RETURN, + MODEL_ID type STRING, + MODEL_VERSION type STRING, + DOCUMENTS type STANDARD TABLE OF T_DOCUMENT WITH NON-UNIQUE DEFAULT KEY, + ALIGNED_ELEMENTS type STANDARD TABLE OF T_ALIGNED_ELEMENT WITH NON-UNIQUE DEFAULT KEY, + 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, + NUM_PAGES type STRING, + AUTHOR type STRING, + PUBLICATION_DATE type STRING, + TITLE type STRING, + HTML type STRING, + end of T_HTMLRETURN. + types: + "! Feedback data for submission. + begin of T_FEEDBACK_DATA_INPUT, + FEEDBACK_TYPE type STRING, + DOCUMENT type T_SHORT_DOC, + MODEL_ID type STRING, + MODEL_VERSION type STRING, + LOCATION type T_LOCATION, + TEXT type STRING, + ORIGINAL_LABELS type T_ORIGINAL_LABELS_IN, + 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, + FUNCTION type STRING, + INPUT_BUCKET_LOCATION type STRING, + INPUT_BUCKET_NAME type STRING, + OUTPUT_BUCKET_LOCATION type STRING, + OUTPUT_BUCKET_NAME type STRING, + BATCH_ID type STRING, + DOCUMENT_COUNTS type T_DOC_COUNTS, + STATUS type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + end of T_BATCH_STATUS. + types: + "! The results of a successful **List Batches** request. + begin of T_BATCHES, + BATCHES type STANDARD TABLE OF T_BATCH_STATUS WITH NON-UNIQUE DEFAULT KEY, + end of T_BATCHES. + types: + "! + begin of T_INLINE_OBJECT, + 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, + STATUS type INTEGER, + 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, + USER_ID type STRING, + COMMENT type STRING, + FEEDBACK_DATA type T_FEEDBACK_DATA_INPUT, + end of T_FEEDBACK_INPUT. + types: + "! + begin of T_INLINE_OBJECT1, + FILE type FILE, + end of T_INLINE_OBJECT1. + types: + "! + begin of T_INLINE_OBJECT2, + FILE type FILE, + end of T_INLINE_OBJECT2. + types: + "! + begin of T_INLINE_OBJECT3, + FILE_1 type FILE, + FILE_2 type FILE, + end of T_INLINE_OBJECT3. + types: + "! + begin of T_INLINE_OBJECT4, + INPUT_CREDENTIALS_FILE type FILE, + INPUT_BUCKET_LOCATION type STRING, + INPUT_BUCKET_NAME type STRING, + OUTPUT_CREDENTIALS_FILE type FILE, + OUTPUT_BUCKET_LOCATION type STRING, + 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, + FEEDBACK_ID type STRING, + CREATED type DATETIME, + COMMENT type STRING, + 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, + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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( ). + + 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 = '20191002122838'. + + 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..8b29df8 --- /dev/null +++ b/src/zcl_ibmc_discovery_v1.clas.abap @@ -0,0 +1,7440 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + TYPE type STRING, + RESULTS type STANDARD TABLE OF DATA_REFERENCE WITH NON-UNIQUE DEFAULT KEY, + MATCHING_RESULTS type INTEGER, + 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 type STRING, + MATCHING_RESULTS type INTEGER, + 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, + TOTAL_EXAMPLES type INTEGER, + AVAILABLE type BOOLEAN, + PROCESSING type BOOLEAN, + MINIMUM_QUERIES_ADDED type BOOLEAN, + MINIMUM_EXAMPLES_ADDED type BOOLEAN, + SUFFICIENT_LABEL_DIVERSITY type BOOLEAN, + NOTICES type INTEGER, + SUCCESSFULLY_TRAINED type DATETIME, + 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, + STATUS type STRING, + 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, + 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, + DOCUMENT type BOOLEAN, + 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, + ENTITIES type BOOLEAN, + KEYWORDS type BOOLEAN, + 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, + SENTIMENT type BOOLEAN, + EMOTION type BOOLEAN, + LIMIT type INTEGER, + MENTIONS type BOOLEAN, + MENTION_TYPES type BOOLEAN, + SENTENCE_LOCATIONS type BOOLEAN, + 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, + DOCUMENT type BOOLEAN, + 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, + 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, + SENTIMENT type BOOLEAN, + EMOTION type BOOLEAN, + 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, + KEYWORDS type T_NLU_ENRICHMENT_KEYWORDS, + ENTITIES type T_NLU_ENRICHMENT_ENTITIES, + SENTIMENT type T_NLU_ENRICHMENT_SENTIMENT, + EMOTION type T_NLU_ENRICHMENT_EMOTION, + CATEGORIES type T_NLU_ENRICHMENT_CATEGORIES, + SEMANTIC_ROLES type T_NL_ENRICHMENT_SEMANTIC_ROLES, + RELATIONS type T_NLU_ENRICHMENT_RELATIONS, + 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, + FEATURES type T_NLU_ENRICHMENT_FEATURES, + LANGUAGE type STRING, + end of T_NLU_ENRICHMENT_OPTIONS. + types: + "! An object defining a single tokenizaion rule. + begin of T_TOKEN_DICT_RULE, + TEXT type STRING, + TOKENS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + READINGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + TOKENIZATION_RULES type STANDARD TABLE OF T_TOKEN_DICT_RULE WITH NON-UNIQUE DEFAULT KEY, + end of T_TOKEN_DICT. + types: + "! + begin of T_FILTER, + 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, + URL type STRING, + LIMIT_TO_STARTING_HOSTS type BOOLEAN, + CRAWL_SPEED type STRING, + ALLOW_UNTRUSTED_CERTIFICATE type BOOLEAN, + MAXIMUM_HOPS type INTEGER, + REQUEST_TIMEOUT type INTEGER, + OVERRIDE_ROBOTS_TXT type BOOLEAN, + 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, + CREDENTIAL_TYPE type STRING, + CLIENT_ID type STRING, + ENTERPRISE_ID type STRING, + URL type STRING, + USERNAME type STRING, + ORGANIZATION_URL type STRING, + SITE_COLLECTION_PATH type STRING, + CLIENT_SECRET type STRING, + PUBLIC_KEY_ID type STRING, + PRIVATE_KEY type STRING, + PASSPHRASE type STRING, + PASSWORD type STRING, + GATEWAY_ID type STRING, + SOURCE_VERSION type STRING, + WEB_APPLICATION_URL type STRING, + DOMAIN type STRING, + ENDPOINT type STRING, + ACCESS_KEY_ID type STRING, + SECRET_ACCESS_KEY type STRING, + end of T_CREDENTIAL_DETAILS. + types: + "! Object containing credential information. + begin of T_CREDENTIALS, + CREDENTIAL_ID type STRING, + SOURCE_TYPE type STRING, + CREDENTIAL_DETAILS type T_CREDENTIAL_DETAILS, + STATUS type STRING, + end of T_CREDENTIALS. + types: + "! Object containing array of credential definitions. + begin of T_CREDENTIALS_LIST, + 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, + AVAILABLE type INTEGER, + MAXIMUM_ALLOWED type INTEGER, + end of T_COLLECTION_USAGE. + types: + "! Summary of the disk usage statistics for the environment. + begin of T_DISK_USAGE, + USED_BYTES type INTEGER, + 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, + INDEXED type INTEGER, + 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, + DOCUMENTS type T_ENVIRONMENT_DOCUMENTS, + DISK_USAGE type T_DISK_USAGE, + 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, + SCOPE type STRING, + STATUS type STRING, + STATUS_DESCRIPTION type STRING, + LAST_TRAINED type DATE, + end of T_SEARCH_STATUS. + types: + "! Details about an environment. + begin of T_ENVIRONMENT, + ENVIRONMENT_ID type STRING, + NAME type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + STATUS type STRING, + READ_ONLY type BOOLEAN, + SIZE type STRING, + REQUESTED_SIZE type STRING, + INDEX_CAPACITY type T_INDEX_CAPACITY, + 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, + 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, + GATEWAY_ID type STRING, + STATUS type STRING, + end of T_GATEWAY_DELETE. + types: + "! Training example details. + begin of T_TRAINING_EXAMPLE, + DOCUMENT_ID type STRING, + CROSS_REFERENCE type STRING, + RELEVANCE type INTEGER, + end of T_TRAINING_EXAMPLE. + types: + "! Training query details. + begin of T_TRAINING_QUERY, + QUERY_ID type STRING, + NATURAL_LANGUAGE_QUERY type STRING, + FILTER type STRING, + 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, + DOCUMENT_ID type STRING, + PASSAGE_SCORE type DOUBLE, + PASSAGE_TEXT type STRING, + START_OFFSET type INTEGER, + END_OFFSET type INTEGER, + FIELD type STRING, + end of T_QUERY_PASSAGES. + types: + "! Object containing normalization operations. + begin of T_NORMALIZATION_OPERATION, + OPERATION type STRING, + SOURCE_FIELD type STRING, + DESTINATION_FIELD type STRING, + end of T_NORMALIZATION_OPERATION. + types: + "! Font matching configuration. + begin of T_FONT_SETTING, + LEVEL type INTEGER, + MIN_SIZE type INTEGER, + MAX_SIZE type INTEGER, + BOLD type BOOLEAN, + ITALIC type BOOLEAN, + 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, + LEVEL type INTEGER, + 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, + FONTS type STANDARD TABLE OF T_FONT_SETTING WITH NON-UNIQUE DEFAULT KEY, + 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, + 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, + 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, + OWNER_USER_ID type STRING, + FOLDER_ID type STRING, + 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, + NAME type STRING, + LIMIT type INTEGER, + end of T_SOURCE_OPTIONS_BUCKETS. + types: + "! Object containing the schedule information for the source. + begin of T_SOURCE_SCHEDULE, + ENABLED type BOOLEAN, + TIME_ZONE type STRING, + 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, + NAME type STRING, + 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, + SITE_COLLECTION_PATH1 type STRING, + 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, + FOLDERS type STANDARD TABLE OF T_SOURCE_OPTIONS_FOLDER WITH NON-UNIQUE DEFAULT KEY, + OBJECTS type STANDARD TABLE OF T_SOURCE_OPTIONS_OBJECT WITH NON-UNIQUE DEFAULT KEY, + SITE_COLLECTIONS type STANDARD TABLE OF T_SOURCE_OPTIONS_SITE_COLL WITH NON-UNIQUE DEFAULT KEY, + URLS type STANDARD TABLE OF T_SOURCE_OPTIONS_WEB_CRAWL WITH NON-UNIQUE DEFAULT KEY, + BUCKETS type STANDARD TABLE OF T_SOURCE_OPTIONS_BUCKETS WITH NON-UNIQUE DEFAULT KEY, + CRAWL_ALL_BUCKETS type BOOLEAN, + end of T_SOURCE_OPTIONS. + types: + "! Object containing source parameters for the configuration. + begin of T_SOURCE, + TYPE type STRING, + CREDENTIAL_ID type STRING, + SCHEDULE type T_SOURCE_SCHEDULE, + OPTIONS type T_SOURCE_OPTIONS, + end of T_SOURCE. + types: + "! Object containing an array of XPaths. + begin of T_XPATH_PATTERNS, + 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, + FEATURES type T_NLU_ENRICHMENT_FEATURES, + LANGUAGE type STRING, + 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, + DESCRIPTION type STRING, + DESTINATION_FIELD type STRING, + SOURCE_FIELD type STRING, + OVERWRITE type BOOLEAN, + ENRICHMENT type STRING, + IGNORE_DOWNSTREAM_ERRORS type BOOLEAN, + OPTIONS type T_ENRICHMENT_OPTIONS, + end of T_ENRICHMENT. + types: + "! A list of Document Segmentation settings. + begin of T_SEGMENT_SETTINGS, + ENABLED type BOOLEAN, + SELECTOR_TAGS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + HEADING type T_WORD_HEADING_DETECTION, + end of T_WORD_SETTINGS. + types: + "! A list of HTML conversion settings. + begin of T_HTML_SETTINGS, + EXCLUDE_TAGS_COMPLETELY type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + EXCLUDE_TAGS_KEEP_CONTENT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + KEEP_CONTENT type T_XPATH_PATTERNS, + EXCLUDE_CONTENT type T_XPATH_PATTERNS, + KEEP_TAG_ATTRIBUTES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + PDF type T_PDF_SETTINGS, + WORD type T_WORD_SETTINGS, + HTML type T_HTML_SETTINGS, + SEGMENT type T_SEGMENT_SETTINGS, + JSON_NORMALIZATIONS type STANDARD TABLE OF T_NORMALIZATION_OPERATION WITH NON-UNIQUE DEFAULT KEY, + IMAGE_TEXT_RECOGNITION type BOOLEAN, + end of T_CONVERSIONS. + types: + "! A custom configuration for the environment. + begin of T_CONFIGURATION, + CONFIGURATION_ID type STRING, + NAME type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + DESCRIPTION type STRING, + CONVERSIONS type T_CONVERSIONS, + ENRICHMENTS type STANDARD TABLE OF T_ENRICHMENT WITH NON-UNIQUE DEFAULT KEY, + NORMALIZATIONS type STANDARD TABLE OF T_NORMALIZATION_OPERATION WITH NON-UNIQUE DEFAULT KEY, + SOURCE type T_SOURCE, + end of T_CONFIGURATION. + types: + "! Object containing an array of available configurations. + begin of T_LIST_CONFIGURATIONS_RESPONSE, + 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, + STATUS type STRING, + NEXT_CRAWL type DATETIME, + end of T_SOURCE_STATUS. + types: + "! Object returned after credentials are deleted. + begin of T_DELETE_CREDENTIALS, + CREDENTIAL_ID type STRING, + STATUS type STRING, + end of T_DELETE_CREDENTIALS. + types: + "! A notice produced for the collection. + begin of T_NOTICE, + NOTICE_ID type STRING, + CREATED type DATETIME, + DOCUMENT_ID type STRING, + QUERY_ID type STRING, + SEVERITY type STRING, + STEP type STRING, + DESCRIPTION type STRING, + end of T_NOTICE. + types: + "! Information returned after an uploaded document is accepted. + begin of T_DOCUMENT_ACCEPTED, + DOCUMENT_ID type STRING, + STATUS type STRING, + 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, + GATEWAY_ID type STRING, + NAME type STRING, + STATUS type STRING, + TOKEN type STRING, + TOKEN_ID type STRING, + end of T_GATEWAY. + types: + "! Aggregation result data for the requested metric. + begin of T_METRIC_AGGREGATION_RESULT, + KEY_AS_STRING type DATETIME, + KEY type LONG, + MATCHING_RESULTS type INTEGER, + 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, + INTERVAL type STRING, + EVENT_TYPE type STRING, + 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, + 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, + SCORE type DOUBLE, + CONFIDENCE type DOUBLE, + end of T_QUERY_RESULT_METADATA. + types: + "! Query result object. + begin of T_QUERY_NOTICES_RESULT, + ID type STRING, + METADATA type MAP, + COLLECTION_ID type STRING, + RESULT_METADATA type T_QUERY_RESULT_METADATA, + TITLE type STRING, + CODE type INTEGER, + FILENAME type STRING, + FILE_TYPE type STRING, + SHA1 type STRING, + 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, + POSITION type INTEGER, + DOCUMENT_ID type STRING, + SCORE type DOUBLE, + CONFIDENCE type DOUBLE, + 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, + RESULTS type STANDARD TABLE OF T_LOG_QRY_RESP_RSLT_DOCS_RSLT WITH NON-UNIQUE DEFAULT KEY, + COUNT type INTEGER, + end of T_LOG_QUERY_RESP_RESULT_DOCS. + types: + "! Object containing field details. + begin of T_FIELD, + FIELD type STRING, + TYPE type STRING, + end of T_FIELD. + types: + "! Query event data object. + begin of T_EVENT_DATA, + ENVIRONMENT_ID type STRING, + SESSION_TOKEN type STRING, + CLIENT_TIMESTAMP type DATETIME, + DISPLAY_RANK type INTEGER, + COLLECTION_ID type STRING, + DOCUMENT_ID type STRING, + QUERY_ID type STRING, + end of T_EVENT_DATA. + types: + "! An object defining the event being created. + begin of T_CREATE_EVENT_OBJECT, + TYPE type STRING, + DATA type T_EVENT_DATA, + end of T_CREATE_EVENT_OBJECT. + types: + "! + begin of T_NESTED, + PATH type STRING, + end of T_NESTED. + types: + "! Object that describes a long query. + begin of T_QUERY_LARGE, + FILTER type STRING, + QUERY type STRING, + NATURAL_LANGUAGE_QUERY type STRING, + PASSAGES type BOOLEAN, + AGGREGATION type STRING, + COUNT type INTEGER, + RETURN type STRING, + OFFSET type INTEGER, + SORT type STRING, + HIGHLIGHT type BOOLEAN, + PASSAGES_FIELDS type STRING, + PASSAGES_COUNT type INTEGER, + PASSAGES_CHARACTERS type INTEGER, + DEDUPLICATE type BOOLEAN, + DEDUPLICATE_FIELD type STRING, + SIMILAR type BOOLEAN, + SIMILAR_DOCUMENT_IDS type STRING, + SIMILAR_FIELDS type STRING, + BIAS type STRING, + end of T_QUERY_LARGE. + types: + "! Object containing user-defined name. + begin of T_GATEWAY_NAME, + NAME type STRING, + end of T_GATEWAY_NAME. + types: + "! Object containing collection document count information. + begin of T_DOCUMENT_COUNTS, + AVAILABLE type LONG, + PROCESSING type LONG, + FAILED type LONG, + 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, + DEFINED type LONG, + 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, + ENABLED type BOOLEAN, + TOTAL_ANNOTATED_PAGES type LONG, + TOTAL_PAGES type LONG, + TOTAL_DOCUMENTS type LONG, + 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, + 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, + USED_BYTES type INTEGER, + end of T_COLLECTION_DISK_USAGE. + types: + "! A collection for storing documents. + begin of T_COLLECTION, + COLLECTION_ID type STRING, + NAME type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + STATUS type STRING, + CONFIGURATION_ID type STRING, + LANGUAGE type STRING, + DOCUMENT_COUNTS type T_DOCUMENT_COUNTS, + DISK_USAGE type T_COLLECTION_DISK_USAGE, + TRAINING_STATUS type T_TRAINING_STATUS, + CRAWL_STATUS type T_COLLECTION_CRAWL_STATUS, + 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, + MODEL type STRING, + end of T_ELEMENTS_ENRICHMENT_OPTIONS. + types: + "! Object containing information about a new environment. + begin of T_CREATE_ENVIRONMENT_REQUEST, + NAME type STRING, + DESCRIPTION type STRING, + SIZE type STRING, + end of T_CREATE_ENVIRONMENT_REQUEST. + types: + "! Object containing specification for a new collection. + begin of T_CREATE_COLLECTION_REQUEST, + NAME type STRING, + DESCRIPTION type STRING, + CONFIGURATION_ID type STRING, + LANGUAGE type STRING, + end of T_CREATE_COLLECTION_REQUEST. + types: + "! + begin of T_INLINE_OBJECT, + STOPWORD_FILE type FILE, + end of T_INLINE_OBJECT. + types: + "! Query result object. + begin of T_QUERY_RESULT, + ID type STRING, + METADATA type MAP, + COLLECTION_ID type STRING, + RESULT_METADATA type T_QUERY_RESULT_METADATA, + TITLE type STRING, + end of T_QUERY_RESULT. + types: + "! Top hit information for this query. + begin of T_TOP_HITS_RESULTS, + MATCHING_RESULTS type INTEGER, + 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, + COLLECTION_ID type STRING, + STATUS type STRING, + end of T_DELETE_COLLECTION_RESPONSE. + types: + "! + begin of T_TERM, + FIELD type STRING, + COUNT type INTEGER, + end of T_TERM. + types: + "! An object containing an array of autocompletion suggestions. + begin of T_COMPLETIONS, + 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, + DOCUMENT_RETRIEVAL_STRATEGY type STRING, + end of T_RETRIEVAL_DETAILS. + types: + "! Response object returned when deleting an environment. + begin of T_DELETE_ENVIRONMENT_RESPONSE, + ENVIRONMENT_ID type STRING, + 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, + 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, + NAME type STRING, + DESCRIPTION type STRING, + CONFIGURATION_ID type STRING, + end of T_UPDATE_COLLECTION_REQUEST. + types: + "! Object containing gateways array. + begin of T_GATEWAY_LIST, + 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, + KEY type STRING, + MATCHING_RESULTS type INTEGER, + 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, + EVENT_TYPE type STRING, + 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, + FILTER type STRING, + QUERY type STRING, + NATURAL_LANGUAGE_QUERY type STRING, + PASSAGES type BOOLEAN, + AGGREGATION type STRING, + COUNT type INTEGER, + RETURN type STRING, + OFFSET type INTEGER, + SORT type STRING, + HIGHLIGHT type BOOLEAN, + PASSAGES_FIELDS type STRING, + PASSAGES_COUNT type INTEGER, + PASSAGES_CHARACTERS type INTEGER, + DEDUPLICATE type BOOLEAN, + DEDUPLICATE_FIELD type STRING, + SIMILAR type BOOLEAN, + SIMILAR_DOCUMENT_IDS type STRING, + SIMILAR_FIELDS type STRING, + BIAS type STRING, + SPELLING_SUGGESTIONS type BOOLEAN, + end of T_COLL_QUERY_LARGE. + types: + "! Object containing environment update information. + begin of T_UPDATE_ENVIRONMENT_REQUEST, + NAME type STRING, + DESCRIPTION type STRING, + SIZE type STRING, + end of T_UPDATE_ENVIRONMENT_REQUEST. + types: + "! Information returned when a configuration is deleted. + begin of T_DEL_CONFIGURATION_RESPONSE, + CONFIGURATION_ID type STRING, + STATUS type STRING, + 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, + MATCHING_RESULTS type INTEGER, + RESULTS type STANDARD TABLE OF T_QUERY_RESULT WITH NON-UNIQUE DEFAULT KEY, + AGGREGATIONS type STANDARD TABLE OF T_QUERY_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + PASSAGES type STANDARD TABLE OF T_QUERY_PASSAGES WITH NON-UNIQUE DEFAULT KEY, + DUPLICATES_REMOVED type INTEGER, + SESSION_TOKEN type STRING, + RETRIEVAL_DETAILS type T_RETRIEVAL_DETAILS, + end of T_QUERY_RESPONSE. + types: + "! + begin of T_TIMESLICE, + FIELD type STRING, + INTERVAL type STRING, + ANOMALY type BOOLEAN, + end of T_TIMESLICE. + types: + "! Training query to add. + begin of T_NEW_TRAINING_QUERY, + NATURAL_LANGUAGE_QUERY type STRING, + FILTER type STRING, + 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, + DOCUMENT_ID type STRING, + CONFIGURATION_ID type STRING, + STATUS type STRING, + STATUS_DESCRIPTION type STRING, + FILENAME type STRING, + FILE_TYPE type STRING, + SHA1 type STRING, + 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, + FILTER type STRING, + QUERY type STRING, + NATURAL_LANGUAGE_QUERY type STRING, + PASSAGES type BOOLEAN, + AGGREGATION type STRING, + COUNT type INTEGER, + RETURN type STRING, + OFFSET type INTEGER, + SORT type STRING, + HIGHLIGHT type BOOLEAN, + PASSAGES_FIELDS type STRING, + PASSAGES_COUNT type INTEGER, + PASSAGES_CHARACTERS type INTEGER, + DEDUPLICATE type BOOLEAN, + DEDUPLICATE_FIELD type STRING, + SIMILAR type BOOLEAN, + SIMILAR_DOCUMENT_IDS type STRING, + SIMILAR_FIELDS type STRING, + BIAS type STRING, + COLLECTION_IDS type STRING, + end of T_FED_QUERY_LARGE. + types: + "! An error response object. + begin of T_ERROR_RESPONSE, + CODE type INTEGER, + 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, + INPUT_TERMS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + 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, + TYPE type STRING, + 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, + 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, + 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, + DOCUMENT_ID type STRING, + STATUS type STRING, + end of T_DELETE_DOCUMENT_RESPONSE. + types: + "! + begin of T_TOP_HITS, + SIZE type INTEGER, + 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, + ENVIRONMENT_ID type STRING, + CUSTOMER_ID type STRING, + DOCUMENT_TYPE type STRING, + NATURAL_LANGUAGE_QUERY type STRING, + DOCUMENT_RESULTS type T_LOG_QUERY_RESP_RESULT_DOCS, + CREATED_TIMESTAMP type DATETIME, + CLIENT_TIMESTAMP type DATETIME, + QUERY_ID type STRING, + SESSION_TOKEN type STRING, + COLLECTION_ID type STRING, + DISPLAY_RANK type INTEGER, + DOCUMENT_ID type STRING, + EVENT_TYPE type STRING, + 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, + MATCHING_RESULTS type INTEGER, + 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, + CROSS_REFERENCE type STRING, + RELEVANCE type INTEGER, + end of T_TRAINING_EXAMPLE_PATCH. + types: + "! Response object containing an array of collection details. + begin of T_LIST_COLLECTIONS_RESPONSE, + COLLECTIONS type STANDARD TABLE OF T_COLLECTION WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_COLLECTIONS_RESPONSE. + types: + "! + begin of T_CALCULATION, + FIELD type STRING, + VALUE type DOUBLE, + end of T_CALCULATION. + types: + "! Training information for a specific collection. + begin of T_TRAINING_DATA_SET, + ENVIRONMENT_ID type STRING, + COLLECTION_ID type STRING, + 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, + MATCHING_RESULTS type INTEGER, + RESULTS type STANDARD TABLE OF T_QUERY_NOTICES_RESULT WITH NON-UNIQUE DEFAULT KEY, + AGGREGATIONS type STANDARD TABLE OF T_QUERY_AGGREGATION WITH NON-UNIQUE DEFAULT KEY, + PASSAGES type STANDARD TABLE OF T_QUERY_PASSAGES WITH NON-UNIQUE DEFAULT KEY, + DUPLICATES_REMOVED type INTEGER, + end of T_QUERY_NOTICES_RESPONSE. + types: + "! + begin of T_HISTOGRAM, + FIELD type STRING, + 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', + ID type string value 'id', + METADATA type string value 'metadata', + INNER type string value 'inner', + RESULT_METADATA type string value 'result_metadata', + TITLE type string value 'title', + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + methods UPDATE_COLLECTION + importing + !I_environment_id type STRING + !I_collection_id type STRING + !I_body type T_UPDATE_COLLECTION_REQUEST 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_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 + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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. + "! + 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 confiruration 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 + "! + 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 + "! + 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 confiruration 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 + "! + 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 + "! + 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 + "! + 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 `` 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 + "! + 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 | + "! + "! @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 + "! + methods FEDERATED_QUERY + importing + !I_environment_id type STRING + !I_query_long type T_FED_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 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 `` 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 + "! + 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_field | + "! The field in the result documents that autocompletion suggestions are identified + "! from. + "! @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_count | + "! The number of autocompletion suggestions to return. + "! @parameter E_RESPONSE | + "! Service return value of type T_COMPLETIONS + "! + methods GET_AUTOCOMPLETION + importing + !I_environment_id type STRING + !I_collection_id type STRING + !I_field type STRING optional + !I_prefix 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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( ). + + 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 = '20191002122840'. + + 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(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 = '/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 = ''. + 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 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(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 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 = ''. + 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->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_field TYPE STRING(optional) +* | [--->] I_prefix 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. + + 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_prefix is supplied. + 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. + 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..33ffa69 --- /dev/null +++ b/src/zcl_ibmc_discovery_v1.clas.xml @@ -0,0 +1,16 @@ + + + + + + ZCL_IBMC_DISCOVERY_V1 + E + Watson Discovery + 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..7d56975 --- /dev/null +++ b/src/zcl_ibmc_lang_translator_v3.clas.abap @@ -0,0 +1,1375 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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: + "! + begin of T_IDENTIFIABLE_LANGUAGE, + LANGUAGE type STRING, + NAME type STRING, + end of T_IDENTIFIABLE_LANGUAGE. + types: + "! + begin of T_IDENTIFIABLE_LANGUAGES, + LANGUAGES type STANDARD TABLE OF T_IDENTIFIABLE_LANGUAGE WITH NON-UNIQUE DEFAULT KEY, + end of T_IDENTIFIABLE_LANGUAGES. + types: + "! + begin of T_TRANSLATION, + TRANSLATION type STRING, + end of T_TRANSLATION. + types: + "! + begin of T_TRANSLATION_RESULT, + WORD_COUNT type INTEGER, + CHARACTER_COUNT type INTEGER, + TRANSLATIONS type STANDARD TABLE OF T_TRANSLATION WITH NON-UNIQUE DEFAULT KEY, + end of T_TRANSLATION_RESULT. + types: + "! + begin of T_IDENTIFIED_LANGUAGE, + LANGUAGE type STRING, + CONFIDENCE type DOUBLE, + end of T_IDENTIFIED_LANGUAGE. + types: + "! + begin of T_IDENTIFIED_LANGUAGES, + 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, + DOCUMENT_ID type STRING, + FILENAME type STRING, + STATUS type STRING, + MODEL_ID type STRING, + BASE_MODEL_ID type STRING, + SOURCE type STRING, + TARGET type STRING, + CREATED type DATETIME, + COMPLETED type DATETIME, + WORD_COUNT type INTEGER, + CHARACTER_COUNT type INTEGER, + end of T_DOCUMENT_STATUS. + types: + "! + begin of T_ERROR_RESPONSE, + CODE type INTEGER, + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! Translation source language code. + T_SOURCE type String. + types: + "! + begin of T_INLINE_OBJECT1, + MODEL_ID type STRING, + SOURCE type STRING, + TARGET type STRING, + DOCUMENT_ID type STRING, + FILE type FILE, + end of T_INLINE_OBJECT1. + types: + "! + begin of T_INLINE_OBJECT, + FORCED_GLOSSARY type FILE, + PARALLEL_CORPUS type FILE, + end of T_INLINE_OBJECT. + types: + "! Response payload for models. + begin of T_TRANSLATION_MODEL, + MODEL_ID type STRING, + NAME type STRING, + SOURCE type STRING, + TARGET type STRING, + BASE_MODEL_ID type STRING, + DOMAIN type STRING, + CUSTOMIZABLE type BOOLEAN, + DEFAULT_MODEL type BOOLEAN, + OWNER type STRING, + STATUS type STRING, + end of T_TRANSLATION_MODEL. + types: + "! The response type for listing existing translation models. + begin of T_TRANSLATION_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: + "! + begin of T_TRANSLATE_REQUEST, + TEXT type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + MODEL_ID type STRING, + SOURCE type STRING, + TARGET type STRING, + end of T_TRANSLATE_REQUEST. + types: + "! + begin of T_DELETE_MODEL_RESULT, + STATUS type STRING, + end of T_DELETE_MODEL_RESULT. + types: + "! + begin of T_DOCUMENT_LIST, + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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( ). + + 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 = '20191002122842'. + + 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..897a4d8 --- /dev/null +++ b/src/zcl_ibmc_nat_lang_class_v1.clas.abap @@ -0,0 +1,743 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + CODE type INTEGER, + ERROR type STRING, + DESCRIPTION type STRING, + end of T_ERROR_RESPONSE. + types: + "! Request payload to classify. + begin of T_CLASSIFY_INPUT, + TEXT type STRING, + end of T_CLASSIFY_INPUT. + types: + "! + begin of T_INLINE_OBJECT, + TRAINING_METADATA type FILE, + TRAINING_DATA type FILE, + end of T_INLINE_OBJECT. + types: + "! Class and confidence. + begin of T_CLASSIFIED_CLASS, + CONFIDENCE type DOUBLE, + 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, + TEXT type STRING, + TOP_CLASS type STRING, + 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, + NAME type STRING, + URL type STRING, + STATUS type STRING, + CLASSIFIER_ID type STRING, + CREATED type DATETIME, + STATUS_DESCRIPTION type STRING, + LANGUAGE type STRING, + end of T_CLASSIFIER. + types: + "! List of available classifiers. + begin of T_CLASSIFIER_LIST, + 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, + CLASSIFIER_ID type STRING, + URL type STRING, + TEXT type STRING, + TOP_CLASS type STRING, + 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, + 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, + CODE type INTEGER, + ERROR type STRING, + end of T_ERROR_CLOUD. + types: + "! + T_EMPTY type JSONOBJECT. + types: + "! Response from the classifier for multiple phrases. + begin of T_CLASSIFICATION_COLLECTION, + CLASSIFIER_ID type STRING, + URL type STRING, + 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 + "! + 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 + "! + 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/services/natural-language-classifier?to + "! pic=natural-language-classifier-using-your-data). + "! @parameter E_RESPONSE | + "! Service return value of type T_CLASSIFIER + "! + 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 + "! + 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 + "! + 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. + "! + 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( ). + + 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 = '20191002122844'. + + 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..1284cf8 --- /dev/null +++ b/src/zcl_ibmc_nat_lang_undrstnd_v1.clas.abap @@ -0,0 +1,983 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, relations, and categories in Natural Language +"! Understanding.
+class ZCL_IBMC_NAT_LANG_UNDRSTND_V1 DEFINITION + public + inheriting from ZCL_IBMC_SERVICE_EXT + create public . + +public section. + types: + "! + begin of T_SEMANTIC_ROLES_ENTITY, + TYPE type STRING, + TEXT type STRING, + end of T_SEMANTIC_ROLES_ENTITY. + types: + "! + begin of T_SEMANTIC_ROLES_KEYWORD, + TEXT type STRING, + end of T_SEMANTIC_ROLES_KEYWORD. + types: + "! The extracted subject from the sentence. + begin of T_SMNTC_ROLES_RESULT_SUBJECT, + TEXT type STRING, + ENTITIES type STANDARD TABLE OF T_SEMANTIC_ROLES_ENTITY WITH NON-UNIQUE DEFAULT KEY, + 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, + TEXT type STRING, + KEYWORDS type STANDARD TABLE OF T_SEMANTIC_ROLES_KEYWORD WITH NON-UNIQUE DEFAULT KEY, + end of T_SEMANTIC_ROLES_RESULT_OBJECT. + types: + "! + begin of T_SEMANTIC_ROLES_VERB, + TEXT type STRING, + TENSE type STRING, + end of T_SEMANTIC_ROLES_VERB. + types: + "! The extracted action from the sentence. + begin of T_SEMANTIC_ROLES_RESULT_ACTION, + TEXT type STRING, + NORMALIZED type STRING, + 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 type STRING, + SUBJECT type T_SMNTC_ROLES_RESULT_SUBJECT, + ACTION type T_SEMANTIC_ROLES_RESULT_ACTION, + 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, + LIMIT type INTEGER, + KEYWORDS type BOOLEAN, + ENTITIES type BOOLEAN, + end of T_SEMANTIC_ROLES_OPTIONS. + types: + "! An entity that corresponds with an argument in a relation. + begin of T_RELATION_ENTITY, + TEXT type STRING, + TYPE type STRING, + end of T_RELATION_ENTITY. + types: + "! + begin of T_RELATION_ARGUMENT, + ENTITIES type STANDARD TABLE OF T_RELATION_ENTITY WITH NON-UNIQUE DEFAULT KEY, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + TEXT type STRING, + end of T_RELATION_ARGUMENT. + types: + "! The relations between entities found in the content. + begin of T_RELATIONS_RESULT, + SCORE type DOUBLE, + SENTENCE type STRING, + TYPE type STRING, + ARGUMENTS type STANDARD TABLE OF T_RELATION_ARGUMENT WITH NON-UNIQUE DEFAULT KEY, + end of T_RELATIONS_RESULT. + types: + "! + begin of T_MODEL, + STATUS type STRING, + MODEL_ID type STRING, + LANGUAGE type STRING, + DESCRIPTION type STRING, + WORKSPACE_ID type STRING, + VERSION type STRING, + VERSION_DESCRIPTION type STRING, + CREATED type DATETIME, + end of T_MODEL. + types: + "! + begin of T_FEATURE_SENTIMENT_RESULTS, + SCORE type DOUBLE, + end of T_FEATURE_SENTIMENT_RESULTS. + types: + "! + begin of T_EMOTION_SCORES, + ANGER type DOUBLE, + DISGUST type DOUBLE, + FEAR type DOUBLE, + JOY type DOUBLE, + SADNESS type DOUBLE, + end of T_EMOTION_SCORES. + types: + "! The author of the analyzed content. + begin of T_AUTHOR, + NAME type STRING, + end of T_AUTHOR. + types: + "! RSS or ATOM feed found on the webpage. + begin of T_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, + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + PUBLICATION_DATE type STRING, + TITLE type STRING, + IMAGE type STRING, + FEEDS type STANDARD TABLE OF T_FEED WITH NON-UNIQUE DEFAULT KEY, + end of T_FEATURES_RESULTS_METADATA. + types: + "! + begin of T_ENTITY_MENTION, + TEXT type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + CONFIDENCE type DOUBLE, + end of T_ENTITY_MENTION. + types: + "! Disambiguation information for the entity. + begin of T_DISAMBIGUATION_RESULT, + NAME type STRING, + DBPEDIA_RESOURCE type STRING, + 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, + TYPE type STRING, + TEXT type STRING, + RELEVANCE type DOUBLE, + CONFIDENCE type DOUBLE, + MENTIONS type STANDARD TABLE OF T_ENTITY_MENTION WITH NON-UNIQUE DEFAULT KEY, + COUNT type INTEGER, + EMOTION type T_EMOTION_SCORES, + SENTIMENT type T_FEATURE_SENTIMENT_RESULTS, + DISAMBIGUATION type T_DISAMBIGUATION_RESULT, + end of T_ENTITIES_RESULT. + types: + "! Emotion results for a specified target. + begin of T_TARGETED_EMOTION_RESULTS, + TEXT type STRING, + 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, + COUNT type INTEGER, + RELEVANCE type DOUBLE, + TEXT type STRING, + EMOTION type T_EMOTION_SCORES, + SENTIMENT type T_FEATURE_SENTIMENT_RESULTS, + end of T_KEYWORDS_RESULT. + types: + "! + begin of T_TARGETED_SENTIMENT_RESULTS, + TEXT type STRING, + SCORE type DOUBLE, + end of T_TARGETED_SENTIMENT_RESULTS. + types: + "! Relevant text that contributed to the categorization. + begin of T_CATEGORIES_RELEVANT_TEXT, + 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 type T_EMOTION_SCORES, + end of T_DOCUMENT_EMOTION_RESULTS. + types: + "! + begin of T_DOCUMENT_SENTIMENT_RESULTS, + LABEL type STRING, + SCORE type DOUBLE, + end of T_DOCUMENT_SENTIMENT_RESULTS. + types: + "! The sentiment of the content. + begin of T_SENTIMENT_RESULT, + DOCUMENT type T_DOCUMENT_SENTIMENT_RESULTS, + TARGETS type STANDARD TABLE OF T_TARGETED_SENTIMENT_RESULTS WITH NON-UNIQUE DEFAULT KEY, + end of T_SENTIMENT_RESULT. + types: + "! + begin of T_TOKEN_RESULT, + TEXT type STRING, + PART_OF_SPEECH type STRING, + LOCATION type STANDARD TABLE OF INTEGER WITH NON-UNIQUE DEFAULT KEY, + LEMMA type STRING, + end of T_TOKEN_RESULT. + types: + "! + begin of T_SENTENCE_RESULT, + TEXT type STRING, + 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, + TOKENS type STANDARD TABLE OF T_TOKEN_RESULT WITH NON-UNIQUE DEFAULT KEY, + 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, + TEXT type STRING, + RELEVANCE type DOUBLE, + 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, + 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, + LABEL type STRING, + SCORE type DOUBLE, + 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, + DOCUMENT type T_DOCUMENT_EMOTION_RESULTS, + 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, + CONCEPTS type STANDARD TABLE OF T_CONCEPTS_RESULT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_ENTITIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + KEYWORDS type STANDARD TABLE OF T_KEYWORDS_RESULT WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + EMOTION type T_EMOTION_RESULT, + METADATA type T_FEATURES_RESULTS_METADATA, + RELATIONS type STANDARD TABLE OF T_RELATIONS_RESULT WITH NON-UNIQUE DEFAULT KEY, + SEMANTIC_ROLES type STANDARD TABLE OF T_SEMANTIC_ROLES_RESULT WITH NON-UNIQUE DEFAULT KEY, + SENTIMENT type T_SENTIMENT_RESULT, + 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, + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + PUBLICATION_DATE type STRING, + TITLE type STRING, + IMAGE type STRING, + FEEDS type STANDARD TABLE OF T_FEED WITH NON-UNIQUE DEFAULT KEY, + end of T_METADATA_RESULT. + types: + "! + begin of T_ERROR_RESPONSE, + CODE type INTEGER, + 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, + DOCUMENT type BOOLEAN, + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_EMOTION_OPTIONS. + types: + "! Usage information. + begin of T_USAGE, + FEATURES type INTEGER, + TEXT_CHARACTERS type INTEGER, + 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, + DOCUMENT type BOOLEAN, + TARGETS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_SENTIMENT_OPTIONS. + types: + "! + begin of T_SEMANTIC_ROLES_ACTION, + TEXT type STRING, + NORMALIZED type STRING, + VERB type T_SEMANTIC_ROLES_VERB, + end of T_SEMANTIC_ROLES_ACTION. + types: + "! Tokenization options. + begin of T_SYNTAX_OPTIONS_TOKENS, + LEMMA type BOOLEAN, + 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, + LIMIT type INTEGER, + SENTIMENT type BOOLEAN, + 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, + 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, + LIMIT type INTEGER, + MENTIONS type BOOLEAN, + MODEL type STRING, + SENTIMENT type BOOLEAN, + 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, + 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, + TOKENS type T_SYNTAX_OPTIONS_TOKENS, + 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, + EXPLANATION type BOOLEAN, + LIMIT type INTEGER, + MODEL type STRING, + end of T_CATEGORIES_OPTIONS. + types: + "! Analysis features and options. + begin of T_FEATURES, + CONCEPTS type T_CONCEPTS_OPTIONS, + EMOTION type T_EMOTION_OPTIONS, + ENTITIES type T_ENTITIES_OPTIONS, + KEYWORDS type T_KEYWORDS_OPTIONS, + METADATA type T_METADATA_OPTIONS, + RELATIONS type T_RELATIONS_OPTIONS, + SEMANTIC_ROLES type T_SEMANTIC_ROLES_OPTIONS, + SENTIMENT type T_SENTIMENT_OPTIONS, + CATEGORIES type T_CATEGORIES_OPTIONS, + 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, + AUTHORS type STANDARD TABLE OF T_AUTHOR WITH NON-UNIQUE DEFAULT KEY, + PUBLICATION_DATE type STRING, + TITLE type STRING, + IMAGE type STRING, + 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, + FEATURES type INTEGER, + TEXT_CHARACTERS type INTEGER, + TEXT_UNITS type INTEGER, + end of T_ANALYSIS_RESULTS_USAGE. + types: + "! Results of the analysis, organized by feature. + begin of T_ANALYSIS_RESULTS, + LANGUAGE type STRING, + ANALYZED_TEXT type STRING, + RETRIEVED_URL type STRING, + USAGE type T_ANALYSIS_RESULTS_USAGE, + CONCEPTS type STANDARD TABLE OF T_CONCEPTS_RESULT WITH NON-UNIQUE DEFAULT KEY, + ENTITIES type STANDARD TABLE OF T_ENTITIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + KEYWORDS type STANDARD TABLE OF T_KEYWORDS_RESULT WITH NON-UNIQUE DEFAULT KEY, + CATEGORIES type STANDARD TABLE OF T_CATEGORIES_RESULT WITH NON-UNIQUE DEFAULT KEY, + EMOTION type T_EMOTION_RESULT, + METADATA type T_ANALYSIS_RESULTS_METADATA, + RELATIONS type STANDARD TABLE OF T_RELATIONS_RESULT WITH NON-UNIQUE DEFAULT KEY, + SEMANTIC_ROLES type STANDARD TABLE OF T_SEMANTIC_ROLES_RESULT WITH NON-UNIQUE DEFAULT KEY, + SENTIMENT type T_SENTIMENT_RESULT, + SYNTAX type T_SYNTAX_RESULT, + end of T_ANALYSIS_RESULTS. + types: + "! + begin of T_SEMANTIC_ROLES_SUBJECT, + TEXT type STRING, + ENTITIES type STANDARD TABLE OF T_SEMANTIC_ROLES_ENTITY WITH NON-UNIQUE DEFAULT KEY, + 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, + MODELS type STANDARD TABLE OF T_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_LIST_MODELS_RESULTS. + types: + "! + begin of T_SEMANTIC_ROLES_OBJECT, + TEXT type STRING, + 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, + TEXT type STRING, + HTML type STRING, + URL type STRING, + FEATURES type T_FEATURES, + CLEAN type BOOLEAN, + XPATH type STRING, + FALLBACK_TO_RAW type BOOLEAN, + RETURN_ANALYZED_TEXT type BOOLEAN, + LANGUAGE type STRING, + LIMIT_TEXT_CHARACTERS type INTEGER, + end of T_PARAMETERS. + types: + "! Link to the corresponding DBpedia resource. + T_DBPEDIA_RESOURCE type String. + types: + "! Delete model results. + begin of T_DELETE_MODEL_RESULTS, + 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_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_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', + 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', + NAME type string value 'name', + 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 + "! + 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 + "! + 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 + "! + 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( ). + + 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 = '20191002122846'. + + 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..870b7a8 --- /dev/null +++ b/src/zcl_ibmc_personal_insights_v3.clas.abap @@ -0,0 +1,693 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + TRAIT_ID type STRING, + NAME type STRING, + CATEGORY type STRING, + PERCENTILE type DOUBLE, + RAW_SCORE type DOUBLE, + SIGNIFICANT type BOOLEAN, + 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, + TRAIT_ID type STRING, + NAME type STRING, + CATEGORY type STRING, + PERCENTAGE type DOUBLE, + end of T_BEHAVIOR. + types: + "! A consumption preference that the service inferred from the input content. + begin of T_CONSUMPTION_PREFERENCES, + CONSUMPTION_PREFERENCE_ID type STRING, + NAME type STRING, + SCORE type DOUBLE, + end of T_CONSUMPTION_PREFERENCES. + types: + "! A warning message that is associated with the input content. + begin of T_WARNING, + WARNING_ID type STRING, + 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, + CNSMPTN_PREFERENCE_CATEGORY_ID type STRING, + NAME type STRING, + 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, + PROCESSED_LANGUAGE type STRING, + WORD_COUNT type INTEGER, + WORD_COUNT_MESSAGE type STRING, + PERSONALITY type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + NEEDS type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + VALUES type STANDARD TABLE OF T_TRAIT WITH NON-UNIQUE DEFAULT KEY, + BEHAVIOR type STANDARD TABLE OF T_BEHAVIOR WITH NON-UNIQUE DEFAULT KEY, + CONSUMPTION_PREFERENCES type STANDARD TABLE OF T_CNSMPTN_PREFERENCES_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + 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, + CONTENT type STRING, + ID type STRING, + CREATED type LONG, + UPDATED type LONG, + CONTENTTYPE type STRING, + LANGUAGE type STRING, + PARENTID type STRING, + REPLY type BOOLEAN, + 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, + CODE type INTEGER, + SUB_CODE type STRING, + ERROR type STRING, + HELP type STRING, + end of T_ERROR_MODEL. + types: + "! The full input content that the service is to analyze. + begin of T_CONTENT, + 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 + "! + 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. + "! + 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' + 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( ). + + 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 = '20191002122847'. + + 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') +* | [!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 ). + + + +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..d3ee132 --- /dev/null +++ b/src/zcl_ibmc_service.clas.abap @@ -0,0 +1,1281 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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: + 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 . + + 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 . + + 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 . + methods GET_REQUEST_PROP + importing + !I_AUTH_METHOD type STRING default C_DEFAULT + returning + value(E_REQUEST_PROP) type TS_REQUEST_PROP . + class-methods GET_DATATYPE + importing + !I_FIELD type ANY + returning + value(E_DATATYPE) type ZIF_IBMC_SERVICE_ARCH~CHAR . + methods ADD_FORM_PART + importing + !I_CLIENT type TS_CLIENT + !IT_FORM_PART type TT_FORM_PART + raising + ZCX_IBMC_SERVICE_EXCEPTION . + class-methods UNESCAPE_UNICODE + importing + !I_IN type STRING + returning + value(E_OUT) type STRING . + class-methods GET_FILE_EXTENSION + importing + value(I_MIME_TYPE) type STRING + returning + value(E_EXTENSION) type STRING . + 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 . + 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 . + 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 . + class-methods GET_FULL_URL + importing + !I_URL type TS_URL + returning + value(E_URL) type STRING . + methods GET_APPNAME + returning + value(E_APPNAME) type STRING . + class-methods NORMALIZE_URL + changing + !C_URL type TS_URL . + 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 . + methods CONSTRUCTOR + importing + !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 . + methods GET_REST_CLIENT + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_CLIENT) type TS_CLIENT + raising + ZCX_IBMC_SERVICE_EXCEPTION . + 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 . + methods HTTP_DELETE + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + methods SET_ACCESS_TOKEN + importing + !I_ACCESS_TOKEN type TS_ACCESS_TOKEN + raising + ZCX_IBMC_SERVICE_EXCEPTION . + methods HTTP_GET + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + methods HTTP_POST + importing + !I_REQUEST_PROP type TS_REQUEST_PROP + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + 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 . + 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 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 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 = i_value. + 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 i_value to . + if = c_i_zero. + lv_json_num = '0'. + exit. + endif. + elseif lv_type eq '8'. + assign i_value to . + if = c_i8_zero. + lv_json_num = '0'. + exit. + endif. + elseif lv_type eq 'F'. + assign i_value to . + if = c_f_zero. + lv_json_num = '0'. + exit. + endif. + endif. + + lv_json_num = conv #( i_value ). + 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 = i_value + importing + e_components = lt_compname ). + clear lv_sep. + lv_json = lv_json && `{`. + loop at lt_compname assigning . + assign component of structure i_value 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 i_value 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_form_part. + + data: + ls_form_part type ts_form_part, + lo_part type to_form_part. + + loop at it_form_part into ls_form_part. + lo_part = form_part_add( i_client = i_client ). + if not ls_form_part-content_type is initial. + form_part_set_header( i_form_part = lo_part i_name = 'Content-Type' i_value = ls_form_part-content_type ) ##NO_TEXT. + endif. + if not ls_form_part-content_disposition is initial. + form_part_set_header( i_form_part = lo_part i_name = 'Content-Disposition' i_value = ls_form_part-content_disposition ) ##NO_TEXT. + endif. + if not ls_form_part-xdata is initial. + form_part_set_xdata( i_form_part = lo_part i_data = ls_form_part-xdata ). + endif. + if not ls_form_part-cdata is initial. + form_part_set_cdata( i_form_part = lo_part i_data = ls_form_part-cdata ). + endif. + endloop. + + 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, + lo_service_exception type ref to zcx_ibmc_service_exception. + + lv_http_status = get_http_status( i_rest_response = i_response ). + if lv_http_status-code ne '200' and " ok + lv_http_status-code ne '201' and " ok with response + lv_http_status-code ne '202' and " Accepted (asynchronous function call) + lv_http_status-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_http_status-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. + + super->constructor( ). + + p_request_prop_default-url-host = i_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_datatype. + + get_field_type( + exporting + i_field = i_field + importing + e_technical_type = e_datatype ). + + 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. + + data: + lv_path_base type string value is initial, + lv_path type string, + lv_protocol type ts_url-protocol, + lv_host type ts_url-host, + lv_strlen type i, + lv_offset type i. + + check not c_url is initial. + + if not c_url-path_base is initial. + lv_path = c_url-path_base. + else. + lv_path = c_url-path. + endif. + + " extract host from path + if lv_path cp 'http:*' or lv_path cp 'https:*'. + find regex '(http.?:\/\/[^\/]*)' in lv_path submatches lv_host. + lv_strlen = strlen( lv_host ). + lv_path = lv_path+lv_strlen. + c_url-host = lv_host. + endif. + + " extract protocol from host + if c_url-host cp 'http:*' or c_url-host cp 'https:*'. + find regex '(http.?):\/\/' in c_url-host submatches lv_protocol. + lv_strlen = strlen( lv_protocol ). + lv_strlen = lv_strlen + 3. " for :// + c_url-host = c_url-host+lv_strlen. + c_url-protocol = lv_protocol. + endif. + + " extrcat base path from host + find first occurrence of '/' in c_url-host match offset lv_offset. + if sy-subrc = 0. + lv_path_base = c_url-host+lv_offset. + c_url-host = c_url-host+0(lv_offset). + endif. + + if c_url-path_base is initial. + c_url-path_base = lv_path_base. + c_url-path = lv_path. + else. + c_url-path_base = lv_path_base && lv_path. + 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..c890b4f --- /dev/null +++ b/src/zcl_ibmc_service.clas.xml @@ -0,0 +1,42 @@ + + + + + + ZCL_IBMC_SERVICE + E + ABAP SDK for IBM Watson - Service Class + 1 + X + X + X + + + + ZCL_IBMC_SERVICE + GET_DATATYPE + E + Returns data type of a variable + + + ZCL_IBMC_SERVICE + GET_FILE_EXTENSION + E + Returns file extension for given mime type + + + ZCL_IBMC_SERVICE + MOVE_DATA_REFERENCE_TO_ABAP + E + moves type DATA_REFERENCE to ABAP structure + + + 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..931afd7 --- /dev/null +++ b/src/zcl_ibmc_service_arch.clas.abap @@ -0,0 +1,571 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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_HTTP_CLIENT . + types TO_REST_CLIENT type ref to CL_REST_HTTP_CLIENT . + types TO_HTTP_ENTITY type ref to IF_HTTP_ENTITY . + types TO_REST_ENTITY type ref to IF_REST_ENTITY . + types TO_REST_REQUEST type ref to IF_REST_ENTITY . + types TO_REST_RESPONSE type ref to IF_REST_ENTITY . + types TO_FORM_PART type ref to IF_HTTP_ENTITY . + types: + begin of ts_client, + http type to_http_client, + rest type to_rest_client, + end of ts_client . + types TS_HTTP_STATUS type ZIF_IBMC_SERVICE_ARCH~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 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 . + 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 FORM_PART_SET_CDATA + importing + !I_FORM_PART type TO_FORM_PART + !I_DATA type STRING . + class-methods FORM_PART_SET_HEADER + importing + !I_FORM_PART type TO_FORM_PART + !I_NAME type STRING + !I_VALUE type STRING . + class-methods FORM_PART_SET_XDATA + importing + !I_FORM_PART type TO_FORM_PART + !I_DATA type XSTRING . + class-methods GET_COMPONENTS + importing + !I_STRUCTURE type ANY + exporting + value(E_COMPONENTS) type ZIF_IBMC_SERVICE_ARCH~TT_STRING . + 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 . + class-methods FORM_PART_ADD + importing + !I_CLIENT type TS_CLIENT + returning + value(E_FORM_PART) type TO_FORM_PART . + class-methods EXECUTE + importing + !I_CLIENT type TS_CLIENT + !I_METHOD type ZIF_IBMC_SERVICE_ARCH~CHAR default ZIF_IBMC_SERVICE_ARCH~C_METHOD_GET + returning + value(E_RESPONSE) type TO_REST_RESPONSE + raising + ZCX_IBMC_SERVICE_EXCEPTION . + class-methods GET_RESPONSE_STRING + importing + !I_RESPONSE type TO_REST_RESPONSE + returning + value(E_DATA) type STRING . + 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 . + 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 ESCAPE_URL + importing + !I_UNESCAPED type STRING + returning + value(E_ESCAPED) type STRING . + class-methods GET_RESPONSE_BINARY + importing + !I_RESPONSE type TO_REST_RESPONSE + returning + value(E_DATA) type XSTRING . + class-methods GET_REST_REQUEST + importing + !I_CLIENT type TS_CLIENT + returning + value(E_REST_REQUEST) type TO_REST_REQUEST . + class-methods GET_HTTP_STATUS + importing + !I_REST_RESPONSE type TO_REST_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. + + call function 'SCMS_BASE64_DECODE_STR' + exporting + input = i_base64 + importing + output = e_binary + exceptions + failed = 1 + others = 2. + + if sy-subrc <> 0. + zcl_ibmc_service=>raise_exception( i_msgno = '030' ). " Decoding of base64 string failed + endif. + + endmethod. + + + method convert_string_to_utf8. + + data: + lv_codepage type cpcodepage, + lv_encoding type abap_encoding. + + clear e_utf8. + call function 'SCP_CODEPAGE_BY_EXTERNAL_NAME' + exporting + external_name = 'UTF-8' + importing + sap_codepage = lv_codepage + exceptions + not_found = 1 + others = 2. + if sy-subrc <> 0. + zcl_ibmc_service=>raise_exception( i_text = 'Cannot determine UTF-8 codepage' ) ##NO_TEXT. + endif. + lv_encoding = lv_codepage. + call function 'SCMS_STRING_TO_XSTRING' + exporting + text = i_string + encoding = lv_encoding + importing + buffer = e_utf8 + exceptions + failed = 1 + others = 2. + 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. + + cl_http_client=>create_by_url( + exporting + url = i_url + proxy_host = i_request_prop-proxy_host " proxy server (w/o protocol prefix) + proxy_service = i_request_prop-proxy_port " proxy port + ssl_id = i_request_prop-ssl_id + importing + client = e_client-http + exceptions + argument_not_found = 1 + plugin_not_active = 2 + internal_error = 3 + others = 99 ) ##NUMBER_OK. + if sy-subrc <> 0. + case sy-subrc. + when 1. + lv_text = 'Argument not found' ##NO_TEXT. + when 2. + lv_text = 'Plugin not active' ##NO_TEXT. + when others. + lv_text = 'Internal error' ##NO_TEXT. + endcase. + lv_text = `HTTP client cannot be created: ` && lv_text ##NO_TEXT. + zcl_ibmc_service=>raise_exception( i_text = lv_text ). + endif. + + " set http protocol version + e_client-http->request->set_version( if_http_request=>co_protocol_version_1_1 ). + e_client-http->propertytype_logon_popup = if_http_client=>co_disabled. + + " create REST client instance from http client instance + create object e_client-rest + exporting + io_http_client = e_client-http. + + endmethod. + + + method escape_url. + + e_escaped = cl_http_utility=>escape_url( unescaped = i_unescaped ). + + endmethod. + + + method execute. + + data: + lo_request type to_rest_request, + lv_method type string, + lv_text type string, + lo_exception type ref to cx_rest_client_exception. + + try. + case i_method. + when zif_ibmc_service_arch~c_method_get. + lv_method = 'GET' ##NO_TEXT. + i_client-rest->if_rest_client~get( ). + when zif_ibmc_service_arch~c_method_post. + lv_method = 'POST' ##NO_TEXT. + lo_request = get_rest_request( i_client = i_client ). + i_client-rest->if_rest_client~post( lo_request ). + when zif_ibmc_service_arch~c_method_put. + lv_method = 'PUT' ##NO_TEXT. + lo_request = get_rest_request( i_client = i_client ). + i_client-rest->if_rest_client~put( lo_request ). + when zif_ibmc_service_arch~c_method_delete. + lv_method = 'DELETE' ##NO_TEXT. + i_client-rest->if_rest_client~delete( ). + when others. + "raise_exception( ). + endcase. + catch cx_rest_client_exception 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. + + e_response = i_client-rest->if_rest_client~get_response_entity( ). + + endmethod. + + + method form_part_add. + + e_form_part = i_client-http->request->if_http_entity~add_multipart( ). + + endmethod. + + + method form_part_set_cdata. + + i_form_part->append_cdata( data = i_data ). + + endmethod. + + + method form_part_set_header. + + i_form_part->set_header_field( name = i_name value = i_value ). + + endmethod. + + + method form_part_set_xdata. + + data: + lv_length type i. + + lv_length = xstrlen( i_data ). + i_form_part->set_data( data = i_data offset = 0 length = lv_length ). + + 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_default_proxy. + + data: + ls_proxy type pproxy_c, + lv_protocol type i. + if i_url-protocol eq 'https' or i_url-protocol eq 'HTTPS'. + lv_protocol = 2. + else. + lv_protocol = 1. + endif. + call function 'ICF_READ_PROXY_CONFIGURATION' + exporting + authority_check = space + mandant = sy-mandt + protocol = lv_protocol + hostname = i_url-host + importing + proxy_configuraion = ls_proxy + exceptions + authority_not_available = 1 + proxy_invalid_protocol = 2 + proxy_entry_not_available = 3 + proxy_entry_not_active = 4 + proxy_parameter_not_available = 5 + proxy_not_necessary = 6 + proxy_no_authority = 7 + proxy_exit_erroneous = 8 + others = 9. + if sy-subrc <> 0. + else. + e_proxy_host = ls_proxy-host. + e_proxy_port = ls_proxy-port. + endif. + + endmethod. + + + method get_field_type. + data: + lo_abap_type type ref to cl_abap_typedescr. + + describe field i_field type e_technical_type. + + 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. + describe field i_field length e_length in character mode. + else. + e_length = 0. + endif. + endif. + + endmethod. + + + method get_http_status. + + e_status-code = i_rest_response->get_header_field( '~status_code' ). + e_status-reason = i_rest_response->get_header_field( '~status_reason' ). + e_status-json = i_rest_response->get_string_data( ). + + endmethod. + + + method get_progname. + + e_progname = sy-cprog. + + endmethod. + + + method get_response_binary. + + e_data = i_response->get_binary_data( ). + + endmethod. + + + method get_response_string. + + e_data = i_response->get_string_data( ). + + endmethod. + + + method get_rest_request. + + e_rest_request = i_client-rest->if_rest_client~create_request_entity( ). + + endmethod. + + + method get_timezone. + + e_timezone = sy-zonlo. + + 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 set_authentication_basic. + + i_client-http->authenticate( username = i_username password = i_password ). + + endmethod. + + + method set_request_body_cdata. + + i_client-http->request->if_http_entity~set_cdata( data = i_data ). + + endmethod. + + + method set_request_body_xdata. + + i_client-http->request->if_http_entity~set_data( data = i_data ). + + endmethod. + + + method set_request_header. + + i_client-rest->if_rest_client~set_request_header( iv_name = i_name iv_value = i_value ) . + + endmethod. + + + method set_request_uri. + + cl_http_utility=>set_request_uri( + exporting + request = i_client-http->request + uri = 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..53546d8 --- /dev/null +++ b/src/zcl_ibmc_service_arch.clas.xml @@ -0,0 +1,162 @@ + + + + + + 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 + CREATE_CLIENT_BY_URL + E + returns a HTTP/REST client based on an URL + + + ZCL_IBMC_SERVICE_ARCH + ESCAPE_URL + E + Makes a string to url conform + + + ZCL_IBMC_SERVICE_ARCH + EXECUTE + E + executes a HTTP request (GET, POST or DELETE) + + + ZCL_IBMC_SERVICE_ARCH + FORM_PART_ADD + E + adds a part to a multipart request + + + ZCL_IBMC_SERVICE_ARCH + FORM_PART_SET_CDATA + E + sets character data for a part of a multipart request + + + ZCL_IBMC_SERVICE_ARCH + FORM_PART_SET_HEADER + E + sets a header within a part of a multiform request + + + ZCL_IBMC_SERVICE_ARCH + FORM_PART_SET_XDATA + E + sets binary data for a part of a multipart request + + + ZCL_IBMC_SERVICE_ARCH + GET_COMPONENTS + E + returns the component names of a given structure + + + ZCL_IBMC_SERVICE_ARCH + GET_DEFAULT_PROXY + E + returns the default proxy host and port + + + ZCL_IBMC_SERVICE_ARCH + GET_FIELD_TYPE + E + returns the absolute type of a field + + + 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..e0f719b --- /dev/null +++ b/src/zcl_ibmc_service_ext.clas.abap @@ -0,0 +1,915 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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. + data P_INSTANCE_ID type TY_INSTANCE_ID . + data P_SERVICENAME type TY_SERVICENAME . + + methods GET_BEARER_TOKEN + returning + value(E_BEARER_TOKEN) type STRING . + methods GET_SDK_VERSION_DATE + returning + value(E_SDK_VERSION_DATE) type STRING . + methods SET_BEARER_TOKEN + importing + !I_BEARER_TOKEN type STRING . + 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 . + class-methods GET_INSTANCE + importing + !I_INSTANCE_ID type TY_INSTANCE_ID 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 . + 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 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 . + + 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 . + 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 . + 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. + + field-symbols: + 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. + + 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 'u' or lv_type eq 'v'. " structure + 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. + = 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: + lv_service type zibmc_token-service, + lo_response type to_rest_response, + lv_grand_urlencoded type string, +* lv_usr_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-access_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_usr_urlencoded = escape( val = p_oauth_prop-username format = cl_abap_format=>e_uri_full ). + 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 = lv_service. + 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. + + get_field_type( + exporting + i_field = eo_instance + importing + e_relative_type = lv_classname ). + + create object eo_instance type (lv_classname) + exporting + 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 ). + + " 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 ). + + " 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 = 'iam.bluemix.net' ##NO_TEXT. + 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 = '/identity/token' ##NO_TEXT. + 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_sdk_version_date. + + e_sdk_version_date = '20191001'. + + 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..35b8c3d --- /dev/null +++ b/src/zcl_ibmc_speech_to_text_v1.clas.abap @@ -0,0 +1,4734 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + CODE type STRING, + 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, + 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, + CONFIDENCE type DOUBLE, + 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, + START_TIME type DOUBLE, + END_TIME type DOUBLE, + 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, + BEGIN type FLOAT, + END type FLOAT, + 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, + FROM type FLOAT, + TO type FLOAT, + SPEAKER type INTEGER, + CONFIDENCE type FLOAT, + FINAL type BOOLEAN, + end of T_SPEAKER_LABELS_RESULT. + types: + "! An alternative transcript from speech recognition results. + begin of T_SPCH_RECOGNITION_ALTERNATIVE, + TRANSCRIPT type STRING, + CONFIDENCE type DOUBLE, + TIMESTAMPS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + RECEIVED type FLOAT, + SEEN_BY_ENGINE type FLOAT, + TRANSCRIPTION type FLOAT, + 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, + PROCESSED_AUDIO type T_PROCESSED_AUDIO, + WLL_CLCK_SNC_FRST_BYT_RECEIVED type FLOAT, + 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, + FINAL type BOOLEAN, + END_TIME type FLOAT, + SIGNAL_TO_NOISE_RATIO type FLOAT, + SPEECH_RATIO type FLOAT, + HIGH_FREQUENCY_LOSS type FLOAT, + DIRECT_CURRENT_OFFSET type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + CLIPPING_RATE type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + SPEECH_LEVEL type STANDARD TABLE OF T_AUDIO_METRICS_HISTOGRAM_BIN WITH NON-UNIQUE DEFAULT KEY, + 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, + SAMPLING_INTERVAL type FLOAT, + 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, + FINAL type BOOLEAN, + ALTERNATIVES type STANDARD TABLE OF T_SPCH_RECOGNITION_ALTERNATIVE WITH NON-UNIQUE DEFAULT KEY, + KEYWORDS_RESULT type MAP, + WORD_ALTERNATIVES type STANDARD TABLE OF T_WORD_ALTERNATIVE_RESULTS WITH NON-UNIQUE DEFAULT KEY, + end of T_SPEECH_RECOGNITION_RESULT. + types: + "! The complete results for a speech recognition request. + begin of T_SPEECH_RECOGNITION_RESULTS, + RESULTS type STANDARD TABLE OF T_SPEECH_RECOGNITION_RESULT WITH NON-UNIQUE DEFAULT KEY, + RESULT_INDEX type INTEGER, + SPEAKER_LABELS type STANDARD TABLE OF T_SPEAKER_LABELS_RESULT WITH NON-UNIQUE DEFAULT KEY, + PROCESSING_METRICS type T_PROCESSING_METRICS, + AUDIO_METRICS type T_AUDIO_METRICS, + 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, + NAME type STRING, + OUT_OF_VOCABULARY_WORDS type INTEGER, + STATUS type STRING, + ERROR type STRING, + end of T_GRAMMAR. + types: + "! Information about the grammars from a custom language model. + begin of T_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, + ID type STRING, + STATUS type STRING, + CREATED type STRING, + UPDATED type STRING, + URL type STRING, + USER_TOKEN type STRING, + RESULTS type STANDARD TABLE OF T_SPEECH_RECOGNITION_RESULTS WITH NON-UNIQUE DEFAULT KEY, + 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, + 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, + TYPE type STRING, + CODEC type STRING, + FREQUENCY type INTEGER, + COMPRESSION type STRING, + end of T_AUDIO_DETAILS. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + ERROR type STRING, + CODE type INTEGER, + CODE_DESCRIPTION type STRING, + 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, + DURATION type INTEGER, + NAME type STRING, + DETAILS type T_AUDIO_DETAILS, + STATUS type STRING, + end of T_AUDIO_RESOURCE. + types: + "! Information about an audio resource from a custom acoustic model. + begin of T_AUDIO_LISTING, + DURATION type INTEGER, + NAME type STRING, + DETAILS type T_AUDIO_DETAILS, + STATUS type STRING, + CONTAINER type T_AUDIO_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, + ELEMENT type STRING, + end of T_WORD_ERROR. + types: + "! Information about a word from a custom language model. + begin of T_WORD, + WORD type STRING, + SOUNDS_LIKE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + DISPLAY_AS type STRING, + COUNT type INTEGER, + SOURCE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + 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, + WORD type STRING, + SOUNDS_LIKE type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + 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, + TOTAL_MINUTES_OF_AUDIO type DOUBLE, + 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, + NAME type STRING, + TOTAL_WORDS type INTEGER, + OUT_OF_VOCABULARY_WORDS type INTEGER, + STATUS type STRING, + ERROR type STRING, + end of T_CORPUS. + types: + "! Information about the corpora from a custom language model. + begin of T_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, + CUSTOMIZATION_ID type STRING, + CREATED type STRING, + UPDATED type STRING, + LANGUAGE type STRING, + DIALECT type STRING, + VERSIONS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + OWNER type STRING, + NAME type STRING, + DESCRIPTION type STRING, + BASE_MODEL_NAME type STRING, + STATUS type STRING, + PROGRESS type INTEGER, + ERROR type STRING, + WARNINGS type STRING, + end of T_LANGUAGE_MODEL. + types: + "! Information about existing custom language models. + begin of T_LANGUAGE_MODELS, + 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, + CUSTOMIZATION_ID type STRING, + CREATED type STRING, + UPDATED type STRING, + LANGUAGE type STRING, + VERSIONS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + OWNER type STRING, + NAME type STRING, + DESCRIPTION type STRING, + BASE_MODEL_NAME type STRING, + STATUS type STRING, + PROGRESS type INTEGER, + WARNINGS type STRING, + end of T_ACOUSTIC_MODEL. + types: + "! Information about existing custom acoustic models. + begin of T_ACOUSTIC_MODELS, + CUSTOMIZATIONS type STANDARD TABLE OF T_ACOUSTIC_MODEL WITH NON-UNIQUE DEFAULT KEY, + end of T_ACOUSTIC_MODELS. + types: + "! + begin of T_INLINE_OBJECT, + CORPUS_FILE type FILE, + end of T_INLINE_OBJECT. + types: + "! Additional service features that are supported with the model. + begin of T_SUPPORTED_FEATURES, + CUSTOM_LANGUAGE_MODEL type BOOLEAN, + SPEAKER_LABELS type BOOLEAN, + end of T_SUPPORTED_FEATURES. + types: + "! Information about the new custom language model. + begin of T_CREATE_LANGUAGE_MODEL, + NAME type STRING, + BASE_MODEL_NAME type STRING, + DIALECT type STRING, + DESCRIPTION type STRING, + end of T_CREATE_LANGUAGE_MODEL. + types: + "! Information about an available language model. + begin of T_SPEECH_MODEL, + NAME type STRING, + LANGUAGE type STRING, + RATE type INTEGER, + URL type STRING, + SUPPORTED_FEATURES type T_SUPPORTED_FEATURES, + DESCRIPTION type STRING, + end of T_SPEECH_MODEL. + types: + "! Information about the available language models. + begin of T_SPEECH_MODELS, + 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, + NAME type STRING, + BASE_MODEL_NAME type STRING, + 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, + 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, + NORMALIZED_TEXT type STRING, + START_TIME type DOUBLE, + END_TIME type DOUBLE, + 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, + STATUS type STRING, + 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', + 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 + "! + 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 + "! + 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. + "! @parameter E_RESPONSE | + "! Service return value of type T_SPEECH_RECOGNITION_RESULTS + "! + 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_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 + "! + 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. + "! + 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. + "! @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. + "! @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. + "! @parameter E_RESPONSE | + "! Service return value of type T_RECOGNITION_JOB + "! + 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_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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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. + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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. + "! + 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 + "! + 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). + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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). + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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. + "! + 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( ). + + 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 = '20191002122849'. + + 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_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. + + " 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_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. + + " 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..fa133da --- /dev/null +++ b/src/zcl_ibmc_text_to_speech_v1.clas.abap @@ -0,0 +1,1522 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + WORD type STRING, + TRANSLATION type STRING, + PART_OF_SPEECH type STRING, + end of T_WORD. + types: + "! Information about an existing custom voice model. + begin of T_VOICE_MODEL, + CUSTOMIZATION_ID type STRING, + NAME type STRING, + LANGUAGE type STRING, + OWNER type STRING, + CREATED type STRING, + LAST_MODIFIED type STRING, + DESCRIPTION type STRING, + 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, + CUSTOM_PRONUNCIATION type BOOLEAN, + VOICE_TRANSFORMATION type BOOLEAN, + end of T_SUPPORTED_FEATURES. + types: + "! Information about an available voice model. + begin of T_VOICE, + URL type STRING, + GENDER type STRING, + NAME type STRING, + LANGUAGE type STRING, + DESCRIPTION type STRING, + CUSTOMIZABLE type BOOLEAN, + SUPPORTED_FEATURES type T_SUPPORTED_FEATURES, + CUSTOMIZATION type T_VOICE_MODEL, + end of T_VOICE. + types: + "! Information about the new custom voice model. + begin of T_CREATE_VOICE_MODEL, + NAME type STRING, + LANGUAGE type STRING, + DESCRIPTION type STRING, + end of T_CREATE_VOICE_MODEL. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + ERROR type STRING, + CODE type INTEGER, + 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, + 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, + NAME type STRING, + DESCRIPTION type STRING, + 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, + 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, + 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, + TEXT type STRING, + end of T_TEXT. + types: + "! The pronunciation of the specified text. + begin of T_PRONUNCIATION, + PRONUNCIATION type STRING, + end of T_PRONUNCIATION. + types: + "! Information about the translation for the specified text. + begin of T_TRANSLATION, + TRANSLATION type STRING, + 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 + "! + 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 + "! + 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 | + "! + "! @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 + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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 | + "! + "! + 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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. + "! + 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( ). + + 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 = '20191002122851'. + + 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..bf6f2eb --- /dev/null +++ b/src/zcl_ibmc_tone_analyzer_v3.clas.abap @@ -0,0 +1,603 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + SCORE type DOUBLE, + TONE_ID type STRING, + TONE_NAME type STRING, + end of T_TONE_SCORE. + types: + "! The category for a tone from the input content. + begin of T_TONE_CATEGORY, + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + CATEGORY_ID type STRING, + CATEGORY_NAME type STRING, + end of T_TONE_CATEGORY. + types: + "! Input for the general-purpose endpoint. + begin of T_TONE_INPUT, + TEXT type STRING, + end of T_TONE_INPUT. + types: + "! The score for an utterance from the input content. + begin of T_TONE_CHAT_SCORE, + SCORE type DOUBLE, + TONE_ID type STRING, + 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, + TEXT type STRING, + USER type STRING, + end of T_UTTERANCE. + types: + "! Input for the customer-engagement endpoint. + begin of T_TONE_CHAT_INPUT, + 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, + SENTENCE_ID type INTEGER, + TEXT type STRING, + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + TONE_CATEGORIES type STANDARD TABLE OF T_TONE_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + INPUT_FROM type INTEGER, + 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, + UTTERANCE_ID type INTEGER, + UTTERANCE_TEXT type STRING, + TONES type STANDARD TABLE OF T_TONE_CHAT_SCORE WITH NON-UNIQUE DEFAULT KEY, + 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, + UTTERANCES_TONE type STANDARD TABLE OF T_UTTERANCE_ANALYSIS WITH NON-UNIQUE DEFAULT KEY, + WARNING type STRING, + end of T_UTTERANCE_ANALYSES. + types: + "! The error response from a failed request. + begin of T_ERROR_MODEL, + CODE type INTEGER, + SUB_CODE type STRING, + ERROR type STRING, + HELP type STRING, + end of T_ERROR_MODEL. + types: + "! The results of the analysis for the full input content. + begin of T_DOCUMENT_ANALYSIS, + TONES type STANDARD TABLE OF T_TONE_SCORE WITH NON-UNIQUE DEFAULT KEY, + TONE_CATEGORIES type STANDARD TABLE OF T_TONE_CATEGORY WITH NON-UNIQUE DEFAULT KEY, + 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, + DOCUMENT_TONE type T_DOCUMENT_ANALYSIS, + 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 + "! + 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 + "! + 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( ). + + 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 = '20191002122853'. + + 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..f083043 --- /dev/null +++ b/src/zcl_ibmc_util.clas.abap @@ -0,0 +1,185 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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. + + class-methods CONVERT_TIMESTAMP_TO_LOCAL + importing + !IV_TIMESTAMP type TIMESTAMP + returning + value(EV_LOCAL) type STRING . + class-methods GET_MIMETYPE_FROM_EXTENSION + importing + !I_FILENAME type STRING + returning + value(E_MIMETYPE) type STRING . + 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 . + class-methods CONVERT_DATETIME_TO_TIMESTAMP + importing + !I_DATETIME type ZCL_IBMC_SERVICE=>DATETIME + returning + value(E_TIMESTAMP) type TIMESTAMP . + 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. + +* select single type +* into e_mimetype +* from sdokfext +* where extension = l_extension. +* +* if sy-subrc <> 0. +* e_mimetype = `application/` && l_extension. +* endif. + + 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..ac71b34 --- /dev/null +++ b/src/zcl_ibmc_util.clas.xml @@ -0,0 +1,48 @@ + + + + + + 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 + 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..a9ae428 --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v3.clas.abap @@ -0,0 +1,1142 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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, + CLASS type STRING, + SCORE type FLOAT, + TYPE_HIERARCHY type STRING, + end of T_CLASS_RESULT. + types: + "! Classifier and score combination. + begin of T_CLASSIFIER_RESULT, + NAME type STRING, + CLASSIFIER_ID type STRING, + 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, + CODE type INTEGER, + DESCRIPTION type STRING, + ERROR_ID type STRING, + end of T_ERROR_INFO. + types: + "! Results for one image. + begin of T_CLASSIFIED_IMAGE, + SOURCE_URL type STRING, + RESOLVED_URL type STRING, + IMAGE type STRING, + ERROR type T_ERROR_INFO, + 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, + WARNING_ID type STRING, + DESCRIPTION type STRING, + end of T_WARNING_INFO. + types: + "! Results for all images. + begin of T_CLASSIFIED_IMAGES, + CUSTOM_CLASSES type INTEGER, + IMAGES_PROCESSED type INTEGER, + IMAGES type STANDARD TABLE OF T_CLASSIFIED_IMAGE WITH NON-UNIQUE DEFAULT KEY, + 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, + CLASS type STRING, + end of T_CLASS. + types: + "! Empty object. + T_EMPTY type JSONOBJECT. + types: + "! Error information. + begin of T_ERROR_RESPONSE, + CODE type INTEGER, + ERROR type STRING, + end of T_ERROR_RESPONSE. + types: + "! + begin of T_INLINE_OBJECT1, + NAME type STRING, + POSITIVE_EXAMPLES type FILE, + NEGATIVE_EXAMPLES type FILE, + end of T_INLINE_OBJECT1. + types: + "! + begin of T_INLINE_OBJECT, + IMAGES_FILE type FILE, + URL type STRING, + THRESHOLD type FLOAT, + OWNERS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + CLASSIFIER_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + end of T_INLINE_OBJECT. + types: + "! + begin of T_INLINE_OBJECT2, + POSITIVE_EXAMPLES type FILE, + NEGATIVE_EXAMPLES type FILE, + end of T_INLINE_OBJECT2. + types: + "! Information about a classifier. + begin of T_CLASSIFIER, + CLASSIFIER_ID type STRING, + NAME type STRING, + OWNER type STRING, + STATUS type STRING, + CORE_ML_ENABLED type BOOLEAN, + EXPLANATION type STRING, + CREATED type DATETIME, + CLASSES type STANDARD TABLE OF T_CLASS WITH NON-UNIQUE DEFAULT KEY, + RETRAINED type DATETIME, + 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, + 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, + 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 + "! + 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**. + "! + "! 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 + "! + 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 + "! + 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 + "! + 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`. + "! + "! 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 + "! + 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. + "! + 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 + "! + 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. + "! + 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( ). + + 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 = '20191002122854'. + + 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..9a4be29 --- /dev/null +++ b/src/zcl_ibmc_visual_recognition_v4.clas.abap @@ -0,0 +1,1629 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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. +"! +"! **Beta:** The Visual Recognition v4 API and Object Detection model are beta +"! features. For more information about beta features, see the [Release +"! notes](https://cloud.ibm.com/docs/services/visual-recognition?topic=visual-reco +"! gnition-release-notes#beta). +"! {: important}
+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, + TOP type INTEGER, + LEFT type INTEGER, + WIDTH type INTEGER, + HEIGHT type INTEGER, + end of T_LOCATION. + types: + "! Training status for the objects in the collection. + begin of T_OBJECT_TRAINING_STATUS, + READY type BOOLEAN, + IN_PROGRESS type BOOLEAN, + DATA_CHANGED type BOOLEAN, + LATEST_FAILED type BOOLEAN, + DESCRIPTION type STRING, + end of T_OBJECT_TRAINING_STATUS. + types: + "! Training status information for the collection. + begin of T_TRAINING_STATUS, + OBJECTS type T_OBJECT_TRAINING_STATUS, + end of T_TRAINING_STATUS. + types: + "! The source type of the image. + begin of T_IMAGE_SOURCE, + TYPE type STRING, + FILENAME type STRING, + ARCHIVE_FILENAME type STRING, + SOURCE_URL type STRING, + RESOLVED_URL type STRING, + end of T_IMAGE_SOURCE. + types: + "! Details about the training data. + begin of T_TRAINING_DATA_OBJECT, + OBJECT type STRING, + LOCATION type T_LOCATION, + end of T_TRAINING_DATA_OBJECT. + types: + "! Training data for all objects. + begin of T_TRAINING_DATA_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, + COLLECTION_ID type STRING, + NAME type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + IMAGE_COUNT type INTEGER, + TRAINING_STATUS type T_TRAINING_STATUS, + end of T_COLLECTION. + types: + "! Height and width of an image. + begin of T_IMAGE_DIMENSIONS, + HEIGHT type INTEGER, + WIDTH type INTEGER, + end of T_IMAGE_DIMENSIONS. + types: + "! Details about the specific area of the problem. + begin of T_ERROR_TARGET, + TYPE type STRING, + NAME type STRING, + end of T_ERROR_TARGET. + types: + "! Details about an error. + begin of T_ERROR, + CODE type STRING, + MESSAGE type STRING, + MORE_INFO type STRING, + TARGET type T_ERROR_TARGET, + end of T_ERROR. + types: + "! A container for the list of request-level problems. + begin of T_ERROR_RESPONSE, + ERRORS type STANDARD TABLE OF T_ERROR WITH NON-UNIQUE DEFAULT KEY, + TRACE type STRING, + end of T_ERROR_RESPONSE. + types: + "! Details about an object and its location. + begin of T_BASE_OBJECT, + OBJECT type STRING, + LOCATION type T_LOCATION, + end of T_BASE_OBJECT. + types: + "! + begin of T_INLINE_OBJECT, + COLLECTION_IDS type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + FEATURES type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + IMAGES_FILE type STANDARD TABLE OF FILE WITH NON-UNIQUE DEFAULT KEY, + IMAGE_URL type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + THRESHOLD type FLOAT, + end of T_INLINE_OBJECT. + types: + "! Details about an object in the collection. + begin of T_OBJECT_DETAIL, + OBJECT type STRING, + LOCATION type T_LOCATION, + 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, + COLLECTION_ID type STRING, + 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, + 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, + COLLECTIONS type STANDARD TABLE OF T_COLLECTION WITH NON-UNIQUE DEFAULT KEY, + end of T_COLLECTIONS_LIST. + types: + "! Details about an image. + begin of T_IMAGE_DETAILS, + IMAGE_ID type STRING, + UPDATED type DATETIME, + CREATED type DATETIME, + SOURCE type T_IMAGE_SOURCE, + DIMENSIONS type T_IMAGE_DIMENSIONS, + ERRORS type T_ERROR, + TRAINING_DATA type T_TRAINING_DATA_OBJECTS, + end of T_IMAGE_DETAILS. + types: + "! Details about a problem. + begin of T_WARNING, + CODE type STRING, + MESSAGE type STRING, + MORE_INFO type STRING, + end of T_WARNING. + types: + "! List of information about the images. + begin of T_IMAGE_DETAILS_LIST, + IMAGES type STANDARD TABLE OF T_IMAGE_DETAILS WITH NON-UNIQUE DEFAULT KEY, + WARNINGS type STANDARD TABLE OF T_WARNING WITH NON-UNIQUE DEFAULT KEY, + 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, + IMAGE_ID type STRING, + UPDATED type DATETIME, + end of T_IMAGE_SUMMARY. + types: + "! Container for the training data. + begin of T_BASE_TRAINING_DATA_OBJECTS, + OBJECTS type STANDARD TABLE OF T_TRAINING_DATA_OBJECT WITH NON-UNIQUE DEFAULT KEY, + end of T_BASE_TRAINING_DATA_OBJECTS. + types: + "! + begin of T_INLINE_OBJECT1, + IMAGES_FILE type STANDARD TABLE OF FILE WITH NON-UNIQUE DEFAULT KEY, + IMAGE_URL type STANDARD TABLE OF STRING WITH NON-UNIQUE DEFAULT KEY, + TRAINING_DATA type STRING, + end of T_INLINE_OBJECT1. + types: + "! List of images. + begin of T_IMAGE_SUMMARY_LIST, + 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, + SOURCE type T_IMAGE_SOURCE, + DIMENSIONS type T_IMAGE_DIMENSIONS, + OBJECTS type T_DETECTED_OBJECTS, + ERRORS type T_ERROR, + end of T_IMAGE. + types: + "! Results for all images. + begin of T_ANALYZE_RESPONSE, + IMAGES type STANDARD TABLE OF T_IMAGE WITH NON-UNIQUE DEFAULT KEY, + WARNINGS type STANDARD TABLE OF T_WARNING WITH NON-UNIQUE DEFAULT KEY, + TRACE type STRING, + end of T_ANALYZE_RESPONSE. + types: + "! Base details about a collection. + begin of T_BASE_COLLECTION, + COLLECTION_ID type STRING, + NAME type STRING, + DESCRIPTION type STRING, + CREATED type DATETIME, + UPDATED type DATETIME, + IMAGE_COUNT type INTEGER, + TRAINING_STATUS type T_TRAINING_STATUS, + end of T_BASE_COLLECTION. + +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_IMAGE_SOURCE type string value '|TYPE|', + T_TRAINING_DATA_OBJECT type string value '|', + T_TRAINING_DATA_OBJECTS type string value '|OBJECTS|', + T_COLLECTION type string value '|COLLECTION_ID|NAME|DESCRIPTION|CREATED|UPDATED|IMAGE_COUNT|TRAINING_STATUS|', + T_IMAGE_DIMENSIONS type string value '|HEIGHT|WIDTH|', + 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_IMAGE_DETAILS type string value '|IMAGE_ID|UPDATED|CREATED|SOURCE|DIMENSIONS|TRAINING_DATA|', + 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 '|', + __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', + OBJECTS type string value 'objects', + 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', + OBJECT type string value 'object', + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 + "! + 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 + "! + 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 + "! + 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. + "! + 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 | + "! Specify the image size. + "! @parameter E_RESPONSE | + "! Service return value of type FILE + "! + 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 . + + "! Train a collection. + "! + "! @parameter I_collection_id | + "! The identifier of the collection. + "! @parameter E_RESPONSE | + "! Service return value of type T_COLLECTION + "! + 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 + "! + 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 . + + "! Delete labeled data. + "! + "! @parameter I_customer_id | + "! The customer ID for which all data is to be deleted. + "! + 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( ). + + 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 = '20191002122856'. + + 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->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->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..a24a33b --- /dev/null +++ b/src/zibmc_config.tabl.xml @@ -0,0 +1,72 @@ + + + + + + ZIBMC_CONFIG + E + TRANSP + IBM Cloud Service Integration - Configuration + X + C + 1 + + + ZIBMC_CONFIG + A + 2 + APPL2 + X + X + + + + ZIBMC_CONFIG + SERVICE + E + 0001 + X + 0 + C + 000060 + X + CHAR + 000030 + CHAR + + + ZIBMC_CONFIG + INSTANCE_UID + 0002 + X + ZIBMC_TY_INSTANCE_UID + 0 + X + E + + + ZIBMC_CONFIG + PARAM + E + 0003 + X + 0 + C + 000064 + X + CHAR + 000032 + CHAR + + + ZIBMC_CONFIG + VALUE + 0004 + 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..c00fd4e --- /dev/null +++ b/src/zibmc_token.tabl.xml @@ -0,0 +1,125 @@ + + + + + + ZIBMC_TOKEN + E + TRANSP + IAM tokens + X + L + 4 + + + ZIBMC_TOKEN + A + 4 + APPL2 + N + + + + ZIBMC_TOKEN + SERVICE + E + 0001 + X + 0 + C + 000060 + X + CHAR + 000030 + CHAR + + + ZIBMC_TOKEN + INSTANCE_UID + 0002 + X + ZIBMC_TY_INSTANCE_UID + 0 + X + E + + + ZIBMC_TOKEN + ACCESS_TOKEN + E + 0003 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + REFRESH_TOKEN + E + 0004 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + TOKEN_TYPE + E + 0005 + 0 + g + 000008 + STRG + STRG + + + ZIBMC_TOKEN + EXPIRES_IN + E + 0006 + 0 + X + 000004 + INT4 + 000010 + INT4 + + + ZIBMC_TOKEN + EXPIRES_TS + 0007 + TIMESTAMP + 0 + E + + + ZIBMC_TOKEN + EXPIRATION + E + 0008 + 0 + X + 000004 + INT4 + 000010 + INT4 + + + ZIBMC_TOKEN + SCOPE + E + 0009 + 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..b80cd38 --- /dev/null +++ b/src/zif_ibmc_service_arch.intf.abap @@ -0,0 +1,141 @@ +* Copyright 2019 IBM Corp. All Rights Reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT 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 . + + 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 + + + +