Exemplos de API Gateway usando SDK para SAP ABAP - AWS SDK para SAP ABAP

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Exemplos de API Gateway usando SDK para SAP ABAP

Os exemplos de código a seguir mostram como realizar ações e implementar cenários comuns usando o AWS SDK para SAP ABAP com API Gateway.

Ações são trechos de código de programas maiores e devem ser executadas em contexto. Embora as ações mostrem como chamar perfis de serviço individuais, você pode ver as ações no contexto em seus cenários relacionados.

Cada exemplo inclui um link para o código-fonte completo, em que você pode encontrar instruções sobre como configurar e executar o código.

Tópicos

Ações

O código de exemplo a seguir mostra como usar CreateDeployment.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a CreateDeploymentreferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar CreateResource.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a CreateResourcereferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar CreateRestApi.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a CreateRestApireferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar DeleteRestApi.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a DeleteRestApireferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar GetResources.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a GetResourcesreferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar GetRestApis.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a GetRestApisreferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar PutIntegration.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a PutIntegrationreferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar PutIntegrationResponse.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.

O código de exemplo a seguir mostra como usar PutMethod.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a PutMethodreferência da API AWS SDK for SAP ABAP.

O código de exemplo a seguir mostra como usar PutMethodResponse.

SDK para SAP ABAP
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no AWS Code Examples Repository.

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.
  • Para obter detalhes da API, consulte a PutMethodResponsereferência da API AWS SDK for SAP ABAP.