Skip to content

Commit

Permalink
Release 1.2.0 (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
jridfe authored Dec 3, 2024
1 parent 411fa6e commit 075020c
Show file tree
Hide file tree
Showing 11 changed files with 3,842 additions and 1,093 deletions.
28 changes: 0 additions & 28 deletions MIGRATION-V1.1.0.md

This file was deleted.

38 changes: 38 additions & 0 deletions MIGRATION-V1.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Upgrading to ABAP SDK version 1.2.0

Note: If migrating from a version less than v1.1.0, also see the
[v1.1.0 migration guide wiki](https://github.com/IBM/abap-sdk-btp-x/blob/main/MIGRATION-V1.1.0.md).

<details>
<summary>Table of Contents</summary>

- [Breaking changes by service](#breaking-changes-by-service)
- [New features by service](#new-features-by-service)
- [watsonx.ai](#watsonxai)
- [Other changes](#other-changes)
- [Renaming of service _Watson Machine Learning_](#renaming-of-service-watson-machine-learning)
</details>

## Breaking changes by service

- None.

## New features by service

### watsonx.ai

- Support for new category *Text chat*
- New methods `Text_Chat`, `Text_Chat_Stream`

- Support for new category *Text extraction*
- New methods `Text_Extraction`, `List_Text_Extractions`, `Text_Extraction_Get`, `Text_Extraction_Delete`

- Support for new category *Text rerank*
- New method `Text_Rerank`

## Other changes

### Renaming of service _Watson Machine Learning_

- Service _Watson Machine Learning_ has been renamed to _watsonx.ai Runtime_.
The ABAP class name remains `ZCL_IBMX_WML_V4`.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

[![License](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

ABAP<sup>®</sup> client library to use the [Watson Machine Learning][wml] and the
[watsonx.ai][wxai] APIs.
ABAP<sup>®</sup> client library to use the [watsonx.ai Runtime][wml] (formerly
Watson Machine Learning) and the [watsonx.ai][wxai] APIs.

This is a community SDK written by ABAPers for the ABAPers in the Open
Source community, to provide easy usage of IBM<sup>®</sup>
Expand All @@ -45,7 +45,7 @@ information in [Support and Feedback](#support-and-feedback).
<summary>Table of Contents</summary>

- [Announcements](#announcements)
- [Version 1.1.0 released](#version-110-released)
- [Version 1.2.0 released](#version-120-released)
- [Before you begin](#before-you-begin)
- [Installation](#installation)
- [SSL Certificates](#ssl-certificates)
Expand All @@ -62,10 +62,10 @@ information in [Support and Feedback](#support-and-feedback).

## Announcements

### Version 1.1.0 released
### Version 1.2.0 released

Version v1.1.0 of the SDK has been released - see what's changed in
the [migration guide](MIGRATION-V1.1.0.md).
Version v1.2.0 of the SDK has been released - see what's changed in
the [migration guide](MIGRATION-V1.2.0.md).

## Before you begin

Expand Down Expand Up @@ -167,7 +167,7 @@ watsonx services are currently supported:

| Service | ABAP Class Name |
|:------------------------------ |:----------------------------------- |
| Watson Machine Learning | ZCL_IBMX_WML_V4 |
| watsonx.ai Runtime | ZCL_IBMX_WML_V4 |
| watsonx.ai | ZCL_IBMX_WATSONX_AI_ML_V1 |

Using the client library requires two steps:
Expand Down Expand Up @@ -206,7 +206,7 @@ Using the client library requires two steps:
### Examples

<details>
<summary>Watson Machine Learning Example</summary>
<summary>watsonx.ai Runtime Example</summary>

```abap
* Z_WML_DEMO
Expand Down Expand Up @@ -248,7 +248,7 @@ Using the client library requires two steps:
"[PRG] message lo_zip_exception type 'E'.
endtry.
" instantiate Watson Machine Learning wrapper class (explicit type declaration is required)
" instantiate watsonx.ai Runtime wrapper class (explicit type declaration is required)
data: lo_wml type ref to zcl_ibmx_wml_v4.
zcl_ibmx_service_ext=>get_instance(
exporting
Expand Down
40 changes: 20 additions & 20 deletions src/zcl_ibmx_service.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,9 @@ CLASS ZCL_IBMX_SERVICE IMPLEMENTATION.
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
if ( c_request_prop-auth_basic eq c_boolean_true or
c_request_prop-auth_oauth eq c_boolean_true or
c_request_prop-auth_apikey eq c_boolean_true ) 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 ).
Expand Down Expand Up @@ -2036,23 +2036,8 @@ endmethod.

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.
" Basic authentication
if 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.
Expand Down Expand Up @@ -2098,6 +2083,21 @@ endmethod.
set_request_body_cdata( i_client = i_client i_data = lv_body ).
set_request_header( i_client = i_client i_name = ZIF_IBMX_service_arch~c_header_content_type i_value = ZIF_IBMX_service_arch~c_mediatype-appl_json ).
endif.

" Other authentication including OAuth authorization and ZenApiKey
else.
if i_request_prop-auth_header eq c_boolean_true.
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.
set_request_header( i_client = i_client i_name = i_request_prop-auth_headername i_value = lv_full_token ).
endif.
endif.

e_uri = get_full_url( ls_url ).
Expand Down
28 changes: 27 additions & 1 deletion src/zcl_ibmx_service_arch.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ CLASS ZCL_IBMX_SERVICE_ARCH DEFINITION
VALUE(e_binary) TYPE xstring
RAISING
ZCX_IBMX_SERVICE_EXCEPTION .
"! <p class="shorttext synchronized" lang="en">Encodes a string to base64 format.</p>
"!
"! @parameter I_UNENCODED | String, unencoded
"! @parameter E_ENCODED | Base64-encoded string
"!
class-methods base64_encode
importing
!i_unencoded type string
returning
value(e_encoded) type string .
"! <p class="shorttext synchronized" lang="en">Returns a HTTP/REST client based on an URL.</p>
"!
"! @parameter I_URL | URL
Expand Down Expand Up @@ -287,6 +297,22 @@ CLASS ZCL_IBMX_SERVICE_ARCH IMPLEMENTATION.
ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_IBMX_SERVICE_ARCH=>BASE64_ENCODE
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_UNENCODED TYPE STRING
* | [<-()] E_ENCODED TYPE STRING
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD base64_encode.

e_encoded = cl_web_http_utility=>encode_base64(
exporting
unencoded = i_unencoded
).

ENDMETHOD.


METHOD convert_string_to_utf8.

CALL METHOD cl_web_http_utility=>encode_utf8
Expand Down Expand Up @@ -527,7 +553,7 @@ CLASS ZCL_IBMX_SERVICE_ARCH IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_IBMC_SERVICE_ARCH=>FIND_REGEX
* | Static Public Method ZCL_IBMX_SERVICE_ARCH=>FIND_REGEX
* +-------------------------------------------------------------------------------------------------+
* | [--->] I_REGEX TYPE STRING
* | [--->] I_WITH TYPE STRING(optional)
Expand Down
22 changes: 19 additions & 3 deletions src/zcl_ibmx_service_ext.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ CLASS ZCL_IBMX_SERVICE_EXT IMPLEMENTATION.
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-auth_header = c_tribool_false.
ls_token_request_prop-header_accept = ZCL_IBMX_service=>ZIF_IBMX_service_arch~c_mediatype-appl_json.


Expand Down Expand Up @@ -936,10 +937,25 @@ CLASS ZCL_IBMX_SERVICE_EXT IMPLEMENTATION.
endif.

if not i_access_token-access_token is initial.
lo_instance->p_token_generation = c_token_generation_never.
lo_instance->p_request_prop_default-auth_header = c_boolean_true.
lo_instance->p_token_generation = c_token_generation_never.
lo_instance->set_access_token( i_access_token = i_access_token ).
else.
lo_instance->p_token_generation = i_token_generation.
if ls_request_prop-auth_name eq 'ZenApiKey'.
if not lo_instance->p_request_prop_default-username is initial and not lo_instance->p_request_prop_default-apikey is initial.
data(ls_access_token) = value ts_access_token(
access_token = base64_encode(
exporting
i_unencoded = lo_instance->p_request_prop_default-username && `:` && lo_instance->p_request_prop_default-apikey
)
token_type = ls_request_prop-auth_type
).
lo_instance->p_request_prop_default-auth_header = c_boolean_true.
lo_instance->set_access_token( i_access_token = ls_access_token ).
endif.
else.
lo_instance->p_token_generation = i_token_generation.
endif.
endif.

lo_instance->p_version = i_version.
Expand Down Expand Up @@ -992,7 +1008,7 @@ CLASS ZCL_IBMX_SERVICE_EXT IMPLEMENTATION.
* +--------------------------------------------------------------------------------------</SIGNATURE>
method get_sdk_version_date.

e_sdk_version_date = '20240625'.
e_sdk_version_date = '20241203'.

endmethod.

Expand Down
Loading

0 comments on commit 075020c

Please sign in to comment.