Package org.hyperledger.fabric.sdk
Class NetworkConfig
- java.lang.Object
-
- org.hyperledger.fabric.sdk.NetworkConfig
-
public class NetworkConfig extends java.lang.Object
Holds details of network and channel configurations typically loaded from an external config file.
Also contains convenience methods for utilizing the config details, including the mainHFClient.getChannel(String)
method
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NetworkConfig.CAInfo
Holds the details of a Certificate Authoritystatic class
NetworkConfig.OrgInfo
Holds details of an Organizationstatic class
NetworkConfig.UserInfo
Holds details of a User
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NetworkConfig
fromJsonFile(java.io.File configFile)
Creates a new NetworkConfig instance configured with details supplied in a JSON file.static NetworkConfig
fromJsonObject(javax.json.JsonObject jsonConfig)
Creates a new NetworkConfig instance configured with details supplied in a JSON objectstatic NetworkConfig
fromJsonStream(java.io.InputStream configStream)
Creates a new NetworkConfig instance configured with details supplied in JSON formatstatic NetworkConfig
fromYamlFile(java.io.File configFile)
Creates a new NetworkConfig instance configured with details supplied in a YAML file.static NetworkConfig
fromYamlStream(java.io.InputStream configStream)
Creates a new NetworkConfig instance configured with details supplied in YAML formatjava.util.Set<java.lang.String>
getChannelNames()
Get the channel names found.NetworkConfig.OrgInfo
getClientOrganization()
java.util.Collection<java.lang.String>
getEventHubNames()
Names of EventHubs foundjava.util.Properties
getEventHubsProperties(java.lang.String name)
Get properties for a specific eventhub.java.util.Collection<java.lang.String>
getOrdererNames()
Names of Orderers foundjava.util.Properties
getOrdererProperties(java.lang.String name)
Get properties for a specific Orderer.NetworkConfig.OrgInfo
getOrganizationInfo(java.lang.String orgName)
java.util.Collection<NetworkConfig.OrgInfo>
getOrganizationInfos()
NetworkConfig.UserInfo
getPeerAdmin()
Returns the admin user associated with the client organizationNetworkConfig.UserInfo
getPeerAdmin(java.lang.String orgName)
Returns the admin user associated with the specified organizationjava.util.Collection<java.lang.String>
getPeerNames()
Names of Peers foundjava.util.Properties
getPeerProperties(java.lang.String name)
Get properties for a specific peer.void
setEventHubProperties(java.lang.String name, java.util.Properties properties)
Set a specific eventhub's properties.void
setOrdererProperties(java.lang.String name, java.util.Properties properties)
Set a specific orderer's properties.void
setPeerProperties(java.lang.String name, java.util.Properties properties)
Set a specific peer's properties.
-
-
-
Method Detail
-
getPeerNames
public java.util.Collection<java.lang.String> getPeerNames()
Names of Peers found- Returns:
- Collection of peer names found.
-
getOrdererNames
public java.util.Collection<java.lang.String> getOrdererNames()
Names of Orderers found- Returns:
- Collection of peer names found.
-
getEventHubNames
public java.util.Collection<java.lang.String> getEventHubNames()
Names of EventHubs found- Returns:
- Collection of eventhubs names found.
-
getPeerProperties
public java.util.Properties getPeerProperties(java.lang.String name) throws InvalidArgumentException
Get properties for a specific peer.- Parameters:
name
- Name of peer to get the properties for.- Returns:
- The peer's properties.
- Throws:
InvalidArgumentException
-
getOrdererProperties
public java.util.Properties getOrdererProperties(java.lang.String name) throws InvalidArgumentException
Get properties for a specific Orderer.- Parameters:
name
- Name of orderer to get the properties for.- Returns:
- The orderer's properties.
- Throws:
InvalidArgumentException
-
getEventHubsProperties
public java.util.Properties getEventHubsProperties(java.lang.String name) throws InvalidArgumentException
Get properties for a specific eventhub.- Parameters:
name
- Name of eventhub to get the properties for.- Returns:
- The eventhubs's properties.
- Throws:
InvalidArgumentException
-
setPeerProperties
public void setPeerProperties(java.lang.String name, java.util.Properties properties) throws InvalidArgumentException
Set a specific peer's properties.- Parameters:
name
- The name of the peer's property to set.properties
- The properties to set.- Throws:
InvalidArgumentException
-
setOrdererProperties
public void setOrdererProperties(java.lang.String name, java.util.Properties properties) throws InvalidArgumentException
Set a specific orderer's properties.- Parameters:
name
- The name of the orderer's property to set.properties
- The properties to set.- Throws:
InvalidArgumentException
-
setEventHubProperties
public void setEventHubProperties(java.lang.String name, java.util.Properties properties) throws InvalidArgumentException
Set a specific eventhub's properties.- Parameters:
name
- The name of the eventhub's property to set.properties
- The properties to set.- Throws:
InvalidArgumentException
-
fromYamlFile
public static NetworkConfig fromYamlFile(java.io.File configFile) throws InvalidArgumentException, java.io.IOException, NetworkConfigurationException
Creates a new NetworkConfig instance configured with details supplied in a YAML file.- Parameters:
configFile
- The file containing the network configuration- Returns:
- A new NetworkConfig instance
- Throws:
InvalidArgumentException
java.io.IOException
NetworkConfigurationException
-
fromJsonFile
public static NetworkConfig fromJsonFile(java.io.File configFile) throws InvalidArgumentException, java.io.IOException, NetworkConfigurationException
Creates a new NetworkConfig instance configured with details supplied in a JSON file.- Parameters:
configFile
- The file containing the network configuration- Returns:
- A new NetworkConfig instance
- Throws:
InvalidArgumentException
java.io.IOException
NetworkConfigurationException
-
fromYamlStream
public static NetworkConfig fromYamlStream(java.io.InputStream configStream) throws InvalidArgumentException, NetworkConfigurationException
Creates a new NetworkConfig instance configured with details supplied in YAML format- Parameters:
configStream
- A stream opened on a YAML document containing network configuration details- Returns:
- A new NetworkConfig instance
- Throws:
InvalidArgumentException
NetworkConfigurationException
-
fromJsonStream
public static NetworkConfig fromJsonStream(java.io.InputStream configStream) throws InvalidArgumentException, NetworkConfigurationException
Creates a new NetworkConfig instance configured with details supplied in JSON format- Parameters:
configStream
- A stream opened on a JSON document containing network configuration details- Returns:
- A new NetworkConfig instance
- Throws:
InvalidArgumentException
NetworkConfigurationException
-
fromJsonObject
public static NetworkConfig fromJsonObject(javax.json.JsonObject jsonConfig) throws InvalidArgumentException, NetworkConfigurationException
Creates a new NetworkConfig instance configured with details supplied in a JSON object- Parameters:
jsonConfig
- JSON object containing network configuration details- Returns:
- A new NetworkConfig instance
- Throws:
InvalidArgumentException
NetworkConfigurationException
-
getClientOrganization
public NetworkConfig.OrgInfo getClientOrganization()
-
getOrganizationInfo
public NetworkConfig.OrgInfo getOrganizationInfo(java.lang.String orgName)
-
getOrganizationInfos
public java.util.Collection<NetworkConfig.OrgInfo> getOrganizationInfos()
-
getPeerAdmin
public NetworkConfig.UserInfo getPeerAdmin() throws NetworkConfigurationException
Returns the admin user associated with the client organization- Returns:
- The admin user details
- Throws:
NetworkConfigurationException
-
getPeerAdmin
public NetworkConfig.UserInfo getPeerAdmin(java.lang.String orgName) throws NetworkConfigurationException
Returns the admin user associated with the specified organization- Parameters:
orgName
- The name of the organization- Returns:
- The admin user details
- Throws:
NetworkConfigurationException
-
getChannelNames
public java.util.Set<java.lang.String> getChannelNames()
Get the channel names found.- Returns:
- A set of the channel names found in the configuration file or empty set if none found.
-
-