Overview - Common API - Client API - Admin API - Runtime API
BusinessNetworkConnection
Use this class to connect to and then interact with a deployed BusinessNetworkDefinition. Use the AdminConnection class in the composer-admin module to deploy BusinessNetworksDefinitions.
Details
Extends EventEmitter
Module client
See also
Method Summary
Name | Returns | Description |
---|---|---|
addAssetRegistry | Promise |
Add a new asset registry |
addParticipantRegistry | Promise |
Add a new participant registry |
assetRegistryExists | Promise |
Determine whether a asset registry exists |
bindIdentity | Promise |
Bind an existing identity to the specified participant |
buildQuery | Query |
Build a query ready for later execution |
connect | Promise |
Connects to a business network using a business network card, and authenticates to the Hyperledger Fabric |
constructor | void |
Create an instance of the BusinessNetworkConnection class |
disconnect | Promise |
Disconnects from the Hyperledger Fabric |
getAllAssetRegistries | Promise |
Get a list of all existing asset registries |
getAllParticipantRegistries | Promise |
Get a list of all existing participant registries |
getAllTransactionRegistries | Promise |
Get all transaction registries |
getAssetRegistry | Promise |
Get an existing asset registry |
getBusinessNetwork | BusinessNetworkDefinition |
Returns the currently connected BusinessNetworkDefinition |
getHistorian | Promise |
Get the historian |
getIdentityRegistry | Promise |
Get the identity registry |
getParticipantRegistry | Promise |
Get an existing participant registry |
getRegistry | Promise |
Given a fully qualified name, works out and looks up the registry that this resource will be found in |
getTransactionRegistry | Promise |
Get the transaction registry |
issueIdentity | Promise |
Issue an identity with the specified name and map it to the specified participant |
participantRegistryExists | Promise |
Determine whether a participant registry exists |
ping | Promise |
Test the connection to the runtime and verify that the version of the runtime is compatible with this level of the client node |
query | Promise |
Execute a query defined in a Composer query file, or execute a query built with buildQuery |
revokeIdentity | Promise |
Revoke the specified identity by removing any existing mapping to a participant |
submitTransaction | Promise |
Submit a transaction for processing by the currently connected business network |
transactionRegistryExists | Promise |
Determine whether a transaction registry exists |
Method Details
new BusinessNetworkConnection()
Create an instance of the BusinessNetworkConnection class. must be called to connect to a deployed BusinessNetworkDefinition.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
options | Object | Yes | an optional set of options to configure the instance. |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.cardStore | BusinessNetworkCardStore | Yes | specify a card store implementation to use. |
getBusinessNetwork
BusinessNetworkDefinition getBusinessNetwork( )
Returns the currently connected BusinessNetworkDefinition
Example
// Get the Business Network Definition
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getBusinessNetwork();
})
.then(function(BusinessNetworkDefinition){
// Retrieved Business Network Definition
});
Returns
BusinessNetworkDefinition - the business network
See also
Parameters
No parameters
Example
// Get the Business Network Definition
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getBusinessNetwork();
})
.then(function(BusinessNetworkDefinition){
// Retrieved Business Network Definition
});
getAllAssetRegistries
Promise getAllAssetRegistries( [boolean includesystem] )
Get a list of all existing asset registries.
Example
// Get all asset registries
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllAssetRegistries();
})
.then(function(assetRegistries){
// Retrieved Asset Registries
});
Returns
Promise - A promise that will be resolved with a list of existing asset registries
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
includeSystem | boolean | Yes | if true the returned list will include the system transaction registries (optional, default to false) |
Example
// Get all asset registries
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllAssetRegistries();
})
.then(function(assetRegistries){
// Retrieved Asset Registries
});
getAssetRegistry
Promise getAssetRegistry( string id )
Get an existing asset registry.
Example
// Get a asset registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAssetRegistry('businessNetworkIdentifier.registryId');
})
.then(function(assetRegistry){
// Retrieved Asset Registry
});
Returns
Promise - A promise that will be resolved with the existing asset registry, or rejected if the asset registry does not exist.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the asset registry |
Example
// Get a asset registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAssetRegistry('businessNetworkIdentifier.registryId');
})
.then(function(assetRegistry){
// Retrieved Asset Registry
});
assetRegistryExists
Promise assetRegistryExists( string id )
Determine whether a asset registry exists.
Example
// Determine whether an asset registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.assetRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
Returns
Promise - A promise that will be resolved with a boolean indicating whether the asset registry exists.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the asset registry |
Example
// Determine whether an asset registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.assetRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
addAssetRegistry
Promise addAssetRegistry( string id, string name )
Add a new asset registry.
Example
// Add a new asset registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.addAssetRegistry('registryId','registryName');
});
Returns
Promise - A promise that will be resolved with the new asset registry after it has been added.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the asset registry |
name | string | Yes | The name of the asset registry |
Example
// Add a new asset registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.addAssetRegistry('registryId','registryName');
});
getAllParticipantRegistries
Promise getAllParticipantRegistries( [boolean includesystem] )
Get a list of all existing participant registries.
Example
// Get all participant registries
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllParticipantRegistries();
})
.then(function(participantRegistries){
// Retrieved Participant Registries
});
Returns
Promise - A promise that will be resolved with a list of existing participant registries
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
includeSystem | boolean | Yes | if true the returned list will include the system transaction registries (optional, default to false) |
Example
// Get all participant registries
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllParticipantRegistries();
})
.then(function(participantRegistries){
// Retrieved Participant Registries
});
getParticipantRegistry
Promise getParticipantRegistry( string id )
Get an existing participant registry.
Example
// Get a participant registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getParticipantRegistry('businessNetworkIdentifier.registryId');
})
.then(function(participantRegistry){
// Retrieved Participant Registry
});
Returns
Promise - A promise that will be resolved with the existing participant registry, or rejected if the participant registry does not exist.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the participant registry |
Example
// Get a participant registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getParticipantRegistry('businessNetworkIdentifier.registryId');
})
.then(function(participantRegistry){
// Retrieved Participant Registry
});
participantRegistryExists
Promise participantRegistryExists( string id )
Determine whether a participant registry exists.
Example
// Determine whether an asset registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.participantRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
Returns
Promise - A promise that will be resolved with a boolean indicating whether the participant registry exists.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the participant registry |
Example
// Determine whether an asset registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.participantRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
addParticipantRegistry
Promise addParticipantRegistry( string id, string name )
Add a new participant registry.
Example
// Add a new participant registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.addParticipantRegistry('registryId','registryName');
});
Returns
Promise - A promise that will be resolved with the new participant registry after it has been added.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the participant registry |
name | string | Yes | The name of the participant registry |
Example
// Add a new participant registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.addParticipantRegistry('registryId','registryName');
});
getTransactionRegistry
Promise getTransactionRegistry( string id )
Get the transaction registry.
Example
// Get the transaction registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getTransactionRegistry('org.acme.exampleTransaction');
})
.then(function(transactionRegistry){
// Retrieved transaction registry.
});
Returns
Promise - A promise that will be resolved to the TransactionRegistry
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the transaction registry |
Example
// Get the transaction registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getTransactionRegistry('org.acme.exampleTransaction');
})
.then(function(transactionRegistry){
// Retrieved transaction registry.
});
getAllTransactionRegistries
Promise getAllTransactionRegistries( [boolean includesystem] )
Get all transaction registries.
Example
// Get the transaction registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllTransactionRegistries();
})
.then(function(transactionRegistries){
// Retrieved transaction Registries
});
Returns
Promise - A promise that will be resolved to the TransactionRegistry
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
includeSystem | boolean | Yes | if true the returned list will include the system transaction registries (optional, default to false) |
Example
// Get the transaction registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getAllTransactionRegistries();
})
.then(function(transactionRegistries){
// Retrieved transaction Registries
});
transactionRegistryExists
Promise transactionRegistryExists( string id )
Determine whether a transaction registry exists.
Example
// Determine whether an transaction registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetwork){
return businessNetwork.transactionRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
Returns
Promise - A promise that will be resolved with a boolean indicating whether the transaction registry exists.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
id | string | Yes | The unique identifier of the transaction registry |
Example
// Determine whether an transaction registry exists
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetwork){
return businessNetwork.transactionRegistryExists('businessNetworkIdentifier.registryId');
})
.then(function(exists){
// if (exists === true) {
// logic here...
//}
});
getHistorian
Promise getHistorian( )
Get the historian
Example
// Get the historian
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getHistorian();
})
.then(function(historian){
// Retrieved historian
});
Returns
Promise - A promise that will be resolved to the Historian
See also
Parameters
No parameters
Example
// Get the historian
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getHistorian();
})
.then(function(historian){
// Retrieved historian
});
getIdentityRegistry
Promise getIdentityRegistry( )
Get the identity registry.
Example
// Get the identity registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getIdentityRegistry();
})
.then(function(identityRegistry){
// Retrieved identity registry
});
Returns
Promise - A promise that will be resolved to the IdentityRegistry
See also
Parameters
No parameters
Example
// Get the identity registry
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.getIdentityRegistry();
})
.then(function(identityRegistry){
// Retrieved identity registry
});
connect
Promise connect( String cardname, [Object additionalconnectoptions] )
Connects to a business network using a business network card, and authenticates to the Hyperledger Fabric.
Example
// Connect and log in to HLF
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('cardName')
.then(function(businessNetworkDefinition){
// Connected
});
Returns
Promise - A promise to a BusinessNetworkDefinition that indicates the connection is complete
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
cardName | String | Yes | businessNetworkCard Name (must have been imported already) |
additionalConnectOptions | Object | Yes | Additional configuration options supplied at runtime that override options set in the connection profile. which will override those in the specified connection profile. |
Example
// Connect and log in to HLF
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('cardName')
.then(function(businessNetworkDefinition){
// Connected
});
getRegistry
Promise getRegistry( String fullyqualifiedname )
Given a fully qualified name, works out and looks up the registry that this resource will be found in. This only gives back the default registry - it does not look in any application defined registry.
Example
// Locate the registry for a fully qualififed name
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetwork){
var sampleAssetRegistry = businessNetwork.getRegistry('org.acme.sampleAsset');
var sampleTransactionRegistry = businessNetwork.getRegistry('org.acme.sampleTransaction');
var sampleParticipantRegistry = businessNetwork.getRegistry('org.acme.sampleParticipant');
});
Returns
Promise - resolved with the registry that this fqn could be found in by default
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
fullyQualifiedName | String | Yes | The fully qualified name of the resources |
Example
// Locate the registry for a fully qualififed name
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetwork){
var sampleAssetRegistry = businessNetwork.getRegistry('org.acme.sampleAsset');
var sampleTransactionRegistry = businessNetwork.getRegistry('org.acme.sampleTransaction');
var sampleParticipantRegistry = businessNetwork.getRegistry('org.acme.sampleParticipant');
});
disconnect
Promise disconnect( )
Disconnects from the Hyperledger Fabric.
Example
// Disconnects from HLF
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.disconnect();
})
.then(function(){
// Disconnected.
});
Returns
Promise - A promise that will be resolved when the connection is terminated.
See also
Parameters
No parameters
Example
// Disconnects from HLF
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetworkDefinition.disconnect();
})
.then(function(){
// Disconnected.
});
submitTransaction
Promise submitTransaction( Resource transaction )
Submit a transaction for processing by the currently connected business network.
Example
// Submits a transaction
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
var factory = businessNetworkDefinition.getBusinessNetwork().getFactory();
var transaction = factory.newTransaction('network.transactions', 'TransactionType');
return businessNetworkDefinition.submitTransaction(transaction);
})
.then(function(){
// Submitted a transaction.
});
Returns
Promise - A promise that will be fulfilled when the transaction has been processed.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
transaction | Resource | Yes | The transaction to submit. Use newTransaction to create this object. |
Example
// Submits a transaction
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
var factory = businessNetworkDefinition.getBusinessNetwork().getFactory();
var transaction = factory.newTransaction('network.transactions', 'TransactionType');
return businessNetworkDefinition.submitTransaction(transaction);
})
.then(function(){
// Submitted a transaction.
});
buildQuery
Query buildQuery( string query )
Build a query ready for later execution. The specified query string must be written in the Composer query language. This functionality is Blockchain platform dependent. For example, when a Composer business network is deployed to Hyperledger Fabric v1.0, Hyperledger Fabric must be configured with the CouchDB database for the world state.
Example
// Build and execute a query.
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function () {
var query = businessNetwork.buildQuery('SELECT org.acme.sample.SampleAsset WHERE (value == _$inputValue)');
return businessNetwork.query(query, { inputValue: 'blue' })
})
.then(function (assets) {
assets.forEach(function (asset) {
// Process each asset.
});
})
.catch(function (error) {
// Add optional error handling here.
});
Returns
Query - The built query, which can be passed in a call to query.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
query | string | Yes | The query string, written using the Composer query language. |
Example
// Build and execute a query.
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function () {
var query = businessNetwork.buildQuery('SELECT org.acme.sample.SampleAsset WHERE (value == _$inputValue)');
return businessNetwork.query(query, { inputValue: 'blue' })
})
.then(function (assets) {
assets.forEach(function (asset) {
// Process each asset.
});
})
.catch(function (error) {
// Add optional error handling here.
});
query
Promise query( string; Query query, [Object parameters] )
Execute a query defined in a Composer query file, or execute a query built with buildQuery. This functionality is Blockchain platform dependent. For example, when a Composer business network is deployed to Hyperledger Fabric v1.0, Hyperledger Fabric must be configured with the CouchDB database for the world state.
Example
// Execute the query.
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function () {
return query('Q1', { inputValue: 'blue' })
})
.then(function (assets) {
assets.forEach(function (asset) {
// Process each asset.
});
})
.catch(function (error) {
// Add optional error handling here.
});
Returns
Promise - A promise that will be resolved with an array of {@link module:composer-common.Resource Resource} representing the resources returned by the query.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
query | string; Query | Yes | The name of the query, or a built query. |
parameters | Object | Yes | The parameters for the query. |
Example
// Execute the query.
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function () {
return query('Q1', { inputValue: 'blue' })
})
.then(function (assets) {
assets.forEach(function (asset) {
// Process each asset.
});
})
.catch(function (error) {
// Add optional error handling here.
});
ping
Promise ping( )
Test the connection to the runtime and verify that the version of the runtime is compatible with this level of the client node.js module.
Example
// Test the connection to the runtime
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetwork.ping();
})
.then(function(){
// Connection tested.
});
Returns
Promise - A promise that will be fulfilled when the connection has been tested. The promise will be rejected if the version is incompatible.
See also
Parameters
No parameters
Example
// Test the connection to the runtime
var businessNetwork = new BusinessNetworkConnection();
return businessNetwork.connect('testprofile', 'businessNetworkIdentifier', 'WebAppAdmin', 'DJY27pEnl16d')
.then(function(businessNetworkDefinition){
return businessNetwork.ping();
})
.then(function(){
// Connection tested.
});
issueIdentity
Promise issueIdentity( Resource; Relationship; string participant, string identityname, [object options] )
Issue an identity with the specified name and map it to the specified participant.
Returns
Promise - A promise that will be fulfilled when the identity has been added to the specified participant. The promise will be rejected if the participant does not exist, or if the identity is already mapped to another participant.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
participant | Resource; Relationship; string | Yes | The participant, a relationship to the participant, or the fully qualified identifier of the participant. The participant must already exist. |
identityName | string | Yes | The name for the new identity. |
options | object | Yes | Options for the new identity. |
Sub-options
Name | Type | Mandatory | Description |
---|---|---|---|
options.issuer | boolean | Yes | Whether or not the new identity should have permissions to create additional new identities. False by default. |
bindIdentity
Promise bindIdentity( Resource; string participant, string certificate )
Bind an existing identity to the specified participant.
Returns
Promise - A promise that will be fulfilled when the identity has been added to the specified participant. The promise will be rejected if the participant does not exist, or if the identity is already mapped to another participant.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
participant | Resource; string | Yes | The participant, or the fully qualified identifier of the participant. The participant must already exist. |
certificate | string | Yes | The certificate for the existing identity. |
revokeIdentity
Promise revokeIdentity( Resource; string identity )
Revoke the specified identity by removing any existing mapping to a participant.
Returns
Promise - A promise that will be fulfilled when the identity has been removed from the specified participant. The promise will be rejected if the participant does not exist, or if the identity is not mapped to the participant.
See also
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
identity | Resource; string | Yes | The identity, or the identifier of the identity. |