rails_service_broker 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/initializers/rails_service_broker.rb +4 -0
- data/lib/generators/rails_service_broker/api_generator.rb +27 -0
- data/lib/generators/templates/apis/base.rb +5 -0
- data/lib/generators/templates/apis/v2/base.rb +13 -0
- data/lib/generators/templates/apis/v2/catalog.rb +13 -0
- data/lib/generators/templates/apis/v2/service_binding.rb +29 -0
- data/lib/generators/templates/apis/v2/service_instance.rb +42 -0
- data/lib/generators/templates/config/service.yml +33 -0
- data/lib/generators/templates/views/v2/catalog.json.jbuilder +2 -0
- data/lib/rails_service_broker/engine.rb +5 -0
- data/lib/rails_service_broker/version.rb +3 -0
- data/lib/rails_service_broker.rb +5 -0
- data/rails_service_broker.gemspec +25 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31a62376238ea4d6d128c93c0299684d638ee91a
|
4
|
+
data.tar.gz: 50caf2a7fa37536055ef96023fdc016ca48725d7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33c5efd5dc2a70fc5586e305189205a390537f14b0c540b8d548f646f29debd7f320d32834f222d657488e84e67ef2982f1fc2498ca70883747bc21dadb509c7
|
7
|
+
data.tar.gz: 124a80dd9e923d4d3963a8551273189c997e3707d08faa0f898a5de2ac792f842946858f483d16f7ba409fb61fc3ca737bd03fdd2b6cf6dbb585ebcf9dd85f0b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Toshio Maki
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Rails Service Broker
|
2
|
+
|
3
|
+
Very simple solution for create service broker on Ruby on Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails_service_broker'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rails_service_broker
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
When you would like to create AwesomeService ServiceBroker, you can write this.
|
24
|
+
|
25
|
+
```
|
26
|
+
# rails g rails_service_broker:api awesome_service
|
27
|
+
create app/apis/awesome_service/base.rb
|
28
|
+
create app/apis/awesome_service/v2/base.rb
|
29
|
+
create app/apis/awesome_service/v2/catalog.rb
|
30
|
+
create app/apis/awesome_service/v2/service_binding.rb
|
31
|
+
create app/apis/awesome_service/v2/service_instance.rb
|
32
|
+
create config/awesome_service.yml
|
33
|
+
create app/views/api/awesome_service/v2/catalog.json.jbuilder
|
34
|
+
route mount AwesomeService::Base => '/awesome_service'
|
35
|
+
```
|
36
|
+
|
37
|
+
Service Broker Endpoint is create at `http://localhost:3000/awesome_service/` enjoy!
|
38
|
+
|
39
|
+
You have to edit `config/awesome_service.yml` for define service.
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kirikak2/rails_service_broker.
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_service_broker"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module RailsServiceBroker
|
2
|
+
class ApiGenerator < Rails::Generators::NamedBase
|
3
|
+
source_root File.expand_path('../../templates', __FILE__)
|
4
|
+
argument :api_version, type: :string, default: "v2"
|
5
|
+
argument :api_dir, type: :string, default: "apis"
|
6
|
+
|
7
|
+
def add_template_grape_files
|
8
|
+
template "apis/base.rb", "app/#{api_dir}/#{plural_name.singularize}/base.rb"
|
9
|
+
template "apis/#{api_version}/base.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/base.rb"
|
10
|
+
template "apis/#{api_version}/catalog.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/catalog.rb"
|
11
|
+
template "apis/#{api_version}/service_binding.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/service_binding.rb"
|
12
|
+
template "apis/#{api_version}/service_instance.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/service_instance.rb"
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_template_service_yaml
|
16
|
+
template "config/service.yml", "config/#{plural_name.singularize}_service.yml"
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_template_jbuilder_files
|
20
|
+
template "views/#{api_version}/catalog.json.jbuilder", "app/views/api/#{plural_name.singularize}/v2/catalog.json.jbuilder"
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_routes
|
24
|
+
route "mount #{plural_name.singularize.classify}::Base => '/#{plural_name.singularize}'"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module <%= plural_name.singularize.classify %>
|
2
|
+
module V2
|
3
|
+
class Base < Grape::API
|
4
|
+
version '<%= api_version %>'
|
5
|
+
format :json
|
6
|
+
formatter :json, Grape::Formatter::Jbuilder
|
7
|
+
|
8
|
+
mount Catalog
|
9
|
+
mount ServiceBinding
|
10
|
+
mount ServiceInstance
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module <%= plural_name.singularize.classify %>
|
2
|
+
module V2
|
3
|
+
class Catalog < Grape::API
|
4
|
+
resource :catalog do
|
5
|
+
desc 'GET /v2/catalog'
|
6
|
+
get '/', jbuilder: '<%= plural_name.singularize %>/v2/catalog.json' do
|
7
|
+
@services = YAML.load_file(File.join(Rails.root, 'config', '<%= plural_name.singularize %>_service.yml'))
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module <%= plural_name.singularize.classify %>
|
2
|
+
module V2
|
3
|
+
class ServiceBinding < Grape::API
|
4
|
+
resource :service_instances do
|
5
|
+
route_param :instance_id do
|
6
|
+
resource :service_bindings do
|
7
|
+
desc 'PUT /v2/service_instances/:instance_id/service_bindings/:binding_id'
|
8
|
+
# Bind service
|
9
|
+
# 201 Created Binding has been created.
|
10
|
+
# 200 OK the binding already exists and requested parameters are identical to the existing binding.
|
11
|
+
# 409 Conflict the requested binding already exists.
|
12
|
+
# 422 Unprocessable Entity
|
13
|
+
put '/:binding_id' do
|
14
|
+
# TODO Write code to return HTTP status code for create service binding result.
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'DELETE /v2/service_instances/:instance_id/service_bindings/:binding_id'
|
18
|
+
# Unbinding service
|
19
|
+
# 200 OK Binding was deleted.
|
20
|
+
# 410 Gone Binding does not exist.
|
21
|
+
put '/:binding_id' do
|
22
|
+
# TODO Write code to return HTTP status code for delete service binding result.
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module <%= plural_name.singularize.classify %>
|
2
|
+
module V2
|
3
|
+
class ServiceInstance < Grape::API
|
4
|
+
resource :service_instances do
|
5
|
+
desc 'PUT /v2/service_instances/:instance_id'
|
6
|
+
# Catalog Management
|
7
|
+
# Status Code
|
8
|
+
# 200 OK The expected response body is below.
|
9
|
+
put '/:instance_id' do
|
10
|
+
# TODO Write code to return HTTP status code for create service instance
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'GET /v2/service_instances/:instance_id/last_opration'
|
14
|
+
# Polling Last Operation(async only)
|
15
|
+
# 200 OK The expected response body is below.
|
16
|
+
# 410 GONE Appropriate only for asynchronous delete requests.
|
17
|
+
get '/:instance_id/last_operation' do
|
18
|
+
# TODO Write code to return HTTP status code for create service progress(optional)
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'PATCH /v2/service_instances/:instance_id'
|
22
|
+
# Updating a Service Instance
|
23
|
+
# 200 OK New plan is effective.
|
24
|
+
# 202 Accepted Service instance update is in progress.
|
25
|
+
# 422 Unprocessable entity May be returned if the particular plan change requested is not supported.
|
26
|
+
patch '/:instance_id' do
|
27
|
+
# TODO Write code to return HTTP status code for update service instance(optional)
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'DELETE /v2/service_instances/:instance_id'
|
31
|
+
# Deprovisioning
|
32
|
+
# 200 OK Service instance was deleted.
|
33
|
+
# 202 Accepted Service instance deletion is in progress.
|
34
|
+
# 410 Gone The service instance does not exist.
|
35
|
+
# 422 Unprocessable Entity
|
36
|
+
delete '/:instance_id' do
|
37
|
+
# TODO Write code to return HTTP status code for delete service instance
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
services:
|
2
|
+
- name: "TODO: Put your service"
|
3
|
+
id: "<%= SecureRandom.uuid %>"
|
4
|
+
description: "TODO: Put your description"
|
5
|
+
tags: "TODO: Put your service type"
|
6
|
+
requires: ""
|
7
|
+
bindable: true
|
8
|
+
metadata:
|
9
|
+
name: "TODO: A short name for the service to be displayed"
|
10
|
+
description: "TODO: A short-1-line description for the service"
|
11
|
+
displayName: "TODO: The name of the service to be displayed in graphical clients"
|
12
|
+
imageUrl: "TODO: The URL to an image"
|
13
|
+
longDescription: "TODO: Long description"
|
14
|
+
providerDisplayName: "TODO: The name of the upstream entity providing the actual service"
|
15
|
+
documentationUrl: "TODO: Link to documentation page for service"
|
16
|
+
supportUrl: "TODO: Link to support for the service"
|
17
|
+
dashboard_client:
|
18
|
+
plan_updateable: true
|
19
|
+
plans:
|
20
|
+
- name: "TODO: Add your plan"
|
21
|
+
id: "<%= SecureRandom.uuid %>"
|
22
|
+
description: "TODO: A short description of the service that will appear in the catalog"
|
23
|
+
metadata:
|
24
|
+
name: "TODO: A short name for the service plan to be displayed in a catalog"
|
25
|
+
description: "TODO: A description of the service plan to be displayed in a catalog"
|
26
|
+
bullets:
|
27
|
+
- "TODO: Features of this plan, to be displayed in a bulleted-list"
|
28
|
+
costs:
|
29
|
+
amount:
|
30
|
+
usd: 0
|
31
|
+
unit: "MONTHLY"
|
32
|
+
displayName: "TODO: Name of the plan to be display in graphical clients"
|
33
|
+
free: true
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rails_service_broker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_service_broker"
|
8
|
+
spec.version = RailsServiceBroker::VERSION
|
9
|
+
spec.authors = ["Toshio Maki"]
|
10
|
+
spec.email = ["toshio.maki.yy@hitachi-solutions.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Generate service broker template for Cloud Foundry}
|
13
|
+
spec.description = %q{This gem is generate api template for Cloud Foundry Service Broker API.}
|
14
|
+
spec.homepage = %q{https://github.com/kirikak2/rails_service_broker}
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "grape"
|
21
|
+
spec.add_dependency "grape-jbuilder"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_service_broker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Toshio Maki
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grape
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: grape-jbuilder
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: This gem is generate api template for Cloud Foundry Service Broker API.
|
84
|
+
email:
|
85
|
+
- toshio.maki.yy@hitachi-solutions.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/console
|
98
|
+
- bin/setup
|
99
|
+
- config/initializers/rails_service_broker.rb
|
100
|
+
- lib/generators/rails_service_broker/api_generator.rb
|
101
|
+
- lib/generators/templates/apis/base.rb
|
102
|
+
- lib/generators/templates/apis/v2/base.rb
|
103
|
+
- lib/generators/templates/apis/v2/catalog.rb
|
104
|
+
- lib/generators/templates/apis/v2/service_binding.rb
|
105
|
+
- lib/generators/templates/apis/v2/service_instance.rb
|
106
|
+
- lib/generators/templates/config/service.yml
|
107
|
+
- lib/generators/templates/views/v2/catalog.json.jbuilder
|
108
|
+
- lib/rails_service_broker.rb
|
109
|
+
- lib/rails_service_broker/engine.rb
|
110
|
+
- lib/rails_service_broker/version.rb
|
111
|
+
- rails_service_broker.gemspec
|
112
|
+
homepage: https://github.com/kirikak2/rails_service_broker
|
113
|
+
licenses:
|
114
|
+
- MIT
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.5.1
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Generate service broker template for Cloud Foundry
|
136
|
+
test_files: []
|