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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c61028240f2447955b2ec8ca55f0db60e8c16d85a0d2a28f4c8062ec694672f
|
4
|
+
data.tar.gz: a315cc287b53fa158e641689a2ee1d5d372ed05d86883001f0d8b9c811247dca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4aa949c1e34750273e010eebe97ed06b4a1cefbbd93113331d696ef13683c79fc7b8fcdc9c5e1563eaff7a4bee0a291966bc23b0d3e697fe7aa55d2494f08aa
|
7
|
+
data.tar.gz: c00cf477e61dc797288ee6129b0f8b825408a088fc3badba6a5d9a3f60775f7043647bf2200f1171440ca8019d1330e939e545442aca855e72ccc86eebab9cf0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,28 @@
|
|
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
|
+
|
19
|
+
## [0.3.2](https://github.com/looker-open-source/gzr/compare/v0.3.1...v0.3.2) (2023-04-21)
|
20
|
+
|
21
|
+
|
22
|
+
### Features
|
23
|
+
|
24
|
+
* Alerts management through gazer ([#180](https://github.com/looker-open-source/gzr/issues/180)) ([74d0307](https://github.com/looker-open-source/gzr/commit/74d0307d63602df5efad98e7c8e92b91740a4afc))
|
25
|
+
|
3
26
|
## [0.3.1](https://github.com/looker-open-source/gzr/compare/v0.3.0...v0.3.1) (2023-04-20)
|
4
27
|
|
5
28
|
|
data/Gemfile.lock
CHANGED
data/lib/gzr/cli.rb
CHANGED
@@ -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
|
@@ -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)
|
@@ -58,6 +60,9 @@ module Gzr
|
|
58
60
|
map %w(--version -v) => :version
|
59
61
|
map space: :folder # Alias space command to folder
|
60
62
|
|
63
|
+
require_relative 'commands/alert'
|
64
|
+
register Gzr::Commands::Alert, 'alert', 'alert [SUBCOMMAND]', 'Command description...'
|
65
|
+
|
61
66
|
require_relative 'commands/attribute'
|
62
67
|
register Gzr::Commands::Attribute, 'attribute', 'attribute [SUBCOMMAND]', 'Command description...'
|
63
68
|
|
@@ -93,5 +98,11 @@ module Gzr
|
|
93
98
|
|
94
99
|
require_relative 'commands/folder'
|
95
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'
|
96
107
|
end
|
97
108
|
end
|
data/lib/gzr/command.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT icense (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
|
@@ -52,6 +52,27 @@ module Gzr
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
+
def get_user_by_id(user_id, req=nil)
|
56
|
+
user = nil
|
57
|
+
begin
|
58
|
+
user = @sdk.user(user_id, req)
|
59
|
+
rescue LookerSDK::Error => e
|
60
|
+
say_error "Error querying get_user_by_id(#{user_id})"
|
61
|
+
say_error e
|
62
|
+
raise
|
63
|
+
end
|
64
|
+
user
|
65
|
+
end
|
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
|
+
|
55
76
|
def query(query_id)
|
56
77
|
data = nil
|
57
78
|
begin
|
@@ -389,6 +410,66 @@ module Gzr
|
|
389
410
|
parts.join('&.')
|
390
411
|
end
|
391
412
|
|
413
|
+
|
414
|
+
# This version of field names yields an expression that can be evaluated against a hash structure
|
415
|
+
# like this one...
|
416
|
+
#
|
417
|
+
# data&.fetch(:a,nil)
|
418
|
+
# val1
|
419
|
+
# data&.fetch(:b,nil)
|
420
|
+
# val2
|
421
|
+
# data&.fetch(:c,nil)&.fetch(:d,nil)
|
422
|
+
# val3
|
423
|
+
# data&.fetch(:c,nil)&.fetch(:e,nil)&.fetch(:f,nil)
|
424
|
+
# val4
|
425
|
+
# data&.fetch(:c,nil)&.fetch(:e,nil)&.fetch(:g,nil)
|
426
|
+
# val5
|
427
|
+
# data&.fetch(:h,nil)
|
428
|
+
# val6
|
429
|
+
#
|
430
|
+
# data =
|
431
|
+
# {
|
432
|
+
# a: "val",
|
433
|
+
# b: "val",
|
434
|
+
# c: {
|
435
|
+
# d: "val",
|
436
|
+
# e: {
|
437
|
+
# f: "val",
|
438
|
+
# g: "val"
|
439
|
+
# }
|
440
|
+
# },
|
441
|
+
# h: "val"
|
442
|
+
# }
|
443
|
+
#
|
444
|
+
# field_names_hash(fields).each do |field|
|
445
|
+
# puts "data#{field}"
|
446
|
+
# puts eval "data#{field}"
|
447
|
+
# end
|
448
|
+
|
449
|
+
def field_names_hash(opt_fields)
|
450
|
+
fields = []
|
451
|
+
token_stack = []
|
452
|
+
last_token = false
|
453
|
+
tokens = opt_fields.split /(\(|,|\))/
|
454
|
+
tokens << nil
|
455
|
+
tokens.each do |t|
|
456
|
+
if t == '(' then
|
457
|
+
token_stack.push(last_token)
|
458
|
+
elsif t.nil? || t == ',' then
|
459
|
+
fields << "&.fetch(:#{(token_stack + [last_token]).join(',nil)&.fetch(:')},nil)" if last_token
|
460
|
+
elsif t.empty? then
|
461
|
+
next
|
462
|
+
elsif t == ')' then
|
463
|
+
fields << "&.fetch(:#{(token_stack + [last_token]).join(',nil)&.fetch(:')},nil)" if last_token
|
464
|
+
token_stack.pop
|
465
|
+
last_token = false
|
466
|
+
else
|
467
|
+
last_token = t
|
468
|
+
end
|
469
|
+
end
|
470
|
+
fields
|
471
|
+
end
|
472
|
+
|
392
473
|
##
|
393
474
|
# This method will accept two arrays, a and b, and create a third array
|
394
475
|
# like [ [a[0],b[0]], [a[1],b[1]], [a[2],b[2]], ...].
|
@@ -0,0 +1,52 @@
|
|
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/alert'
|
26
|
+
require_relative '../../modules/filehelper'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Alert
|
31
|
+
class Cat < Gzr::Command
|
32
|
+
include Gzr::Alert
|
33
|
+
include Gzr::FileHelper
|
34
|
+
def initialize(alert_id,options)
|
35
|
+
super()
|
36
|
+
@alert_id = alert_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
|
+
alert = get_alert(@alert_id)
|
44
|
+
write_file(@options[:dir] ? "Alert_#{alert.id}_#{alert.field.name}.json" : nil, @options[:dir],nil, output) do |f|
|
45
|
+
f.puts JSON.pretty_generate(alert.to_attrs)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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/alert'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Alert
|
30
|
+
class Chown < Gzr::Command
|
31
|
+
include Gzr::Alert
|
32
|
+
def initialize(alert_id,owner_id,options)
|
33
|
+
super()
|
34
|
+
@alert_id = alert_id
|
35
|
+
@owner_id = owner_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
|
+
update_alert_field(@alert_id, owner_id: @owner_id)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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/alert'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Alert
|
30
|
+
class Delete < Gzr::Command
|
31
|
+
include Gzr::Alert
|
32
|
+
def initialize(alert_id,options)
|
33
|
+
super()
|
34
|
+
@alert_id = alert_id
|
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
|
+
delete_alert(@alert_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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/alert'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Alert
|
30
|
+
class Disable < Gzr::Command
|
31
|
+
include Gzr::Alert
|
32
|
+
def initialize(alert_id, disabled_reason, options)
|
33
|
+
super()
|
34
|
+
@alert_id = alert_id
|
35
|
+
@disabled_reason = disabled_reason
|
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
|
+
update_alert_field(@alert_id, is_disabled: true, disabled_reason: @disabled_reason)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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/alert'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Alert
|
30
|
+
class Enable < Gzr::Command
|
31
|
+
include Gzr::Alert
|
32
|
+
def initialize(alert_id,options)
|
33
|
+
super()
|
34
|
+
@alert_id = alert_id
|
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
|
+
update_alert_field(@alert_id, is_disabled: false)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
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/alert'
|
26
|
+
|
27
|
+
module Gzr
|
28
|
+
module Commands
|
29
|
+
class Alert
|
30
|
+
class Follow < Gzr::Command
|
31
|
+
include Gzr::Alert
|
32
|
+
def initialize(alert_id,options)
|
33
|
+
super()
|
34
|
+
@alert_id = alert_id
|
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
|
+
follow_alert(@alert_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
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 '../../../gzr'
|
25
|
+
require_relative '../../command'
|
26
|
+
require_relative '../../modules/alert'
|
27
|
+
require_relative '../../modules/user'
|
28
|
+
require_relative '../../modules/filehelper'
|
29
|
+
|
30
|
+
module Gzr
|
31
|
+
module Commands
|
32
|
+
class Alert
|
33
|
+
class Import < Gzr::Command
|
34
|
+
include Gzr::Alert
|
35
|
+
include Gzr::User
|
36
|
+
include Gzr::FileHelper
|
37
|
+
def initialize(file, dashboard_element_id, options)
|
38
|
+
super()
|
39
|
+
@file = file
|
40
|
+
@dashboard_element_id = dashboard_element_id
|
41
|
+
@options = options
|
42
|
+
end
|
43
|
+
|
44
|
+
def execute(input: $stdin, output: $stdout)
|
45
|
+
say_warning("options: #{@options.inspect}", output: output) if @options[:debug]
|
46
|
+
with_session do
|
47
|
+
|
48
|
+
@me ||= query_me("id")
|
49
|
+
|
50
|
+
read_file(@file) do |data|
|
51
|
+
data.select! do |k,v|
|
52
|
+
keys_to_keep('create_alert').include? k
|
53
|
+
end
|
54
|
+
data[:owner_id] = @me[:id]
|
55
|
+
data[:dashboard_element_id] = @dashboard_element_id if @dashboard_element_id
|
56
|
+
alert = create_alert(data)
|
57
|
+
output.puts "Imported alert #{alert[:id]}" unless @options[:plain]
|
58
|
+
output.puts alert[:id] if @options[:plain]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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/alert'
|
26
|
+
require 'tty-table'
|
27
|
+
|
28
|
+
module Gzr
|
29
|
+
module Commands
|
30
|
+
class Alert
|
31
|
+
class Ls < Gzr::Command
|
32
|
+
include Gzr::Alert
|
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
|
+
req = {}
|
42
|
+
req[:fields] = @options[:fields] unless @options[:fields].nil?
|
43
|
+
req[:disabled] = @options[:disabled] unless @options[:disabled].nil?
|
44
|
+
req[:all_owners] = @options[:all] unless @options[:all].nil?
|
45
|
+
data = search_alerts(**req)
|
46
|
+
begin
|
47
|
+
say_ok "No alerts found"
|
48
|
+
return nil
|
49
|
+
end unless data && data.length > 0
|
50
|
+
|
51
|
+
table_hash = Hash.new
|
52
|
+
fields = field_names(@options[:fields])
|
53
|
+
table_hash[:header] = fields unless @options[:plain]
|
54
|
+
expressions = fields.collect { |fn| field_expression(fn) }
|
55
|
+
table_hash[:rows] = data.map do |row|
|
56
|
+
expressions.collect do |e|
|
57
|
+
eval "row.#{e}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
table = TTY::Table.new(table_hash)
|
61
|
+
alignments = fields.collect do |k|
|
62
|
+
(k =~ /id$/) ? :right : :left
|
63
|
+
end
|
64
|
+
begin
|
65
|
+
if @options[:csv] then
|
66
|
+
output.puts render_csv(table)
|
67
|
+
else
|
68
|
+
output.puts table.render(if @options[:plain] then :basic else :ascii end, alignments: alignments, width: @options[:width] || TTY::Screen.width)
|
69
|
+
end
|
70
|
+
end if table
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|