Module: Grafana::Tags
- Defined in:
- lib/grafana/tags.rb
Instance Method Summary collapse
-
#expand_tags(params) ⇒ Hash
expand the Template Tags helper function to expand the Dashboard Tags with an own Array of Tags.
Instance Method Details
#expand_tags(params) ⇒ Hash
expand the Template Tags helper function to expand the Dashboard Tags with an own Array of Tags
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/grafana/tags.rb', line 25 def ( params ) raise ArgumentError.new(format('wrong type. \'params\' must be an Hash, given \'%s\'', params.class.to_s)) unless( params.is_a?(Hash) ) raise ArgumentError.new('missing \'params\'') if( params.size.zero? ) dashboard = validate( params, required: true, var: 'dashboard', type: Hash ) = validate( params, required: true, var: 'additional_tags', type: Array ) # add tags # dashboard = JSON.parse( dashboard ) if( dashboard.is_a?( String ) ) = .values if( .is_a?( Hash ) ) = dashboard.dig( 'dashboard', 'tags' ) if( !.nil? && .count > 0 ) << .flatten! .sort! dashboard['dashboard']['tags'] = end JSON.generate( dashboard ) if( dashboard.is_a?( Hash ) ) end |