/AWS1/IF_NWS=>CREATEPOLICY()¶
About CreatePolicy¶
Creates a policy. A policy combines templates and rules with enforcement settings for a firewall type, such as AWS WAF or AWS Shield Advanced. Use isPublished to create the policy in published (ACTIVE) or draft (DRAFT) state.
Method Signature¶
METHODS /AWS1/IF_NWS~CREATEPOLICY
IMPORTING
!IV_CLIENTTOKEN TYPE /AWS1/NWSIDEMPOTENCYTOKEN OPTIONAL
!IV_POLICYNAME TYPE /AWS1/NWSPOLICYNAME OPTIONAL
!IV_POLICYDESCRIPTION TYPE /AWS1/NWSDESCRIPTION OPTIONAL
!IV_PRIORITY TYPE /AWS1/NWSPRIORITY OPTIONAL
!IT_ASSOCTEMPLATEANDRULELIST TYPE /AWS1/CL_NWSTEMPLATEORRULEREF=>TT_TEMPLATEANDRULEREFLIST OPTIONAL
!IV_FIREWALLTYPE TYPE /AWS1/NWSPOLICYFIREWALLTYPE OPTIONAL
!IO_POLICYCONFIGURATION TYPE REF TO /AWS1/CL_NWSPOLICYCONF OPTIONAL
!IV_ISPUBLISHED TYPE /AWS1/NWSISPUBLISHED OPTIONAL
!IT_TAGS TYPE /AWS1/CL_NWSTAGMAP_W=>TT_TAGMAP OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_nwscreatepolicyoutput
RAISING
/AWS1/CX_NWSACCESSDENIEDEX
/AWS1/CX_NWSCONFLICTEXCEPTION
/AWS1/CX_NWSINTERNALSERVEREX
/AWS1/CX_NWSSERVICEQUOTAEXCDEX
/AWS1/CX_NWSSERVICEUNAVAILEX
/AWS1/CX_NWSTAGPOLICYVIOEX
/AWS1/CX_NWSTHROTTLINGEX
/AWS1/CX_NWSVLDTNEXCEPTION
/AWS1/CX_NWSCLIENTEXC
/AWS1/CX_NWSSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_policyname TYPE /AWS1/NWSPOLICYNAME /AWS1/NWSPOLICYNAME¶
The name of the policy.
iv_priority TYPE /AWS1/NWSPRIORITY /AWS1/NWSPRIORITY¶
The priority of the resource. A lower number indicates a higher priority.
iv_firewalltype TYPE /AWS1/NWSPOLICYFIREWALLTYPE /AWS1/NWSPOLICYFIREWALLTYPE¶
The firewall type associated with the resource.
io_policyconfiguration TYPE REF TO /AWS1/CL_NWSPOLICYCONF /AWS1/CL_NWSPOLICYCONF¶
The configuration settings that control the policy's behavior, including remediation and firewall-type-specific settings.
Optional arguments:¶
iv_clienttoken TYPE /AWS1/NWSIDEMPOTENCYTOKEN /AWS1/NWSIDEMPOTENCYTOKEN¶
A unique, case-sensitive token that you provide to ensure that the operation completes no more than one time. If you retry a request with the same client token and the same parameters, the service returns the result of the original successful request.
iv_policydescription TYPE /AWS1/NWSDESCRIPTION /AWS1/NWSDESCRIPTION¶
A description of the policy.
it_assoctemplateandrulelist TYPE /AWS1/CL_NWSTEMPLATEORRULEREF=>TT_TEMPLATEANDRULEREFLIST TT_TEMPLATEANDRULEREFLIST¶
The templates and rules to associate with the policy. For AWS WAF policies, specify 1 to 100 templates or rules, of which at most 2 can be templates. For AWS Shield Advanced policies, this list must be empty.
iv_ispublished TYPE /AWS1/NWSISPUBLISHED /AWS1/NWSISPUBLISHED¶
Specifies whether to publish the resource. When
true, the resource is saved in published (ACTIVE) state. Whenfalse, it is saved as a draft (DRAFT). Default:true.
it_tags TYPE /AWS1/CL_NWSTAGMAP_W=>TT_TAGMAP TT_TAGMAP¶
The tags to add to the resource when it is created.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_nwscreatepolicyoutput /AWS1/CL_NWSCREATEPOLICYOUTPUT¶
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_policyconfiguration = new /aws1/cl_nwspolicyconf(
io_wafconfig = new /aws1/cl_nwswafconfig(
iv_conflictresolution = |string|
iv_exstcustomerwebaclrsln = |string|
)
iv_remediationenabled = ABAP_TRUE
iv_resourcescleanup = ABAP_TRUE
)
it_assoctemplateandrulelist = VALUE /aws1/cl_nwstemplateorruleref=>tt_templateandrulereflist(
(
new /aws1/cl_nwstemplateorruleref(
iv_ruleidentifier = |string|
iv_templateidentifier = |string|
)
)
)
it_tags = VALUE /aws1/cl_nwstagmap_w=>tt_tagmap(
(
VALUE /aws1/cl_nwstagmap_w=>ts_tagmap_maprow(
key = |string|
value = new /aws1/cl_nwstagmap_w( |string| )
)
)
)
iv_clienttoken = |string|
iv_firewalltype = |string|
iv_ispublished = ABAP_TRUE
iv_policydescription = |string|
iv_policyname = |string|
iv_priority = 123
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_policyid = lo_result->get_policyid( ).
lv_policyarn = lo_result->get_policyarn( ).
lv_policyname = lo_result->get_policyname( ).
lv_description = lo_result->get_policydescription( ).
lv_entitystatus = lo_result->get_status( ).
lv_priority = lo_result->get_priority( ).
LOOP AT lo_result->get_assoctemplateandrulelist( ) into lo_row.
lo_row_1 = lo_row.
IF lo_row_1 IS NOT INITIAL.
lv_templatearn = lo_row_1->get_templatearn( ).
lv_rulearn = lo_row_1->get_rulearn( ).
ENDIF.
ENDLOOP.
lv_entityversion = lo_result->get_version( ).
lv_updatetoken = lo_result->get_updatetoken( ).
lv_issnapshot = lo_result->get_issnapshot( ).
lv_haspublishedversion = lo_result->get_haspublishedversion( ).
lv_policyfirewalltype = lo_result->get_firewalltype( ).
lo_policyconfiguration = lo_result->get_policyconfiguration( ).
IF lo_policyconfiguration IS NOT INITIAL.
lv_remediationenabled = lo_policyconfiguration->get_remediationenabled( ).
lv_resourcescleanup = lo_policyconfiguration->get_resourcescleanup( ).
lo_wafconfig = lo_policyconfiguration->get_wafconfig( ).
IF lo_wafconfig IS NOT INITIAL.
lv_existingcustomerwebaclr = lo_wafconfig->get_exstcustomerwebaclrsln( ).
lv_wafconflictresolutionop = lo_wafconfig->get_conflictresolution( ).
ENDIF.
ENDIF.
lv_datetimestamp = lo_result->get_updatedat( ).
ENDIF.
Create a WAF policy¶
Creates a new WAF policy in draft state with a template association.
DATA(lo_result) = lo_client->createpolicy(
io_policyconfiguration = new /aws1/cl_nwspolicyconf(
io_wafconfig = new /aws1/cl_nwswafconfig(
iv_conflictresolution = |MERGE_WHERE_APPLICABLE|
iv_exstcustomerwebaclrsln = |NO_REMEDIATION|
)
iv_remediationenabled = ABAP_FALSE
iv_resourcescleanup = ABAP_FALSE
)
it_assoctemplateandrulelist = VALUE /aws1/cl_nwstemplateorruleref=>tt_templateandrulereflist(
( new /aws1/cl_nwstemplateorruleref( iv_templateidentifier = |arn:aws:network-security-manager:us-east-1:123456789012:template:xyz789| ) )
)
iv_clienttoken = |550e8400-e29b-41d4-a716-446655440002|
iv_firewalltype = |WAF|
iv_ispublished = ABAP_FALSE
iv_policydescription = |WAF policy for web application protection|
iv_policyname = |web-app-waf-policy|
iv_priority = 1
).