Class: ChinoRuby::Groups

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

#add_user_schema_to_group(user_schema_id, group_id) ⇒ Object



810
811
812
813
814
# File 'lib/chino_ruby/classes.rb', line 810

def add_user_schema_to_group(user_schema_id, group_id)
  check_string(group_id)
  check_string(user_schema_id)
  post_resource("/groups/#{group_id}/user_schemas/#{user_schema_id}")
end

#add_user_to_group(user_id, group_id) ⇒ Object



804
805
806
807
808
# File 'lib/chino_ruby/classes.rb', line 804

def add_user_to_group(user_id, group_id)
  check_string(group_id)
  check_string(user_id)
  post_resource("/groups/#{group_id}/users/#{user_id}")
end

#create_group(group_name, attributes) ⇒ Object



779
780
781
782
783
784
785
786
# File 'lib/chino_ruby/classes.rb', line 779

def create_group(group_name, attributes)
  check_string(group_name)
  check_json(attributes)
  data = {"group_name": group_name, "attributes": attributes}.to_json
  group = Group.new
  group.from_json(post_resource("/groups", data).to_json, true)
  group
end

#delete_group(group_id, force) ⇒ Object



798
799
800
801
802
# File 'lib/chino_ruby/classes.rb', line 798

def delete_group(group_id, force)
  check_string(group_id)
  check_boolean(force)
  delete_resource("/groups/#{group_id}", force)
end

#get_group(group_id) ⇒ Object



755
756
757
758
759
760
# File 'lib/chino_ruby/classes.rb', line 755

def get_group(group_id)
  check_string(group_id)
  g = Group.new
  g.from_json(get_resource("/groups/#{group_id}").to_json, true)
  g
end

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



762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
# File 'lib/chino_ruby/classes.rb', line 762

def list_groups(limit=nil, offset=nil)
  groups = GetGroupsResponse.new
  if limit==nil && offset==nil
    groups.from_json(get_resource("/groups", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    groups.from_json(get_resource("/groups", limit, offset).to_json)
  end
  gs = groups.groups
  groups.groups = []
  gs.each do |g|
    group = Group.new
    group.from_json(g.to_json)
    groups.groups.push(group)
  end
  groups
end

#remove_user_from_group(user_id, group_id) ⇒ Object



816
817
818
819
820
# File 'lib/chino_ruby/classes.rb', line 816

def remove_user_from_group(user_id, group_id)
  check_string(group_id)
  check_string(user_id)
  delete_resource("/groups/#{group_id}/users/#{user_id}", false)
end

#remove_user_schema_from_group(user_schema_id, group_id) ⇒ Object



822
823
824
825
826
# File 'lib/chino_ruby/classes.rb', line 822

def remove_user_schema_from_group(user_schema_id, group_id)
  check_string(group_id)
  check_string(user_schema_id)
  delete_resource("/groups/#{group_id}/user_schemas/#{user_schema_id}", false)
end

#update_group(group_id, group_name, attributes) ⇒ Object



788
789
790
791
792
793
794
795
796
# File 'lib/chino_ruby/classes.rb', line 788

def update_group(group_id, group_name, attributes)
  check_string(group_id)
  check_string(group_name)
  check_json(attributes)
  data = {"group_name": group_name, "attributes": attributes}.to_json
  group = Group.new
  group.from_json(put_resource("/groups/#{group_id}", data).to_json, true)
  group
end