Module: Gzr::Group

Instance Method Summary collapse

Instance Method Details

#query_all_groups(fields = nil, sorts = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gzr/modules/group.rb', line 26

def query_all_groups(fields=nil, sorts=nil)
  req = {
    :per_page=>128
  }
  req[:fields] = fields if fields
  req[:sorts] = sorts if sorts

  data = Array.new
  page = 1
  loop do
    begin
      req[:page] = page
      scratch_data = @sdk.all_groups(req).collect { |e| e.to_attrs }
    rescue LookerSDK::ClientError => e
      say_error "Unable to get all_groups(#{JSON.pretty_generate(req)})"
      say_error e
      raise
    end
    break if scratch_data.length == 0
    page += 1
    data += scratch_data
  end
  data
end

#query_group(id, fields = nil) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/gzr/modules/group.rb', line 104

def query_group(id, fields=nil)
  req = Hash.new
  req[:fields] = fields if fields
  begin
    return @sdk.group(id,req).to_attrs
  rescue LookerSDK::NotFound => e
    return nil
  rescue LookerSDK::ClientError => e
    say_error "Unable to find group(#{id},#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end

#query_group_groups(group_id, fields = nil) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/gzr/modules/group.rb', line 51

def query_group_groups(group_id,fields=nil)
  req = { }
  req[:fields] = fields if fields

  begin
    @sdk.all_group_groups(group_id,req).collect { |e| e.to_attrs }
  rescue LookerSDK::NotFound => e
    return []
  rescue LookerSDK::ClientError => e
    say_error "Unable to get all_group_groups(#{group_id},#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end

#query_group_users(group_id, fields = nil, sorts = nil) ⇒ Object



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/group.rb', line 66

def query_group_users(group_id,fields=nil,sorts=nil)
  req = {
    :per_page=>128
  }
  req[:fields] = fields if fields
  req[:sorts] = sorts if sorts

  data = Array.new
  page = 1
  loop do
    begin
      req[:page] = page
      scratch_data = @sdk.all_group_users(group_id,req).collect { |e| e.to_attrs }
    rescue LookerSDK::ClientError => e
      say_error "Unable to get all_group_users(#{group_id},#{JSON.pretty_generate(req)})"
      say_error e
      raise
    end
    break if scratch_data.length == 0
    page += 1
    data += scratch_data
  end
  data
end

#search_groups(name) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/gzr/modules/group.rb', line 91

def search_groups(name)
  req = {:name => name }
  begin
    return @sdk.search_groups(req).collect { |e| e.to_attrs }
  rescue LookerSDK::NotFound => e
    return []
  rescue LookerSDK::ClientError => e
    say_error "Unable to search_groups(#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end

#update_user_attribute_group_value(group_id, attr_id, value) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/gzr/modules/group.rb', line 118

def update_user_attribute_group_value(group_id, attr_id, value)
  req = Hash.new
  req[:value] = value
  begin
    return @sdk.update_user_attribute_group_value(group_id,attr_id, req).to_attrs
  rescue LookerSDK::ClientError => e
    say_error "Unable to update_user_attribute_group_value(#{group_id},#{attr_id},#{JSON.pretty_generate(req)})"
    say_error e
    raise
  end
end