growthforecast-client 0.62.0 → 0.62.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +29 -0
- data/README.md +22 -0
- data/VERSION +1 -1
- data/lib/growthforecast/cli.rb +118 -27
- data/lib/growthforecast/client.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aa8e954466d6a600a54404856ea29e0acf5a1cb
|
4
|
+
data.tar.gz: 613aef8e40914d64cac2dfba25734435dea1d6d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c1a97d6d60df53dcae6e2d34954d985799295269148fdc6d8da5e1cc37c6756989741477c41b1b6ef4d2c8b1c9f295d6478f64e9cbe651c5f04e997b860c76e
|
7
|
+
data.tar.gz: 36bfaf46fc2fe603f4df520cd1d5b7aee52792212be118c9cd63e48215b9509b3df9e3fa0c9cb997097faabbb7903d86879c17608486fd171b00218f4372495a
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
# 0.62.3 (2013/09/20)
|
2
|
+
|
3
|
+
Features:
|
4
|
+
|
5
|
+
- Add -g and -s options to `delete` command
|
6
|
+
|
7
|
+
# 0.62.2 (2013/09/19)
|
8
|
+
|
9
|
+
Changes:
|
10
|
+
|
11
|
+
- Change option -u to an argument of `color`, `create_complex` command
|
12
|
+
|
13
|
+
# 0.62.1 (2013/09/19)
|
14
|
+
|
15
|
+
Features:
|
16
|
+
|
17
|
+
- Add `growthforecast-client color` command
|
18
|
+
- Add `growthforecast-client create_complex` command
|
19
|
+
|
20
|
+
Changes:
|
21
|
+
|
22
|
+
- Change `growthforecast-client delete_graph` to `delete` command
|
23
|
+
|
24
|
+
# 0.62.0 (2013/07/02)
|
25
|
+
|
26
|
+
Changes:
|
27
|
+
|
28
|
+
- Version up!
|
29
|
+
|
1
30
|
# 0.0.6 (2013/05/17)
|
2
31
|
|
3
32
|
Features:
|
data/README.md
CHANGED
@@ -14,6 +14,28 @@ With growthforecast-client, for example, you can edit properties of a graph such
|
|
14
14
|
|
15
15
|
See [examples](examples) directory.
|
16
16
|
|
17
|
+
### CLI
|
18
|
+
|
19
|
+
GrowthForecast Client also provides a CLI named `growthforecast-client`.
|
20
|
+
|
21
|
+
Delete a graph or graphs under a path (copy and paste the URL from your GrowthForecast):
|
22
|
+
|
23
|
+
```
|
24
|
+
$ growthforecast-client delete 'http://fqdn.to.growthforecast:5125/list/service_name'
|
25
|
+
```
|
26
|
+
|
27
|
+
Change the colors of graphs
|
28
|
+
|
29
|
+
```
|
30
|
+
$ growthforecast-client color 'http://fqdn.to.growthforecast:5125/list/service_name' -c 'graph_name:#1111cc' ...
|
31
|
+
```
|
32
|
+
|
33
|
+
See help for more:
|
34
|
+
|
35
|
+
```
|
36
|
+
$ growthforecast-client help
|
37
|
+
```
|
38
|
+
|
17
39
|
## Contributing
|
18
40
|
|
19
41
|
1. Fork it
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.62.
|
1
|
+
0.62.3
|
data/lib/growthforecast/cli.rb
CHANGED
@@ -2,49 +2,140 @@
|
|
2
2
|
require 'thor'
|
3
3
|
|
4
4
|
class GrowthForecast::CLI < Thor
|
5
|
-
|
5
|
+
class_option :silent, :aliases => ["-S"], :type => :boolean
|
6
|
+
|
7
|
+
def initialize(args = [], opts = [], config = {})
|
8
|
+
super(args, opts, config)
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'delete <url>', 'delete a graph or graphs under a url'
|
6
12
|
long_desc <<-LONGDESC
|
7
|
-
Delete a graph or graphs under a <url> where <url> is the one obtained from the
|
13
|
+
Delete a graph or graphs under a <url> where <url> is the one obtained from the GrowthForecast URI, e.g.,
|
8
14
|
http://{hostname}:{port}/list/{service_name}/{section_name}?t=sh
|
9
15
|
or
|
10
16
|
http://{hostname}:{port}/view_graph/{service_name}/{section_name}/{graph_name}?t=sh
|
17
|
+
|
18
|
+
ex) growthforecast-client delete 'http://{hostname}:{port}/list/{service_name}/{section_name}'
|
11
19
|
LONGDESC
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
option :graph_names, :type => :array, :aliases => '-g'
|
21
|
+
option :section_names, :type => :array, :aliases => '-s'
|
22
|
+
def delete(url)
|
23
|
+
section_names, graph_names = options[:section_names], options[:graph_names]
|
24
|
+
|
25
|
+
base_uri, service_name, section_name, graph_name = split_url(url)
|
26
|
+
@client = client(base_uri)
|
27
|
+
|
28
|
+
graphs = @client.list_graph(service_name, section_name, graph_name)
|
29
|
+
delete_graphs(graphs, graph_names, section_names)
|
30
|
+
|
31
|
+
complexes = @client.list_complex(service_name, section_name, graph_name)
|
32
|
+
delete_complexes(complexes, graph_names, section_names)
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'color <url>', 'change the color of graphs'
|
36
|
+
long_desc <<-LONGDESC
|
37
|
+
Change the color of graphs
|
38
|
+
|
39
|
+
ex) growthforecast-client color 'http://{hostname}:{port}/list/{service_name}/{section_name}' -c '2xx_count:#1111cc' '3xx_count:#11cc11'
|
40
|
+
LONGDESC
|
41
|
+
option :colors, :type => :hash, :aliases => '-c', :required => true, :banner => 'GRAPH_NAME:COLOR ...'
|
42
|
+
def color(url)
|
43
|
+
colors = options[:colors]
|
44
|
+
|
45
|
+
base_uri, service_name, section_name, graph_name = split_url(url)
|
46
|
+
@client = client(base_uri)
|
47
|
+
|
48
|
+
graphs = @client.list_graph(service_name, section_name, graph_name)
|
49
|
+
setup_colors(colors, graphs)
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'create_complex <url>', 'create complex graphs'
|
53
|
+
long_desc <<-LONGDESC
|
54
|
+
Create complex graphs under a url
|
55
|
+
|
56
|
+
ex) growthforecast-client create_complex 'http://{hostname}:{port}/list/{service_name}' -f 2xx_count 3xx_count -t status_count
|
57
|
+
LONGDESC
|
58
|
+
option :from_graphs, :type => :array, :aliases => '-f', :required => true, :banner => 'GRAPH_NAMES ...'
|
59
|
+
option :to_complex, :type => :string, :aliases => '-t', :required => true
|
60
|
+
def create_complex(url)
|
61
|
+
from_graphs, to_complex = options[:from_graphs], options[:to_complex]
|
62
|
+
base_uri, service_name, section_name, graph_name = split_url(url)
|
63
|
+
@client = client(base_uri)
|
64
|
+
|
65
|
+
graphs = @client.list_graph(service_name, section_name, graph_name)
|
66
|
+
setup_complex(from_graphs, to_complex, graphs)
|
67
|
+
end
|
68
|
+
|
69
|
+
no_tasks do
|
70
|
+
def delete_graphs(graphs, graph_names = nil, section_names = nil)
|
71
|
+
graphs.each do |graph|
|
72
|
+
service_name, section_name, graph_name = graph['service_name'], graph['section_name'], graph['graph_name']
|
73
|
+
next if section_names and !section_names.include?(section_name)
|
74
|
+
next if graph_names and !graph_names.include?(graph_name)
|
75
|
+
|
76
|
+
puts "Delete #{service_name}/#{section_name}/#{graph_name}" unless @options[:silent]
|
77
|
+
exec { @client.delete_graph(service_name, section_name, graph_name) }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete_complexes(complexes, graph_names = nil, section_names = nil)
|
82
|
+
complexes.each do |graph|
|
83
|
+
service_name, section_name, graph_name = graph['service_name'], graph['section_name'], graph['graph_name']
|
84
|
+
next if section_names and !section_names.include?(section_name)
|
85
|
+
next if graph_names and !graph_names.include?(graph_name)
|
86
|
+
|
87
|
+
puts "Delete #{service_name}/#{section_name}/#{graph_name}" unless @options[:silent]
|
88
|
+
exec { @client.delete_complex(service_name, section_name, graph_name) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def setup_colors(colors, graphs)
|
93
|
+
graphs.each do |graph|
|
94
|
+
service_name, section_name, graph_name = graph['service_name'], graph['section_name'], graph['graph_name']
|
95
|
+
next unless color = colors[graph_name]
|
96
|
+
|
97
|
+
params = { 'color' => color }
|
98
|
+
puts "Setup #{service_name}/#{section_name}/#{graph_name} with #{color}" unless @options[:silent]
|
99
|
+
exec { @client.edit_graph(service_name, section_name, graph_name, params) }
|
23
100
|
end
|
24
101
|
end
|
25
|
-
|
26
|
-
|
102
|
+
|
103
|
+
def setup_complex(from_graphs, to_complex, graphs)
|
104
|
+
from_graph_first = from_graphs.first
|
105
|
+
graphs.each do |graph|
|
106
|
+
service_name, section_name, graph_name = graph['service_name'], graph['section_name'], graph['graph_name']
|
107
|
+
next unless graph_name == from_graph_first
|
108
|
+
|
109
|
+
base = { "service_name" => service_name, "section_name" => section_name, "gmode" => 'gauge', "stack" => true, "type" => 'AREA' }
|
110
|
+
from_graphs_params = from_graphs.map {|graph_name| base.merge('graph_name' => graph_name) }
|
111
|
+
to_complex_params = { "service_name" => service_name, "section_name" => section_name, "graph_name" => to_complex, "sort" => 0 }
|
112
|
+
|
113
|
+
puts "Setup #{service_name}/#{section_name}/#{to_complex} with #{from_graphs}" unless @options[:silent]
|
114
|
+
exec { @client.create_complex(from_graphs_params, to_complex_params) }
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def exec(&blk)
|
27
119
|
begin
|
28
|
-
|
29
|
-
puts "Deleted #{e graph['service_name']}/#{e graph['section_name']}/#{e graph['graph_name']}"
|
120
|
+
yield
|
30
121
|
rescue => e
|
31
|
-
puts "\tclass:#{e.class}\t#{e.message}"
|
122
|
+
$stderr.puts "\tclass:#{e.class}\t#{e.message}"
|
32
123
|
end
|
33
124
|
end
|
34
|
-
end
|
35
125
|
|
36
|
-
|
37
|
-
|
38
|
-
CGI.escape(str).gsub('+', '%20') if str
|
126
|
+
def client(base_uri)
|
127
|
+
GrowthForecast::Client.new(base_uri)
|
39
128
|
end
|
40
129
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
130
|
+
def split_url(url)
|
131
|
+
uri = URI.parse(url)
|
132
|
+
base_uri = "#{uri.scheme}://#{uri.host}:#{uri.port}"
|
133
|
+
[base_uri] + split_path(uri.path)
|
44
134
|
end
|
45
135
|
|
46
|
-
def
|
47
|
-
|
136
|
+
def split_path(path)
|
137
|
+
path = path.gsub(/.*list\/?/, '').gsub(/.*view_graph\/?/, '')
|
138
|
+
path.split('/').map {|p| CGI.unescape(p.gsub('%20', '+')) }
|
48
139
|
end
|
49
140
|
end
|
50
141
|
end
|
@@ -100,8 +100,8 @@ module GrowthForecast
|
|
100
100
|
# "section_name2",
|
101
101
|
# ],
|
102
102
|
# }
|
103
|
-
def list_section
|
104
|
-
graphs = list_graph
|
103
|
+
def list_section(service_name = nil, section_name = nil, graph_name = nil)
|
104
|
+
graphs = list_graph(service_name, section_name, graph_name)
|
105
105
|
services = {}
|
106
106
|
graphs.each do |graph|
|
107
107
|
service_name, section_name = graph['service_name'], graph['section_name']
|
@@ -118,8 +118,8 @@ module GrowthForecast
|
|
118
118
|
# "service_name1",
|
119
119
|
# "service_name2",
|
120
120
|
# ]
|
121
|
-
def list_service
|
122
|
-
graphs = list_graph
|
121
|
+
def list_service(service_name = nil, section_name = nil, graph_name = nil)
|
122
|
+
graphs = list_graph(service_name, section_name, graph_name)
|
123
123
|
services = {}
|
124
124
|
graphs.each do |graph|
|
125
125
|
service_name = graph['service_name']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: growthforecast-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.62.
|
4
|
+
version: 0.62.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.0.
|
160
|
+
rubygems_version: 2.0.3
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: A Ruby Client Library for GrowthForecast API
|