gazer 0.3.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e630fbc5e90c7e94aab072a64ab725a78478dac8d6009b1b61c753af0146d13e
4
- data.tar.gz: 4c2f9b5227addbc40bc59f813f0139bcb4b56622f87ba71d975c8ab9f7c7040c
3
+ metadata.gz: 1c61028240f2447955b2ec8ca55f0db60e8c16d85a0d2a28f4c8062ec694672f
4
+ data.tar.gz: a315cc287b53fa158e641689a2ee1d5d372ed05d86883001f0d8b9c811247dca
5
5
  SHA512:
6
- metadata.gz: 8ed72435dbf7192b52d45c67bf3180f27d3b3a1bef4575748ea28762df6c63449712256b9313a4456f4ee2d60835f1a727490fc699d86930db3bfdccfd5d92ef
7
- data.tar.gz: 7b0998e2ffe58768867e66fc345450bd0e365de1936a09d8de4cb56f689ee283896b326dc27dc5ab3ac49a9f79a1c7d5364cbff152be0335d8e3c3d206fada63
6
+ metadata.gz: c4aa949c1e34750273e010eebe97ed06b4a1cefbbd93113331d696ef13683c79fc7b8fcdc9c5e1563eaff7a4bee0a291966bc23b0d3e697fe7aa55d2494f08aa
7
+ data.tar.gz: c00cf477e61dc797288ee6129b0f8b825408a088fc3badba6a5d9a3f60775f7043647bf2200f1171440ca8019d1330e939e545442aca855e72ccc86eebab9cf0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.3](https://github.com/looker-open-source/gzr/compare/v0.3.2...v0.3.3) (2023-05-02)
4
+
5
+
6
+ ### Features
7
+
8
+ * Connection handling with Gazer ([#184](https://github.com/looker-open-source/gzr/issues/184)) ([346c9b7](https://github.com/looker-open-source/gzr/commit/346c9b7ea846acd604dbe929fab71e2ae0a5cf71))
9
+ * get and create deplpy keys for git. ([7b4a9e2](https://github.com/looker-open-source/gzr/commit/7b4a9e225596f54b6ec58d4923ac9e3d73106bd6))
10
+ * import and update a project ([#186](https://github.com/looker-open-source/gzr/issues/186)) ([825ab29](https://github.com/looker-open-source/gzr/commit/825ab297e99b4c09721bda3c72fce969fd16c5e8))
11
+ * Persistent tokens for login ([#182](https://github.com/looker-open-source/gzr/issues/182)) ([482c00f](https://github.com/looker-open-source/gzr/commit/482c00f4cb40519a3d3e7aac771e3b52c553e5d1))
12
+ * Project management and session management additions ([#185](https://github.com/looker-open-source/gzr/issues/185)) ([0093a60](https://github.com/looker-open-source/gzr/commit/0093a6057bd953773939fdf901631bab0e9109c6))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * wrong method called in project update ([165630d](https://github.com/looker-open-source/gzr/commit/165630d3dabbe2947a22a439e54f6692d21e013a))
18
+
3
19
  ## [0.3.2](https://github.com/looker-open-source/gzr/compare/v0.3.1...v0.3.2) (2023-04-21)
4
20
 
5
21
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.3.2)
4
+ gazer (0.3.3)
5
5
  faraday (~> 1.10.3)
6
6
  looker-sdk (~> 0.1.1)
7
7
  net-http-persistent (~> 4.0, >= 4.0.1)
data/lib/gzr/cli.rb CHANGED
@@ -46,6 +46,8 @@ module Gzr
46
46
  class_option :su, type: :string, desc: 'After connecting, change to user_id given'
47
47
  class_option :width, type: :numeric, default: nil, desc: 'Width of rendering for tables'
48
48
  class_option :persistent, type: :boolean, default: false, desc: 'Use persistent connection to communicate with host'
49
+ class_option :token, type: :string, default: nil, desc: "Access token to use for authentication"
50
+ class_option :token_file, type: :boolean, default: false, desc: "Use access token stored in file for authentication"
49
51
 
50
52
  # Error raised by this runner
51
53
  Error = Class.new(StandardError)
@@ -96,5 +98,11 @@ module Gzr
96
98
 
97
99
  require_relative 'commands/folder'
98
100
  register Gzr::Commands::Folder, 'folder', 'folder [SUBCOMMAND]', 'Commands pertaining to folders'
101
+
102
+ require_relative 'commands/session'
103
+ register Gzr::Commands::Session, 'session', 'session [SUBCOMMAND]', 'Commands pertaining to sessions'
104
+
105
+ require_relative 'commands/project'
106
+ register Gzr::Commands::Project, 'project', 'project [SUBCOMMAND]', 'Commands pertaining to projects'
99
107
  end
100
108
  end
data/lib/gzr/command.rb CHANGED
@@ -64,6 +64,15 @@ module Gzr
64
64
  user
65
65
  end
66
66
 
67
+ def get_auth()
68
+ begin
69
+ return @sdk.session()&.to_attrs
70
+ rescue LookerSDK::Error => e
71
+ say_error "Unable to run session()"
72
+ say_error e
73
+ end
74
+ end
75
+
67
76
  def query(query_id)
68
77
  data = nil
69
78
  begin
@@ -0,0 +1,66 @@
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 'json'
25
+ require_relative '../../command'
26
+ require_relative '../../modules/connection'
27
+ require_relative '../../modules/filehelper'
28
+
29
+ module Gzr
30
+ module Commands
31
+ class Connection
32
+ class Cat < Gzr::Command
33
+ include Gzr::Connection
34
+ include Gzr::FileHelper
35
+ def initialize(connection_id,options)
36
+ super()
37
+ @connection_id = connection_id
38
+ @options = options
39
+ end
40
+
41
+ def execute(*args, input: $stdin, output: $stdout)
42
+ say_warning("options: #{@options.inspect}") if @options[:debug]
43
+ with_session do
44
+ data = cat_connection(@connection_id)
45
+ if data.nil?
46
+ say_warning "Connection #{@connection_id} not found"
47
+ return
48
+ end
49
+ data = trim_connection(data) if @options[:trim]
50
+
51
+ outputJSON = JSON.pretty_generate(data)
52
+
53
+ file_name = if @options[:dir]
54
+ @options[:simple_filename] ? "Connection_#{data[:name]}.json" : "Connection_#{data[:name]}_#{data[:dialect_name]}.json"
55
+ else
56
+ nil
57
+ end
58
+ write_file(file_name, @options[:dir], nil, output) do |f|
59
+ f.puts outputJSON
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,78 @@
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/connection'
27
+ require_relative '../../modules/filehelper'
28
+
29
+ module Gzr
30
+ module Commands
31
+ class Connection
32
+ class Import < Gzr::Command
33
+ include Gzr::Connection
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
+ connection = nil
45
+
46
+ if @options[:prompt]
47
+ reader = TTY::Reader.new
48
+ @secret = reader.read_line("Enter your connection password:", echo: false)
49
+ @secret.chomp!
50
+ end
51
+
52
+ read_file(@file) do |data|
53
+ if !!cat_connection(data[:name])
54
+ name = data[:name]
55
+ if !@options[:force]
56
+ raise Gzr::CLI::Error, "Connection #{name} already exists\nUse --force if you want to overwrite it"
57
+ end
58
+ data.select! do |k,v|
59
+ keys_to_keep('update_connection').include? k
60
+ end
61
+ data[:password] = @secret if @secret
62
+ connection = update_connection(name, data)
63
+ else
64
+ data.select! do |k,v|
65
+ keys_to_keep('create_connection').include? k
66
+ end
67
+ data[:password] = @secret if @secret
68
+ connection = create_connection(data)
69
+ end
70
+ output.puts "Imported connection #{connection[:name]}" unless @options[:plain]
71
+ output.puts connection[:id] if @options[:name]
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ 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 'json'
25
+ require_relative '../../command'
26
+ require_relative '../../modules/connection'
27
+ require_relative '../../modules/filehelper'
28
+
29
+ module Gzr
30
+ module Commands
31
+ class Connection
32
+ class Rm < Gzr::Command
33
+ include Gzr::Connection
34
+ include Gzr::FileHelper
35
+ def initialize(connection_name,options)
36
+ super()
37
+ @connection_name = connection_name
38
+ @options = options
39
+ end
40
+
41
+ def execute(*args, input: $stdin, output: $stdout)
42
+ say_warning("options: #{@options.inspect}") if @options[:debug]
43
+ with_session do
44
+ delete_connection(@connection_name)
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,69 @@
1
+ # The MIT License (MIT)
2
+
3
+ # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, 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/connection'
26
+ require 'tty-table'
27
+
28
+ module Gzr
29
+ module Commands
30
+ class Connection
31
+ class Test < Gzr::Command
32
+ include Gzr::Connection
33
+ def initialize(connection_name,options)
34
+ super()
35
+ @connection_name = connection_name
36
+ @options = options
37
+ end
38
+
39
+ def execute(input: $stdin, output: $stdout)
40
+ say_warning(@options) if @options[:debug]
41
+ with_session do
42
+ data = test_connection(@connection_name)
43
+
44
+ table_hash = Hash.new
45
+ fields = field_names(@options[:fields])
46
+ table_hash[:header] = fields unless @options[:plain]
47
+ expressions = fields.collect { |fn| field_expression(fn) }
48
+ table_hash[:rows] = data.map do |row|
49
+ expressions.collect do |e|
50
+ eval "row.#{e}"
51
+ end
52
+ end
53
+ table = TTY::Table.new(table_hash)
54
+ alignments = fields.collect do |k|
55
+ (k =~ /id$/) ? :right : :left
56
+ end
57
+ begin
58
+ if @options[:csv] then
59
+ output.puts render_csv(table)
60
+ else
61
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, multiline: if @options[:plain] then false else true end, width: @options[:width] || TTY::Screen.width)
62
+ end
63
+ end if table
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -1,6 +1,6 @@
1
1
  # The MIT License (MIT)
2
2
 
3
- # Copyright (c) 2018 Mike DeAngelo Looker Data Sciences, Inc.
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
@@ -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