gazer 0.3.3 → 0.3.5

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: 1c61028240f2447955b2ec8ca55f0db60e8c16d85a0d2a28f4c8062ec694672f
4
- data.tar.gz: a315cc287b53fa158e641689a2ee1d5d372ed05d86883001f0d8b9c811247dca
3
+ metadata.gz: 8353db2512a7ffe580a29ee37366871008368b6398d458fbc544eb5eca2e0e48
4
+ data.tar.gz: 32c1c523488511675f82106447f2d78572322399548894eb35bf9fb882358b20
5
5
  SHA512:
6
- metadata.gz: c4aa949c1e34750273e010eebe97ed06b4a1cefbbd93113331d696ef13683c79fc7b8fcdc9c5e1563eaff7a4bee0a291966bc23b0d3e697fe7aa55d2494f08aa
7
- data.tar.gz: c00cf477e61dc797288ee6129b0f8b825408a088fc3badba6a5d9a3f60775f7043647bf2200f1171440ca8019d1330e939e545442aca855e72ccc86eebab9cf0
6
+ metadata.gz: c5cdda279be77bb67a70ac68c8d7970550b67bfbf6a4a9ec93df3ed4515cf326179c1b7fc5b3a6d41c6f2ee8888c1b31e1e189bdf12ac5620cdc0a6c31bcedf5
7
+ data.tar.gz: babe51b71247333c6fd6091d814fa7ada1adaf71d852f07a4aa7ece6b93c8576415157c82370a49e4317bf9610b4cc3796e2aca22c43791fe2df5e3409448e29
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.5](https://github.com/looker-open-source/gzr/compare/v0.3.4...v0.3.5) (2023-05-05)
4
+
5
+
6
+ ### Features
7
+
8
+ * dashboard import_lookml ([#192](https://github.com/looker-open-source/gzr/issues/192)) ([248d5eb](https://github.com/looker-open-source/gzr/commit/248d5eb4b9e1c9ae302ab1b598784dd5065e9bf0))
9
+
10
+ ## [0.3.4](https://github.com/looker-open-source/gzr/compare/v0.3.3...v0.3.4) (2023-05-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * More project and model commands ([#190](https://github.com/looker-open-source/gzr/issues/190)) ([2d05d00](https://github.com/looker-open-source/gzr/commit/2d05d00a13721fdde733aecb6c99985ee5a1b081))
16
+
3
17
  ## [0.3.3](https://github.com/looker-open-source/gzr/compare/v0.3.2...v0.3.3) (2023-05-02)
4
18
 
5
19
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gazer (0.3.3)
4
+ gazer (0.3.5)
5
5
  faraday (~> 1.10.3)
6
6
  looker-sdk (~> 0.1.1)
7
7
  net-http-persistent (~> 4.0, >= 4.0.1)
@@ -0,0 +1,72 @@
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/dashboard'
27
+
28
+ module Gzr
29
+ module Commands
30
+ class Dashboard
31
+ class ImportLookml < Gzr::Command
32
+ include Gzr::Dashboard
33
+ def initialize(dashboard_id, target_folder_id, options)
34
+ super()
35
+ @dashboard_id = dashboard_id
36
+ @target_folder_id = target_folder_id
37
+ @options = options
38
+ end
39
+
40
+ def execute(input: $stdin, output: $stdout)
41
+ say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
42
+ with_session do
43
+
44
+ dash = query_dashboard(@dashboard_id)
45
+ raise Gzr::CLI::Error, "Dashboard with id #{@dashboard_id} does not exist" unless dash
46
+
47
+ matching_title = search_dashboards_by_title(dash[:title],@target_folder_id)
48
+ if matching_title.empty? || matching_title.first[:deleted]
49
+ matching_title = false
50
+ end
51
+
52
+ if matching_title
53
+ raise Gzr::CLI::Error, "Dashboard #{dash[:title]} already exists in folder #{@target_folder_id}\nUse --force if you want to overwrite it" unless @options[:force]
54
+ say_ok "Deleting existing dashboard #{matching_title.first[:id]} #{matching_title.first[:title]} in folder #{@target_folder_id}", output: output
55
+ update_dashboard(matching_title.first[:id],{:deleted=>true})
56
+ end
57
+
58
+ new_dash = import_lookml_dashboard(@dashboard_id,@target_folder_id)
59
+
60
+ if @options[:unlink]
61
+ body = {}
62
+ body[:lookml_link_id] = nil
63
+ update_dashboard(new_dash[:id],body)
64
+ end
65
+ output.puts "Created user defined dashboard #{new_dash[:id]} in folder #{@target_folder_id}" unless @options[:plain]
66
+ output.puts new_dash[:id] if @options[:plain]
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -96,6 +96,22 @@ module Gzr
96
96
  Gzr::Commands::Dashboard::Rm.new(id, options).execute
97
97
  end
98
98
  end
99
+
100
+ desc 'import_lookml DASHBOARD_ID TARGET_FOLDER_ID', 'Create a UDD from a lookml dashboard in the given folder'
101
+ method_option :help, aliases: '-h', type: :boolean,
102
+ desc: 'Display usage information'
103
+ method_option :unlink, type: :boolean,
104
+ desc: 'Unlink the new user defined dashboard from the LookML dashboard'
105
+ method_option :force, type: :boolean,
106
+ desc: 'Overwrite a dashboard with the same name in the target folder'
107
+ def import_lookml(dashboard_id, target_folder_id)
108
+ if options[:help]
109
+ invoke :help, ['import_lookml']
110
+ else
111
+ require_relative 'dashboard/import_lookml'
112
+ Gzr::Commands::Dashboard::ImportLookml.new(dashboard_id, target_folder_id, options).execute
113
+ end
114
+ end
99
115
  end
100
116
  end
101
117
  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/model'
26
+ require_relative '../../modules/filehelper'
27
+
28
+ module Gzr
29
+ module Commands
30
+ class Model
31
+ class Cat < Gzr::Command
32
+ include Gzr::Model
33
+ include Gzr::FileHelper
34
+ def initialize(model_name,options)
35
+ super()
36
+ @model_name = model_name
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_model(@model_name)
44
+ if data.nil?
45
+ say_warning "Model #{@model_name} not found"
46
+ return
47
+ end
48
+ data = trim_model(data) if @options[:trim]
49
+
50
+ write_file(@options[:dir] ? "Model_#{data[:name]}.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,57 @@
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/model'
27
+ require_relative '../../modules/filehelper'
28
+
29
+ module Gzr
30
+ module Commands
31
+ class Model
32
+ class Import < Gzr::Command
33
+ include Gzr::Model
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
+ read_file(@file) do |data|
45
+ data.select! do |k,v|
46
+ keys_to_keep('create_lookml_model').include? k
47
+ end
48
+ model = create_model(data)
49
+ output.puts "Created model #{model[:name]}" unless @options[:plain]
50
+ output.puts model[:name] if @options[:plain]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -46,6 +46,35 @@ module Gzr
46
46
  Gzr::Commands::Model::Ls.new(options).execute
47
47
  end
48
48
  end
49
+
50
+ desc 'cat MODEL_ID', 'Output json information about a model to screen or file'
51
+ method_option :help, aliases: '-h', type: :boolean,
52
+ desc: 'Display usage information'
53
+ method_option :dir, type: :string,
54
+ desc: 'Directory to store output file'
55
+ method_option :trim, type: :boolean,
56
+ desc: 'Trim output to minimal set of fields for later import'
57
+ def cat(model_id)
58
+ if options[:help]
59
+ invoke :help, ['cat']
60
+ else
61
+ require_relative 'model/cat'
62
+ Gzr::Commands::Model::Cat.new(model_id,options).execute
63
+ end
64
+ end
65
+
66
+ desc 'import MODEL_FILE', 'Import a model configuration from a file containing json information'
67
+ method_option :help, aliases: '-h', type: :boolean,
68
+ desc: 'Display usage information'
69
+ def import(model_file)
70
+ if options[:help]
71
+ invoke :help, ['import']
72
+ else
73
+ require_relative 'model/import'
74
+ Gzr::Commands::Model::Import.new(model_file,options).execute
75
+ end
76
+ end
77
+
49
78
  end
50
79
  end
51
80
  end
@@ -0,0 +1,96 @@
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 Branch < Gzr::Command
32
+ include Gzr::Project
33
+ def initialize(project_id,options)
34
+ super()
35
+ @project_id = project_id
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
+ 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
+ return
53
+ end
54
+
55
+ say_warning "querying git_branch(#{@project_id})" if @options[:debug]
56
+ data = [git_branch(@project_id)]
57
+ begin
58
+ say_ok "No active branch found"
59
+ return nil
60
+ end unless data && data.length > 0
61
+
62
+ if @options[:all]
63
+ say_warning "querying all_git_branches(#{@project_id})" if @options[:debug]
64
+ data += all_git_branches(@project_id).select{ |e| e.name != data[0].name }
65
+ end
66
+ begin
67
+ say_ok "No branches found"
68
+ return nil
69
+ end unless data && data.length > 0
70
+
71
+ table_hash = Hash.new
72
+ fields = field_names(@options[:fields])
73
+ table_hash[:header] = fields unless @options[:plain]
74
+ expressions = fields.collect { |fn| field_expression(fn) }
75
+ table_hash[:rows] = data.map do |row|
76
+ expressions.collect do |e|
77
+ eval "row.#{e}"
78
+ end
79
+ end
80
+ table = TTY::Table.new(table_hash)
81
+ alignments = fields.collect do |k|
82
+ (k =~ /id$/) ? :right : :left
83
+ end
84
+ begin
85
+ if @options[:csv] then
86
+ output.puts render_csv(table)
87
+ else
88
+ output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
89
+ end
90
+ end if table
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,65 @@
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
+
27
+ module Gzr
28
+ module Commands
29
+ class Project
30
+ class Checkout < Gzr::Command
31
+ include Gzr::Project
32
+ def initialize(project_id,name,options)
33
+ super()
34
+ @project_id = project_id
35
+ @name = 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
+ 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
+ return
53
+ end
54
+ data = update_git_branch(@project_id, @name )
55
+ if data.nil?
56
+ say_warning "Project #{@project_id} not found"
57
+ return
58
+ end
59
+ output.puts data
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,65 @@
1
+
2
+ # The MIT License (MIT)
3
+
4
+ # Copyright (c) 2023 Mike DeAngelo Google, Inc.
5
+
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ # this software and associated documentation files (the "Software"), to deal in
8
+ # the Software without restriction, including without limitation the rights to
9
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ # the Software, and to permit persons to whom the Software is furnished to do so,
11
+ # subject to the following conditions:
12
+
13
+ # The above copyright notice and this permission notice shall be included in all
14
+ # copies or substantial portions of the Software.
15
+
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+ # frozen_string_literal: true
24
+
25
+ require_relative '../../command'
26
+ require_relative '../../modules/project'
27
+
28
+ module Gzr
29
+ module Commands
30
+ class Project
31
+ class Deploy < Gzr::Command
32
+ include Gzr::Project
33
+ def initialize(project_id,options)
34
+ super()
35
+ @project_id = project_id
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
+ 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
+ return
53
+ end
54
+ data = deploy_to_production(@project_id)
55
+ if data.nil?
56
+ say_warning "Project #{@project_id} not found"
57
+ return
58
+ end
59
+ output.puts data
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -99,6 +99,53 @@ module Gzr
99
99
  end
100
100
  end
101
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
+
102
149
  end
103
150
  end
104
151
  end
@@ -354,5 +354,15 @@ module Gzr
354
354
 
355
355
  trimmed
356
356
  end
357
+
358
+ def import_lookml_dashboard(id,folder)
359
+ begin
360
+ return @sdk.import_lookml_dashboard(id,folder)&.to_attrs
361
+ rescue LookerSDK::Error => e
362
+ say_error "Error import_lookml_dashboard(#{id},#{folder})"
363
+ say_error e
364
+ raise
365
+ end
366
+ end
357
367
  end
358
368
  end
@@ -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
@@ -102,5 +102,54 @@ module Gzr
102
102
  end
103
103
  end
104
104
 
105
+ def all_git_branches(proj_id)
106
+ begin
107
+ return @sdk.all_git_branches(proj_id)
108
+ rescue LookerSDK::NotFound => e
109
+ return nil
110
+ rescue LookerSDK::Error => e
111
+ say_error "Error running all_git_branches(#{proj_id})"
112
+ say_error e
113
+ raise
114
+ end
115
+ end
116
+
117
+ def git_branch(proj_id)
118
+ begin
119
+ return @sdk.git_branch(proj_id)
120
+ rescue LookerSDK::NotFound => e
121
+ return nil
122
+ rescue LookerSDK::Error => e
123
+ say_error "Error running git_branch(#{proj_id})"
124
+ say_error e
125
+ raise
126
+ end
127
+ end
128
+
129
+ def deploy_to_production(proj_id)
130
+ begin
131
+ return @sdk.deploy_to_production(proj_id)
132
+ rescue LookerSDK::NotFound => e
133
+ return nil
134
+ rescue LookerSDK::Error => e
135
+ say_error "Error running deploy_to_production(#{proj_id})"
136
+ say_error e
137
+ raise
138
+ end
139
+ end
140
+
141
+ def update_git_branch(proj_id, name)
142
+ body = { name: name }
143
+ begin
144
+ return @sdk.update_git_branch(proj_id, body)&.to_attrs
145
+ rescue LookerSDK::NotFound => e
146
+ return nil
147
+ rescue LookerSDK::Error => e
148
+ say_error "Error running update_git_branch(#{proj_id},#{JSON.pretty_generate(body)})"
149
+ say_error e
150
+ raise
151
+ end
152
+ end
153
+
105
154
  end
106
155
  end
data/lib/gzr/version.rb CHANGED
@@ -20,5 +20,5 @@
20
20
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  module Gzr
23
- VERSION = '0.3.3'.freeze
23
+ VERSION = '0.3.5'.freeze
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gazer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike DeAngelo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-02 00:00:00.000000000 Z
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-reader
@@ -300,6 +300,7 @@ files:
300
300
  - lib/gzr/commands/dashboard.rb
301
301
  - lib/gzr/commands/dashboard/cat.rb
302
302
  - lib/gzr/commands/dashboard/import.rb
303
+ - lib/gzr/commands/dashboard/import_lookml.rb
303
304
  - lib/gzr/commands/dashboard/mv.rb
304
305
  - lib/gzr/commands/dashboard/rm.rb
305
306
  - lib/gzr/commands/folder.rb
@@ -320,6 +321,8 @@ files:
320
321
  - lib/gzr/commands/look/mv.rb
321
322
  - lib/gzr/commands/look/rm.rb
322
323
  - lib/gzr/commands/model.rb
324
+ - lib/gzr/commands/model/cat.rb
325
+ - lib/gzr/commands/model/import.rb
323
326
  - lib/gzr/commands/model/ls.rb
324
327
  - lib/gzr/commands/permissions.rb
325
328
  - lib/gzr/commands/permissions/ls.rb
@@ -333,7 +336,10 @@ files:
333
336
  - lib/gzr/commands/plan/rm.rb
334
337
  - lib/gzr/commands/plan/run.rb
335
338
  - lib/gzr/commands/project.rb
339
+ - lib/gzr/commands/project/branch.rb
336
340
  - lib/gzr/commands/project/cat.rb
341
+ - lib/gzr/commands/project/checkout.rb
342
+ - lib/gzr/commands/project/deploy.rb
337
343
  - lib/gzr/commands/project/deploy_key.rb
338
344
  - lib/gzr/commands/project/import.rb
339
345
  - lib/gzr/commands/project/ls.rb