Class: 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
Constructor Details
This class inherits a constructor from ChinoBaseAPI
Instance Method Details
#create_schema(repository_id, description, fields) ⇒ Object
950
951
952
953
954
955
956
957
958
|
# File 'lib/chino_ruby.rb', line 950
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
974
975
976
977
978
|
# File 'lib/chino_ruby.rb', line 974
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
925
926
927
928
929
930
|
# File 'lib/chino_ruby.rb', line 925
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
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
|
# File 'lib/chino_ruby.rb', line 932
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
960
961
962
963
964
965
966
967
968
969
970
971
972
|
# File 'lib/chino_ruby.rb', line 960
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
|