admin-vmc-plugin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,49 @@
1
+ require "vmc/cli"
2
+
3
+ module VMCAdmin
4
+ class Curl < VMC::CLI
5
+ def precondition
6
+ check_target
7
+ end
8
+
9
+ desc "Execute a raw request"
10
+ group :admin
11
+ input :mode, :argument => :required,
12
+ :desc => "Request mode (Get/Put/etc.)"
13
+ input :path, :argument => :required,
14
+ :desc => "Request path"
15
+ input :headers, :argument => :splat,
16
+ :desc => "Headers (i.e. Foo: bar)"
17
+ input :body, :alias => "-b",
18
+ :desc => "Request body"
19
+ def curl
20
+ mode = input[:mode].capitalize.to_sym
21
+ path = input[:path]
22
+ body = input[:body]
23
+
24
+ headers = {}
25
+ input[:headers].each do |h|
26
+ k, v = h.split(/\s*:\s*/, 2)
27
+ headers[k.downcase] = v
28
+ end
29
+
30
+ content = headers["content-type"] || :json
31
+ accept = headers["accept"] || :json
32
+
33
+ res =
34
+ client.base.request_path(
35
+ Net::HTTP.const_get(mode),
36
+ path.split("/"),
37
+ :headers => headers,
38
+ :accept => accept,
39
+ :payload => body,
40
+ :content => body && content)
41
+
42
+ if [:json, "application/json"].include? accept
43
+ puts MultiJson.dump(res, :pretty => true)
44
+ else
45
+ puts res
46
+ end
47
+ end
48
+ end
49
+ end
@@ -1 +1,2 @@
1
+ require "admin-vmc-plugin/curl"
1
2
  require "admin-vmc-plugin/service_auth_token"
@@ -1,3 +1,3 @@
1
1
  module VMCAdmin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin-vmc-plugin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-09-17 00:00:00 Z
18
+ date: 2012-11-09 00:00:00 -08:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: cfoundry
@@ -44,9 +45,11 @@ extra_rdoc_files: []
44
45
 
45
46
  files:
46
47
  - Rakefile
48
+ - lib/admin-vmc-plugin/version.rb
47
49
  - lib/admin-vmc-plugin/plugin.rb
48
50
  - lib/admin-vmc-plugin/service_auth_token.rb
49
- - lib/admin-vmc-plugin/version.rb
51
+ - lib/admin-vmc-plugin/curl.rb
52
+ has_rdoc: true
50
53
  homepage: http://cloudfoundry.com/
51
54
  licenses: []
52
55
 
@@ -76,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
79
  requirements: []
77
80
 
78
81
  rubyforge_project: admin-vmc-plugin
79
- rubygems_version: 1.8.24
82
+ rubygems_version: 1.6.2
80
83
  signing_key:
81
84
  specification_version: 3
82
85
  summary: Cloud Foundry administration commands.