Sha256: e588abb15102da32c8e2d6f40b333f77c202fa17846a1bde02df89ab883d22cd
Contents?: true
Size: 1.32 KB
Versions: 6
Compression:
Stored size: 1.32 KB
Contents
module ThreeScaleToolbox module Tasks class CopyMethodsTask include CopyTask def call puts "original service hits metric #{source_hits.fetch('id')} has #{source_methods.size} methods" puts "target service hits metric #{target_hits.fetch('id')} has #{target_methods.size} methods" missing_methods.each(&method(:create_method)) puts "created #{missing_methods.size} missing methods on target service" invalidate_target_methods if missing_methods.size.positive? end private def create_method(method) Entities::Method.create( service: target, parent_id: target_hits.fetch('id'), attrs: ThreeScaleToolbox::Helper.filter_params(%w[friendly_name system_name], method) ) rescue ThreeScaleToolbox::ThreeScaleApiError => e raise e unless ThreeScaleToolbox::Helper.system_name_already_taken_error?(e.apierrors) warn "[WARN] method #{method.fetch('system_name')} not created. " \ 'Metric with the same system_name exists.' end def missing_methods @missing_methods ||= ThreeScaleToolbox::Helper.array_difference(source_methods, target_methods) do |method, target| ThreeScaleToolbox::Helper.compare_hashes(method, target, ['system_name']) end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems