Esempi di API Gateway che utilizzano SDK per SAP ABAP - AWS SDK per SAP ABAP

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Esempi di API Gateway che utilizzano SDK per SAP ABAP

I seguenti esempi di codice mostrano come eseguire azioni e implementare scenari comuni utilizzando l' AWS SDK per SAP ABAP con API Gateway.

Le azioni sono estratti di codice da programmi più grandi e devono essere eseguite nel contesto. Sebbene le azioni mostrino come richiamare le singole funzioni del servizio, è possibile visualizzarle contestualizzate negli scenari correlati.

Ogni esempio include un link al codice sorgente completo, in cui vengono fornite le istruzioni su come configurare ed eseguire il codice nel contesto.

Argomenti

Azioni

Il seguente esempio di codice mostra come utilizzare. CreateDeployment

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->createdeployment( iv_restapiid = iv_rest_api_id iv_stagename = iv_stage_name iv_description = 'Deployment created by ABAP SDK' ). DATA(lv_deployment_id) = oo_result->get_id( ). MESSAGE 'Deployment created with ID: ' && lv_deployment_id TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, CreateDeploymentconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. CreateResource

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->createresource( iv_restapiid = iv_rest_api_id iv_parentid = iv_parent_id iv_pathpart = iv_resource_path ). DATA(lv_resource_id) = oo_result->get_id( ). MESSAGE 'Resource created with ID: ' && lv_resource_id TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, CreateResourceconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. CreateRestApi

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->createrestapi( iv_name = iv_api_name iv_description = 'Sample REST API created by ABAP SDK' ). DATA(lv_api_id) = oo_result->get_id( ). MESSAGE 'REST API created with ID: ' && lv_api_id TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. CATCH /aws1/cx_agwunauthorizedex INTO DATA(lo_unauthorized). MESSAGE lo_unauthorized->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_unauthorized. ENDTRY.
  • Per i dettagli sulle API, CreateRestApiconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. DeleteRestApi

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. lo_agw->deleterestapi( iv_restapiid = iv_rest_api_id ). MESSAGE 'REST API deleted successfully' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, DeleteRestApiconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. GetResources

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->getresources( iv_restapiid = iv_rest_api_id ). DATA(lt_resources) = oo_result->get_items( ). DATA(lv_count) = lines( lt_resources ). MESSAGE 'Found ' && lv_count && ' resources' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, GetResourcesconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. GetRestApis

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->getrestapis( ). DATA(lt_apis) = oo_result->get_items( ). DATA(lv_count) = lines( lt_apis ). MESSAGE 'Found ' && lv_count && ' REST APIs' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, GetRestApisconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. PutIntegration

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->putintegration( iv_restapiid = iv_rest_api_id iv_resourceid = iv_resource_id iv_httpmethod = iv_http_method iv_type = 'AWS_PROXY' iv_integrationhttpmethod = 'POST' iv_uri = iv_integration_uri ). MESSAGE 'Integration configured for method' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, PutIntegrationconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. PutIntegrationResponse

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->putintegrationresponse( iv_restapiid = iv_rest_api_id iv_resourceid = iv_resource_id iv_httpmethod = iv_http_method iv_statuscode = '200' ). MESSAGE 'Integration response configured for status 200' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.

Il seguente esempio di codice mostra come utilizzare. PutMethod

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->putmethod( iv_restapiid = iv_rest_api_id iv_resourceid = iv_resource_id iv_httpmethod = iv_http_method iv_authorizationtype = 'NONE' ). MESSAGE 'Method ' && iv_http_method && ' added to resource' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, PutMethodconsulta AWS SDK for SAP ABAP API reference.

Il seguente esempio di codice mostra come utilizzare. PutMethodResponse

SDK per SAP ABAP
Nota

C'è altro da fare. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

TRY. oo_result = lo_agw->putmethodresponse( iv_restapiid = iv_rest_api_id iv_resourceid = iv_resource_id iv_httpmethod = iv_http_method iv_statuscode = '200' ). MESSAGE 'Method response configured for status 200' TYPE 'I'. CATCH /aws1/cx_agwbadrequestex INTO DATA(lo_bad_request). MESSAGE lo_bad_request->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_bad_request. CATCH /aws1/cx_agwnotfoundexception INTO DATA(lo_not_found). MESSAGE lo_not_found->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_not_found. CATCH /aws1/cx_agwtoomanyrequestsex INTO DATA(lo_too_many). MESSAGE lo_too_many->get_text( ) TYPE 'I'. RAISE EXCEPTION lo_too_many. ENDTRY.
  • Per i dettagli sulle API, PutMethodResponseconsulta AWS SDK for SAP ABAP API reference.