Class: ChinoRuby::Permissions

Inherits:
ChinoBaseAPI show all
Defined in:
lib/chino_ruby/classes.rb

Instance Method Summary collapse

Methods inherited from ChinoBaseAPI

#delete_resource, #get_resource, #initialize, #parse_response, #patch_resource, #post_resource, #post_resource_with_string_result, #put_resource, #return_uri

Methods inherited from CheckValues

#check_boolean, #check_int, #check_json, #check_string

Constructor Details

This class inherits a constructor from ChinoRuby::ChinoBaseAPI

Instance Method Details

#list_permissions(limit = nil, offset = nil) ⇒ Object



1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
# File 'lib/chino_ruby/classes.rb', line 1177

def list_permissions(limit=nil, offset=nil)
  perms = GetPermissionsResponse.new
  if limit==nil && offset==nil
    perms.from_json(get_resource("/perms", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    perms.from_json(get_resource("/perms", limit, offset).to_json)
  end
  ps = perms.permissions
  perms.permissions = []
  ps.each do |p|
    perm = Permission.new
    perm.from_json(p.to_json)
    perms.permissions.push(perm)
  end
  perms
end

#permissions_on_a_resource(action, resource_type, resource_id, subject_type, subject_id, manage, authorize) ⇒ Object



1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
# File 'lib/chino_ruby/classes.rb', line 1259

def permissions_on_a_resource(action, resource_type, resource_id, subject_type, subject_id, manage, authorize)
  check_string(action)
  check_string(resource_type)
  check_string(resource_id)
  check_string(subject_type)
  check_string(subject_id)
  check_json(manage)
  check_json(authorize)
  data = {"manage": manage, "authorize": authorize}.to_json
  post_resource_with_string_result("/perms/#{action}/#{resource_type}/#{resource_id}/#{subject_type}/#{subject_id}", data)
end

#permissions_on_a_resource_children(action, resource_type, resource_id, resource_children, subject_type, subject_id, manage, authorize) ⇒ Object



1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
# File 'lib/chino_ruby/classes.rb', line 1271

def permissions_on_a_resource_children(action, resource_type, resource_id, resource_children, subject_type, subject_id, manage, authorize)
  check_string(action)
  check_string(resource_type)
  check_string(resource_id)
  check_string(resource_children)
  check_string(subject_type)
  check_string(subject_id)
  check_json(manage)
  check_json(authorize)
  data = {"manage": manage, "authorize": authorize}.to_json
  post_resource_with_string_result("/perms/#{action}/#{resource_type}/#{resource_id}/#{resource_children}/#{subject_type}/#{subject_id}", data)
end

#permissions_on_a_resource_children_created_document(action, resource_type, resource_id, resource_children, subject_type, subject_id, manage, authorize, manage_created_document, authorize_created_document) ⇒ Object



1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
# File 'lib/chino_ruby/classes.rb', line 1284

def permissions_on_a_resource_children_created_document(action, resource_type, resource_id, resource_children, subject_type, subject_id, manage, authorize, manage_created_document, authorize_created_document)
  check_string(action)
  check_string(resource_type)
  check_string(resource_id)
  check_string(resource_children)
  check_string(subject_type)
  check_string(subject_id)
  check_json(manage)
  check_json(authorize)
  data = {"manage": manage, "authorize": authorize, "created_document": { "manage": manage_created_document, "authorize": authorize_created_document}}.to_json
  post_resource_with_string_result("/perms/#{action}/#{resource_type}/#{resource_id}/#{resource_children}/#{subject_type}/#{subject_id}", data)
end

#permissions_on_resources(action, resource_type, subject_type, subject_id, manage, authorize) ⇒ Object



1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
# File 'lib/chino_ruby/classes.rb', line 1248

def permissions_on_resources(action, resource_type, subject_type, subject_id, manage, authorize)
  check_string(action)
  check_string(resource_type)
  check_string(subject_type)
  check_string(subject_id)
  check_json(manage)
  check_json(authorize)
  data = {"manage": manage, "authorize": authorize}.to_json
  post_resource_with_string_result("/perms/#{action}/#{resource_type}/#{subject_type}/#{subject_id}", data)
end

#read_permissions_of_a_group(group_id, limit = nil, offset = nil) ⇒ Object



1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
# File 'lib/chino_ruby/classes.rb', line 1230

def read_permissions_of_a_group(group_id, limit=nil, offset=nil)
  check_string(group_id)
  perms = GetPermissionsResponse.new
  if limit==nil && offset==nil
    perms.from_json(get_resource("/perms/groups/#{group_id}", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    perms.from_json(get_resource("/perms/groups/#{group_id}", limit, offset).to_json)
  end
  ps = perms.permissions
  perms.permissions = []
  ps.each do |p|
    perm = Permission.new
    perm.from_json(p.to_json)
    perms.permissions.push(perm)
  end
  perms
end

#read_permissions_of_a_user(user_id, limit = nil, offset = nil) ⇒ Object



1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
# File 'lib/chino_ruby/classes.rb', line 1212

def read_permissions_of_a_user(user_id, limit=nil, offset=nil)
  check_string(user_id)
  perms = GetPermissionsResponse.new
  if limit==nil && offset==nil
    perms.from_json(get_resource("/perms/users/#{user_id}", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    perms.from_json(get_resource("/perms/users/#{user_id}", limit, offset).to_json)
  end
  ps = perms.permissions
  perms.permissions = []
  ps.each do |p|
    perm = Permission.new
    perm.from_json(p.to_json)
    perms.permissions.push(perm)
  end
  perms
end

#read_permissions_on_a_document(document_id, limit = nil, offset = nil) ⇒ Object



1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
# File 'lib/chino_ruby/classes.rb', line 1194

def read_permissions_on_a_document(document_id, limit=nil, offset=nil)
  check_string(document_id)
  perms = GetPermissionsResponse.new
  if limit==nil && offset==nil
    perms.from_json(get_resource("/perms/documents/#{document_id}", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    perms.from_json(get_resource("/perms/documents/#{document_id}", limit, offset).to_json)
  end
  ps = perms.permissions
  perms.permissions = []
  ps.each do |p|
    perm = Permission.new
    perm.from_json(p.to_json)
    perms.permissions.push(perm)
  end
  perms
end