-
Notifications
You must be signed in to change notification settings - Fork 0
/
lognit_rest.rb
78 lines (57 loc) · 1.58 KB
/
lognit_rest.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
ROOT = File.expand_path(File.join(File.dirname(__FILE__)))
#Acerto o LOAD PATH
$: << ROOT
require 'rubygems'
require 'rest-client'
require 'json'
require 'pp'
require "logger"
require 'lib/parse'
require 'lib/lognit_client'
require 'lib/commands'
#RestClient.log = Logger.new(STDOUT)
parse()
def print_line
puts "------------------------------------------------"
end
url = "#{OPTIONS[:lognit_url]}#{RESOURCES[:log_groups]}"
puts "login: #{OPTIONS[:login]}"
puts "lognit_url: #{OPTIONS[:lognit_url]}"
puts "url: #{url}"
print_line()
lognit_client = Lognit::Client.new("#{OPTIONS[:lognit_url]}", "#{OPTIONS[:login]}", "#{OPTIONS[:password]}")
lognit_client.login
if OPTIONS[:delete_all_groups]
lognit_client.url = RESOURCES[:group]
log_groups = group.list_groups
pp "------"
log_groups.each do |log_group|
pp "#{log_group['name']} -> #{log_group['id']}"
lognit_client.delete_group(log_group['id'])
end
end
if OPTIONS[:create_groups]
lognit_client.url = RESOURCES[:group]
(1..5).each do |n|
puts "Criando grupo: #{n}"
lognit_client.create_group(lognit_client.get_data(n))
end
end
if OPTIONS[:stats]
Lognit::Command.command_stat(lognit_client)
end
if OPTIONS[:import_user]
Lognit::Command.command_importa_usuario(lognit_client)
end
if OPTIONS[:import_team]
Lognit::Command.command_importa_time(lognit_client)
end
if OPTIONS[:export_group]
Lognit::Command.command_export_group(lognit_client)
end
if OPTIONS[:import_group]
Lognit::Command.command_import_group(lognit_client)
end
if OPTIONS[:report]
Lognit::Command.report(lognit_client)
end