diff --git a/schemaregistry.go b/schemaregistry.go index 51d08f4..f45f368 100644 --- a/schemaregistry.go +++ b/schemaregistry.go @@ -604,6 +604,21 @@ func (c *Client) GetLatestSchema(subject string) (Schema, error) { return c.getSubjectSchemaAtVersion(subject, SchemaLatestVersion) } +// getGlobalConfig returns the default compatibility level of the schema registry +func (c *Client) getGlobalConfig() (Config, error) { + var err error + var config = Config{} + + resp, respErr := c.do(http.MethodGet, "/config", "", nil) + if respErr != nil && respErr.(ResourceError).ErrorCode != 404 { + return config, respErr + } + if resp != nil { + err = c.readJSON(resp, &config) + } + return config, err +} + // getConfigSubject returns the Config of global or for a given subject. It handles 404 error in a // different way, since not-found for a subject configuration means it's using global. func (c *Client) getConfigSubject(subject string) (Config, error) { @@ -618,7 +633,6 @@ func (c *Client) getConfigSubject(subject string) (Config, error) { if resp != nil { err = c.readJSON(resp, &config) } - return config, err } @@ -650,6 +664,11 @@ func (c *Client) GetConfig(subject string) (Config, error) { return c.getConfigSubject(subject) } +// GetGlobalConfig returns the global compatibility level of the schema registry +func (c *Client) GetGlobalConfig() (Config, error) { + return c.getGlobalConfig() +} + // SetConfig sets the configuration (Config type) for global Schema-Registry or a specific // subject. When Config returned has "compatibilityLevel" empty, it's using global settings. func (c *Client) SetConfig(subject, level string) error {