-
Notifications
You must be signed in to change notification settings - Fork 86
Resource Provider Scenarios
We distinguish the following scenarios:
- Service provider - CF Broker
- Multi-tenant application - Application with users
I am a service provider and like to meter usage of my service. The service is a CF service which is consumed via Service Broker API.
Example: I provide the MongoDB service and like to meter the actual stored data volume per service instance.
Resource provider runs in organization services
and space mongodb
. Provides mongodb databases as CF service instances.
Consumer runs as the emporiumify
application (guid d98b5916-3c77-44b9-ac12-045678edaba) in organization shop
, space cart
(guid d98b5916-3c77-44b9-ac12-04456df23eae). It stores items added in the cart in different mongodb collections, all in the same database for which it created service instance mydb
(guid d98b5916-3c77-44b9-ac12-04d61c7a4eae). The customer using the application is identified by the identity zone identifier of its subaccount (guid 54257f98-83f0-4eca-ae04-9ea35277a538).
{
"start": 1396421450000,
"end": 1396421451000,
"organization_id": "idz:54257f98-83f0-4eca-ae04-9ea35277a538",
"space_id": "d98b5916-3c77-44b9-ac12-04456df23eae",
"consumer_id": "app:d98b5916-3c77-44b9-ac12-045678edabae",
"resource_id": "7971aac1-8e39-46e4-91de-41cda206f782",
"plan_id": "standard",
"resource_instance_id": "d98b5916-3c77-44b9-ac12-04d61c7a4eae",
"measured_usage": [
{
"measure": "storage",
"quantity": 145
}
]
}
Fields:
-
"organization_id": "idz:54257f98-83f0-4eca-ae04-9ea35277a538"
Can be broken into:
- idz: UAA's Identity Zone schema
- 54257f98-83f0-4eca-ae04-9ea35277a538: GUID of the consumer's identity zone/sub-account
Each organization is associated with identity zone. Therefore, since each application belongs to organization, it is associated with identity zone. If the consumer tenant cannot be identified, then you should use the identity zone of the application consuming the service.
-
"space_id": "d98b5916-3c77-44b9-ac12-04456df23eae"
GUID of the consumer's
cart
space (undershop
organization) -
"consumer_id": "app:d98b5916-3c77-44b9-ac12-045678edabae"
Can be either:
- consumer's
emporiumify
application GUID - service binding GUID if no application data is available (in case service key is used)
- consumer's
-
"resource_id": "7971aac1-8e39-46e4-91de-41cda206f782"
MongoDB Resource Provider ID. Generated by Abacus Service Broker and available under
VCAP_SERVICES
credentials keyresource_id
-
"plan_id": "standard"
Use hard-coded value
standard
. This is not a service instance plan, but a metering plan. -
"resource_instance_id": "d98b5916-3c77-44b9-ac12-04d61c7a4eae"
ID of the MongoDB database (or service instance) created for the consumer.
-
"measured_usage"
(example) KiB of storage used in the database
When Cloud Foundry creates service instance, it provides most of the entities above. The create instance call contains:
- organization_guid
- space_guid
The bind call adds:
- app_guid
So you can fill:
- organization_id:
idz:<idz corresponding to organization_guid from create_instance>
- space_id: <space_guid from create_instance>
- consumer_id: <app_guid from create_instance>
In case you are using service key, you should be able to identify the customer that uses the key via JWT token in your API or by custom configuration during key creation.
I like to meter data of my multi-tenant application. Application is called by a consumer tenant who does not necessarily has an org/space (i.e. consumer might be a plain SaaS customer who has no own org/space). Consumer calls app with a tenant-specific URL, API key or OAuth scope to identify itself.
Resource provider runs as part of the emporiumify
application (guid d98b5916-3c77-44b9-ac12-045678edabae) in organization shop
, space cart
(guid d98b5916-3c77-44b9-ac12-04456df23eae). It provides marketplace services to end-users.
Consumer (id zone d98b5916-3c77-44b9-ac12-04d61c7a4eae) accesses the emporiumify
application to add items to the marketplace so end-users can add them to cart and buy them.
{
"start": 1396421450000,
"end": 1396421451000,
"organization_id": "idz:d98b5916-3c77-44b9-ac12-04d61c7a4eae",
"space_id": "na",
"consumer_id": "na",
"resource_id": "89ee1a04-98ef-4394-a361-e5c8f58437a3",
"plan_id": "standard",
"resource_instance_id": "na",
"measured_usage": [
{
"measure": "storage",
"quantity": 145
}
]
}
Fields:
-
"organization_id": "idz:d98b5916-3c77-44b9-ac12-04d61c7a4eae"
Consists of:
- idz: UAA identity zone schema
- d98b5916-3c77-44b9-ac12-04d61c7a4eae: GUID of the consumer's identity zone/subaccount
-
"space_id": "na"
Hardcoded value "na" (consumer in this scenario has no space).
-
"consumer_id": "na"
Hardcoded value "na" (consumer client in this scenario is not an application, but business users).
-
"resource_id": "89ee1a04-98ef-4394-a361-e5c8f58437a3"
Our
emporiumify
Abacus resource provider ID. Generated by Abacus Service Broker and available underVCAP_SERVICES
credentials keyresource_id
. -
"plan_id": "standard"
Use hard-coded value
standard
. This is not a service instance plan, but a metering plan. -
"resource_instance_id": "na"
Hardcoded value "na".
<< Under the Hood | Create a Resource Provider>> |
---|
ABOUT | RESOURCE PROVIDER | ABACUS INTEGRATOR
*Abacus icon made by Freepik from www.flaticon.com