Method: Compliance::API.version
- Defined in:
- lib/bundles/inspec-compliance/api.rb
.version(config) ⇒ Object
return the server api version NB this method does not use Compliance::Configuration to allow for using it before we know the version (e.g. oidc or not)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bundles/inspec-compliance/api.rb', line 64 def self.version(config) url = config['server'] insecure = config['insecure'] raise ServerConfigurationMissing if url.nil? headers = get_headers(config) response = Compliance::HTTP.get(url+'/version', headers, insecure) return {} if response.code == '404' data = response.body return {} if data.nil? || data.empty? parsed = JSON.parse(data) return {} unless parsed.key?('version') && !parsed['version'].empty? parsed end |