Class: SchemaRegistry::Subject

Inherits:
Object
  • Object
show all
Defined in:
lib/schema_registry/subject.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, name) ⇒ Subject



21
22
23
# File 'lib/schema_registry/subject.rb', line 21

def initialize(client, name)
  @client, @name = client, name
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



19
20
21
# File 'lib/schema_registry/subject.rb', line 19

def client
  @client
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/schema_registry/subject.rb', line 19

def name
  @name
end

Instance Method Details

#compatibility_levelObject



41
42
43
44
# File 'lib/schema_registry/subject.rb', line 41

def compatibility_level
  response = client.request(:get, "/config/#{name}")
  response["compatibilityLevel"]
end

#compatibility_level=(level) ⇒ Object



46
47
48
# File 'lib/schema_registry/subject.rb', line 46

def compatibility_level=(level)
  client.request(:put, "/config/#{name}", compatibility: level)
end

#compatible?(schema, version = "latest") ⇒ Boolean



50
51
52
53
# File 'lib/schema_registry/subject.rb', line 50

def compatible?(schema, version = "latest")
  response = client.request(:post, "/compatibility/subjects/#{name}/versions/#{version}", schema: schema)
  response["is_compatible"]
end

#register_schema(schema_json) ⇒ Object



37
38
39
# File 'lib/schema_registry/subject.rb', line 37

def register_schema(schema_json)
  client.request(:post, "/subjects/#{name}/versions", schema: schema_json)['id']
end

#verify_schema(schema_json) ⇒ Object



33
34
35
# File 'lib/schema_registry/subject.rb', line 33

def verify_schema(schema_json)
  SchemaRegistration.new(self, client.request(:post, "/subjects/#{name}", schema: schema_json))
end

#version(version) ⇒ Object



29
30
31
# File 'lib/schema_registry/subject.rb', line 29

def version(version)
  SchemaRegistration.new(self, client.request(:get, "/subjects/#{name}/versions/#{version}"))
end

#versionsObject



25
26
27
# File 'lib/schema_registry/subject.rb', line 25

def versions
  client.request(:get, "/subjects/#{name}/versions")
end