Robotframework request package upgrade changes

Current working package version
   robotframework-requests            0.7.2

To Test:
      pip3 install robotframework-requests -U
                 or
      # Once this commit is merged.
      pip3 install -r requirements.txt

      Version latest:
      robotframework-requests         0.9.3

Refer Documentation:
   https://marketsquare.github.io/robotframework-requests/doc/RequestsLibrary.html

What is not changed:
     - The test cases under directory tests/ is not modified and is
       deprecated but you can continue using it with older package
       and configuration using

       git clone -b v3.0-stable https://github.com/openbmc/openbmc-test-automation

Tested:
      Upstream HW_CI test list, firmware code update and few other
      test suite like ipmi, certificate, dumps, ffdc and redfish
      test suites.

Note: I have not tested end to end, so it is likely there could be
      grey areas where it could fail but should be minor w.r.t
      response data format.

Resolves:  openbmc/openbmc-test-automation#2105

Change-Id: Ie03b25ff88948bcccb09e9d82f8da86e28c92697
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/rest_client.robot b/lib/rest_client.robot
index d8e9590..649352b 100644
--- a/lib/rest_client.robot
+++ b/lib/rest_client.robot
@@ -1,7 +1,7 @@
 *** Settings ***
 Library           Collections
 Library           String
-Library           RequestsLibrary.RequestsKeywords
+Library           RequestsLibrary
 Library           OperatingSystem
 Resource          resource.robot
 Library           disable_warning_urllib.py
@@ -47,10 +47,10 @@
     Set To Dictionary  ${kwargs}  headers  ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Get
     ...  base_uri=${base_uri}  args=&{kwargs}
-    ${ret}=  Get Request  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
-    Run Keyword If  '${quiet}' == '${0}'  Log Response  ${ret}
+    ${resp}=  GET On Session  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}  expected_status=any
+    Run Keyword If  '${quiet}' == '${0}'  Log Response  ${resp}
     Delete All Sessions
-    [Return]    ${ret}
+    [Return]    ${resp}
 
 OpenBMC Post Request
     [Documentation]  Do REST POST request and return the result.
@@ -71,10 +71,10 @@
     ${base_uri}=    Catenate    SEPARATOR=    ${DBUS_PREFIX}    ${uri}
     ${headers}=  Create Dictionary   Content-Type=application/json
     ...  X-Auth-Token=${XAUTH_TOKEN}
-    set to dictionary   ${kwargs}       headers     ${headers}
+    Set To Dictionary  ${kwargs}  headers  ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Post
     ...  base_uri=${base_uri}  args=&{kwargs}
-    ${ret}=  Post Request  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
+    ${ret}=  POST On Session  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
     Run Keyword If  '${quiet}' == '${0}'  Log Response  ${ret}
     Delete All Sessions
     [Return]    ${ret}
@@ -93,15 +93,14 @@
     #          ${kwargs}=  Create Dictionary  allow_redirect=${True}.
 
     Initialize OpenBMC    ${timeout}
-    ${base_uri}=    Catenate    SEPARATOR=    ${DBUS_PREFIX}    ${uri}
-    ${headers}=     Create Dictionary   Content-Type=application/json
+    ${base_uri}=   Catenate    SEPARATOR=    ${DBUS_PREFIX}    ${uri}
+    ${headers}=  Create Dictionary   Content-Type=application/json
     ...  X-Auth-Token=${XAUTH_TOKEN}
-    set to dictionary   ${kwargs}       headers     ${headers}
-    Log Request    method=Put    base_uri=${base_uri}    args=&{kwargs}
-    ${ret}=  Put Request  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
-    Log Response    ${ret}
+    Log Request  method=Put  base_uri=${base_uri}  args=&{kwargs}
+    ${resp}=  PUT On Session  openbmc  ${base_uri}  json=${kwargs["data"]}  headers=${headers}
+    Log Response    ${resp}
     Delete All Sessions
-    [Return]    ${ret}
+    [Return]    ${resp}
 
 OpenBMC Delete Request
     [Documentation]  Do REST request to delete the resource identified by the
@@ -124,7 +123,7 @@
     Set To Dictionary   ${kwargs}  headers   ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Delete
     ...  base_uri=${base_uri}  args=&{kwargs}
-    ${ret}=  Delete Request  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
+    ${ret}=  DELETE On Session  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
     Run Keyword If  '${quiet}' == '${0}'  Log Response    ${ret}
     Delete All Sessions
     [Return]    ${ret}
@@ -167,7 +166,7 @@
     ${headers}=  Create Dictionary  Content-Type=application/json
     @{credentials}=  Create List  ${rest_username}  ${rest_password}
     ${data}=  Create Dictionary  data=@{credentials}
-    ${resp}=  Post Request  openbmc  /login  data=${data}  headers=${headers}
+    ${resp}=  POST On Session  openbmc  /login  json=${data}  headers=${headers}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
 
     ${processed_token_data}=
@@ -197,7 +196,7 @@
     ${headers}=  Create Dictionary  Content-Type=application/json
     @{credentials}=  Create List  ${rest_username}  ${rest_password}
     ${data}=  create dictionary   data=@{credentials}
-    ${status}  ${resp}=  Run Keyword And Ignore Error  Post Request  openbmc
+    ${status}  ${resp}=  Run Keyword And Ignore Error  POST On Session  openbmc
     ...  /login  data=${data}  headers=${headers}
 
     Should Be Equal  ${status}  PASS  msg=${resp}
@@ -213,12 +212,13 @@
 
     # If there is no active sesion it will throw the following exception
     # "Non-existing index or alias 'openbmc'"
-    ${resp}=  Post Request  openbmc
+    ${resp}=  POST On Session  openbmc
     ...  /logout  data=${data}  headers=${headers}
 
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
     ...  msg=${resp}
 
+
 Log Request
     [Documentation]  Log the specific REST URI, method name on the console.
     [Arguments]    &{kwargs}
@@ -226,17 +226,21 @@
     ...  , method:  ${kwargs["method"]}  , args:  ${kwargs["args"]}
     Logging    ${msg}    console=True
 
+
 Log Response
     [Documentation]  Log the response code on the console.
     [Arguments]    ${resp}
+
     ${msg}=  Catenate  SEPARATOR=  Response code:  ${resp.status_code}
     ...  , Content:  ${resp.content}
     Logging    ${msg}    console=True
 
+
 Logging
     [Documentation]  Log the specified message on the console.
     [Arguments]    ${msg}    ${console}=default False
-    Log    ${msg}    console=True
+    Log  ${msg}  console=True
+
 
 Read Attribute
     [Documentation]  Retrieve attribute value from URI and return result.
@@ -260,10 +264,9 @@
     ${resp}=  OpenBMC Get Request  ${uri}attr/${attr}  timeout=${timeout}
     ...  quiet=${quiet}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-    ${content}=     To Json    ${resp.content}
     Run Keyword If  '${expected_value}' != '${EMPTY}'
-    ...  Should Be Equal As Strings  ${expected_value}  ${content["data"]}
-    [Return]    ${content["data"]}
+    ...  Should Be Equal As Strings  ${expected_value}  ${resp.json()["data"]}
+    [Return]    ${resp.json()["data"]}
 
 
 Write Attribute
@@ -319,9 +322,8 @@
 
     ${resp}=  OpenBMC Get Request  ${uri}  timeout=${timeout}  quiet=${quiet}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_OK}
-    ${content}=  To Json Ordered  ${resp.content}
 
-    [Return]  ${content["data"]}
+    [Return]  ${resp.json()["data"]}
 
 Call Method
     [Documentation]  Invoke the specific REST service method.
@@ -365,7 +367,7 @@
     Set To Dictionary  ${kwargs}  headers  ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Post
     ...  base_uri=${base_uri}  args=&{kwargs}
-    ${ret}=  Post Request  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
+    ${ret}=  POST On Session  openbmc  ${base_uri}  &{kwargs}  timeout=${timeout}
     Run Keyword If  '${quiet}' == '${0}'  Log Response  ${ret}
     Valid Value  ret.status_code  ${valid_status_codes}
     Delete All Sessions
@@ -393,15 +395,13 @@
     ...    {"UserName":"${rest_username}", "Password":"${rest_password}"}
     ...    {"UserName":"${rest_username}", "Password":"${rest_password}", ${kwargs}}
 
-    ${resp}=  Post Request  redfish  /redfish/v1/SessionService/Sessions
+    ${resp}=  POST On Session  redfish  /redfish/v1/SessionService/Sessions
     ...  data=${data}  headers=${headers}
     Should Be Equal As Strings  ${resp.status_code}  ${HTTP_CREATED}
 
-    ${content}=  To JSON  ${resp.content}
-
     Set Global Variable  ${XAUTH_TOKEN}  ${resp.headers["X-Auth-Token"]}
 
-    [Return]  ${content}
+    [Return]  ${resp.json()}
 
 
 Redfish Get Request
@@ -422,7 +422,7 @@
     ${headers}=  Create Dictionary  Content-Type=application/json  X-Auth-Token=${XAUTH_TOKEN}
     Set To Dictionary   ${kwargs}  headers  ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Post  base_uri=${base_uri}  args=&{kwargs}
-    ${resp}=  Get Request  redfish  ${base_uri}  &{kwargs}  timeout=${timeout}
+    ${resp}=  GET On Session  redfish  ${base_uri}  &{kwargs}  timeout=${timeout}
     Run Keyword If  '${quiet}' == '${0}'  Log Response  ${resp}
 
     [Return]  ${resp}
@@ -446,7 +446,7 @@
     ${headers}=  Create Dictionary  Content-Type=application/json  X-Auth-Token=${XAUTH_TOKEN}
     Set To Dictionary   ${kwargs}  headers  ${headers}
     Run Keyword If  '${quiet}' == '${0}'  Log Request  method=Post  base_uri=${base_uri}  args=&{kwargs}
-    ${resp}=  Post Request  redfish  ${base_uri}  &{kwargs}  timeout=${timeout}
+    ${resp}=  POST On Session  redfish  ${base_uri}  &{kwargs}  timeout=${timeout}  expected_status=any
     Run Keyword If  '${quiet}' == '${0}'  Log Response  ${resp}
 
     [Return]  ${resp}