Skip to content

/AWS1/IF_COA=>CREATEAUTOMATIONRULE()

About CreateAutomationRule

Creates a new automation rule to apply recommended actions to resources based on specified criteria.

Method Signature

METHODS /AWS1/IF_COA~CREATEAUTOMATIONRULE
  IMPORTING
    !IV_NAME TYPE /AWS1/COARULENAME OPTIONAL
    !IV_DESCRIPTION TYPE /AWS1/COARULEDESCRIPTION OPTIONAL
    !IV_RULETYPE TYPE /AWS1/COARULETYPE OPTIONAL
    !IO_ORGANIZATIONCONFIGURATION TYPE REF TO /AWS1/CL_COAORGANIZATIONCONF OPTIONAL
    !IV_PRIORITY TYPE /AWS1/COASTRING OPTIONAL
    !IT_RECOMMENDEDACTIONTYPES TYPE /AWS1/CL_COARECDACTTYPELIST_W=>TT_RECOMMENDEDACTIONTYPELIST OPTIONAL
    !IO_CRITERIA TYPE REF TO /AWS1/CL_COACRITERIA OPTIONAL
    !IO_SCHEDULE TYPE REF TO /AWS1/CL_COASCHEDULE OPTIONAL
    !IV_STATUS TYPE /AWS1/COARULESTATUS OPTIONAL
    !IT_TAGS TYPE /AWS1/CL_COATAG=>TT_TAGLIST OPTIONAL
    !IV_CLIENTTOKEN TYPE /AWS1/COACLIENTTOKEN OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_coacreateautorulersp
  RAISING
    /AWS1/CX_COAACCESSDENIEDEX
    /AWS1/CX_COAFORBIDDENEXCEPTION
    /AWS1/CX_COAIDEMTOKENINUSEEX
    /AWS1/CX_COAIDEMPARAMMMEX
    /AWS1/CX_COAINTERNALSERVEREX
    /AWS1/CX_COAINVPARAMVALUEEX
    /AWS1/CX_COAOPTINREQUIREDEX
    /AWS1/CX_COARESOURCENOTFOUNDEX
    /AWS1/CX_COASERVICEQUOTAEXCDEX
    /AWS1/CX_COASERVICEUNAVAILEX
    /AWS1/CX_COATHROTTLINGEX
    /AWS1/CX_COACLIENTEXC
    /AWS1/CX_COASERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_name TYPE /AWS1/COARULENAME /AWS1/COARULENAME

The name of the automation rule.

iv_ruletype TYPE /AWS1/COARULETYPE /AWS1/COARULETYPE

The type of rule.

Only the management account or a delegated administrator can set the ruleType to be OrganizationRule.

it_recommendedactiontypes TYPE /AWS1/CL_COARECDACTTYPELIST_W=>TT_RECOMMENDEDACTIONTYPELIST TT_RECOMMENDEDACTIONTYPELIST

The types of recommended actions this rule will automate.

io_schedule TYPE REF TO /AWS1/CL_COASCHEDULE /AWS1/CL_COASCHEDULE

The schedule for when the rule should run.

iv_status TYPE /AWS1/COARULESTATUS /AWS1/COARULESTATUS

The status of the rule

Optional arguments:

iv_description TYPE /AWS1/COARULEDESCRIPTION /AWS1/COARULEDESCRIPTION

A description of the automation rule.

io_organizationconfiguration TYPE REF TO /AWS1/CL_COAORGANIZATIONCONF /AWS1/CL_COAORGANIZATIONCONF

Configuration for organization-level rules. Required for OrganizationRule type.

iv_priority TYPE /AWS1/COASTRING /AWS1/COASTRING

A string representation of a decimal number between 0 and 1 (having up to 30 digits after the decimal point) that determines the priority of the rule. When multiple rules match the same recommended action, Compute Optimizer assigns the action to the rule with the lowest priority value (highest priority), even if that rule is scheduled to run later than other matching rules.

io_criteria TYPE REF TO /AWS1/CL_COACRITERIA /AWS1/CL_COACRITERIA

A set of conditions that specify which recommended action qualify for implementation. When a rule is active and a recommended action matches these criteria, Compute Optimizer implements the action at the scheduled run time.

it_tags TYPE /AWS1/CL_COATAG=>TT_TAGLIST TT_TAGLIST

The tags to associate with the rule.

iv_clienttoken TYPE /AWS1/COACLIENTTOKEN /AWS1/COACLIENTTOKEN

A unique identifier to ensure idempotency of the request.

RETURNING

oo_output TYPE REF TO /aws1/cl_coacreateautorulersp /AWS1/CL_COACREATEAUTORULERSP

Domain /AWS1/RT_ACCOUNT_ID
Primitive Type NUMC

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->createautomationrule(
  io_criteria = new /aws1/cl_coacriteria(
    it_ebsvolumesizeingib = VALUE /aws1/cl_coaintegercritcond=>tt_integercriteriacondlist(
      (
        new /aws1/cl_coaintegercritcond(
          it_values = VALUE /aws1/cl_coaintegerlist_w=>tt_integerlist(
            ( new /aws1/cl_coaintegerlist_w( 123 ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_ebsvolumetype = VALUE /aws1/cl_coastringcriteriacond=>tt_stringcriteriaconditionlist(
      (
        new /aws1/cl_coastringcriteriacond(
          it_values = VALUE /aws1/cl_coastringcritvalues_w=>tt_stringcriteriavalues(
            ( new /aws1/cl_coastringcritvalues_w( |string| ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_estimatedmonthlysavings = VALUE /aws1/cl_coadoublecriteriacond=>tt_doublecriteriaconditionlist(
      (
        new /aws1/cl_coadoublecriteriacond(
          it_values = VALUE /aws1/cl_coadoublelist_w=>tt_doublelist(
            ( new /aws1/cl_coadoublelist_w( |0.1| ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_lookbackperiodindays = VALUE /aws1/cl_coaintegercritcond=>tt_integercriteriacondlist(
      (
        new /aws1/cl_coaintegercritcond(
          it_values = VALUE /aws1/cl_coaintegerlist_w=>tt_integerlist(
            ( new /aws1/cl_coaintegerlist_w( 123 ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_region = VALUE /aws1/cl_coastringcriteriacond=>tt_stringcriteriaconditionlist(
      (
        new /aws1/cl_coastringcriteriacond(
          it_values = VALUE /aws1/cl_coastringcritvalues_w=>tt_stringcriteriavalues(
            ( new /aws1/cl_coastringcritvalues_w( |string| ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_resourcearn = VALUE /aws1/cl_coastringcriteriacond=>tt_stringcriteriaconditionlist(
      (
        new /aws1/cl_coastringcriteriacond(
          it_values = VALUE /aws1/cl_coastringcritvalues_w=>tt_stringcriteriavalues(
            ( new /aws1/cl_coastringcritvalues_w( |string| ) )
          )
          iv_comparison = |string|
        )
      )
    )
    it_resourcetag = VALUE /aws1/cl_coarestagscritcond=>tt_resourcetagscritcondlist(
      (
        new /aws1/cl_coarestagscritcond(
          it_values = VALUE /aws1/cl_coastringcritvalues_w=>tt_stringcriteriavalues(
            ( new /aws1/cl_coastringcritvalues_w( |string| ) )
          )
          iv_comparison = |string|
          iv_key = |string|
        )
      )
    )
    it_restartneeded = VALUE /aws1/cl_coastringcriteriacond=>tt_stringcriteriaconditionlist(
      (
        new /aws1/cl_coastringcriteriacond(
          it_values = VALUE /aws1/cl_coastringcritvalues_w=>tt_stringcriteriavalues(
            ( new /aws1/cl_coastringcritvalues_w( |string| ) )
          )
          iv_comparison = |string|
        )
      )
    )
  )
  io_organizationconfiguration = new /aws1/cl_coaorganizationconf(
    it_accountids = VALUE /aws1/cl_coaorgconfacctids_w=>tt_organizationconfaccountids(
      ( new /aws1/cl_coaorgconfacctids_w( |string| ) )
    )
    iv_ruleapplyorder = |string|
  )
  io_schedule = new /aws1/cl_coaschedule(
    iv_executionwindowinminutes = 123
    iv_scheduleexpression = |string|
    iv_schedulexprsntimezone = |string|
  )
  it_recommendedactiontypes = VALUE /aws1/cl_coarecdacttypelist_w=>tt_recommendedactiontypelist(
    ( new /aws1/cl_coarecdacttypelist_w( |string| ) )
  )
  it_tags = VALUE /aws1/cl_coatag=>tt_taglist(
    (
      new /aws1/cl_coatag(
        iv_key = |string|
        iv_value = |string|
      )
    )
  )
  iv_clienttoken = |string|
  iv_description = |string|
  iv_name = |string|
  iv_priority = |string|
  iv_ruletype = |string|
  iv_status = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_rulearn = lo_result->get_rulearn( ).
  lv_ruleid = lo_result->get_ruleid( ).
  lv_rulename = lo_result->get_name( ).
  lv_string = lo_result->get_description( ).
  lv_ruletype = lo_result->get_ruletype( ).
  lv_long = lo_result->get_rulerevision( ).
  lo_organizationconfigurati = lo_result->get_organizationconf( ).
  IF lo_organizationconfigurati IS NOT INITIAL.
    lv_ruleapplyorder = lo_organizationconfigurati->get_ruleapplyorder( ).
    LOOP AT lo_organizationconfigurati->get_accountids( ) into lo_row.
      lo_row_1 = lo_row.
      IF lo_row_1 IS NOT INITIAL.
        lv_accountid = lo_row_1->get_value( ).
      ENDIF.
    ENDLOOP.
  ENDIF.
  lv_string = lo_result->get_priority( ).
  LOOP AT lo_result->get_recommendedactiontypes( ) into lo_row_2.
    lo_row_3 = lo_row_2.
    IF lo_row_3 IS NOT INITIAL.
      lv_recommendedactiontype = lo_row_3->get_value( ).
    ENDIF.
  ENDLOOP.
  lo_criteria = lo_result->get_criteria( ).
  IF lo_criteria IS NOT INITIAL.
    LOOP AT lo_criteria->get_region( ) into lo_row_4.
      lo_row_5 = lo_row_4.
      IF lo_row_5 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_5->get_comparison( ).
        LOOP AT lo_row_5->get_values( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_stringcriteriavalue = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_resourcearn( ) into lo_row_4.
      lo_row_5 = lo_row_4.
      IF lo_row_5 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_5->get_comparison( ).
        LOOP AT lo_row_5->get_values( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_stringcriteriavalue = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_ebsvolumetype( ) into lo_row_4.
      lo_row_5 = lo_row_4.
      IF lo_row_5 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_5->get_comparison( ).
        LOOP AT lo_row_5->get_values( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_stringcriteriavalue = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_ebsvolumesizeingib( ) into lo_row_8.
      lo_row_9 = lo_row_8.
      IF lo_row_9 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_9->get_comparison( ).
        LOOP AT lo_row_9->get_values( ) into lo_row_10.
          lo_row_11 = lo_row_10.
          IF lo_row_11 IS NOT INITIAL.
            lv_integer = lo_row_11->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_estimatedmonthlysavings( ) into lo_row_12.
      lo_row_13 = lo_row_12.
      IF lo_row_13 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_13->get_comparison( ).
        LOOP AT lo_row_13->get_values( ) into lo_row_14.
          lo_row_15 = lo_row_14.
          IF lo_row_15 IS NOT INITIAL.
            lv_double = lo_row_15->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_resourcetag( ) into lo_row_16.
      lo_row_17 = lo_row_16.
      IF lo_row_17 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_17->get_comparison( ).
        lv_stringcriteriavalue = lo_row_17->get_key( ).
        LOOP AT lo_row_17->get_values( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_stringcriteriavalue = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_lookbackperiodindays( ) into lo_row_8.
      lo_row_9 = lo_row_8.
      IF lo_row_9 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_9->get_comparison( ).
        LOOP AT lo_row_9->get_values( ) into lo_row_10.
          lo_row_11 = lo_row_10.
          IF lo_row_11 IS NOT INITIAL.
            lv_integer = lo_row_11->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
    LOOP AT lo_criteria->get_restartneeded( ) into lo_row_4.
      lo_row_5 = lo_row_4.
      IF lo_row_5 IS NOT INITIAL.
        lv_comparisonoperator = lo_row_5->get_comparison( ).
        LOOP AT lo_row_5->get_values( ) into lo_row_6.
          lo_row_7 = lo_row_6.
          IF lo_row_7 IS NOT INITIAL.
            lv_stringcriteriavalue = lo_row_7->get_value( ).
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDLOOP.
  ENDIF.
  lo_schedule = lo_result->get_schedule( ).
  IF lo_schedule IS NOT INITIAL.
    lv_string = lo_schedule->get_scheduleexpression( ).
    lv_string = lo_schedule->get_schedulexprsntimezone( ).
    lv_integer = lo_schedule->get_executionwindowinminutes( ).
  ENDIF.
  lv_rulestatus = lo_result->get_status( ).
  LOOP AT lo_result->get_tags( ) into lo_row_18.
    lo_row_19 = lo_row_18.
    IF lo_row_19 IS NOT INITIAL.
      lv_tagkey = lo_row_19->get_key( ).
      lv_tagvalue = lo_row_19->get_value( ).
    ENDIF.
  ENDLOOP.
  lv_timestamp = lo_result->get_createdtimestamp( ).
ENDIF.