class ChinoRuby::Schemas

Public Instance Methods

create_schema(repository_id, description, fields) click to toggle source
# File lib/chino_ruby/classes.rb, line 894
def create_schema(repository_id, description, fields)
  check_string(repository_id)
  check_string(description)
  check_json(fields)
  data = {"description": description, "structure": { "fields": fields}}.to_json
  schema = Schema.new
  schema.from_json(post_resource("/repositories/#{repository_id}/schemas", data).to_json, true)
  schema
end
delete_schema(schema_id, force) click to toggle source
# File lib/chino_ruby/classes.rb, line 918
def delete_schema(schema_id, force)
  check_string(schema_id)
  check_boolean(force)
  delete_resource("/schemas/#{schema_id}", force)
end
get_schema(schema_id) click to toggle source
# File lib/chino_ruby/classes.rb, line 869
def get_schema(schema_id)
  check_string(schema_id)
  s = Schema.new
  s.from_json(get_resource("/schemas/#{schema_id}").to_json, true)
  s
end
list_schemas(repository_id, limit=nil, offset=nil) click to toggle source
# File lib/chino_ruby/classes.rb, line 876
def list_schemas(repository_id, limit=nil, offset=nil)
  check_string(repository_id)
  schemas = GetSchemasResponse.new
  if limit==nil && offset==nil
    schemas.from_json(get_resource("/repositories/#{repository_id}/schemas", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    schemas.from_json(get_resource("/repositories/#{repository_id}/schemas", limit, offset).to_json)
  end
  ss = schemas.schemas
  schemas.schemas = []
  ss.each do |s|
    schema = Schema.new
    schema.from_json(s.to_json)
    schemas.schemas.push(schema)
  end
  schemas
end
update_schema(schema_id, description, fields, is_active=nil) click to toggle source
# File lib/chino_ruby/classes.rb, line 904
def update_schema(schema_id, description, fields, is_active=nil)
  check_string(schema_id)
  check_string(description)
  check_json(fields)
  if is_active.nil?
    data = {"description": description, "structure": { "fields": fields}}.to_json
  else
    data = {"description": description, "structure": { "fields": fields}, "is_active": is_active}.to_json
  end
  schema = Schema.new
  schema.from_json(put_resource("/schemas/#{schema_id}", data).to_json, true)
  schema
end