radiosonde 0.1.1 → 0.2.0.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5453299693d666c8203cc4ac18dda1a6b6f5ac29
4
- data.tar.gz: 0f7270861c8a03f9781499adb97cfe2b6ea87722
3
+ metadata.gz: 2fd996f58c5a00b537d2e18788677303e682443f
4
+ data.tar.gz: 6c697fdec4968eb129539b4fb76ae51b38d3a9ae
5
5
  SHA512:
6
- metadata.gz: 004c1745134cfd3fe5e235d6e133b9b562b77e1eae74140e9fadff9b7703a863c88d9fec1a7eb1a02451819a27ccf43284b6831385bb9402a411dea462d653cf
7
- data.tar.gz: 1c69c27564da763732c5465b6e324b9a8bbdd20a3f2d2d1cb6b408ac074a6f56051d2045fa21f80763cf28a47c158b82641ea494850fe8fa4518ca7c0616afa7
6
+ metadata.gz: c7471238fc343fd02749a154281fe0029a778eebe65d97d178355aae08101ac970a6b6b95c730312d3673a08063d04c82dccf0268b531e32f5a63408a9fa59ee
7
+ data.tar.gz: 619cbd2478165ebaa7ac8f4f064bce83d7572d42407e33f747388b6de46a8078e5dc322166faf032e51163304098b403ff93bcfe2141993a9087dc1c598a41aa
data/bin/radiosonde CHANGED
@@ -71,17 +71,17 @@ ARGV.options do |opt|
71
71
  :secret_access_key => secret_key
72
72
  )
73
73
  elsif profile_name
74
- provider = AWS::Core::CredentialProviders::SharedCredentialFileProvider.new(
74
+ credentials = Aws::SharedCredentials.new(
75
75
  :profile_name => profile_name
76
76
  )
77
- aws_opts[:credential_provider] = provider
77
+ aws_opts[:credentials] = credentials
78
78
  elsif (access_key and !secret_key) or (!access_key and secret_key) or mode.nil?
79
79
  puts opt.help
80
80
  exit 1
81
81
  end
82
82
 
83
83
  aws_opts[:region] = region if region
84
- AWS.config(aws_opts)
84
+ Aws.config.update(aws_opts)
85
85
  rescue => e
86
86
  $stderr.puts("[ERROR] #{e.message}")
87
87
  exit 1
@@ -91,7 +91,7 @@ end
91
91
  String.colorize = options[:color]
92
92
 
93
93
  if options[:debug]
94
- AWS.config({
94
+ Aws.config.update({
95
95
  :http_wire_trace => true,
96
96
  :logger => Radiosonde::Logger.instance,
97
97
  })
data/lib/radiosonde.rb CHANGED
@@ -7,7 +7,7 @@ require 'ostruct'
7
7
  require 'singleton'
8
8
  require 'pp'
9
9
 
10
- require 'aws-sdk-v1'
10
+ require 'aws-sdk-core'
11
11
  require 'term/ansicolor'
12
12
  require 'diffy'
13
13
  require 'hashie'
@@ -4,15 +4,13 @@ class Radiosonde::Client
4
4
 
5
5
  def initialize(options = {})
6
6
  @options = options
7
- @cloud_watch = AWS::CloudWatch.new
7
+ @cloud_watch = Aws::CloudWatch::Client.new
8
8
  end
9
9
 
10
10
  def export(opts = {})
11
11
  exported = nil
12
12
 
13
- AWS.memoize do
14
- exported = Radiosonde::Exporter.export(@cloud_watch, @options.merge(opts))
15
- end
13
+ exported = Radiosonde::Exporter.export(@cloud_watch, @options.merge(opts))
16
14
 
17
15
  Radiosonde::DSL.convert(exported, @options.merge(opts))
18
16
  end
@@ -20,34 +18,30 @@ class Radiosonde::Client
20
18
  def metrics(opts = {})
21
19
  namespaces = {}
22
20
 
23
- AWS.memoize do
24
- ms = @cloud_watch.metrics
25
-
26
- [:namespace, :metric_name].each do |name|
27
- if (value = opts[name])
28
- ms = ms.filter(name.to_s, value)
29
- end
30
- end
31
-
32
- ms.sort_by {|m| [m.namespace, m.metric_name] }.each do |m|
33
- if opts[:with_statistics]
34
- namespaces[m.namespace] ||= {}
35
- statistics_ops = {}
36
- [:start_time, :end_time, :statistics].each do |name|
37
- statistics_ops[name] = opts[name] if opts[name]
38
- end
39
- statistics = m.statistics(statistics_ops)
40
- namespaces[m.namespace][m.metric_name] = {
41
- :label => statistics.label,
42
- :datapoints => statistics.datapoints
43
- }
44
- elsif opts[:with_dimensions]
45
- namespaces[m.namespace] ||= {}
46
- namespaces[m.namespace][m.metric_name] = m.dimensions
47
- else
48
- namespaces[m.namespace] ||= []
49
- namespaces[m.namespace] << m.metric_name
21
+ ms = @cloud_watch.list_metrics(namespace: opts[:namespace], metric_name: opts[:metric_name]).flat_map(&:metrics)
22
+ ms.sort_by {|m| [m.namespace, m.metric_name] }.each do |m|
23
+ if opts[:with_statistics]
24
+ namespaces[m.namespace] ||= {}
25
+ statistics_ops = {
26
+ namespace: opts[:namespace],
27
+ metric_name: opts[:metric_name],
28
+ period: 60,
29
+ dimensions: m.dimensions,
30
+ }
31
+ [:start_time, :end_time, :statistics].each do |name|
32
+ statistics_ops[name] = opts[name] if opts[name]
50
33
  end
34
+ statistics = @cloud_watch.get_metric_statistics(statistics_ops)
35
+ namespaces[m.namespace][m.metric_name] = {
36
+ label: statistics.label,
37
+ datapoints: statistics.datapoints.map(&:to_h),
38
+ }
39
+ elsif opts[:with_dimensions]
40
+ namespaces[m.namespace] ||= {}
41
+ namespaces[m.namespace][m.metric_name] = m.dimensions.map(&:to_h)
42
+ else
43
+ namespaces[m.namespace] ||= []
44
+ namespaces[m.namespace] << m.metric_name
51
45
  end
52
46
  end
53
47
 
@@ -55,7 +49,7 @@ class Radiosonde::Client
55
49
  end
56
50
 
57
51
  def apply(file)
58
- AWS.memoize { walk(file) }
52
+ walk(file)
59
53
  end
60
54
 
61
55
  private
@@ -53,7 +53,7 @@ class Radiosonde::DSL::Context::Alarm
53
53
 
54
54
  if value.kind_of?(Hash)
55
55
  value = value.map do |name, value|
56
- {:name => name, :value => value}
56
+ Aws::CloudWatch::Types::Dimension.new(name: name, value: value)
57
57
  end
58
58
  end
59
59
 
@@ -15,9 +15,11 @@ class Radiosonde::Exporter
15
15
  def export
16
16
  result = {}
17
17
 
18
- @cloud_watch.alarms.each do |alarm|
19
- if matched?(alarm.alarm_name, @options[:include], @options[:exclude])
20
- export_alarm(alarm, result)
18
+ @cloud_watch.describe_alarms.each do |page|
19
+ page.metric_alarms.each do |alarm|
20
+ if matched?(alarm.alarm_name, @options[:include], @options[:exclude])
21
+ export_alarm(alarm, result)
22
+ end
21
23
  end
22
24
  end
23
25
 
@@ -1,4 +1,4 @@
1
- class AWS::CloudWatch
1
+ class Aws::CloudWatch::Client
2
2
  def modify!
3
3
  @modified = true
4
4
  end
@@ -1,3 +1,3 @@
1
1
  module Radiosonde
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0.beta'
3
3
  end
@@ -63,7 +63,7 @@ class Radiosonde::Wrapper::Alarm
63
63
 
64
64
  unless @options[:dry_run]
65
65
  opts = self.class.normalize_attrs(dsl)
66
- @alarm.update(opts)
66
+ @cloud_watch.put_metric_alarm(opts.merge(alarm_name: alarm_name))
67
67
  @cloud_watch.modify!
68
68
  end
69
69
  end
@@ -72,7 +72,7 @@ class Radiosonde::Wrapper::Alarm
72
72
  log(:info, 'Delete Alarm', :red, self.alarm_name)
73
73
 
74
74
  unless @options[:dry_run]
75
- @alarm.delete
75
+ @cloud_watch.delete_alarms(alarm_names: [alarm_name])
76
76
  @cloud_watch.modify!
77
77
  end
78
78
  end
@@ -1,15 +1,16 @@
1
1
  class Radiosonde::Wrapper::AlarmCollection
2
2
  include Radiosonde::Logger::Helper
3
3
 
4
- def initialize(cloud_watch, alarms, options = {})
4
+ def initialize(cloud_watch, options = {})
5
5
  @cloud_watch = cloud_watch
6
- @alarms = alarms
7
6
  @options = options
8
7
  end
9
8
 
10
9
  def each
11
- @alarms.each do |alarm|
12
- yield(Radiosonde::Wrapper::Alarm.new(@cloud_watch, alarm, @options))
10
+ @cloud_watch.describe_alarms.each do |page|
11
+ page.metric_alarms.each do |alarm|
12
+ yield(Radiosonde::Wrapper::Alarm.new(@cloud_watch, alarm, @options))
13
+ end
13
14
  end
14
15
  end
15
16
 
@@ -17,10 +18,9 @@ class Radiosonde::Wrapper::AlarmCollection
17
18
  log(:info, 'Create Alarm', :cyan, name)
18
19
  opts = Radiosonde::Wrapper::Alarm.normalize_attrs(dsl)
19
20
 
20
- if @options[:dry_run]
21
- alarm = OpenStruct.new(opts.merge(:alarm_name => name))
22
- else
23
- alarm = @alarms.create(name, opts)
21
+ alarm = Aws::CloudWatch::Types::MetricAlarm.new(opts.merge(alarm_name: name))
22
+ unless @options[:dry_run]
23
+ @cloud_watch.put_metric_alarm(alarm.to_h)
24
24
  @cloud_watch.modify!
25
25
  end
26
26
 
@@ -5,7 +5,7 @@ class Radiosonde::Wrapper::CloudWatch
5
5
  end
6
6
 
7
7
  def alarms
8
- Radiosonde::Wrapper::AlarmCollection.new(@cloud_watch, @cloud_watch.alarms, @options)
8
+ Radiosonde::Wrapper::AlarmCollection.new(@cloud_watch, @options)
9
9
  end
10
10
 
11
11
  def modified?
data/radiosonde.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'aws-sdk-v1'
21
+ spec.add_dependency 'aws-sdk-core', '>= 2.1.0'
22
22
  spec.add_dependency 'json'
23
23
  spec.add_dependency 'term-ansicolor'
24
24
  spec.add_dependency 'diffy'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiosonde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: aws-sdk-v1
14
+ name: aws-sdk-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -177,9 +177,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ">="
180
+ - - ">"
181
181
  - !ruby/object:Gem::Version
182
- version: '0'
182
+ version: 1.3.1
183
183
  requirements: []
184
184
  rubyforge_project:
185
185
  rubygems_version: 2.4.5.1