PROBLEM
In order to call Predix services such as Asset, ACS, Analytics, or Time Series you must specify a Predix-Zone-Id header in your requests. How do you find the zone id when you do not yet have an app to push?
STEPS
Services such as Asset, ACS, and Time Series are multi-tenant and therefore share a common service endpoint. Your data is kept separate from others through the
Predix-Zone-Id. There are a few ways to retrieve this guid that is needed when making any requests to the service. You do want to keep this value a secret between you and the service to help prevent unauthorized use of your partition.
The following examples use an instance of predix-timeseries called my-predix-timeseries.
(a) Run
cf service my-predix-timeseries --guid and use the returned value.
This command simply returns a string such as:
12345678-1234-abcd-1a2b-1234abcd5678
(b) Use a Predix service key to get all of the VCAP details for your service including the Predix-Zone-Id, URIs, and connection details.
$ cf create-service-key my-predix-timeseries my-timeseries-key
...
OK
$ cf service-key my-predix-timeseries my-timeseries-key
{
"ingest": {
"uri": "wss://gateway-predix-data-services.run.aws-usw02-pr.ice.predix.io/v1/stream/messages",
"zone-http-header-name": "Predix-Zone-Id",
"zone-http-header-value": "12345678-1234-abcd-12ab-1234abcd5678",
"zone-token-scopes": [
"timeseries.zones.12345678-1234-abcd-12ab-1234abcd5678.user",
"timeseries.zones.12345678-1234-abcd-12ab-1234abcd5678.ingest"
]
},
"query": {
"uri": "https://time-series-store-predix.run.aws-usw02-pr.ice.predix.io/v1/datapoints",
"zone-http-header-name": "Predix-Zone-Id",
"zone-http-header-value": "12345678-1234-abcd-12ab-1234abcd5678",
"zone-token-scopes": [
"timeseries.zones.12345678-1234-abcd-12ab-1234abcd5678.user",
"timeseries.zones.12345678-1234-abcd-12ab-1234abcd5678.query"
]
}
}
You can find the Predix-Zone-Id in that returned dictionary.
(c) You can start with a hello world application,
cf push to cloud foundry,
cf bind the service to the app, then run cf env for the app.
DEPENDENCIES
Cloud Foundry CLI
You should know how to create services in Cloud Foundry.
RESOURCES
Cloud Foundry Documentation on Managing Service Keys
https://docs.cloudfoundry.org/devguide/services/service-keys.html