class ThreeScaleToolbox::Commands::PlansCommand::Import::CreateOrUpdateAppPlanStep
Public Instance Methods
call()
click to toggle source
Creates if it does not exist, updates otherwise
# 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
Private Instance Methods
create_plan_attrs()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/create_or_update_app_plan_step.rb, line 27 def create_plan_attrs resource_plan.merge('system_name' => plan_system_name) end
update_plan_attrs()
click to toggle source
# File lib/3scale_toolbox/commands/plans_command/import/create_or_update_app_plan_step.rb, line 31 def update_plan_attrs resource_plan.reject { |key, _| %w[system_name].include? key } end