/AWS1/IF_VPS=>CREATEPOLICY()¶
About CreatePolicy¶
Creates a Cedar policy and saves it in the specified policy store. You can create either a static policy or a policy linked to a policy template.
-
To create a static policy, provide the Cedar policy text in the
StaticPolicysection of thePolicyDefinition. -
To create a policy that is dynamically linked to a policy template, specify the policy template ID and the principal and resource to associate with this policy in the
templateLinkedsection of thePolicyDefinition. If the policy template is ever updated, any policies linked to the policy template automatically use the updated template.
Creating a policy causes it to be validated against the schema in the policy store. If the policy doesn't pass validation, the operation fails and the policy isn't stored.
Verified Permissions is eventually consistent . It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.
Method Signature¶
METHODS /AWS1/IF_VPS~CREATEPOLICY
IMPORTING
!IV_CLIENTTOKEN TYPE /AWS1/VPSIDEMPOTENCYTOKEN OPTIONAL
!IV_POLICYSTOREID TYPE /AWS1/VPSPOLICYSTOREID OPTIONAL
!IO_DEFINITION TYPE REF TO /AWS1/CL_VPSPOLICYDEFINITION OPTIONAL
!IV_NAME TYPE /AWS1/VPSPOLICYNAME OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_vpscreatepolicyoutput
RAISING
/AWS1/CX_VPSACCESSDENIEDEX
/AWS1/CX_VPSINTERNALSERVEREX
/AWS1/CX_VPSTHROTTLINGEX
/AWS1/CX_VPSVALIDATIONEX
/AWS1/CX_VPSCONFLICTEXCEPTION
/AWS1/CX_VPSRESOURCENOTFOUNDEX
/AWS1/CX_VPSSERVICEQUOTAEXCDEX
/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
PolicyStoreIdof the policy store you want to store the policy in.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:
PSEXAMPLEabcdefg111111Alias name:
policy-store-alias/example-policy-storeTo view aliases, use ListPolicyStoreAliases.
io_definition TYPE REF TO /AWS1/CL_VPSPOLICYDEFINITION /AWS1/CL_VPSPOLICYDEFINITION¶
A structure that specifies the policy type and content to use for the new policy. You must include either a static or a templateLinked element. The policy content must be written in the Cedar policy language.
Optional arguments:¶
iv_clienttoken TYPE /AWS1/VPSIDEMPOTENCYTOKEN /AWS1/VPSIDEMPOTENCYTOKEN¶
Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value..
If you don't provide this value, then Amazon Web Services generates a random one for you.
If you retry the operation with the same
ClientToken, but with different parameters, the retry fails with anConflictExceptionerror.Verified Permissions recognizes a
ClientTokenfor eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value ofClientToken.
iv_name TYPE /AWS1/VPSPOLICYNAME /AWS1/VPSPOLICYNAME¶
Specifies a name for the policy that is unique among all policies within the policy store. You can use the name in place of the policy ID in API operations that reference the policy. The name must be prefixed with
name/.If you specify a name that is already associated with another policy in the policy store, you receive a
ConflictExceptionerror.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_vpscreatepolicyoutput /AWS1/CL_VPSCREATEPOLICYOUTPUT¶
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->createpolicy(
io_definition = new /aws1/cl_vpspolicydefinition(
io_static = new /aws1/cl_vpsstaticpolicydefn(
iv_description = |string|
iv_statement = |string|
)
io_templatelinked = new /aws1/cl_vpstmpllinkedplydefn(
io_principal = new /aws1/cl_vpsentityidentifier(
iv_entityid = |string|
iv_entitytype = |string|
)
io_resource = new /aws1/cl_vpsentityidentifier(
iv_entityid = |string|
iv_entitytype = |string|
)
iv_policytemplateid = |string|
)
)
iv_clienttoken = |string|
iv_name = |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.
lv_timestampformat = lo_result->get_createddate( ).
lv_timestampformat = lo_result->get_lastupdateddate( ).
lv_policyeffect = lo_result->get_effect( ).
ENDIF.
To create a static policy¶
The following example request creates a static policy with a policy scope that specifies both a principal and a resource. The response includes both the Principal and Resource elements because both were specified in the request policy scope.
DATA(lo_result) = lo_client->createpolicy(
io_definition = new /aws1/cl_vpspolicydefinition(
io_static = new /aws1/cl_vpsstaticpolicydefn(
iv_description = |Grant members of janeFriends UserGroup access to the vacationFolder Album|
iv_statement = |permit( principal in UserGroup::"janeFriends", action, resource in Album::"vacationFolder" );|
)
)
iv_clienttoken = |a1b2c3d4-e5f6-a1b2-c3d4-TOKEN1111111|
iv_name = |name/example-policy|
iv_policystoreid = |C7v5xMplfFH3i3e4Jrzb1a|
).
To create a template-linked policy¶
The following example creates a template-linked policy using the specified policy template and associates the specified principal to use with the new template-linked policy.
DATA(lo_result) = lo_client->createpolicy(
io_definition = new /aws1/cl_vpspolicydefinition(
io_templatelinked = new /aws1/cl_vpstmpllinkedplydefn(
io_principal = new /aws1/cl_vpsentityidentifier(
iv_entityid = |alice|
iv_entitytype = |User|
)
iv_policytemplateid = |PTEXAMPLEabcdefg111111|
)
)
iv_clienttoken = |a1b2c3d4-e5f6-a1b2-c3d4-TOKEN1111111|
iv_name = |name/example-template-linked-policy|
iv_policystoreid = |C7v5xMplfFH3i3e4Jrzb1a|
).