Skip to content

/AWS1/IF_VPS=>GETPOLICY()

About GetPolicy

Retrieves information about the specified policy.

Method Signature

METHODS /AWS1/IF_VPS~GETPOLICY
  IMPORTING
    !IV_POLICYSTOREID TYPE /AWS1/VPSPOLICYSTOREID OPTIONAL
    !IV_POLICYID TYPE /AWS1/VPSPOLICYID OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_vpsgetpolicyoutput
  RAISING
    /AWS1/CX_VPSACCESSDENIEDEX
    /AWS1/CX_VPSINTERNALSERVEREX
    /AWS1/CX_VPSTHROTTLINGEX
    /AWS1/CX_VPSVALIDATIONEX
    /AWS1/CX_VPSRESOURCENOTFOUNDEX
    /AWS1/CX_VPSCLIENTEXC
    /AWS1/CX_VPSSERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_policystoreid TYPE /AWS1/VPSPOLICYSTOREID /AWS1/VPSPOLICYSTOREID

Specifies the ID of the policy store that contains the policy that you want information about.

To specify a policy store, use its ID or alias name. When using an alias name, prefix it with policy-store-alias/. For example:

  • ID: PSEXAMPLEabcdefg111111

  • Alias name: policy-store-alias/example-policy-store

To view aliases, use ListPolicyStoreAliases.

iv_policyid TYPE /AWS1/VPSPOLICYID /AWS1/VPSPOLICYID

Specifies the ID of the policy you want information about.

You can use the policy name in place of the policy ID. When using a name, prefix it with name/. For example:

  • ID: SPEXAMPLEabcdefg111111

  • Name: name/example-policy

RETURNING

oo_output TYPE REF TO /aws1/cl_vpsgetpolicyoutput /AWS1/CL_VPSGETPOLICYOUTPUT

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->getpolicy(
  iv_policyid = |string|
  iv_policystoreid = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_policystoreid = lo_result->get_policystoreid( ).
  lv_policyid = lo_result->get_policyid( ).
  lv_policytype = lo_result->get_policytype( ).
  lo_entityidentifier = lo_result->get_principal( ).
  IF lo_entityidentifier IS NOT INITIAL.
    lv_entitytype = lo_entityidentifier->get_entitytype( ).
    lv_entityid = lo_entityidentifier->get_entityid( ).
  ENDIF.
  lo_entityidentifier = lo_result->get_resource( ).
  IF lo_entityidentifier IS NOT INITIAL.
    lv_entitytype = lo_entityidentifier->get_entitytype( ).
    lv_entityid = lo_entityidentifier->get_entityid( ).
  ENDIF.
  LOOP AT lo_result->get_actions( ) into lo_row.
    lo_row_1 = lo_row.
    IF lo_row_1 IS NOT INITIAL.
      lv_actiontype = lo_row_1->get_actiontype( ).
      lv_actionid = lo_row_1->get_actionid( ).
    ENDIF.
  ENDLOOP.
  lo_policydefinitiondetail = lo_result->get_definition( ).
  IF lo_policydefinitiondetail IS NOT INITIAL.
    lo_staticpolicydefinitiond = lo_policydefinitiondetail->get_static( ).
    IF lo_staticpolicydefinitiond IS NOT INITIAL.
      lv_staticpolicydescription = lo_staticpolicydefinitiond->get_description( ).
      lv_policystatement = lo_staticpolicydefinitiond->get_statement( ).
    ENDIF.
    lo_templatelinkedpolicydef = lo_policydefinitiondetail->get_templatelinked( ).
    IF lo_templatelinkedpolicydef IS NOT INITIAL.
      lv_policytemplateid = lo_templatelinkedpolicydef->get_policytemplateid( ).
      lo_entityidentifier = lo_templatelinkedpolicydef->get_principal( ).
      IF lo_entityidentifier IS NOT INITIAL.
        lv_entitytype = lo_entityidentifier->get_entitytype( ).
        lv_entityid = lo_entityidentifier->get_entityid( ).
      ENDIF.
      lo_entityidentifier = lo_templatelinkedpolicydef->get_resource( ).
      IF lo_entityidentifier IS NOT INITIAL.
        lv_entitytype = lo_entityidentifier->get_entitytype( ).
        lv_entityid = lo_entityidentifier->get_entityid( ).
      ENDIF.
    ENDIF.
  ENDIF.
  lv_timestampformat = lo_result->get_createddate( ).
  lv_timestampformat = lo_result->get_lastupdateddate( ).
  lv_policyeffect = lo_result->get_effect( ).
  lv_policyname = lo_result->get_name( ).
ENDIF.

To retrieve details about a policy

The following example retrieves information about the specified policy contained in the specified policy store. In this example, the requested policy is a template-linked policy, so it returns the ID of the policy template, and the specific principal and resource used by this policy.

DATA(lo_result) = lo_client->getpolicy(
  iv_policyid = |9wYixMplbbZQb5fcZHyJhY|
  iv_policystoreid = |C7v5xMplfFH3i3e4Jrzb1a|
).

To retrieve a policy by name

The following example retrieves information about a policy using its name instead of its ID.

DATA(lo_result) = lo_client->getpolicy(
  iv_policyid = |name/example-policy|
  iv_policystoreid = |C7v5xMplfFH3i3e4Jrzb1a|
).