Sha256: 2b5fe89b7e4ce9e2c7118f37b39aa02ba6a794832dbf939a5249e6c0c49b3225
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
module ThreeScaleToolbox module Commands module ServiceCommand module CopyCommand class CopyMethodsTask include Task def call logger.info "original service hits metric #{source.hits.id} has #{source.methods.size} methods" logger.info "target service hits metric #{target.hits.id} has #{target.methods.size} methods" missing_methods.each(&method(:create_method)) logger.info "created #{missing_methods.size} missing methods on target service" report['missing_methods_created'] = missing_methods.size end private def create_method(method) Entities::Method.create( service: target, attrs: ThreeScaleToolbox::Helper.filter_params(%w[friendly_name system_name], method.attrs) ) rescue ThreeScaleToolbox::ThreeScaleApiError => e raise e unless ThreeScaleToolbox::Helper.system_name_already_taken_error?(e.apierrors) warn "[WARN] method #{method.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| method.system_name == target.system_name end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
3scale_toolbox-0.18.0 | lib/3scale_toolbox/commands/service_command/copy_command/copy_methods_task.rb |