Class: ThreeScaleToolbox::Commands::PlansCommand::Import::CreateOrUpdateAppPlanStep
- Inherits:
-
Object
- Object
- ThreeScaleToolbox::Commands::PlansCommand::Import::CreateOrUpdateAppPlanStep
- Includes:
- Step
- Defined in:
- lib/3scale_toolbox/commands/plans_command/import/create_or_update_app_plan_step.rb
Instance Attribute Summary
Attributes included from Step
Instance Method Summary collapse
-
#call ⇒ Object
Creates if it does not exist, updates otherwise.
Methods included from Step
#artifacts_resource, #file, #find_feature_by_system_name, #find_metric_by_system_name, #initialize, #plan, #plan_system_name, #resource_features, #resource_limits, #resource_methods, #resource_metrics, #resource_plan, #resource_pricing_rules, #result, #service, #service_features, #service_metrics_and_methods, #service_system_name, #threescale_client
Instance Method Details
#call ⇒ Object
Creates if it does not exist, updates otherwise
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/3scale_toolbox/commands/plans_command/import/create_or_update_app_plan_step.rb', line 9 def call plan_obj = Entities::ApplicationPlan.find(service: service, ref: plan_system_name) if plan_obj.nil? plan_obj = Entities::ApplicationPlan.create(service: service, plan_attrs: create_plan_attrs) puts "Application plan created: #{plan_obj.id}" else res = plan_obj.update(update_plan_attrs) if (errors = res['errors']) raise ThreeScaleToolbox::Error, "Could not update application plan #{plan_system_name}. Errors: #{errors}" end puts "Application plan updated: #{plan_obj.id}" end end |