gazer 0.3.2 → 0.3.4
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 +8 -0
- data/lib/gzr/command.rb +9 -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/model/cat.rb +58 -0
- data/lib/gzr/commands/model/import.rb +57 -0
- data/lib/gzr/commands/model.rb +29 -0
- data/lib/gzr/commands/project/branch.rb +96 -0
- data/lib/gzr/commands/project/cat.rb +58 -0
- data/lib/gzr/commands/project/checkout.rb +65 -0
- data/lib/gzr/commands/project/deploy.rb +65 -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 +151 -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/connection.rb +80 -0
- data/lib/gzr/modules/model.rb +29 -0
- data/lib/gzr/modules/project.rb +155 -0
- data/lib/gzr/modules/session.rb +81 -7
- data/lib/gzr/version.rb +1 -1
- metadata +23 -2
@@ -0,0 +1,151 @@
|
|
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
|
+
desc 'branch PROJECT_ID', 'List the active branch or all branches of PROJECT_ID'
|
103
|
+
method_option :help, aliases: '-h', type: :boolean,
|
104
|
+
desc: 'Display usage information'
|
105
|
+
method_option :all, type: :boolean, default: false,
|
106
|
+
desc: 'List all branches, not just the active branch'
|
107
|
+
method_option :fields, type: :string, default: 'name,error,message',
|
108
|
+
desc: 'Fields to display'
|
109
|
+
method_option :plain, type: :boolean, default: false,
|
110
|
+
desc: 'print without any extra formatting'
|
111
|
+
method_option :csv, type: :boolean, default: false,
|
112
|
+
desc: 'output in csv format per RFC4180'
|
113
|
+
|
114
|
+
def branch(project_id)
|
115
|
+
if options[:help]
|
116
|
+
invoke :help, ['branch']
|
117
|
+
else
|
118
|
+
require_relative 'project/branch'
|
119
|
+
Gzr::Commands::Project::Branch.new(project_id, options).execute
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
desc 'deploy PROJECT_ID', 'Deploy the active branch of PROJECT_ID to production'
|
124
|
+
method_option :help, aliases: '-h', type: :boolean,
|
125
|
+
desc: 'Display usage information'
|
126
|
+
|
127
|
+
def deploy(project_id)
|
128
|
+
if options[:help]
|
129
|
+
invoke :help, ['deploy']
|
130
|
+
else
|
131
|
+
require_relative 'project/deploy'
|
132
|
+
Gzr::Commands::Project::Deploy.new(project_id, options).execute
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
desc 'checkout PROJECT_ID NAME', 'Change the active branch of PROJECT_ID to NAME'
|
137
|
+
method_option :help, aliases: '-h', type: :boolean,
|
138
|
+
desc: 'Display usage information'
|
139
|
+
|
140
|
+
def checkout(project_id,name)
|
141
|
+
if options[:help]
|
142
|
+
invoke :help, ['checkout']
|
143
|
+
else
|
144
|
+
require_relative 'project/checkout'
|
145
|
+
Gzr::Commands::Project::Checkout.new(project_id, name, options).execute
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
end
|
151
|
+
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
|
@@ -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
|
+
|
26
|
+
module Gzr
|
27
|
+
module Commands
|
28
|
+
class Session
|
29
|
+
class Logout < 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
|
+
@sdk.logout
|
39
|
+
token_data = read_token_data || {}
|
40
|
+
token_data[@options[:host].to_sym] ||= {}
|
41
|
+
token_data[@options[:host].to_sym]&.delete(@options[:su]&.to_sym || :default)
|
42
|
+
write_token_data(token_data)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,51 @@
|
|
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 Update < Gzr::Command
|
31
|
+
include Gzr::Session
|
32
|
+
def initialize(workspace_id,options)
|
33
|
+
super()
|
34
|
+
@options = options
|
35
|
+
@workspace_id = workspace_id
|
36
|
+
end
|
37
|
+
|
38
|
+
def execute(input: $stdin, output: $stdout)
|
39
|
+
say_warning(@options) if @options[:debug]
|
40
|
+
if !@options[:token] && !@options[:token_file]
|
41
|
+
say_warning "Setting the session workspace_id only makes sense with a persistent session using --token or --token_file options"
|
42
|
+
end
|
43
|
+
with_session do
|
44
|
+
auth = update_auth(@workspace_id)
|
45
|
+
output.puts JSON.pretty_generate(auth)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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 Session < Thor
|
29
|
+
|
30
|
+
namespace :session
|
31
|
+
|
32
|
+
desc 'login', 'Create a persistent session'
|
33
|
+
method_option :text, type: :boolean, default: false,
|
34
|
+
desc: 'output token to screen instead of file'
|
35
|
+
def login(*)
|
36
|
+
if options[:help]
|
37
|
+
invoke :help, ['login']
|
38
|
+
else
|
39
|
+
require_relative 'session/login'
|
40
|
+
Gzr::Commands::Session::Login.new(options).execute
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'logout', 'End a persistent session'
|
45
|
+
def logout(*)
|
46
|
+
if options[:help]
|
47
|
+
invoke :help, ['logout']
|
48
|
+
else
|
49
|
+
require_relative 'session/logout'
|
50
|
+
Gzr::Commands::Session::Logout.new(options).execute
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'get', 'Get data about current session'
|
55
|
+
def get(*)
|
56
|
+
if options[:help]
|
57
|
+
invoke :help, ['get']
|
58
|
+
else
|
59
|
+
require_relative 'session/get'
|
60
|
+
Gzr::Commands::Session::Get.new(options).execute
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
desc 'update WORKSPACE_ID', 'change the workspace_id of the current session'
|
65
|
+
def update(workspace_id)
|
66
|
+
if options[:help]
|
67
|
+
invoke :help, ['update']
|
68
|
+
else
|
69
|
+
require_relative 'session/update'
|
70
|
+
Gzr::Commands::Session::Update.new(workspace_id,options).execute
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -48,5 +48,85 @@ module Gzr
|
|
48
48
|
data
|
49
49
|
end
|
50
50
|
|
51
|
+
def test_connection(name, tests=nil)
|
52
|
+
data = nil
|
53
|
+
|
54
|
+
if tests.nil?
|
55
|
+
connection = cat_connection(name)
|
56
|
+
if connection.nil?
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
tests = connection[:dialect][:connection_tests]
|
60
|
+
end
|
61
|
+
|
62
|
+
begin
|
63
|
+
data = @sdk.test_connection(name, {}, tests: tests)
|
64
|
+
rescue LookerSDK::NotFound => e
|
65
|
+
return nil
|
66
|
+
rescue LookerSDK::Error => e
|
67
|
+
say_error "Error executing test_connection(#{name},#{tests})"
|
68
|
+
say_error e
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
data
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete_connection(name)
|
75
|
+
begin
|
76
|
+
@sdk.delete_connection(name)
|
77
|
+
rescue LookerSDK::NotFound => e
|
78
|
+
say_warning "Connection #{name} not found"
|
79
|
+
rescue LookerSDK::Error => e
|
80
|
+
say_error "Error executing delete_connection(#{name})"
|
81
|
+
say_error e
|
82
|
+
raise
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_connection(body)
|
87
|
+
data = nil
|
88
|
+
begin
|
89
|
+
data = @sdk.create_connection(body).to_attrs
|
90
|
+
rescue LookerSDK::Error => e
|
91
|
+
say_error "Error executing create_connection(#{JSON.pretty_generate(body)})"
|
92
|
+
say_error e
|
93
|
+
raise
|
94
|
+
end
|
95
|
+
data
|
96
|
+
end
|
97
|
+
|
98
|
+
def update_connection(name,body)
|
99
|
+
data = nil
|
100
|
+
begin
|
101
|
+
data = @sdk.connection(name,body).to_attrs
|
102
|
+
rescue LookerSDK::NotFound => e
|
103
|
+
say_warning "Connection #{name} not found"
|
104
|
+
rescue LookerSDK::Error => e
|
105
|
+
say_error "Error executing update_connection(#{name},#{JSON.pretty_generate(body)})"
|
106
|
+
say_error e
|
107
|
+
raise
|
108
|
+
end
|
109
|
+
data
|
110
|
+
end
|
111
|
+
|
112
|
+
def cat_connection(name)
|
113
|
+
data = nil
|
114
|
+
begin
|
115
|
+
data = @sdk.connection(name).to_attrs
|
116
|
+
rescue LookerSDK::NotFound => e
|
117
|
+
return nil
|
118
|
+
rescue LookerSDK::Error => e
|
119
|
+
say_error "Error executing connection(#{name})"
|
120
|
+
say_error e
|
121
|
+
raise
|
122
|
+
end
|
123
|
+
data
|
124
|
+
end
|
125
|
+
|
126
|
+
def trim_connection(data)
|
127
|
+
data.select do |k,v|
|
128
|
+
(keys_to_keep('create_connection') + [:pdt_context_override]).include? k
|
129
|
+
end
|
130
|
+
end
|
51
131
|
end
|
52
132
|
end
|
data/lib/gzr/modules/model.rb
CHANGED
@@ -36,5 +36,34 @@ module Gzr
|
|
36
36
|
end
|
37
37
|
data
|
38
38
|
end
|
39
|
+
|
40
|
+
def cat_model(model_name)
|
41
|
+
begin
|
42
|
+
return @sdk.lookml_model(model_name)&.to_attrs
|
43
|
+
rescue LookerSDK::NotFound => e
|
44
|
+
return nil
|
45
|
+
rescue LookerSDK::Error => e
|
46
|
+
say_error "Error getting lookml_model(#{model_name})"
|
47
|
+
say_error e
|
48
|
+
raise
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def trim_model(data)
|
53
|
+
data.select do |k,v|
|
54
|
+
keys_to_keep('create_lookml_model').include? k
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def create_model(body)
|
59
|
+
begin
|
60
|
+
return @sdk.create_lookml_model(body)&.to_attrs
|
61
|
+
rescue LookerSDK::Error => e
|
62
|
+
say_error "Error running create_lookml_model(#{JSON.pretty_generate(body)})"
|
63
|
+
say_error e
|
64
|
+
raise
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
39
68
|
end
|
40
69
|
end
|