Name: sample-resource-service-brokers
Owner: International Business Machines
Description: This repository provides sample Open Service Broker (OSB) service brokers for providers to use when integrating services with IBM Cloud.
Created: 2018-04-03 00:58:36.0
Updated: 2018-04-24 13:43:53.0
Pushed: 2018-04-24 13:43:52.0
Size: 1507
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This repository provides sample Open Service Broker (OSB) service brokers for providers to use when integrating services with IBM Cloud. These samples conform to the OSB specification (https://github.com/openservicebrokerapi/servicebroker/blob/v2.12/spec.md). The samples are to be used with the IBM Cloud Resource Management Console (https://console.bluemix.net/onboarding).
These samples include OSB logic for catalog (GET), provision (PUT), bind (PUT), unbind (DELETE), unprovision (DELETE), update service (PATCH) and get service last operation (GET). These samples also include logic for the IBM Cloud extensions of enable (PUT) and state (GET).
Each call into the service broker implementation has an http authorization header. Each call should verify the value. The user and password for this verification correspond to the values provided to the IBM Cloud Resource Management Console.
In order to expose error text from a service broker for the provision, bind, unbind, unprovision, update and get service last operation entry points, return a JSON object with a description entry. This error text will be displayed in the IBM Cloud console when invoked due to an action in the IBM Cloud console.
"description" : "Service failed due to invalid authorization"
This REST API will be called to retrieve the list of service offerings and their service plans.
The URL path for the GET invoked within the service broker implementation is /v2/catalog
.
A status code of 200 is the expected successful value.
The fields returned from a catalog GET within the JSON result are as follows:
bluemix resource service-instance-create
. Use lowercase and don't include spaces.false
if omitted.true
.bluemix resource service-instance-create
. Use lowercase and don't include spaces.
"services" :
[
{
"bindable" : true,
"description" : "Test Node Resource Service Broker Description",
"id" : "service-guid-here",
"metadata" :
{
"displayName : "Test Node Resource Service Broker Display Name",
"documentationUrl" : "http://10.0.1.2/documentation.html,
"imageUrl" : "http://10.0.1.2/servicesample.png",
"instructionsUrl" : "http://10.0.1.2/servicesample.md",
"longDescription" : "Test Node Resource Service Broker Plan Long Description",
"providerDisplayName" : "Some Company",
"supportUrl" : "http://10.0.1.2/support.html",
"termsUrl" : "http://10.0.1.2/terms.html"
},
"name" : "testnoderesourceservicebrokername",
"plan_updateable" : true,
"tags" : [ "lite", "tag1a", "tag1b" ],
"plans" :
[
{
"description" : "Test Node Resource Service Broker Plan Description",
"free" : true,
"id" : "plan-guid-here",
"metadata" :
{
"bullets" : [ "Test bullet 1", "Test bullet 2" ],
"displayName" : "Lite"
},
"name" : "lite"
}
]
}
]
-X GET -H "Accept:application/json" -H "X-Broker-Api-Version:2.12" -u "TestServiceBrokerUser:TestServiceBrokerPassword" http://localhost:3000/v2/catalog
The URL path for the PUT invoked within the service broker implementation is /v2/service_instances/:instance_id
where :instance_id
is the id generated by IBM Cloud for the service instance.
The fields passed into a provision PUT as query parameters are as follows:
false
.The fields passed into a provision PUT within the JSON body are as follows:
ibmcloud
bluemix resource service-instance-create
. This will be one of the service plans ID's from get catalog.bluemix resource service-instance-create
. This will be one of the service ID's from get catalog
"context" :
{
"account_id" : "account-id-here",
"crn" : "crn-here",
"platform" : "ibmcloud",
"resource_group_crn : "resource-group-crn-here",
"target_crn" : "target-crn-here"
},
"plan_id" : "plan-guid-here",
"service_id" : "service-guid-here"
/v2/service_instances/:instance_id/last_operation
will be invoked to check creation status. The expected successful response body is below.{}
.?accepts_incomplete=true
was not specified on the request. The expected response body includes an error field and an optional user-facing description field:
"error" : "AsyncRequired",
"description" : "This service plan requires support for asynchronous service operations."
The fields returned from a successful provision PUT within the JSON result are as follows for a 200/201/202
/v2/service_instances/:instance_id/last_operation
requests
"dashboard_url" : "http://www.ibm.com",
"description" : "Your service is being created asynchronously.",
"operation" : "Provision_45"
-X PUT -H "Accept:application/json" -H "Content-Type:application/json" -H "X-Broker-Api-Version:2.12" -H "X-Broker-Api-Originating-Identity:ibmcloud eyJpYW1faWQiOiJJQk1pZC0zMTAwMDJNNEpGIiwic3ViIjoiYmx1ZW1peF91aV9zb3Rlc3RAbWFpbGluYXRvci5jb20ifQ==" -u "TestServiceBrokerUser:TestServiceBrokerPassword" -d "{\"context\":{\"account_id\":\"499b176abb3e1c9727df87ae48b27c7b\",\"crn\":\"crn:v1:bluemix:public:testjavaresourceservicebrokername:us-south:a\/499b176abb3e1c9727df87ae48b27c7b:7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7::\",\"platform\":\"ibmcloud\",\"resource_group_crn\":\"crn:v1:bluemix:public:resource-controller::a\/499b176abb3e1c9727df87ae48b27c7b::resource-group:2a5f74056b254efbaab5e9e28a711141\",\"target_crn\":\"crn:v1:bluemix:public:resource-catalog::a\/e97a8c01ac694e308ef3ad7795c7cdb3::deployment:e62e2c19-0c3b-41e3-b8b3-c71762ecd489%3Aus-south38399\"}, \"parameters\":{\"parameter1\":1, \"parameter2\":\"value\"}, \"plan_id\":\"e62e2c19-0c3b-41e3-b8b3-c71762ecd489\", \"service_id\":\"cb55391b-3416-4943-a6a6-a541778c1924\"}" http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A?accepts_incomplete=true
The URL path for the PUT invoked within the service broker implementation is /v2/service_instances/:instance_id/service_bindings/:binding_id
where :instance_id
is the id generated by IBM Cloud for the service instance and :binding_id
is the id generated by IBM Cloud for the service/app binding.
The fields passed into a bind PUT within the JSON body are as follows:
bluemix resource service-instance-create
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service ID's from get catalog
"bind_resource :
{
"app_guid" : "80e0caaa-4145-4f2a-9bf8-1ab00fff1766"
},
"plan_id" : "plan-guid-here",
"service_id" : "service-guid-here"
{}
.
"error" : "RequiresApp",
"description" : "This service does not support service keys."
The fields returned from a bind PUT within the JSON result are as follows for a 200/201:
"credentials" :
{
"url" : "http://10.0.1.2:12345",
"userid" : "8401a824-1da7-4114-8664-2460db21661a",
"password" : "b98e9690-c5e7-405f-9ef6-d6fa36afbaba"
}
-X PUT -H "Accept:application/json" -H "Content-Type:application/json" -H "X-Broker-Api-Version:2.12" -H "X-Broker-Api-Originating-Identity:ibmcloud eyJpYW1faWQiOiJJQk1pZC0zMTAwMDJNNEpGIiwic3ViIjoiYmx1ZW1peF91aV9zb3Rlc3RAbWFpbGluYXRvci5jb20ifQ==" -u "TestServiceBrokerUser:TestServiceBrokerPassword" -d "{\"bind_resource\":{\"app_guid\":\"d3f16a48-8bd1-4aab-a7de-e2a22ad38292\"}, \"parameters\":{\"parameter1\":1, \"parameter2\":\"value\"}, \"plan_id\":\"e62e2c19-0c3b-41e3-b8b3-c71762ecd489\", \"service_id\":\"cb55391b-3416-4943-a6a6-a541778c1924\"}" http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A/service_bindings/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3Aresource-key%3A92dba2e9-86e7-4bb6-8e9f-b14294a41cbd
The URL path for the DELETE invoked within the service broker implementation is /v2/service_instances/:instance_id/service_bindings/:binding_id
where :instance_id
is the id generated by IBM Cloud for the service instance and :binding_id
is the id generated by IBM Cloud for the service/app binding.
The fields passed into an unbind DELETE as query parameters are as follows:
bluemix resource service-instance-create
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service ID's from get catalog{}
.{}
.
-X DELETE -H "Accept:application/json" -H "X-Broker-Api-Version:2.12" -H "X-Broker-Api-Originating-Identity:ibmcloud eyJpYW1faWQiOiJJQk1pZC0zMTAwMDJNNEpGIiwic3ViIjoiYmx1ZW1peF91aV9zb3Rlc3RAbWFpbGluYXRvci5jb20ifQ==" -u "TestServiceBrokerUser:TestServiceBrokerPassword" "http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A/service_bindings/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3Aresource-key%3A92dba2e9-86e7-4bb6-8e9f-b14294a41cbd?plan_id=e62e2c19-0c3b-41e3-b8b3-c71762ecd489&service_id=cb55391b-3416-4943-a6a6-a541778c1924"
The URL path for the DELETE invoked within the service broker implementation is /v2/service_instances/:instance_id
where :instance_id
is the id generated by IBM Cloud for the service instance.
The fields passed into an unprovision DELETE as query parameters are as follows:
false
.bluemix resource service-instance-create
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service ID's from get catalog/v2/service_instances/:instance_id/last_operation
will be invoked to check creation status. The expected successful response body is below.?accepts_incomplete=true
was not specified on the request. The expected response body includes an error field and an optional user-facing description field:
"error" : "AsyncRequired",
"description" : "This service plan requires support for asynchronous service operations."
The fields returned from a successful unprovision DELETE within the JSON result are as follows for a 200/202/410
/v2/service_instances/:instance_id/last_operation
requests
"description" : "Your service instance is being deleted asynchronously.",
"operation" : "Unprovision_45"
-X DELETE -H "Accept:application/json" -H "X-Broker-Api-Version:2.12" -H "X-Broker-Api-Originating-Identity:ibmcloud eyJpYW1faWQiOiJJQk1pZC0zMTAwMDJNNEpGIiwic3ViIjoiYmx1ZW1peF91aV9zb3Rlc3RAbWFpbGluYXRvci5jb20ifQ==" -u "TestServiceBrokerUser:TestServiceBrokerPassword" "http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A?accepts_incomplete=true&plan_id=e62e2c19-0c3b-41e3-b8b3-c71762ecd489&service_id=cb55391b-3416-4943-a6a6-a541778c1924"
The URL path for the PATCH invoked within the service broker implementation is /v2/service_instances/:instance_id
where :instance_id
is the id generated by IBM Cloud for the service instance.
The fields passed into an update PATCH as query parameters are as follows:
false
.The fields passed into an update-service PATCH within the JSON body are as follows:
ibmcloud
bluemix resource service-instance-update
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service ID's from get catalog
"context" :
{
"account_id" : "account-id-here",
"crn" : "crn-here",
"platform" : "ibmcloud",
"resource_group_crn : "resource-group-crn-here",
"target_crn" : "target-crn-here"
},
"plan_id" : "new-plan-guid-here",
"previous_values" :
{
"plan_id" : "plan-guid-here",
"service_id" : "service-guid-here"
}
/v2/service_instances/:instance_id/last_operation
will be invoked to check creation status. The expected successful response body is below.?accepts_incomplete=true
was not specified on the request. The expected response body includes an error field and an optional user-facing description field:
"error" : "AsyncRequired",
"description" : "This service plan requires support for asynchronous service operations."
The fields returned from a successful update PATCH within the JSON result are as follows for a 200/202
/v2/service_instances/:instance_id/last_operation
requests
"description" : "Your service instance is being updated asynchronously.",
"operation" : "Update_45"
-X PATCH -H "Accept:application/json" -H "Content-Type:application/json" -H "X-Broker-Api-Version:2.12" -H "X-Broker-Api-Originating-Identity:ibmcloud eyJpYW1faWQiOiJJQk1pZC0zMTAwMDJNNEpGIiwic3ViIjoiYmx1ZW1peF91aV9zb3Rlc3RAbWFpbGluYXRvci5jb20ifQ==" -u "TestServiceBrokerUser:TestServiceBrokerPassword" -d "{\"context\":{\"account_id\":\"499b176abb3e1c9727df87ae48b27c7b\",\"crn\":\"crn:v1:bluemix:public:testjavaresourceservicebrokername:us-south:a\/499b176abb3e1c9727df87ae48b27c7b:7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7::\",\"platform\":\"ibmcloud\",\"resource_group_crn\":\"crn:v1:bluemix:public:resource-controller::a\/499b176abb3e1c9727df87ae48b27c7b::resource-group:2a5f74056b254efbaab5e9e28a7111414\",\"target_crn\":\"crn:v1:bluemix:public:resource-catalog::a\/e97a8c01ac694e308ef3ad7795c7cdb3::deployment:e62e2c19-0c3b-41e3-b8b3-c71762ecd489%3Aus-south38399\"}, \"parameters\":{\"parameter1\":1, \"parameter2\":\"value\"}, \"plan_id\":\"e1031579-4b42-4169-b7cf-f7793c616fdc\", \"previous_values\":{\"plan_id\":\"e62e2c19-0c3b-41e3-b8b3-c71762ecd489\", \"service_id\":\"cb55391b-3416-4943-a6a6-a541778c1924\"}, \"service_id\":\"cb55391b-3416-4943-a6a6-a541778c1924\"}" http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A?accepts_incomplete=true
This REST API will be called intermittently to refresh the current state of an asynchronous service instance operation. This includes provision, unprovision and update.
The URL path for the GET invoked within the service broker implementation is /v2/service_instances/:instance_id/last_operation
where :instance_id
is the id generated by IBM Cloud for the service instance.
The fields passed into a GET last operation as query parameters are as follows:
bluemix resource service-instance-create
. This will be one of the service plans ID's from get catalogbluemix resource service-instance-create
. This will be one of the service ID's from get catalogA status code of 200 is the expected successful value handled by IBM Cloud code.
The fields returned from a catalog GET within the JSON result are as follows:
"state" : "succeeded",
"description" : "The asynchronous creation of your service instance succeeded."
-X GET -H "Accept:application/json" -H "X-Broker-Api-Version:2.12" -u "TestServiceBrokerUser:TestServiceBrokerPassword" "http://localhost:3000/v2/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A/last_operation?operation=Provision_45&plan_id=e62e2c19-0c3b-41e3-b8b3-c71762ecd489&service_id=cb55391b-3416-4943-a6a6-a541778c1924"
This extension supports enablement/disablement of a service instance.
The URL path for the PUT for the service broker implementation is /bluemix_v1/service_instances/:instance_id
where :instance_id
is the id generated by IBM Cloud for the service instance.
The fields passed into an enable PUT within the JSON body are as follows:
"enabled" : true,
"initiator_id" : "the ID of the initiator",
"reason_code" : "the reason code"
A status code of 204 is the expected successful value
-X PUT -H "Content-Type:application/json" -u "TestServiceBrokerUser:TestServiceBrokerPassword" -d "{\"enabled\":true, \"initiator_id\":\"some id\", \"reason_code\":\"some reason code\"}" http://localhost:3000/bluemix_v1/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A
This extension supports retrieving the current state of a service instance.
The URL path for the GET for the service broker implementation is /bluemix_v1/service_instances/:instance_id
where :instance_id
is the id generated by IBM Cloud for the service instance.
A status code of 200 is the expected successful value.
The fields returned from a state GET within the JSON result are as follows:
true
.true
and active is false
.
"enabled" : true,
"active" : false,
"last_active : 1234567890000
-X GET -H "Accept:application/json" -u "TestServiceBrokerUser:TestServiceBrokerPassword" http://localhost:3000/bluemix_v1/service_instances/crn%3Av1%3Abluemix%3Apublic%3Atestjavaresourceservicebrokername%3Aus-south%3Aa%2F499b176abb3e1c9727df87ae48b27c7b%3A7f0d2b93-fd4a-4ce9-8675-978d20b1e0b7%3A%3A