Class: ChinoRuby::Schemas
Instance Method Summary
collapse
#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
Instance Method Details
#create_schema(repository_id, description, fields) ⇒ Object
894
895
896
897
898
899
900
901
902
|
# 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) ⇒ Object
918
919
920
921
922
|
# 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) ⇒ Object
869
870
871
872
873
874
|
# 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) ⇒ Object
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
|
# 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) ⇒ Object
904
905
906
907
908
909
910
911
912
913
914
915
916
|
# 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
|