CloudEnv
public class CloudEnvA convenience class for obtaining environment variables that are mapped to JSON strings. It is mainly used for obtaining credentials for services so Swift applications can be written in a platform agnostic way.
There is a lot of information in the README
explaining how you can use cloudEnv to access credentials for your services; more specific information is listed in the
API documentation below.
- 
                  
                  Name of the mappings file. This is set to mappings.json .DeclarationSwift public static let mappingsFile = "mappings.json"
- 
                  
                  Port number the application can listen to. DeclarationSwift public var port: Int
- 
                  
                  URL that can be assigned to the application. DeclarationSwift public var url: String
- 
                  
                  Initialize an instance of CloudEnv.Usage Example:let cloudEnv = CloudEnv()The example below shows how to load configuration from both a mappings.jsonfile and a Cloud Foundry credentials file when neither are in the default directory.let cloudEnv = CloudEnv(mappingsFilePath: "resources/mappings", cloudFoundryFile: "resources cfresources/cf.json")DeclarationSwift public init(mappingsFilePath: String? = nil, cloudFoundryFile: String? = nil)ParametersmappingsFilePathOptional. The path to the mappings.jsonfile; this path should be relative to the root folder of the Swift application.cloudFoundryFileOptional. The path to a JSON file that contains values for Cloud Foundry environment variables (mainly used for testing); this path should be relative to the current working directory (which in most cases is the folder of the Swift application). 
- 
                  
                  Returns the corresponding JSON dictionary value in a string. If the service you intend to use in your Swift application is not one which we explicitly support, you can leverage the generic getString(name: String)method to get the corresponding credentials.Usage Example:let cloudEnv = CloudEnv() if let credentials = cloudEnv.getString(name: "service1-credentials") { // You can now get the corresponding values from the credentials string. // The result string will follow JSON notation. }DeclarationSwift public func getString(name: String) -> String?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns the corresponding dictionary value. If the service you intend to use in your Swift application is not one which we explicitly support, you can leverage the generic getDictionary(name: String)method to get the corresponding credentials.Usage Example:let cloudEnv = CloudEnv() if let credentials: [String:Any] = cloudEnv.getDictionary(name: "service1-credentials") { // You can now get the corresponding values from the dictionary. }DeclarationSwift public func getDictionary(name: String) -> [String : Any]?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an AlertNotificationCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getAlertNotificationCredentials(name: "AlertNotificationKey")DeclarationSwift public func getAlertNotificationCredentials (name: String) -> AlertNotificationCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an AppIDCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getAppIDCredentials(name: "AppIDKey")DeclarationSwift public func getAppIDCredentials(name: String) -> AppIDCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an AutoScalingCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getAutoScalingCredentials(name: "AutoScalingKey")DeclarationSwift public func getAutoScalingCredentials (name: String) -> AutoScalingCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns a CloudFunctionsCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getCloudFunctionsCredentials(name: "CloudFunctionsKey")DeclarationSwift public func getCloudFunctionsCredentials(name: String) -> CloudFunctionsCredentials?ParametersnameThe key to lookup the credentials. 
- 
                  
                  Returns a CloudantCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getCloudantCredentials(name: "CloudantKey")DeclarationSwift public func getCloudantCredentials(name: String) -> CloudantCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an DB2Credentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getDB2Credentials(name: "DB2Key")DeclarationSwift public func getDB2Credentials (name: String) -> DB2Credentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns a HyperSecureDBaaSCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getHyperSecureDBaaSCredentials(name: "HyperSecureDBaaSKey")DeclarationSwift public func getHyperSecureDBaaSCredentials(name: String) -> HyperSecureDBaaSCredentials?ParametersnameThe key to lookup the credentials object. 
- 
                  
                  Returns a MongoDBCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getMongoDBCredentials(name: "MongoDBKey")DeclarationSwift public func getMongoDBCredentials(name: String) -> MongoDBCredentials?ParametersnameThe key to lookup the credentials object. 
- 
                  
                  Returns an MySQLCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getMySQLCredentials(name: "MySQLKey")DeclarationSwift public func getMySQLCredentials (name: String) -> MySQLCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns a NaturalLanguageUnderstandingCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getNaturalLanguageUnderstandingCredentials(name: "NaturalLanguageUnderstandingKey")DeclarationSwift public func getNaturalLanguageUnderstandingCredentials(name: String) -> NaturalLanguageUnderstandingCredentials?ParametersnameThe key to lookup the credentials object. 
- 
                  
                  Returns an ObjectStorageCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getObjectStorageCredentials(name: "ObjectStorageKey")DeclarationSwift public func getObjectStorageCredentials(name: String) -> ObjectStorageCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an PostgreSQLCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getPostgreSQLCredentials(name: "PostgreSQLKey")DeclarationSwift public func getPostgreSQLCredentials(name: String) -> PostgreSQLCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns a PushSDKCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getPushSDKCredentials(name: "PushNotificationKey")DeclarationSwift public func getPushSDKCredentials(name: String) -> PushSDKCredentials?ParametersnameThe key to lookup the credentials. 
- 
                  
                  Returns an RedisCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getRedisCredentials(name: "RedisKey")DeclarationSwift public func getRedisCredentials(name: String) -> RedisCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an WatsonAssistantCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getWatsonAssistantCredentials(name: "WatsonAssistantCredentialsKey")DeclarationSwift public func getWatsonAssistantCredentials(name: String) -> WatsonAssistantCredentials?ParametersnameThe key to lookup the environment variable. 
- 
                  
                  Returns an WeatherCompanyDataCredentials object with the corresponding credentials. Usage Example:let cloudEnv = CloudEnv() credentials = cloudEnv.getWeatherCompanyDataCredentials(name: "WeatherCompanyDataKey")DeclarationSwift public func getWeatherCompanyDataCredentials(name: String) -> WeatherCompanyDataCredentials?ParametersnameThe key to lookup the environment variable. 
 View on GitHub
            View on GitHub
           CloudEnv Class Reference
      CloudEnv Class Reference