Module: Agilix::Buzz::Commands::Right

Included in:
Api
Defined in:
lib/agilix/buzz/commands/right.rb

Instance Method Summary collapse

Instance Method Details

#create_role(options = {}) ⇒ Object

ISSUE: Why is this create singular, not multiple? api.create_role domainid: 57025, name: “Test Role”, privileges: api.right_flags

Raises:

  • (ArgumentError)


8
9
10
11
12
# File 'lib/agilix/buzz/commands/right.rb', line 8

def create_role(options = {})
  options = argument_cleaner(required_params: %i( domainid name privileges ), optional_params: %i( reference entitytype ), options: options )
  raise ArgumentError.new("Not a valid entitytype. Should be D,C, or empty") unless [nil, "", "D", "C"].include?(options[:entitytype])
  authenticated_post cmd: "createrole", **options
end

#delete_role(options = {}) ⇒ Object

api.delete_role roleid: 61316



15
16
17
18
# File 'lib/agilix/buzz/commands/right.rb', line 15

def delete_role(options = {})
  options = argument_cleaner(required_params: %i( roleid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "deleterole", **options
end

#delete_subscriptions(items = []) ⇒ Object

api.delete_subscriptions subscriberid: 57181, entityid: 57025



21
22
23
24
25
26
# File 'lib/agilix/buzz/commands/right.rb', line 21

def delete_subscriptions(items = [])
  options = items.map do |item|
    argument_cleaner(required_params: %i( subscriberid entityid ), optional_params: %i( flags ), options: item )
  end
  authenticated_bulk_post cmd: "deletesubscriptions", root_node: 'subscription', body: options
end

#get_actor_rights(options = {}) ⇒ Object

api.get_actor_rights actorid: 5000, entitytypes: “U|S|D”



29
30
31
32
# File 'lib/agilix/buzz/commands/right.rb', line 29

def get_actor_rights(options = {})
  options = argument_cleaner(required_params: %i( actorid ), optional_params: %i( entitytypes ), options: options )
  authenticated_get cmd: "getactorrights", **options
end

#get_effective_rights(options = {}) ⇒ Object

api.get_effective_rights entityid: 57025



35
36
37
38
# File 'lib/agilix/buzz/commands/right.rb', line 35

def get_effective_rights(options = {})
  options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "geteffectiverights", **options
end

#get_effective_subscription_list(options = {}) ⇒ Object

api.get_effective_subscription_list



41
42
43
44
# File 'lib/agilix/buzz/commands/right.rb', line 41

def get_effective_subscription_list(options = {})
  options = argument_cleaner(required_params: %i( ), optional_params: %i( select ), options: options )
  authenticated_get cmd: "geteffectivesubscriptionlist", **options
end

#get_entity_rights(options = {}) ⇒ Object

api.get_entity_rights entityid: 57025



47
48
49
50
# File 'lib/agilix/buzz/commands/right.rb', line 47

def get_entity_rights(options = {})
  options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "getentityrights", **options
end

#get_entity_subscription_list(options = {}) ⇒ Object

api.get_entity_subscription_list entityid: 57025



53
54
55
56
# File 'lib/agilix/buzz/commands/right.rb', line 53

def get_entity_subscription_list(options = {})
  options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( subscriberid), options: options )
  authenticated_get cmd: "getentitysubscriptionlist", **options
end

#get_personas(options = {}) ⇒ Object

api.get_personas userid: 57026



59
60
61
62
# File 'lib/agilix/buzz/commands/right.rb', line 59

def get_personas(options = {})
  options = argument_cleaner(required_params: %i( ), optional_params: %i( userid domainid ), options: options )
  authenticated_get cmd: "getpersonas", **options
end

#get_rights(options = {}) ⇒ Object

api.get_rights actorid: 57026, entityid: 57025



65
66
67
68
# File 'lib/agilix/buzz/commands/right.rb', line 65

def get_rights(options = {})
  options = argument_cleaner(required_params: %i( actorid entityid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "getrights", **options
end

#get_rights_list(options = {}) ⇒ Object

api.get_rights_list domainid: 57025



71
72
73
74
# File 'lib/agilix/buzz/commands/right.rb', line 71

def get_rights_list(options = {})
  options = argument_cleaner(required_params: %i(  ), optional_params: %i( domainid restrictdomain ), options: options )
  authenticated_get cmd: "getrightslist", **options
end

#get_role(options = {}) ⇒ Object

api.get_role roleid: 61316



77
78
79
80
# File 'lib/agilix/buzz/commands/right.rb', line 77

def get_role(options = {})
  options = argument_cleaner(required_params: %i( roleid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "getrole", **options
end

#get_subscription_list(options = {}) ⇒ Object

Get for a domain api.get_subscription_list subscriberid: 57025 Get for a user api.get_subscription_list subscriberid: 57026



86
87
88
89
# File 'lib/agilix/buzz/commands/right.rb', line 86

def get_subscription_list(options = {})
  options = argument_cleaner(required_params: %i( subscriberid ), optional_params: %i( entityid ), options: options )
  authenticated_get cmd: "getsubscriptionlist", **options
end

#list_roles(options = {}) ⇒ Object

api.list_roles domainid: 57025



92
93
94
95
# File 'lib/agilix/buzz/commands/right.rb', line 92

def list_roles(options = {})
  options = argument_cleaner(required_params: %i( domainid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "listroles", **options
end

#restore_role(options = {}) ⇒ Object

api.restore_role roleid: 61316



98
99
100
101
# File 'lib/agilix/buzz/commands/right.rb', line 98

def restore_role(options = {})
  options = argument_cleaner(required_params: %i( roleid ), optional_params: %i( ), options: options )
  authenticated_get cmd: "restorerole", **options
end

#right_flagsObject



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/agilix/buzz/commands/right.rb', line 128

def right_flags
  {
    admin: -1,
    none: 0,
    participate: 1,
    create_domain: 16,
    read_domain: 32,
    update_domain: 64,
    delete_domain: 128,
    create_user: 256,
    read_user: 512,
    update_user: 1024,
    delete_user: 2048,
    create_course: 65536,
    read_course: 131072,
    update_course: 262144,
    delete_course: 524288,
    create_section: 1048576,
    read_section: 2097152,
    update_section: 4194304,
    delete_section: 8388608,
    grade_assignment: 16777216,
    grade_forum: 33554432,
    grade_exam: 67108864,
    setup_gradebook: 134217728,
    control_domain: 268435456,
    control_course: 536870912,
    control_section: 1073741824,
    read_gradebook: 2147483648,
    report_domain: 4294967296,
    report_course: 8589934592,
    report_section: 17179869184,
    post_domain_announcements: 34359738368,
    proxy: 68719476736,
    report_user: 274877906944,
    submit_final_grade: 549755813888,
    control_enrollment: 1099511627776,
    read_enrollment: 2199023255552,
    read_course_full: 4398046511104,
    control_user: 8796093022208,
    read_objective: 17592186044416,
    update_objective: 35184372088832
  }
end

#right_flags_hexObject



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/agilix/buzz/commands/right.rb', line 173

def right_flags_hex
  {
    admin: "-0x01",
    none: "0x00",
    participate: "0x01",
    create_domain: "0x10",
    read_domain: "0x20",
    update_domain: "0x40",
    delete_domain: "0x80",
    create_user: "0x100",
    read_user: "0x200",
    update_user: "0x400",
    delete_user: "0x800",
    create_course: "0x10000",
    read_course: "0x20000",
    update_course: "0x40000",
    delete_course: "0x80000",
    create_section: "0x100000",
    read_section: "0x200000",
    update_section: "0x400000",
    delete_section: "0x800000",
    grade_assignment: "0x1000000",
    grade_forum: "0x2000000",
    grade_exam: "0x4000000",
    setup_gradebook: "0x8000000",
    control_domain: "0x10000000",
    control_course: "0x20000000",
    control_section: "0x40000000",
    read_gradebook: "0x80000000",
    report_domain: "0x100000000",
    report_course: "0x200000000",
    report_section: "0x400000000",
    post_domain_announcements: "0x800000000",
    proxy: "0x1000000000",
    report_user: "0x4000000000",
    submit_final_grade: "0x8000000000",
    control_enrollment: "0x10000000000",
    read_enrollment: "0x20000000000",
    read_course_full: "0x40000000000",
    control_user: "0x80000000000",
    read_objective: "0x100000000000",
    update_objective: "0x200000000000"
  }
end

#right_flags_lookup_value(val) ⇒ Object



219
220
221
222
223
224
225
226
227
228
229
# File 'lib/agilix/buzz/commands/right.rb', line 219

def right_flags_lookup_value(val)
  val = val.to_s
  if val.include?("x")
    raise ArgumentError.new("Not a valid right flag") unless right_flags_hex.values.include?(val)
    right_flags_hex.find {|k,v| v == val}.first
  else
    val = val.to_i
    raise ArgumentError.new("Not a valid right flag") unless right_flags.values.include?(val)
    right_flags.find {|k,v| v == val}.first
  end
end

#update_rights(items = []) ⇒ Object

api.update_rights [ 57026, entityid: 57025, roleid: 61316]



104
105
106
107
108
109
# File 'lib/agilix/buzz/commands/right.rb', line 104

def update_rights(items = [])
  options = items.map do |item|
    argument_cleaner(required_params: %i( actorid entityid ), optional_params: %i( roleid flags schema ), options: item )
  end
  authenticated_bulk_post cmd: "updaterights", root_node: 'rights', body: options
end

#update_role(options = {}) ⇒ Object

api.update_role roleid: 61316, name: “Test Role Updates”, privileges: api.right_flags

Raises:

  • (ArgumentError)


112
113
114
115
116
117
# File 'lib/agilix/buzz/commands/right.rb', line 112

def update_role(options = {})
  options = argument_cleaner(required_params: %i( roleid  ), optional_params: %i( name privileges reference entitytype ), options: options )
  raise ArgumentError.new("Not a valid entitytype. Should be D,C, or empty") unless [nil, "", "D", "C"].include?(options[:entitytype])

  authenticated_post cmd: "updaterole", **options
end

#update_subscriptions(items = []) ⇒ Object

ISSUE: Why is this root node singular? api.update_subscriptions subscriberid: 57181, entityid: 60982, startdate: “2019-03-15”, enddate: “2019-03-15”



121
122
123
124
125
126
# File 'lib/agilix/buzz/commands/right.rb', line 121

def update_subscriptions(items = [])
  options = items.map do |item|
    argument_cleaner(required_params: %i( subscriberid entityid startdate enddate ), optional_params: %i( subscriptionflags ), options: item )
  end
  authenticated_bulk_post cmd: "updatesubscriptions", root_node: 'subscription', body: options
end