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

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

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/schema_registry/subject.rb', line 4

def client
  @client
end

#nameObject (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_levelObject



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

Returns:

  • (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

#versionsObject



10
11
12
# File 'lib/schema_registry/subject.rb', line 10

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