gazer 0.3.1 → 0.3.3
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 +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +1 -1
- data/lib/gzr/cli.rb +12 -1
- data/lib/gzr/command.rb +82 -1
- data/lib/gzr/commands/alert/cat.rb +52 -0
- data/lib/gzr/commands/alert/chown.rb +48 -0
- data/lib/gzr/commands/alert/delete.rb +47 -0
- data/lib/gzr/commands/alert/disable.rb +48 -0
- data/lib/gzr/commands/alert/enable.rb +47 -0
- data/lib/gzr/commands/alert/follow.rb +47 -0
- data/lib/gzr/commands/alert/import.rb +65 -0
- data/lib/gzr/commands/alert/ls.rb +76 -0
- data/lib/gzr/commands/alert/notifications.rb +74 -0
- data/lib/gzr/commands/alert/read.rb +49 -0
- data/lib/gzr/commands/alert/threshold.rb +48 -0
- data/lib/gzr/commands/alert/unfollow.rb +47 -0
- data/lib/gzr/commands/alert.rb +200 -0
- data/lib/gzr/commands/connection/cat.rb +66 -0
- data/lib/gzr/commands/connection/import.rb +78 -0
- data/lib/gzr/commands/connection/rm.rb +50 -0
- data/lib/gzr/commands/connection/test.rb +69 -0
- data/lib/gzr/commands/connection.rb +67 -1
- data/lib/gzr/commands/dashboard/cat.rb +1 -1
- data/lib/gzr/commands/dashboard/import.rb +12 -1
- data/lib/gzr/commands/project/cat.rb +58 -0
- data/lib/gzr/commands/project/deploy_key.rb +60 -0
- data/lib/gzr/commands/project/import.rb +68 -0
- data/lib/gzr/commands/project/ls.rb +73 -0
- data/lib/gzr/commands/project/update.rb +69 -0
- data/lib/gzr/commands/project.rb +104 -0
- data/lib/gzr/commands/session/get.rb +47 -0
- data/lib/gzr/commands/session/login.rb +50 -0
- data/lib/gzr/commands/session/logout.rb +47 -0
- data/lib/gzr/commands/session/update.rb +51 -0
- data/lib/gzr/commands/session.rb +76 -0
- data/lib/gzr/modules/alert.rb +169 -0
- data/lib/gzr/modules/connection.rb +80 -0
- data/lib/gzr/modules/dashboard.rb +23 -2
- data/lib/gzr/modules/project.rb +106 -0
- data/lib/gzr/modules/session.rb +81 -7
- data/lib/gzr/version.rb +1 -1
- metadata +32 -2
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -64,6 +64,72 @@ module Gzr
|
|
64
64
|
Gzr::Commands::Connection::Ls.new(options).execute
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
desc 'cat CONNECTION_NAME', 'Output the JSON representation of a connection to the screen or a file'
|
69
|
+
method_option :help, aliases: '-h', type: :boolean,
|
70
|
+
desc: 'Display usage information'
|
71
|
+
method_option :dir, type: :string,
|
72
|
+
desc: 'Directory to store output file'
|
73
|
+
method_option :simple_filename, type: :boolean,
|
74
|
+
desc: 'Use simple filename for output (Connection_<id>.json)'
|
75
|
+
method_option :trim, type: :boolean,
|
76
|
+
desc: 'Trim output to minimal set of fields for later import'
|
77
|
+
def cat(connection_name)
|
78
|
+
if options[:help]
|
79
|
+
invoke :help, ['cat']
|
80
|
+
else
|
81
|
+
require_relative 'connection/cat'
|
82
|
+
Gzr::Commands::Connection::Cat.new(connection_name, options).execute
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'rm CONNECTION_NAME', 'Delete a connection'
|
87
|
+
method_option :help, aliases: '-h', type: :boolean,
|
88
|
+
desc: 'Display usage information'
|
89
|
+
def rm(connection_name)
|
90
|
+
if options[:help]
|
91
|
+
invoke :help, ['rm']
|
92
|
+
else
|
93
|
+
require_relative 'connection/rm'
|
94
|
+
Gzr::Commands::Connection::Rm.new(connection_name, options).execute
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
desc 'import FILE', 'Import a connection from a file'
|
99
|
+
method_option :help, aliases: '-h', type: :boolean,
|
100
|
+
desc: 'Display usage information'
|
101
|
+
method_option :force, type: :boolean,
|
102
|
+
desc: 'Overwrite an existing connection'
|
103
|
+
method_option :prompt, type: :boolean,
|
104
|
+
desc: 'Prompt for the password'
|
105
|
+
method_option :plain, type: :boolean, default: false,
|
106
|
+
desc: 'print without any extra formatting'
|
107
|
+
def import(file)
|
108
|
+
if options[:help]
|
109
|
+
invoke :help, ['import']
|
110
|
+
else
|
111
|
+
require_relative 'connection/import'
|
112
|
+
Gzr::Commands::Connection::Import.new(file, options).execute
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
desc 'test CONNECTION_NAME', 'Test the given connection'
|
117
|
+
method_option :help, aliases: '-h', type: :boolean,
|
118
|
+
desc: 'Display usage information'
|
119
|
+
method_option :fields, type: :string, default: 'name,status,message',
|
120
|
+
desc: 'Fields to display'
|
121
|
+
method_option :plain, type: :boolean, default: false,
|
122
|
+
desc: 'print without any extra formatting'
|
123
|
+
method_option :csv, type: :boolean, default: false,
|
124
|
+
desc: 'output in csv format per RFC4180'
|
125
|
+
def test(connection_name)
|
126
|
+
if options[:help]
|
127
|
+
invoke :help, ['test']
|
128
|
+
else
|
129
|
+
require_relative 'connection/test'
|
130
|
+
Gzr::Commands::Connection::Test.new(connection_name,options).execute
|
131
|
+
end
|
132
|
+
end
|
67
133
|
end
|
68
134
|
end
|
69
135
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License (MIT)
|
2
2
|
|
3
|
-
# Copyright (c)
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
4
|
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
6
|
# this software and associated documentation files (the "Software"), to deal in
|
@@ -89,6 +89,17 @@ module Gzr
|
|
89
89
|
element[:result_maker] = result_maker if result_maker
|
90
90
|
dashboard_element = create_dashboard_element(element)
|
91
91
|
say_warning "dashboard_element #{dashboard_element.inspect}" if @options[:debug]
|
92
|
+
if new_element[:alerts]
|
93
|
+
new_element[:alerts].each do |a|
|
94
|
+
a.select! do |k,v|
|
95
|
+
(keys_to_keep('create_alert') - [:owner_id, :dashboard_element_id]).include? k
|
96
|
+
end
|
97
|
+
a[:dashboard_element_id] = dashboard_element[:id]
|
98
|
+
a[:owner_id] = @me[:id]
|
99
|
+
new_alert = create_alert(a)
|
100
|
+
say_warning "alert #{JSON.pretty_generate(new_alert)}" if @options[:debug]
|
101
|
+
end
|
102
|
+
end
|
92
103
|
dashboard[:dashboard_elements].push dashboard_element
|
93
104
|
[new_element[:id], dashboard_element.id]
|
94
105
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../command'
|
25
|
+
require_relative '../../modules/project'
|
26
|
+
require_relative '../../modules/filehelper'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Project
|
31
|
+
class Cat < Gzr::Command
|
32
|
+
include Gzr::Project
|
33
|
+
include Gzr::FileHelper
|
34
|
+
def initialize(project_id,options)
|
35
|
+
super()
|
36
|
+
@project_id = project_id
|
37
|
+
@options = options
|
38
|
+
end
|
39
|
+
|
40
|
+
def execute(input: $stdin, output: $stdout)
|
41
|
+
say_warning(@options) if @options[:debug]
|
42
|
+
with_session do
|
43
|
+
data = cat_project(@project_id)
|
44
|
+
if data.nil?
|
45
|
+
say_warning "Project #{@project_id} not found"
|
46
|
+
return
|
47
|
+
end
|
48
|
+
data = trim_project(data) if @options[:trim]
|
49
|
+
|
50
|
+
write_file(@options[:dir] ? "Project_#{data[:id]}.json" : nil, @options[:dir],nil, output) do |f|
|
51
|
+
f.puts JSON.pretty_generate(data)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../../gzr'
|
25
|
+
require_relative '../../command'
|
26
|
+
require_relative '../../modules/project'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Project
|
31
|
+
class DeployKey < Gzr::Command
|
32
|
+
include Gzr::Project
|
33
|
+
def initialize(id,options)
|
34
|
+
super()
|
35
|
+
@id = id
|
36
|
+
@options = options
|
37
|
+
end
|
38
|
+
|
39
|
+
def execute(input: $stdin, output: $stdout)
|
40
|
+
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
41
|
+
with_session do
|
42
|
+
if get_auth()[:workspace_id] == 'production'
|
43
|
+
say_warning %Q(
|
44
|
+
This command only works in dev mode. Use persistent sessions and
|
45
|
+
change to dev mode before running this command.
|
46
|
+
|
47
|
+
$ gzr session login --host looker.example.com
|
48
|
+
$ gzr session update dev --token_file --host looker.example.com
|
49
|
+
$ # run the command requiring dev mode here with the --token_file switch
|
50
|
+
$ gzr session logout --token_file --host looker.example.com
|
51
|
+
)
|
52
|
+
end
|
53
|
+
key = git_deploy_key(@id) || create_git_deploy_key(@id)
|
54
|
+
output.puts key
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../../gzr'
|
25
|
+
require_relative '../../command'
|
26
|
+
require_relative '../../modules/project'
|
27
|
+
require_relative '../../modules/filehelper'
|
28
|
+
|
29
|
+
module Gzr
|
30
|
+
module Commands
|
31
|
+
class Project
|
32
|
+
class Import < Gzr::Command
|
33
|
+
include Gzr::Project
|
34
|
+
include Gzr::FileHelper
|
35
|
+
def initialize(file, options)
|
36
|
+
super()
|
37
|
+
@file = file
|
38
|
+
@options = options
|
39
|
+
end
|
40
|
+
|
41
|
+
def execute(input: $stdin, output: $stdout)
|
42
|
+
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
43
|
+
with_session do
|
44
|
+
if get_auth()[:workspace_id] == 'production'
|
45
|
+
say_warning %Q(
|
46
|
+
This command only works in dev mode. Use persistent sessions and
|
47
|
+
change to dev mode before running this command.
|
48
|
+
|
49
|
+
$ gzr session login --host looker.example.com
|
50
|
+
$ gzr session update dev --token_file --host looker.example.com
|
51
|
+
$ # run the command requiring dev mode here with the --token_file switch
|
52
|
+
$ gzr session logout --token_file --host looker.example.com
|
53
|
+
)
|
54
|
+
end
|
55
|
+
read_file(@file) do |data|
|
56
|
+
data.select! do |k,v|
|
57
|
+
(keys_to_keep('create_project') - [:git_remote_url]).include? k
|
58
|
+
end
|
59
|
+
project = create_project(data)
|
60
|
+
output.puts "Created project #{project[:id]}" unless @options[:plain]
|
61
|
+
output.puts project[:id] if @options[:plain]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2018 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../command'
|
25
|
+
require_relative '../../modules/project'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Project
|
31
|
+
class Ls < Gzr::Command
|
32
|
+
include Gzr::Project
|
33
|
+
def initialize(options)
|
34
|
+
super()
|
35
|
+
@options = options
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(input: $stdin, output: $stdout)
|
39
|
+
say_warning(@options) if @options[:debug]
|
40
|
+
with_session do
|
41
|
+
say_warning "querying all_projects({ fields: '#{@options[:fields]}' })" if @options[:debug]
|
42
|
+
data = all_projects(fields: @options[:fields])
|
43
|
+
begin
|
44
|
+
say_ok "No projects found"
|
45
|
+
return nil
|
46
|
+
end unless data && data.length > 0
|
47
|
+
|
48
|
+
table_hash = Hash.new
|
49
|
+
fields = field_names(@options[:fields])
|
50
|
+
table_hash[:header] = fields unless @options[:plain]
|
51
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
52
|
+
table_hash[:rows] = data.map do |row|
|
53
|
+
expressions.collect do |e|
|
54
|
+
eval "row.#{e}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
table = TTY::Table.new(table_hash)
|
58
|
+
alignments = fields.collect do |k|
|
59
|
+
(k =~ /id$/) ? :right : :left
|
60
|
+
end
|
61
|
+
begin
|
62
|
+
if @options[:csv] then
|
63
|
+
output.puts render_csv(table)
|
64
|
+
else
|
65
|
+
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
|
66
|
+
end
|
67
|
+
end if table
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../../gzr'
|
25
|
+
require_relative '../../command'
|
26
|
+
require_relative '../../modules/project'
|
27
|
+
require_relative '../../modules/filehelper'
|
28
|
+
|
29
|
+
module Gzr
|
30
|
+
module Commands
|
31
|
+
class Project
|
32
|
+
class Update < Gzr::Command
|
33
|
+
include Gzr::Project
|
34
|
+
include Gzr::FileHelper
|
35
|
+
def initialize(id,file, options)
|
36
|
+
super()
|
37
|
+
@id = id
|
38
|
+
@file = file
|
39
|
+
@options = options
|
40
|
+
end
|
41
|
+
|
42
|
+
def execute(input: $stdin, output: $stdout)
|
43
|
+
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
44
|
+
with_session do
|
45
|
+
if get_auth()[:workspace_id] == 'production'
|
46
|
+
say_warning %Q(
|
47
|
+
This command only works in dev mode. Use persistent sessions and
|
48
|
+
change to dev mode before running this command.
|
49
|
+
|
50
|
+
$ gzr session login --host looker.example.com
|
51
|
+
$ gzr session update dev --token_file --host looker.example.com
|
52
|
+
$ # run the command requiring dev mode here with the --token_file switch
|
53
|
+
$ gzr session logout --token_file --host looker.example.com
|
54
|
+
)
|
55
|
+
end
|
56
|
+
read_file(@file) do |data|
|
57
|
+
data.select! do |k,v|
|
58
|
+
keys_to_keep('update_project').include? k
|
59
|
+
end
|
60
|
+
project = update_project(@id, data)
|
61
|
+
output.puts "Updated project #{project[:id]}" unless @options[:plain]
|
62
|
+
output.puts project[:id] if @options[:plain]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require 'thor'
|
25
|
+
|
26
|
+
module Gzr
|
27
|
+
module Commands
|
28
|
+
class Project < Thor
|
29
|
+
|
30
|
+
namespace :project
|
31
|
+
|
32
|
+
desc 'ls', 'List all projects'
|
33
|
+
method_option :help, aliases: '-h', type: :boolean,
|
34
|
+
desc: 'Display usage information'
|
35
|
+
method_option :fields, type: :string, default: 'id,name,git_production_branch_name',
|
36
|
+
desc: 'Fields to display'
|
37
|
+
method_option :plain, type: :boolean, default: false,
|
38
|
+
desc: 'print without any extra formatting'
|
39
|
+
method_option :csv, type: :boolean, default: false,
|
40
|
+
desc: 'output in csv format per RFC4180'
|
41
|
+
|
42
|
+
def ls(*)
|
43
|
+
if options[:help]
|
44
|
+
invoke :help, ['ls']
|
45
|
+
else
|
46
|
+
require_relative 'project/ls'
|
47
|
+
Gzr::Commands::Project::Ls.new(options).execute
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'cat PROJECT_ID', 'Output json information about a project to screen or file'
|
52
|
+
method_option :help, aliases: '-h', type: :boolean,
|
53
|
+
desc: 'Display usage information'
|
54
|
+
method_option :dir, type: :string,
|
55
|
+
desc: 'Directory to store output file'
|
56
|
+
method_option :trim, type: :boolean,
|
57
|
+
desc: 'Trim output to minimal set of fields for later import'
|
58
|
+
def cat(project_id)
|
59
|
+
if options[:help]
|
60
|
+
invoke :help, ['cat']
|
61
|
+
else
|
62
|
+
require_relative 'project/cat'
|
63
|
+
Gzr::Commands::Project::Cat.new(project_id,options).execute
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'import PROJECT_FILE', 'Import a project from a file containing json information'
|
68
|
+
method_option :help, aliases: '-h', type: :boolean,
|
69
|
+
desc: 'Display usage information'
|
70
|
+
def import(project_file)
|
71
|
+
if options[:help]
|
72
|
+
invoke :help, ['import']
|
73
|
+
else
|
74
|
+
require_relative 'project/import'
|
75
|
+
Gzr::Commands::Project::Import.new(project_file,options).execute
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'update PROJECT_ID PROJECT_FILE', 'Update the given project from a file containing json information'
|
80
|
+
method_option :help, aliases: '-h', type: :boolean,
|
81
|
+
desc: 'Display usage information'
|
82
|
+
def update(project_id,project_file)
|
83
|
+
if options[:help]
|
84
|
+
invoke :help, ['update']
|
85
|
+
else
|
86
|
+
require_relative 'project/update'
|
87
|
+
Gzr::Commands::Project::Update.new(project_id,project_file,options).execute
|
88
|
+
end
|
89
|
+
end
|
90
|
+
desc 'deploy_key PROJECT_ID', 'Generate a git deploy public key for the given project'
|
91
|
+
method_option :help, aliases: '-h', type: :boolean,
|
92
|
+
desc: 'Display usage information'
|
93
|
+
def deploy_key(project_id)
|
94
|
+
if options[:help]
|
95
|
+
invoke :help, ['deploy_key']
|
96
|
+
else
|
97
|
+
require_relative 'project/deploy_key'
|
98
|
+
Gzr::Commands::Project::DeployKey.new(project_id,options).execute
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../command'
|
25
|
+
require_relative '../../modules/session'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Session
|
30
|
+
class Get < Gzr::Command
|
31
|
+
include Gzr::Session
|
32
|
+
def initialize(options)
|
33
|
+
super()
|
34
|
+
@options = options
|
35
|
+
end
|
36
|
+
|
37
|
+
def execute(input: $stdin, output: $stdout)
|
38
|
+
say_warning(@options) if @options[:debug]
|
39
|
+
with_session do
|
40
|
+
auth = get_auth()
|
41
|
+
output.puts JSON.pretty_generate(auth)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
# Copyright (c) 2023 Mike DeAngelo Google, Inc.
|
4
|
+
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
# this software and associated documentation files (the "Software"), to deal in
|
7
|
+
# the Software without restriction, including without limitation the rights to
|
8
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
# frozen_string_literal: true
|
23
|
+
|
24
|
+
require_relative '../../command'
|
25
|
+
|
26
|
+
module Gzr
|
27
|
+
module Commands
|
28
|
+
class Session
|
29
|
+
class Login < Gzr::Command
|
30
|
+
def initialize(options)
|
31
|
+
super()
|
32
|
+
@options = options
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute(input: $stdin, output: $stdout)
|
36
|
+
say_warning(@options) if @options[:debug]
|
37
|
+
login
|
38
|
+
if @options[:text]
|
39
|
+
puts @sdk.access_token
|
40
|
+
return
|
41
|
+
end
|
42
|
+
token_data = read_token_data || {}
|
43
|
+
token_data[@options[:host].to_sym] ||= {}
|
44
|
+
token_data[@options[:host].to_sym][@options[:su]&.to_sym || :default] = { token: @sdk.access_token, expiration: @sdk.access_token_expires_at }
|
45
|
+
write_token_data(token_data)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|