rails_service_broker 0.1.0 → 0.1.1

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: 31a62376238ea4d6d128c93c0299684d638ee91a
4
- data.tar.gz: 50caf2a7fa37536055ef96023fdc016ca48725d7
3
+ metadata.gz: 2cf2be217815247f31b172b082aec798238cffed
4
+ data.tar.gz: acece6e790e4f8fed0f71b25cff7583fdc81d336
5
5
  SHA512:
6
- metadata.gz: 33c5efd5dc2a70fc5586e305189205a390537f14b0c540b8d548f646f29debd7f320d32834f222d657488e84e67ef2982f1fc2498ca70883747bc21dadb509c7
7
- data.tar.gz: 124a80dd9e923d4d3963a8551273189c997e3707d08faa0f898a5de2ac792f842946858f483d16f7ba409fb61fc3ca737bd03fdd2b6cf6dbb585ebcf9dd85f0b
6
+ metadata.gz: 279d64a5f8cc9382b0a3083bbe55d1b3deb5629cea510bba7ab46b5658779065aee0926315a2c50b892891711413f95acac389624491b4c1ca8c85f14748cf93
7
+ data.tar.gz: 8375b4355d80fbdbb1723a7a226b01407cb118b05e3bc558e6f484a040538ae43739b4630ec9af992109bbdd089d355267e9c56753b34dd9de7b513a889f296d
@@ -3,13 +3,16 @@ module RailsServiceBroker
3
3
  source_root File.expand_path('../../templates', __FILE__)
4
4
  argument :api_version, type: :string, default: "v2"
5
5
  argument :api_dir, type: :string, default: "apis"
6
+ argument :service_id, default: SecureRandom.uuid
7
+ argument :plan_id, default: SecureRandom.uuid
6
8
 
7
- def add_template_grape_files
9
+ def add_template_grape_files_and_spec
8
10
  template "apis/base.rb", "app/#{api_dir}/#{plural_name.singularize}/base.rb"
9
11
  template "apis/#{api_version}/base.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/base.rb"
10
12
  template "apis/#{api_version}/catalog.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/catalog.rb"
11
13
  template "apis/#{api_version}/service_binding.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/service_binding.rb"
12
14
  template "apis/#{api_version}/service_instance.rb", "app/#{api_dir}/#{plural_name.singularize}/#{api_version}/service_instance.rb"
15
+ template "specs/#{api_version}/service_broker_api_spec.rb", "spec/requests/#{api_dir}/#{plural_name.singularize}/#{api_version}/service_broker_api_spec.rb"
13
16
  end
14
17
 
15
18
  def add_template_service_yaml
@@ -2,7 +2,7 @@ module <%= plural_name.singularize.classify %>
2
2
  module V2
3
3
  class Catalog < Grape::API
4
4
  resource :catalog do
5
- desc 'GET /v2/catalog'
5
+ desc 'GET /<%= plural_name.singularize %>/v2/catalog'
6
6
  get '/', jbuilder: '<%= plural_name.singularize %>/v2/catalog.json' do
7
7
  @services = YAML.load_file(File.join(Rails.root, 'config', '<%= plural_name.singularize %>_service.yml'))
8
8
  end
@@ -4,7 +4,7 @@ module <%= plural_name.singularize.classify %>
4
4
  resource :service_instances do
5
5
  route_param :instance_id do
6
6
  resource :service_bindings do
7
- desc 'PUT /v2/service_instances/:instance_id/service_bindings/:binding_id'
7
+ desc 'PUT /<%= plural_name.singularize %>/v2/service_instances/:instance_id/service_bindings/:binding_id'
8
8
  # Bind service
9
9
  # 201 Created Binding has been created.
10
10
  # 200 OK the binding already exists and requested parameters are identical to the existing binding.
@@ -12,14 +12,21 @@ module <%= plural_name.singularize.classify %>
12
12
  # 422 Unprocessable Entity
13
13
  put '/:binding_id' do
14
14
  # TODO Write code to return HTTP status code for create service binding result.
15
+ return {
16
+ credentials: {
17
+ },
18
+ syslog_drain_url: "http://syslog_drain_url", # this parameter is optional.
19
+ route_service_url: "http://route_service_url" # If you create route service broker, this parameter must be need.
20
+ }
15
21
  end
16
22
 
17
- desc 'DELETE /v2/service_instances/:instance_id/service_bindings/:binding_id'
23
+ desc 'DELETE /<%= plural_name.singularize %>/v2/service_instances/:instance_id/service_bindings/:binding_id'
18
24
  # Unbinding service
19
25
  # 200 OK Binding was deleted.
20
26
  # 410 Gone Binding does not exist.
21
- put '/:binding_id' do
27
+ delete '/:binding_id' do
22
28
  # TODO Write code to return HTTP status code for delete service binding result.
29
+ return { }
23
30
  end
24
31
  end
25
32
  end
@@ -2,32 +2,42 @@ module <%= plural_name.singularize.classify %>
2
2
  module V2
3
3
  class ServiceInstance < Grape::API
4
4
  resource :service_instances do
5
- desc 'PUT /v2/service_instances/:instance_id'
5
+ desc 'PUT /<%= plural_name.singularize %>/v2/service_instances/:instance_id'
6
6
  # Catalog Management
7
7
  # Status Code
8
8
  # 200 OK The expected response body is below.
9
9
  put '/:instance_id' do
10
10
  # TODO Write code to return HTTP status code for create service instance
11
+ return {
12
+ dashboard_url: "http://path.to/dashboard_url",
13
+ operation: "create in progress" # TODO 'operation' field is optional.
14
+ }
11
15
  end
12
16
 
13
- desc 'GET /v2/service_instances/:instance_id/last_opration'
17
+ desc 'GET /<%= plural_name.singularize %>/v2/service_instances/:instance_id/last_opration'
14
18
  # Polling Last Operation(async only)
15
19
  # 200 OK The expected response body is below.
16
20
  # 410 GONE Appropriate only for asynchronous delete requests.
17
21
  get '/:instance_id/last_operation' do
18
22
  # TODO Write code to return HTTP status code for create service progress(optional)
23
+ return {
24
+ operation: "create in progress" # TODO 'operation' field is optional
25
+ }
19
26
  end
20
27
 
21
- desc 'PATCH /v2/service_instances/:instance_id'
28
+ desc 'PATCH /<%= plural_name.singularize %>/v2/service_instances/:instance_id'
22
29
  # Updating a Service Instance
23
30
  # 200 OK New plan is effective.
24
31
  # 202 Accepted Service instance update is in progress.
25
32
  # 422 Unprocessable entity May be returned if the particular plan change requested is not supported.
26
33
  patch '/:instance_id' do
27
34
  # TODO Write code to return HTTP status code for update service instance(optional)
35
+ return {
36
+ operation: "update in progress" # TODO 'operation' field is optional
37
+ }
28
38
  end
29
39
 
30
- desc 'DELETE /v2/service_instances/:instance_id'
40
+ desc 'DELETE /<%= plural_name.singularize %>/v2/service_instances/:instance_id'
31
41
  # Deprovisioning
32
42
  # 200 OK Service instance was deleted.
33
43
  # 202 Accepted Service instance deletion is in progress.
@@ -35,6 +45,9 @@ module <%= plural_name.singularize.classify %>
35
45
  # 422 Unprocessable Entity
36
46
  delete '/:instance_id' do
37
47
  # TODO Write code to return HTTP status code for delete service instance
48
+ return {
49
+ operation: "delete in progress" # TODO 'operation' field is optional
50
+ }
38
51
  end
39
52
  end
40
53
  end
@@ -1,6 +1,6 @@
1
1
  services:
2
2
  - name: "TODO: Put your service"
3
- id: "<%= SecureRandom.uuid %>"
3
+ id: "<%= service_id %>"
4
4
  description: "TODO: Put your description"
5
5
  tags: "TODO: Put your service type"
6
6
  requires: ""
@@ -15,19 +15,22 @@ services:
15
15
  documentationUrl: "TODO: Link to documentation page for service"
16
16
  supportUrl: "TODO: Link to support for the service"
17
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
18
+ id: 'TODO: Add client id when you would like to provide dashboard client'
19
+ secret: 'TODO: Add client secret when you would like to provide dashboard client'
20
+ redirect_uri: 'TODO: http://path.to/dashboard/oauth_endpoint'
21
+ plan_updateable: true
22
+ plans:
23
+ - name: "TODO: Add your plan"
24
+ id: "<%= plan_id %>"
25
+ description: "TODO: A short description of the service that will appear in the catalog"
26
+ metadata:
27
+ name: "TODO: A short name for the service plan to be displayed in a catalog"
28
+ description: "TODO: A description of the service plan to be displayed in a catalog"
29
+ bullets:
30
+ - "TODO: Features of this plan, to be displayed in a bulleted-list"
31
+ costs:
32
+ amount:
33
+ usd: 0
34
+ unit: "MONTHLY"
35
+ displayName: "TODO: Name of the plan to be display in graphical clients"
36
+ free: true
@@ -0,0 +1,80 @@
1
+ require 'rails_helper'
2
+
3
+ RSpec.describe "ServiceBrokerApis", type: :request do
4
+ describe "GET /<%= plural_name.singularize %>/v2/catalog" do
5
+ subject { get "/<%= plural_name.singularize %>/v2/catalog" }
6
+
7
+ it "works! (now write some real specs)" do
8
+ subject
9
+ expect(response).to have_http_status(200)
10
+ end
11
+ end
12
+
13
+ describe "PUT /<%= plural_name.singularize %>/v2/service_instances/:instance_id" do
14
+ let(:instance_id) { SecureRandom.uuid }
15
+ let(:organization_guid) { SecureRandom.uuid }
16
+ let(:space_guid) { SecureRandom.uuid }
17
+ let(:parameters) { { } }
18
+
19
+ subject do
20
+ put "/<%= plural_name.singularize %>/v2/service_instances/#{instance_id}",
21
+ params: { organization_guid: organization_guid,
22
+ plan_id: "<%= service_id %>",
23
+ service_id: "<%= plan_id %>",
24
+ space_guid: space_guid,
25
+ parameters: parameters }
26
+ end
27
+
28
+ it "return json with dashbaord_url" do
29
+ subject
30
+ json = JSON.parse(response.body)
31
+ expect(json["dashboard_url"]).to eq("http://path.to/dashboard_url")
32
+ end
33
+ end
34
+
35
+ describe "DELETE /<%= plural_name.singularize %>/v2/service_instances/:instance_id" do
36
+ let(:instance_id) { SecureRandom.uuid }
37
+ subject do
38
+ delete "/<%= plural_name.singularize %>/v2/service_instances/#{instance_id}",
39
+ params: {
40
+ service_id: "<%= service_id %>",
41
+ plan_id: "<%= plan_id %>"
42
+ }
43
+ end
44
+ it{ subject; expect(response.status).to eq(200) }
45
+ it{ subject; expect(response.body).to eq("{}") }
46
+ end
47
+
48
+ describe "PUT /<%= plural_name.singularize %>/v2/service_instances/:instance_id/service_bindings/:binding_id" do
49
+ let(:instance_id){ SecureRandom.uuid }
50
+ let(:app_guid){ SecureRandom.uuid }
51
+ let(:binding_id){ SecureRandom.uuid }
52
+
53
+ subject do
54
+ put "/<%= plural_name.singularize %>/v2/service_instances/#{instance_id}/service_bindings/#{binding_id}",
55
+ params: {
56
+ service_id: "<%= service_id %>",
57
+ plan_id: "<%= plan_id %>",
58
+ app_guid: app_guid
59
+ }
60
+ end
61
+
62
+ it{ subject; expect(response.status).to eq(200) }
63
+ end
64
+
65
+ describe "DELETE /v2/service_instances/:instance_id/service_bindings/:binding_id" do
66
+ let(:instance_id){ SecureRandom.uuid }
67
+ let(:binding_id){ SecureRandom.uuid }
68
+
69
+ subject do
70
+ delete "/<%= plural_name.singularize %>/v2/service_instances/#{instance_id}/service_bindings/#{binding_id}",
71
+ params: {
72
+ service_id: "<%= service_id %>",
73
+ plan_id: "<%= plan_id %>"
74
+ }
75
+ end
76
+
77
+ it{ subject; expect(response.status).to eq(200) }
78
+ end
79
+ end
80
+
@@ -1,5 +1,6 @@
1
1
  require "rails_service_broker/version"
2
2
  require "rails_service_broker/engine"
3
+ require "rails_service_broker/return_codes"
3
4
 
4
5
  require 'grape'
5
6
  require 'grape/jbuilder'
@@ -0,0 +1,8 @@
1
+ module RailsServiceBroker
2
+ OK = 200
3
+ CREATED = 201
4
+ ACCEPTED = 202
5
+ CONFLICT = 409
6
+ GONE = 410
7
+ UNPROCESSABLE_ENTITY = 422
8
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsServiceBroker
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_service_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshio Maki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape
@@ -104,9 +104,11 @@ files:
104
104
  - lib/generators/templates/apis/v2/service_binding.rb
105
105
  - lib/generators/templates/apis/v2/service_instance.rb
106
106
  - lib/generators/templates/config/service.yml
107
+ - lib/generators/templates/specs/v2/service_broker_api_spec.rb
107
108
  - lib/generators/templates/views/v2/catalog.json.jbuilder
108
109
  - lib/rails_service_broker.rb
109
110
  - lib/rails_service_broker/engine.rb
111
+ - lib/rails_service_broker/return_codes.rb
110
112
  - lib/rails_service_broker/version.rb
111
113
  - rails_service_broker.gemspec
112
114
  homepage: https://github.com/kirikak2/rails_service_broker