cabal-api 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2c0db4445951ebe576c4a5bcf531beb97f3cf33
4
- data.tar.gz: 0a5989567df1b010b3fdf3bea2d36172359e7191
3
+ metadata.gz: 20a233adbec4e526558b82962883b7bf777665ae
4
+ data.tar.gz: 4bcbc4c6957abb5ef2602c429d03308c87c258ae
5
5
  SHA512:
6
- metadata.gz: b5940aba27b83d1b4a2ed49df5ab147ce23c3838f908c5b8f0c04382a744da3b10b6b6f63737d571979d67cf486be442cc8bd84320c3bb024ab6cc33f3d4b092
7
- data.tar.gz: 07c9fc0e25fa872c4742c8438a7f66280d0e85711dc33fd53b03c46453e27d82dfc995517e053de115bfbc44e769a37f0e2502aacd8730fc75e51491ba82ca60
6
+ metadata.gz: 322121fd444ec9c09b610f00b8a1a54cd9fe54e8c717e244c4b9a648ce26d331d9d6edf6d4f6c67d108758f2bba39291654f0728d73f04329524e66b32c8c7a2
7
+ data.tar.gz: 73ce4d8efb4fd1ffcb134906fccfed26d6c7831c79fc8008663156eea0ac4bde2e4df72024a088002a48d7a081e381887c929295baf4041484e2d14d7819e818
data/.travis.yml CHANGED
@@ -1,3 +1,4 @@
1
- language: ruby
1
+ sudo: false
2
+ services: redis-server
2
3
  rvm:
3
- - 2.2.2
4
+ - "2.2.2"
data/README.md CHANGED
@@ -66,6 +66,27 @@ The v2 API is made up of both public and private routes. Authentication is perfo
66
66
  > * json - Returns an object with `name` and `private_ssh_key` attributes
67
67
  > * xml - Returns a "hash" document with `name` and `private_ssh_key` elements
68
68
 
69
+ ### APIv2 ###
70
+
71
+ The v3 API is made up of both public and private routes. Authentication is performed by setting the `Authorization` request header to `API_KEY:API_SECRET` prior to performing the request.
72
+
73
+ * **(public)** *GET /api/v3/key/clustername*
74
+
75
+ > This route is exactly equivalent to the `v1` key route.
76
+
77
+ * **(private)** *GET /api/v3/private-key/clustername*
78
+
79
+ > This route is exactly equivalent to the `v2` private-key route.
80
+
81
+ * **(private)** *GET /api/v3/clusters*
82
+
83
+ > Returns the names of the clusters known to the API in the following format:
84
+ >
85
+ > * text - Returns a list of cluster names, one per line
86
+ > * json - Returns an array of objects with `name` attributes
87
+ > * xml - Returns an "array" document containing "hash" elements with a `name` element
88
+
89
+
69
90
  ## Development ##
70
91
 
71
92
  Branches and releases for this project are managed by [git-flow](https://github.com/nvie/gitflow).
data/Rakefile CHANGED
@@ -1 +1,13 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber/rake/task'
4
+
5
+ desc "Run specs"
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.pattern = 'spec/**/*_spec.rb'
8
+ end
9
+
10
+ desc "Run Cucumber suite"
11
+ Cucumber::Rake::Task.new
12
+
13
+ task :default => [:spec, :cucumber]
@@ -1,12 +1,14 @@
1
1
  require 'grape'
2
2
  require 'cabal/api/v1/base'
3
3
  require 'cabal/api/v2/base'
4
+ require 'cabal/api/v3/base'
4
5
 
5
6
  module Cabal
6
7
  module API
7
8
  class Base < Grape::API
8
9
  mount Cabal::API::V1::Base
9
10
  mount Cabal::API::V2::Base
11
+ mount Cabal::API::V3::Base
10
12
  end
11
13
  end
12
14
  end
@@ -0,0 +1,49 @@
1
+ require 'cabal/util'
2
+ require 'cabal/api/cluster'
3
+ require 'cabal/api/user'
4
+ require 'cabal/api/common/authenticated'
5
+ require 'cabal/api/common/mistakes'
6
+
7
+ module Cabal
8
+ module API
9
+ module Common
10
+ module PrivateKey
11
+ def self.included(base)
12
+ base.class_eval do
13
+ include Cabal::API::Common::Authenticated
14
+ include Cabal::API::Common::Mistakes
15
+
16
+ formatter :txt, ->(object, env) {
17
+ object[:private_ssh_key]
18
+ }
19
+
20
+ helpers do
21
+ def error_if_not_found!(cluster, name)
22
+ unless cluster
23
+ error!(
24
+ messagify("The cluster '#{name}' could not be found."),
25
+ 404
26
+ )
27
+ end
28
+ end
29
+ end
30
+
31
+ get '/private-key/:name' do
32
+ authenticate!
33
+
34
+ cluster_name = Cabal::Util.normalize(params[:name])
35
+ cluster = Cabal::API::Cluster.find(name: cluster_name).first
36
+
37
+ error_if_not_found!(cluster, cluster_name)
38
+
39
+ {
40
+ name: cluster.name,
41
+ private_ssh_key: cluster.private_key
42
+ }
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1,45 +1,11 @@
1
1
  require 'grape'
2
- require 'cabal/util'
3
- require 'cabal/api/cluster'
4
- require 'cabal/api/user'
5
- require 'cabal/api/common/authenticated'
6
- require 'cabal/api/common/mistakes'
2
+ require 'cabal/api/common/private_key'
7
3
 
8
4
  module Cabal
9
5
  module API
10
6
  module V2
11
7
  class PrivateKey < Grape::API
12
- include Cabal::API::Common::Authenticated
13
- include Cabal::API::Common::Mistakes
14
-
15
- formatter :txt, ->(object, env) {
16
- object[:private_ssh_key]
17
- }
18
-
19
- helpers do
20
- def error_if_not_found!(cluster, name)
21
- unless cluster
22
- error!(
23
- messagify("The cluster '#{name}' could not be found."),
24
- 404
25
- )
26
- end
27
- end
28
- end
29
-
30
- get '/private-key/:name' do
31
- authenticate!
32
-
33
- cluster_name = Cabal::Util.normalize(params[:name])
34
- cluster = Cabal::API::Cluster.find(name: cluster_name).first
35
-
36
- error_if_not_found!(cluster, cluster_name)
37
-
38
- {
39
- name: cluster.name,
40
- private_ssh_key: cluster.private_key
41
- }
42
- end
8
+ include Cabal::API::Common::PrivateKey
43
9
  end
44
10
  end
45
11
  end
@@ -0,0 +1,18 @@
1
+ require 'grape'
2
+ require 'cabal/api/v3/list'
3
+ require 'cabal/api/v3/public_key'
4
+ require 'cabal/api/v3/private_key'
5
+
6
+ module Cabal
7
+ module API
8
+ module V3
9
+ class Base < Grape::API
10
+ version 'v3', using: :path
11
+
12
+ mount Cabal::API::V3::List
13
+ mount Cabal::API::V3::PublicKey
14
+ mount Cabal::API::V3::PrivateKey
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,30 @@
1
+ require 'grape'
2
+ require 'cabal/util'
3
+ require 'cabal/api/cluster'
4
+ require 'cabal/api/user'
5
+ require 'cabal/api/common/authenticated'
6
+ require 'cabal/api/common/mistakes'
7
+
8
+ module Cabal
9
+ module API
10
+ module V3
11
+ class List < Grape::API
12
+ include Cabal::API::Common::Authenticated
13
+ include Cabal::API::Common::Mistakes
14
+
15
+ formatter :txt, ->(object, env) {
16
+ object.map {|cluster| cluster[:name]}.join("\n")
17
+ }
18
+
19
+ get '/clusters' do
20
+ authenticate!
21
+
22
+ Cabal::API::Cluster.
23
+ all.
24
+ sort(&:name).
25
+ map {|cluster| {name: cluster.name}}
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,12 @@
1
+ require 'grape'
2
+ require 'cabal/api/common/private_key'
3
+
4
+ module Cabal
5
+ module API
6
+ module V3
7
+ class PrivateKey < Grape::API
8
+ include Cabal::API::Common::PrivateKey
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'grape'
2
+ require 'cabal/util'
3
+ require 'cabal/api/common'
4
+
5
+ module Cabal
6
+ module API
7
+ module V3
8
+ class PublicKey < Grape::API
9
+ include Cabal::API::Common::PublicKey
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Cabal
2
2
  module Api
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cabal-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Walters
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2016-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -257,6 +257,7 @@ files:
257
257
  - lib/cabal/api/common.rb
258
258
  - lib/cabal/api/common/authenticated.rb
259
259
  - lib/cabal/api/common/mistakes.rb
260
+ - lib/cabal/api/common/private_key.rb
260
261
  - lib/cabal/api/common/public_key.rb
261
262
  - lib/cabal/api/user.rb
262
263
  - lib/cabal/api/v1/base.rb
@@ -264,6 +265,10 @@ files:
264
265
  - lib/cabal/api/v2/base.rb
265
266
  - lib/cabal/api/v2/private_key.rb
266
267
  - lib/cabal/api/v2/public_key.rb
268
+ - lib/cabal/api/v3/base.rb
269
+ - lib/cabal/api/v3/list.rb
270
+ - lib/cabal/api/v3/private_key.rb
271
+ - lib/cabal/api/v3/public_key.rb
267
272
  - lib/cabal/api/version.rb
268
273
  homepage: http://github.com/engineyard/cabal-api
269
274
  licenses: