Class: SchemaRegistry::Subject
- Inherits:
-
Object
- Object
- SchemaRegistry::Subject
- Defined in:
- lib/schema_registry/subject.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #compatibility_level ⇒ Object
- #compatibility_level=(level) ⇒ Object
- #compatible?(schema, version = "latest") ⇒ Boolean
-
#initialize(client, name) ⇒ Subject
constructor
A new instance of Subject.
- #register_schema(schema_json) ⇒ Object
- #verify_schema(schema_json) ⇒ Object
- #version(version) ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(client, name) ⇒ Subject
Returns a new instance of Subject.
21 22 23 |
# File 'lib/schema_registry/subject.rb', line 21 def initialize(client, name) @client, @name = client, name end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
19 20 21 |
# File 'lib/schema_registry/subject.rb', line 19 def client @client end |
#name ⇒ Object (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_level ⇒ Object
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 |
#versions ⇒ Object
25 26 27 |
# File 'lib/schema_registry/subject.rb', line 25 def versions client.request(:get, "/subjects/#{name}/versions") end |