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.
- #update_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.
6 7 8 |
# File 'lib/schema_registry/subject.rb', line 6 def initialize(client, name) @client, @name = client, name end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/schema_registry/subject.rb', line 4 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/schema_registry/subject.rb', line 4 def name @name end |
Instance Method Details
#compatibility_level ⇒ Object
26 27 28 29 |
# File 'lib/schema_registry/subject.rb', line 26 def compatibility_level response = client.request(:get, "/config/#{name}") response["compatibilityLevel"] end |
#compatibility_level=(level) ⇒ Object
31 32 33 |
# File 'lib/schema_registry/subject.rb', line 31 def compatibility_level=(level) response = client.request(:put, "/config/#{name}", compatibility: level) end |
#compatible?(schema, version = "latest") ⇒ Boolean
35 36 37 38 |
# File 'lib/schema_registry/subject.rb', line 35 def compatible?(schema, version = "latest") response = client.request(:post, "/compatibility/subjects/#{name}/versions/#{version}", schema: schema) response["is_compatible"] end |
#update_schema(schema_json) ⇒ Object
22 23 24 |
# File 'lib/schema_registry/subject.rb', line 22 def update_schema(schema_json) client.request(:post, "/subjects/#{name}/versions", schema: schema_json)["id"] end |
#verify_schema(schema_json) ⇒ Object
18 19 20 |
# File 'lib/schema_registry/subject.rb', line 18 def verify_schema(schema_json) client.request(:post, "/subjects/#{name}", schema: schema_json) end |
#version(version) ⇒ Object
14 15 16 |
# File 'lib/schema_registry/subject.rb', line 14 def version(version) client.request(:get, "/subjects/#{name}/versions/#{version}") end |
#versions ⇒ Object
10 11 12 |
# File 'lib/schema_registry/subject.rb', line 10 def versions client.request(:get, "/subjects/#{name}/versions") end |