diff --git a/apier/v1/apier_it_test.go b/apier/v1/apier_it_test.go index 719bac255..a66a08ebc 100644 --- a/apier/v1/apier_it_test.go +++ b/apier/v1/apier_it_test.go @@ -543,7 +543,7 @@ func testApierTPActions(t *testing.T) { DestinationIds: utils.META_ANY, BalanceWeight: "10", Weight: 10}, }} actWarn := &utils.TPActions{TPid: utils.TEST_SQL, ID: "WARN_VIA_HTTP", Actions: []*utils.TPAction{ - {Identifier: "*call_url", ExtraParameters: "http://localhost:8000", Weight: 10}, + {Identifier: "*http_post", ExtraParameters: "http://localhost:8000", Weight: 10}, }} actLog := &utils.TPActions{TPid: utils.TEST_SQL, ID: "LOG_BALANCE", Actions: []*utils.TPAction{ {Identifier: "*log", Weight: 10}, @@ -1865,7 +1865,7 @@ func testApierStartStopServiceStatus(t *testing.T) { } func testApierReplayFailedPosts(t *testing.T) { - fileName := "act>*call_url|*http_json|http%3A%2F%2Flocalhost%3A2081|63bed4ea-615e-4096-b1f4-499f64f29b28.json" + fileName := "act>*http_post|*http_json|http%3A%2F%2Flocalhost%3A2081|63bed4ea-615e-4096-b1f4-499f64f29b28.json" fileContent := []byte(`{"ID":"cgrates.org:1007","BalanceMap":{"*monetary":[{"Uuid":"367be35a-96ee-40a5-b609-9130661f5f12","ID":"","Value":0,"Directions":{"*out":true},"ExpirationDate":"0001-01-01T00:00:00Z","Weight":10,"DestinationIDs":{},"RatingSubject":"","Categories":{},"SharedGroups":{"SHARED_A":true},"Timings":null,"TimingIDs":{},"Disabled":false,"Factor":null,"Blocker":false}]},"UnitCounters":{"*monetary":[{"CounterType":"*event","Counters":[{"Value":0,"Filter":{"Uuid":null,"ID":"b8531413-10d5-47ad-81ad-2bc272e8f0ca","Type":"*monetary","Value":null,"Directions":{"*out":true},"ExpirationDate":null,"Weight":null,"DestinationIDs":{"FS_USERS":true},"RatingSubject":null,"Categories":null,"SharedGroups":null,"TimingIDs":null,"Timings":null,"Disabled":null,"Factor":null,"Blocker":null}}]}]},"ActionTriggers":[{"ID":"STANDARD_TRIGGERS","UniqueID":"46ac7b8c-685d-4555-bf73-fa6cfbc2fa21","ThresholdType":"*min_balance","ThresholdValue":2,"Recurrent":false,"MinSleep":0,"ExpirationDate":"0001-01-01T00:00:00Z","ActivationDate":"0001-01-01T00:00:00Z","Balance":{"Uuid":null,"ID":null,"Type":"*monetary","Value":null,"Directions":{"*out":true},"ExpirationDate":null,"Weight":null,"DestinationIDs":null,"RatingSubject":null,"Categories":null,"SharedGroups":null,"TimingIDs":null,"Timings":null,"Disabled":null,"Factor":null,"Blocker":null},"Weight":10,"ActionsID":"LOG_WARNING","MinQueuedItems":0,"Executed":true,"LastExecutionTime":"2017-01-31T14:03:57.961651647+01:00"},{"ID":"STANDARD_TRIGGERS","UniqueID":"b8531413-10d5-47ad-81ad-2bc272e8f0ca","ThresholdType":"*max_event_counter","ThresholdValue":5,"Recurrent":false,"MinSleep":0,"ExpirationDate":"0001-01-01T00:00:00Z","ActivationDate":"0001-01-01T00:00:00Z","Balance":{"Uuid":null,"ID":null,"Type":"*monetary","Value":null,"Directions":{"*out":true},"ExpirationDate":null,"Weight":null,"DestinationIDs":{"FS_USERS":true},"RatingSubject":null,"Categories":null,"SharedGroups":null,"TimingIDs":null,"Timings":null,"Disabled":null,"Factor":null,"Blocker":null},"Weight":10,"ActionsID":"LOG_WARNING","MinQueuedItems":0,"Executed":false,"LastExecutionTime":"0001-01-01T00:00:00Z"},{"ID":"STANDARD_TRIGGERS","UniqueID":"8b424186-7a31-4aef-99c5-35e12e6fed41","ThresholdType":"*max_balance","ThresholdValue":20,"Recurrent":false,"MinSleep":0,"ExpirationDate":"0001-01-01T00:00:00Z","ActivationDate":"0001-01-01T00:00:00Z","Balance":{"Uuid":null,"ID":null,"Type":"*monetary","Value":null,"Directions":{"*out":true},"ExpirationDate":null,"Weight":null,"DestinationIDs":null,"RatingSubject":null,"Categories":null,"SharedGroups":null,"TimingIDs":null,"Timings":null,"Disabled":null,"Factor":null,"Blocker":null},"Weight":10,"ActionsID":"LOG_WARNING","MinQueuedItems":0,"Executed":false,"LastExecutionTime":"0001-01-01T00:00:00Z"},{"ID":"STANDARD_TRIGGERS","UniqueID":"28557f3b-139c-4a27-9d17-bda1f54b7c19","ThresholdType":"*max_balance","ThresholdValue":100,"Recurrent":false,"MinSleep":0,"ExpirationDate":"0001-01-01T00:00:00Z","ActivationDate":"0001-01-01T00:00:00Z","Balance":{"Uuid":null,"ID":null,"Type":"*monetary","Value":null,"Directions":{"*out":true},"ExpirationDate":null,"Weight":null,"DestinationIDs":null,"RatingSubject":null,"Categories":null,"SharedGroups":null,"TimingIDs":null,"Timings":null,"Disabled":null,"Factor":null,"Blocker":null},"Weight":10,"ActionsID":"DISABLE_AND_LOG","MinQueuedItems":0,"Executed":false,"LastExecutionTime":"0001-01-01T00:00:00Z"}],"AllowNegative":false,"Disabled":false}"`) args := ArgsReplyFailedPosts{ FailedRequestsInDir: utils.StringPointer("/tmp/TestsApierV1/in"), diff --git a/config/config_defaults.go b/config/config_defaults.go index 968ff5fc9..d90c4c2ba 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -35,7 +35,7 @@ const CGRATES_CFG_JSON = ` "rounding_decimals": 5, // system level precision for floats "dbdata_encoding": "*msgpack", // encoding used to store object data in strings: <*msgpack|*json> "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline TariffPlans - "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR exports) + "poster_attempts": 3, // number of attempts before considering post request failed (eg: *http_post, CDR exports) "failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> "default_category": "call", // default category to consider when missing from requests diff --git a/config/generalcfg_test.go b/config/generalcfg_test.go index ee197e87b..483502885 100644 --- a/config/generalcfg_test.go +++ b/config/generalcfg_test.go @@ -44,7 +44,7 @@ func TestGeneralCfgloadFromJsonCfg(t *testing.T) { "rounding_decimals": 5, // system level precision for floats "dbdata_encoding": "msgpack", // encoding used to store object data in strings: "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans - "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR replication) + "poster_attempts": 3, // number of attempts before considering post request failed (eg: *http_post, CDR replication) "failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> "default_category": "call", // default category to consider when missing from requests diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index c5d4075c9..cd07354e7 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -14,7 +14,7 @@ // "rounding_decimals": 5, // system level precision for floats // "dbdata_encoding": "*msgpack", // encoding used to store object data in strings: <*msgpack|*json> // "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline TariffPlans -// "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR exports) +// "poster_attempts": 3, // number of attempts before considering post request failed (eg: *http_post, CDR exports) // "failed_posts_dir": "/var/spool/cgrates/failed_posts", // directory path where we store failed requests // "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> // "default_category": "call", // default category to consider when missing from requests diff --git a/data/conf/samples/multifiles/d.json b/data/conf/samples/multifiles/d.json index ee0f61da1..4cad502dd 100644 --- a/data/conf/samples/multifiles/d.json +++ b/data/conf/samples/multifiles/d.json @@ -11,7 +11,7 @@ "rounding_decimals": *env:ROUND_DEC, // system level precision for floats "dbdata_encoding": "*env:DB_ENCODING", // encoding used to store object data in strings: <*msgpack|*json> "tpexport_dir": "*env:TP_EXPORT_DIR", // path towards export folder for offline Tariff Plans - "poster_attempts": 3, // number of attempts before considering post request failed (eg: *call_url, CDR replication) + "poster_attempts": 3, // number of attempts before considering post request failed (eg: *http_post, CDR replication) "failed_posts_dir": "*env:FAILED_POSTS_DIR", // directory path where we store failed requests "default_tenant": "*env:DF_TENANT", // default tenant to consider when missing from requests "default_timezone": "*env:TIMEZONE", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> diff --git a/data/tariffplans/testtp/Actions.csv b/data/tariffplans/testtp/Actions.csv index b3edd608d..870a81cd0 100644 --- a/data/tariffplans/testtp/Actions.csv +++ b/data/tariffplans/testtp/Actions.csv @@ -2,7 +2,7 @@ PREPAID_10,*topup,,,,*monetary,,*any,,,*unlimited,,10,10,false,false,20 BONUS_3,*topup,,,,*monetary,,*any,,,*unlimited,,3,10,false,false,10 LOG_BALANCE,*log,,,,,,,,,,,,,false,false,10 -CDRST_WARN_HTTP,*call_url,http://localhost:8080,,,,,,,,,,,,false,false,10 +CDRST_WARN_HTTP,*http_post,http://localhost:8080,,,,,,,,,,,,false,false,10 CDRST_LOG,*log,,,,,,,,,,,,,false,false,10 TOPUP_EXE,*topup,,,,*monetary,,*any,,,*unlimited,,5,10,false,false,10 TOPUP_DATA_r,*topup,,,,*monetary,,DATA_DEST,,,*unlimited,,5000000,10,false,false,10 diff --git a/data/tariffplans/tutorial2/Actions.csv b/data/tariffplans/tutorial2/Actions.csv index a742ac90a..ae15e2a37 100644 --- a/data/tariffplans/tutorial2/Actions.csv +++ b/data/tariffplans/tutorial2/Actions.csv @@ -25,4 +25,4 @@ LOG_WARNING,*log,,,,,,,,,,,,,,,10 DISABLE_ACCOUNT,*disable_account,,,,,,,,,,,,,,,10 # WARN_HTTP_ASYNC will call url asynchronously with the account provided as JSON body -WARN_HTTP_ASYNC,*call_url_async,http://$path/$to/$warn,,,,,,,,,,,,false,false,10 \ No newline at end of file +WARN_HTTP_ASYNC,*http_post_async,http://$path/$to/$warn,,,,,,,,,,,,false,false,10 \ No newline at end of file diff --git a/docs/overview.rst b/docs/overview.rst index 5d78de12f..a06b853d9 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -92,7 +92,7 @@ CGRateS is capable of four charging modes - Safe account operations via in-/inter-process locks and on-disk storage - Shared balances between multiple accounts (family/company bundles) with per-consumer configurable debit strategy and rates selected. - Concurrent sessions per account doing balance reservation in chunks of debit interval and support for refunds and debit sleep when needed -- Scheduled account operations via predefined actions (eg: **\*topup**, **\*debit**) or notifications (**\*http_call_url**, **\*mail**) +- Scheduled account operations via predefined actions (eg: **\*topup**, **\*debit**) or notifications (**\*http_post**, **\*mail**) - Fraud detection with automatic mitigation via action triggers/thresholds monitoring both balance status as well as combined usage 2.1.3. LCR diff --git a/docs/tariff_plans.rst b/docs/tariff_plans.rst index cf5e772c1..9212af832 100644 --- a/docs/tariff_plans.rst +++ b/docs/tariff_plans.rst @@ -450,8 +450,8 @@ TBD The action type. Can have one of the following: + **\*allow_negative**: Allow to the account to have negative balance - + **\*call_url**: Send a http request to the following url - + **\*call_url_async**: Send a http request to the following url Asynchronous + + **\*http_post**: Send a http request to the following url + + **\*http_post_async**: Send a http request to the following url Asynchronous + **\*cdrlog**: Log the current action in the storeDB + **\*debit**: Debit account balance. + **\*deny_negative**: Deny to the account to have negative balance @@ -471,7 +471,7 @@ TBD [2] - ExtraParameters: In Extra Parameter field you can define an argument for the action. In case - of call_url Action, extraParameter will be the url action. In case of + of http_post Action, extraParameter will be the url action. In case of mail_async the email that you want to receive. [3] - Filter diff --git a/engine/action.go b/engine/action.go index cd49ba9a9..d50b6352d 100644 --- a/engine/action.go +++ b/engine/action.go @@ -88,8 +88,8 @@ func getActionFunc(typ string) (actionTypeFunc, bool) { utils.RESET_COUNTERS: resetCountersAction, utils.ENABLE_ACCOUNT: enableAccountAction, utils.DISABLE_ACCOUNT: disableAccountAction, - utils.CALL_URL: callUrl, - utils.CALL_URL_ASYNC: callUrlAsync, + utils.HttpPost: callUrl, + utils.HttpPostAsync: callUrlAsync, utils.MAIL_ASYNC: mailAsync, utils.SET_DDESTINATIONS: setddestinations, utils.REMOVE_ACCOUNT: removeAccountAction, diff --git a/utils/consts.go b/utils/consts.go index e1b92cd25..a7b1b3008 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -721,8 +721,8 @@ const ( RESET_COUNTERS = "*reset_counters" ENABLE_ACCOUNT = "*enable_account" DISABLE_ACCOUNT = "*disable_account" - CALL_URL = "*call_url" - CALL_URL_ASYNC = "*call_url_async" + HttpPost = "*http_post" + HttpPostAsync = "*http_post_async" MAIL_ASYNC = "*mail_async" UNLIMITED = "*unlimited" CDRLOG = "*cdrlog" diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go index 8b4ac8190..3cc306008 100644 --- a/utils/coreutils_test.go +++ b/utils/coreutils_test.go @@ -1265,8 +1265,8 @@ func TestFFNNewFallbackFileNameFronString(t *testing.T) { } else if !reflect.DeepEqual(eFFN, ffn) { t.Errorf("Expecting: %+v, received: %+v", eFFN, ffn) } - fileName = "act>*call_url|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|f52cf23e-da2f-4675-b36b-e8fcc3869270.json" - eFFN = &FallbackFileName{Module: "act>*call_url", + fileName = "act>*http_post|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|f52cf23e-da2f-4675-b36b-e8fcc3869270.json" + eFFN = &FallbackFileName{Module: "act>*http_post", Transport: MetaHTTPjson, Address: "http://localhost:2080/log_warning", RequestID: "f52cf23e-da2f-4675-b36b-e8fcc3869270", @@ -1280,20 +1280,20 @@ func TestFFNNewFallbackFileNameFronString(t *testing.T) { if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "unsupported module: ***" { t.Error(err) } - fileName = "act>*call_url|***|" - if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "unsupported transport in fallback file path: act>*call_url|***|" { + fileName = "act>*http_post|***|" + if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "unsupported transport in fallback file path: act>*http_post|***|" { t.Error(err) } - fileName = "act>*call_url|*http_json|***" - if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "cannot find request ID in fallback file path: act>*call_url|*http_json|***" { + fileName = "act>*http_post|*http_json|***" + if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "cannot find request ID in fallback file path: act>*http_post|*http_json|***" { t.Error(err) } - fileName = "act>*call_url|*http_json|%|.json" + fileName = "act>*http_post|*http_json|%|.json" if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != `invalid URL escape "%"` { t.Error(err) } - fileName = "act>*call_url|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|.test" - if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "unsupported suffix in fallback file path: act>*call_url|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|.test" { + fileName = "act>*http_post|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|.test" + if _, err := NewFallbackFileNameFronString(fileName); err == nil || err.Error() != "unsupported suffix in fallback file path: act>*http_post|*http_json|http%3A%2F%2Flocalhost%3A2080%2Flog_warning|.test" { t.Error(err) }