Module: Gzr::Permission::Set

Instance Method Summary collapse

Instance Method Details

#all_permission_sets(fields = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gzr/modules/permission/set.rb', line 28

def all_permission_sets(fields=nil)
  req = {}
  req[:fields] = fields if fields
  begin
    @sdk.all_permission_sets(req).collect { |s| s.to_attrs }
  rescue LookerSDK::NotFound => e
    return nil
  rescue LookerSDK::Error => e
    say_error "Error querying all_permission_sets(#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end

#cat_permission_set(set_id, fields = nil) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/gzr/modules/permission/set.rb', line 42

def cat_permission_set(set_id, fields=nil)
  req = {}
  req[:fields] = fields if fields
  begin
    return @sdk.permission_set(set_id,req)&.to_attrs
  rescue LookerSDK::NotFound => e
    return nil
  rescue LookerSDK::Error => e
    say_error "Error querying permission_set(#{set_id},#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end

#create_permission_set(data) ⇒ Object



101
102
103
104
105
106
107
108
109
# File 'lib/gzr/modules/permission/set.rb', line 101

def create_permission_set(data)
  begin
    return @sdk.create_permission_set(data)&.to_attrs
  rescue LookerSDK::Error => e
    say_error "Error calling create_permission_set(#{JSON.pretty_generate(data)})"
    say_error e
    raise
  end
end

#delete_permission_set(permission_set_id) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/gzr/modules/permission/set.rb', line 111

def delete_permission_set(permission_set_id)
  begin
    return @sdk.delete_permission_set(permission_set_id)
  rescue LookerSDK::Error => e
    say_error "Error calling delete_permission_set(#{permission_set_id}})"
    say_error e
    raise
  end
end

#search_permission_sets(fields: nil, sorts: nil, id: nil, name: nil, all_access: nil, built_in: nil, filter_or: nil) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/gzr/modules/permission/set.rb', line 63

def search_permission_sets(fields: nil, sorts: nil, id: nil, name: nil, all_access: nil, built_in: nil, filter_or: nil)
  data = []
  begin
    req = {}
    req[:fields] = fields unless fields.nil?
    req[:sorts] = sorts unless sorts.nil?
    req[:id] = id unless id.nil?
    req[:name] = name unless name.nil?
    req[:all_access] = all_access unless all_access.nil?
    req[:built_in] = built_in unless built_in.nil?
    req[:filter_or] = filter_or unless filter_or.nil?
    req[:limit] = 64
    loop do
      page = @sdk.search_permission_sets(req).collect { |s| s.to_attrs }
      data+=page
      break unless page.length == req[:limit]
      req[:offset] = (req[:offset] || 0) + req[:limit]
    end
  rescue LookerSDK::NotFound => e
    # do nothing
  rescue LookerSDK::Error => e
    say_error "Error calling search_permission_sets(#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
  data
end

#trim_permission_set(data) ⇒ Object



56
57
58
59
60
61
# File 'lib/gzr/modules/permission/set.rb', line 56

def trim_permission_set(data)
  trimmed = data.select do |k,v|
    (keys_to_keep('update_permission_set') + [:id,:built_in]).include? k
  end
  trimmed
end

#update_permission_set(permission_set_id, data) ⇒ Object



91
92
93
94
95
96
97
98
99
# File 'lib/gzr/modules/permission/set.rb', line 91

def update_permission_set(permission_set_id, data)
  begin
    return @sdk.update_permission_set(permission_set_id, data)&.to_attrs
  rescue LookerSDK::Error => e
    say_error "Error calling update_permission_set(#{permission_set_id},#{JSON.pretty_generate(data)})"
    say_error e
    raise
  end
end