Service Provider API

Inception

Resellers of Bluzone Cloud services (Service Providers) need an efficient way to create and manage projects on behalf of their end users.  The Service Provider API enables project creation and management via a secure REST API.

Business Requirements

Service Providers must be able to create and manage projects with a REST API.  The API shall support querying of Service Provider details, listing of managed projects, creation of managed projects and deletion of managed projects.  The Service Provider API shall expose templating features

Elaboration

The Service Provider API is enabled for end users via a manual configuration step by Bluzone Administrators.  

Service Provider Record

A Service Provider record is created in the main database.  An API Key is generated and saved in the database, along with contact information about the Service Provider:

*NOTE: even if the access/secret key are the same for your default remote consumer and default remote storage, they must each be assigned a value. 

FieldTypeDescription
serviceProviderIdLong/NumericAuto generated provider id.
nameStringA human friendly name for recognizing the service provider record.
contactNameStringAgent or representative of the Service Provider.
contactEmailStringEmail address for contacting the Service Provider.
contactPhoneStringA phone number for contacting the Service Provider.
templateProjectIdLong/NumericOptional field that maps to a project owned by the serviceProvider and to be used as a "template" to create other projects.
apiKeyStringThe access key for making api calls to the Service Provider API.
dateCreatedString/DateThe timestamp of when this Service Provider record was created.
dateUpdatedString/Date

The timestamp of the last time this Service Provider record was updated.

accessKeyStringThe access key for the default remote storage.
secretKeyStringThe secret key for the default remote storage.
storageResourceIdentifierStringThe name (identifier) of the remote storage, e.g. the bucket name of an S3 bucket.
storageRegionStringThe region of the remote storage, e.g. for S3 a region could be us-east-1.
storageProviderEnumThe storage provider. Current supported provider: AWS
awsAccessKeyStringThe access key for the default remote consumer.
awsSecretKeyString

The secret key for the default remote consumer.

streamTypeEnumThe type of data that will be written to the default remote consumer. Current supported stream types: PACKET_DATA, LOCATION_DATA, POLICY_EVENT_DATA
partitionKeyStringThe partition key for the default remote consumer.
streamNameString

The name for the default remote consumer.

assumeRoleName
StringThe name assumed role used after linking with AWS Account ID 
assumeRoleEnabled
booleanTo enable / disable Assumed role 

Supported APIs

API NameMethodURLDescription
Get ServiceProvider DetailsGET<hostname>/portal/service/:serviceProviderIdReturns the metadata saved in the system about the ServiceProvider.
Get List of Managed ProjectsGET<hostname>/portal/service/:serviceProviderId/projectsList of Projects managed by this ServiceProvider
Get a Managed ProjectGET<hostname>/portal/service/:serviceProviderId/projects/:projectIdGet the details about a single Project managed by this ServiceProvider
Create a ProjectPOST<hosthame>/portal/service/:serviceProviderId/projects/_create?useDefaultRemoteStorage
=<boolean>&useDefaultRemoteConsumer=<boolean>
Create a new managed Project using the values supplied in the request object. There are two query string parameters that you may provide; useDefaultRemoteStorage defaults to false, but when set to true the newly created project will use the default remote storage configuration associated with the service provider; useDefaultRemoteConsumer defaults to false, but when set to true the newly create project will use the default remote consumer configuration associated with the service provider.
Delete a ProjectDELETE<hostname>/portal/service/:serviceProviderId/projects/:projectIdDelete a managed project.
Update Default Remote StoragePUT<hostname>/portal/service/:serviceProviderId/_updateDefaultRemoteStorage?updateProjects=<boolean>Updates the default remote storage configuration. The query string parameter updateProjects defaults to false, but when set to true will update all the projects that use the default remote storage configuration.
Update Default Remote ConsumerPUT<hostname>/portal/service/:serviceProviderId/_updateDefaultRemoteConsumer?updateProjects=<boolean>Updates the default remote consumer configuration. The query string parameter updateProjects default to false, but when set to true will update all the projects that use the default remote consumer configuration.

Examples

Get Service Provider Details

API Call

curl -X GET \
$BLUZONE_URL/portal/service/1 \
-H 'bzspid: example-api-key' \
-H 'cache-control: no-cache' 

Response

Service Provider Response
{
    "serviceProviderId": 1,
    "name": "Example",
    "contactName": "John Doe",
    "contactEmail": "john.doe@example.com",
    "contactPhone": "+3055551212",
    "templateProjectId": null,
    "dateCreated": 1507252266000,
    "dateUpdated": 1507252266000,
	"accessKey": "AKIAIDLBLO9UHGEAJW7A",
    "secretKey": "DcE3uYhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
    "storageProvider": "AWS",
    "storageResourceIdentifier": "john-doe-blob-1",
    "storageRegion": "us-east-1",
    "awsAccessKey": "MKZNADLBLO9UHGEAJW7A",
    "awsSecretKey": "fdaADKQoidIQ2+Jf9FnqP+Hfiqo9naHodnau7Gba",
    "kinesisEndpoint": "kinesis.us-east-1.amazonaws.com",
    "streamType": "PACKET_DATA",
    "partitionKey": null,
    "streamName": "john-doe-stream-1"
}

Update default remote storage

API Call 

Create Managed Project API
curl -X PUT \
  $BLUZONE_URL/portal/service/1/_updateDefaultRemoteStorage \
  -H 'bzspid: example-api-key' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
	"accessKey": "QPAUEPLBLO9UHGEAJW7A",
	"secretKey": "Vcq8q9hNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"storageProvider": "AWS",
	"storageResourceIdentifier": "john-doe-blob-2",
	"storageRegion": "us-west-1"
}'

Request Body

Create Managed Project Request
{
	"accessKey": "QPAUEPLBLO9UHGEAJW7A",
	"secretKey": "Vcq8q9hNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"storageProvider": "AWS",
	"storageResourceIdentifier": "john-doe-blob-2",
	"storageRegion": "us-west-1"
}

Response

Create Managed Project Response
{
    "serviceProviderId": 1,
    "name": "Example",
    "contactName": "John Doe",
    "contactEmail": "john.doe@example.com",
    "contactPhone": "+3055551212",
    "templateProjectId": null,
    "dateCreated": 1507736821000,
    "dateUpdated": 1508970844000,
    "accessKey": "QPAUEPLBLO9UHGEAJW7A",
    "secretKey": "Vcq8q9hNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
    "storageProvider": "AWS",
    "storageResourceIdentifier": "john-doe-blob-2",
    "storageRegion": "us-west-1",
    "awsAccessKey": "MKZNADLBLO9UHGEAJW7A",
    "awsSecretKey": "fdaADKQoidIQ2+Jf9FnqP+Hfiqo9naHodnau7Gba",
    "kinesisEndpoint": "kinesis.us-east-1.amazonaws.com",
    "streamType": "PACKET_DATA",
    "partitionKey": null,
    "streamName": "john-doe-stream-1"
}

Update default remote storage - ARN Changes

API Call 

Create Managed Project API
curl -X PUT \
  $BLUZONE_URL/portal/service/1/_updateDefaultRemoteStorage \
  -H 'bzspid: example-api-key' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
		"storageRegion": "us-east-2",
		"storageProvider": "AWS",
		"storageTypes": ["BEACON_TELEMETRY_DATA"],
		"assumeRoleEnabled": true,
		"isAWS": true,
		"storageResourceIdentifier": "Test Resource Identifier service",
		"assumeRo   leName": "arn changes-updated"
}'

Request Body

Create Managed Project Request
{
		"storageRegion": "us-east-2",
		"storageProvider": "AWS",
		"storageTypes": ["BEACON_TELEMETRY_DATA"],
		"assumeRoleEnabled": true,
		"isAWS": true,
		"storageResourceIdentifier": "Test Resource Identifier service",
		"assumeRo   leName": "arn changes-updated"
}

Response

Create Managed Project Response
{
    {
    "serviceProviderId": 4006,
    "name": "goutham",
    "contactName": "Varma",
    "contactEmail": "goutham@bluvision.com",
    "contactPhone": "5615555555",
    "templateProjectId": null,
    "firmwareUpdateStrategy": "MANUAL",
    "dateCreated": 1565270469000,
    "dateUpdated": 1615806066000,
    "accessKey": null,
    "secretKey": null,
    "storageProvider": "AWS",
    "storageResourceIdentifier": "Test Resource Identifier service",
    "storageRegion": "us-east-2",
    "assumeRoleEnabled": true,
    "assumeRoleName": "arn changes-updated",
    "awsAccessKey": "MKZNADLBLO9UHGEAJW7AS",
    "awsSecretKey": "fdaADKQoidIQ2+Jf9FnqP+Hfiqo9naHodnaus7Gba",
    "kinesisEndpoint": "kinesis.us-east-1.amazonaws.com",
    "streamType": "LOCATION_DATA",
    "partitionKey": "",
    "streamName": "DennisStream",
    "awsAssumeRoleEnabled": true,
    "awsAssumeRoleName": null
}

Update default remote consumer

API Call

Create Managed Project API
curl -X PUT \
  $BLUZONE_URL/portal/service/1/_updateDefaultRemoteStorage \
  -H 'bzspid: example-api-key' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
	"awsAccessKey": "ZLKQWILBLO9UHGEAJW7A",
	"awsSecretKey": "23mKlQhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"kinesisEndpoint": "kinesis.us-east-2.amazonaws.com",
	"streamName": "john-doe-stream-2",
	"streamType": "LOCATION_DATA",
	"partitionKey": "partitionKey"
}'

Request Body

Create Managed Project Request
{
	"awsAccessKey": "ZLKQWILBLO9UHGEAJW7A",
	"awsSecretKey": "23mKlQhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"kinesisEndpoint": "kinesis.us-east-2.amazonaws.com",
	"streamName": "john-doe-stream-2",
	"streamType": "LOCATION_DATA",
	"partitionKey": "partitionKey"
}

Response

Create Managed Project Response
{
    "serviceProviderId": 1,
    "name": "Example",
    "contactName": "John Doe",
    "contactEmail": "john.doe@example.com",
    "contactPhone": "+3055551212",
    "templateProjectId": null,
    "dateCreated": 1507736821000,
    "dateUpdated": 1508970844000,
    "accessKey": "QPAUEPLBLO9UHGEAJW7A",
    "secretKey": "Vcq8q9hNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
    "storageProvider": "AWS",
    "storageResourceIdentifier": "john-doe-blob-2",
    "storageRegion": "us-west-1",
    "awsAccessKey": "ZLKQWILBLO9UHGEAJW7A",
    "awsSecretKey": "23mKlQhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
    "kinesisEndpoint": "kinesis.us-east-2.amazonaws.com",
    "streamType": "LOCATION_DATA",
    "partitionKey": partitionKey,
    "streamName": "john-doe-stream-2"
}

Create Managed Project API

If in the api call you include values for a remote storage or a remote consumer, the newly created project will use those configuration values and begin writing data to them. If you would like to use the default configuration for either remote storage or remote consumer DO NOT provided the associated parameters in the request, instead set the correct query string parameter to true. For example, if you would like to use the default configuration for remote storage but use a new remote consumer configuration, do not provide the values for the remote storage, but provide the values for the remote consumer and set the useDefaultRemoteStorage query string parameter to true.

FieldTypeDescription
serviceProviderIdNumericRequired ServiceProvider Id value.
projectNameStringUser friendly name to help identify this project - usually the company name and type, example:  Acme Prod
defaultOwnerEmailStringOptional value that can be used as the Project owner's email and the username to login to the project.
defaultOwnerPasswordStringOptional value that can be used for the user to login to the project via Bluzone  Console.
joinAccountsEnabledBooleanDefault is false.  When set to true, the system will associate projects with the same username as the owner.
debugEnabledBoolean Default false.  When true, the user will be able to login to this project via Bluzone Console using the provided defaultOwnerEmail as username and defaultOwnerPassword as password
accessKeyStringOptional value for remote storage.
secretKeyStringOptional value for remote storage.
storageProviderEnumOptional value for remote storage.
storageResourceIdentifierStringOptional value for remote storage.
storageRegionStringOptional value for remote storage.
awsAccessKeyStringOptional value for remote consumer.
awsSecretKeyStringOptional value for remote consumer.
kinesisEndpointStringOptional value for remote consumer.
partitionKeyStringOptional value for remote consumer.
streamTypeEnumOptional value for remote consumer.
streamNameStringOptional value for remote consumer.

API Call

Create Managed Project API
curl -X POST \
  $BLUZONE_URL/portal/service/1/projects/_create?useDefaultRemoteStorage=true \
  -H 'bzspid: example-api-key' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -d '{
	"projectName": "SP Create Test 0",
	"defaultOwnerEmail": "owner0@example.com",
	"defaultOwnerPassword": "changeme",
	"joinAccountsEnambed": false,
	"debugEnabled": true,
	"awsAccessKey": "RT9OQLLBLO9UHGEAJW7A",
	"awsSecretKey": "9MLNHQhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"kinesisEndpoint": "kinesis.us-east-2.amazonaws.com",
	"streamName": "john-doe-stream-2",
	"streamType": "LOCATION_DATA",
	"partitionKey": "partitionKey"
	
}'

Request Body

Create Managed Project Request
{
	"projectName": "SP Create Test 0",
	"defaultOwnerEmail": "owner0@example.com",
	"defaultOwnerPassword": "changeme",
	"joinAccountsEnambed": false,
	"debugEnabled": true,
	"awsAccessKey": "RT9OQLLBLO9UHGEAJW7A",
	"awsSecretKey": "9MLNHQhNtXz3o+ADkOPoq+JG81eu5dYotNwbEtiW",
	"kinesisEndpoint": "kinesis.us-east-2.amazonaws.com",
	"streamName": "john-doe-stream-2",
	"streamType": "LOCATION_DATA",
	"partitionKey": "partitionKey"
	
}

Response

Create Managed Project Response
{
    "serviceProviderId": 1,
    "projectId": 2178,
    "accountId": 1823,
    "username": null,
    "projectName": "SP Create Test 0",
    "projectApiKey": "MZP9VuQxDX0MMU6eJn2SDvX0FsY4jUx2lqko8TWcDRZC7ByhU2",
    "debugEnabled": true,
    "dateCreated": 1507641990350,
    "dateUpdated": 1507641990350,
	"beaconTemplates": null
}

List All Managed Projects

API Call

List Managed Projects API
curl -X GET \
  $BLUZONE_URL/portal/service/1/projects \
  -H 'bzspid: example-api-key' \
  -H 'cache-control: no-cache' 

Response

List Managed Projects Response
[
    {
        "serviceProviderId": 1,
        "projectId": 2178,
        "accountId": 1823,
        "username": "owner@example.com",
        "projectName": "SP Create Test 0",
        "projectApiKey": "MZP9VuQxDX0MMU6eJn2SDvX0FsY4jUx2lqko8TWcDRZC7ByhU2",
        "debugEnabled": true,
        "dateCreated": 1507641990000,
        "dateUpdated": 1507641990000
    }
]