Sha256: f09d4a89f9e24bbdfbb8b0931b9132f36b091449650d96ec07a6b79a6ad5e4e9

Contents?: true

Size: 932 Bytes

Versions: 15

Compression:

Stored size: 932 Bytes

Contents

module Berkshelf::API
  module Endpoint
    class V1 < Endpoint::Base
      helpers Berkshelf::API::Mixin::Services
      version 'v1', using: :header, vendor: 'berkshelf'
      default_format :json

      rescue_from Grape::Exceptions::Validation do |e|
        body = JSON.generate({status: e.status, message: e.message, param: e.param})
        rack_response(body, e.status, "Content-type" => "application/json")
      end

      desc "list all known cookbooks"
      get 'universe' do
        if cache_manager.warmed?
          cache_manager.cache
        else
          header "Retry-After", 600
          status 503
        end
      end

      desc "health check"
      get 'status' do
        {
          status: 'ok',
          version: Berkshelf::API::VERSION,
          cache_status: cache_manager.warmed? ? 'ok' : 'warming',
          uptime: Time.now.utc - Application.start_time,
        }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
berkshelf-api-3.0.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.2.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.1.3 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.1.2 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.1.1 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.1.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-2.0.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.4.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.3.1 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.3.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.2.2 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.2.1 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.2.0 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.2.0.rc2 lib/berkshelf/api/endpoint/v1.rb
berkshelf-api-1.2.0.rc1 lib/berkshelf/api/endpoint/v1.rb