Browse Source

improve application plan support

main
Nicolas Massé 4 years ago
parent
commit
9211bbe1af
  1. 19
      samples/01-api-with-apikey.sh
  2. 19
      samples/11-api-with-oidc.sh
  3. 8
      src/00-factory.sh
  4. 2
      src/01-common.sh

19
samples/01-api-with-apikey.sh

@ -89,6 +89,25 @@ declare -A application_plan_def=( ["system_name"]="test" ["name"]="Test plan" )
apply application_plan present application_plan_def apply application_plan present application_plan_def
application_plan_id=$last_object_id application_plan_id=$last_object_id
# Create Limits for the sayHello method
breadcrumb=( application_plans $application_plan_id metrics $method_id )
declare -A limit_def=( ["period"]="minute" ["value"]="5" )
apply limit present limit_def
declare -A limit_def=( ["period"]="day" ["value"]="100" )
apply limit present limit_def
# Re-Create Pricing Rules for the sayHello method
breadcrumb=( application_plans $application_plan_id metrics $method_id )
delete_all "pricing_rule"
declare -A pricing_rule_def=( ["min"]="1" ["max"]="10" ["cost_per_unit"]="1.0" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="11" ["max"]="100" ["cost_per_unit"]="0.9" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="101" ["max"]="1000" ["cost_per_unit"]="0.8" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="1001" ["max"]="" ["cost_per_unit"]="0.75" )
pricing_rule_create pricing_rule_def
## ##
## Create a test application ## Create a test application
## ##

19
samples/11-api-with-oidc.sh

@ -101,6 +101,25 @@ declare -A application_plan_def=( ["system_name"]="test" ["name"]="Test plan" )
apply application_plan present application_plan_def apply application_plan present application_plan_def
application_plan_id=$last_object_id application_plan_id=$last_object_id
# Create Limits for the sayHello method
breadcrumb=( application_plans $application_plan_id metrics $method_id )
declare -A limit_def=( ["period"]="minute" ["value"]="5" )
apply limit present limit_def
declare -A limit_def=( ["period"]="day" ["value"]="100" )
apply limit present limit_def
# Re-Create Pricing Rules for the sayHello method
breadcrumb=( application_plans $application_plan_id metrics $method_id )
delete_all "pricing_rule"
declare -A pricing_rule_def=( ["min"]="1" ["max"]="10" ["cost_per_unit"]="1.0" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="11" ["max"]="100" ["cost_per_unit"]="0.9" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="101" ["max"]="1000" ["cost_per_unit"]="0.8" )
pricing_rule_create pricing_rule_def
declare -A pricing_rule_def=( ["min"]="1001" ["max"]="" ["cost_per_unit"]="0.75" )
pricing_rule_create pricing_rule_def
## ##
## Create a test application ## Create a test application
## ##

8
src/00-factory.sh

@ -1,7 +1,7 @@
declare -A threescale_object_types=( ["backend"]="backend_apis" ["service"]="services" ["metric"]="metrics" ["method"]="methods" ["mapping_rule"]="mapping_rules" ["backend_usage"]="backend_usages" ["application_plan"]="application_plans" ["application_apikey"]="applications" ["application_appid"]="applications" ) declare -A threescale_object_types=( ["backend"]="backend_apis" ["service"]="services" ["metric"]="metrics" ["method"]="methods" ["mapping_rule"]="mapping_rules" ["backend_usage"]="backend_usages" ["application_plan"]="application_plans" ["application_apikey"]="applications" ["application_appid"]="applications" ["limit"]="limits" ["pricing_rule"]="pricing_rules" )
declare -A threescale_contains_external_id=( ["metric"]="contains_external_id_with_prefix" ["method"]="contains_external_id_with_prefix" ["backend_usage"]="contains_numerical_external_id") declare -A threescale_contains_external_id=( ["metric"]="contains_external_id_with_prefix" ["method"]="contains_external_id_with_prefix" ["backend_usage"]="contains_numerical_external_id" )
declare -A threescale_id_of_external_id=( ["metric"]="id_of_external_id_with_prefix" ["method"]="id_of_external_id_with_prefix" ["backend_usage"]="id_of_numerical_external_id") declare -A threescale_id_of_external_id=( ["metric"]="id_of_external_id_with_prefix" ["method"]="id_of_external_id_with_prefix" ["backend_usage"]="id_of_numerical_external_id" )
declare -A threescale_external_id=( ["backend_usage"]="backend_id" ["application_apikey"]="user_key" ["application_appid"]="application_id" ) declare -A threescale_external_id=( ["backend_usage"]="backend_id" ["application_apikey"]="user_key" ["application_appid"]="application_id" ["limit"]="period" ["mapping_rule"]="no external id" ["pricing_rule"]="no external id" )
template=$(cat <<"EOF" template=$(cat <<"EOF"
function OBJECT_TYPE_list () { function OBJECT_TYPE_list () {

2
src/01-common.sh

@ -40,7 +40,7 @@ function threescale_call () {
echo "=> HTTP $(cat "$tmp/$request_name.code")" >&2 echo "=> HTTP $(cat "$tmp/$request_name.code")" >&2
fi fi
if ! egrep -q "^$expected_http_codes\$" "$tmp/$request_name.code"; then if ! egrep -q "^($expected_http_codes)\$" "$tmp/$request_name.code"; then
echo "Unexpected HTTP code: $(cat "$tmp/$request_name.code")" >&2 echo "Unexpected HTTP code: $(cat "$tmp/$request_name.code")" >&2
return 1 return 1
fi fi

Loading…
Cancel
Save