1414 * limitations under the License.
1515 */
1616
17-
1817import Foundation
1918
2019import CloudFoundryEnv
2120
2221public class CloudantService : Service {
23-
22+
2423 public let host : String
2524 public let username : String
2625 public let password : String
2726 public let port : Int
2827 public let url : String
29-
28+
3029 public init ? ( withService service: Service ) {
3130
3231 guard let credentials = service. credentials,
@@ -37,13 +36,13 @@ public class CloudantService: Service {
3736 let url = credentials [ " url " ] as? String else {
3837 return nil
3938 }
40-
39+
4140 self . host = host
4241 self . username = username
4342 self . password = password
4443 self . port = port
4544 self . url = url
46-
45+
4746 super. init ( name: service. name,
4847 label: service. label,
4948 plan: service. plan,
@@ -53,21 +52,51 @@ public class CloudantService: Service {
5352 }
5453}
5554
55+ public class AlertNotificationService : Service {
56+
57+ public let url : String
58+ public let id : String
59+ public let password : String
60+ public let swaggerUI : String
61+
62+ public init ? ( withService service: Service ) {
63+
64+ guard let credentials = service. credentials,
65+ let url = credentials [ " url " ] as? String ,
66+ let id = credentials [ " name " ] as? String ,
67+ let swaggerUI = credentials [ " swaggerui " ] as? String ,
68+ let password = credentials [ " password " ] as? String else {
69+ return nil
70+ }
71+
72+ self . url = url
73+ self . id = id
74+ self . password = password
75+ self . swaggerUI = swaggerUI
76+
77+ super. init ( name: service. name,
78+ label: service. label,
79+ plan: service. plan,
80+ tags: service. tags,
81+ credentials: service. credentials)
82+ }
83+ }
84+
5685public class MongoDBService : Service {
57-
86+
5887 public let host : String
5988 public let username : String
6089 public let password : String
6190 public let port : Int
6291 public let certificate : String
63-
92+
6493 public init ? ( withService service: Service ) {
65-
94+
6695 guard let credentials = service. credentials else {
6796 print ( " Service credentials were nil. " )
6897 return nil
6998 }
70-
99+
71100 // Use SSL uri if available
72101 let initialURI = credentials [ " uri " ] as? String ?? " "
73102 let uris = initialURI. components ( separatedBy: " , " )
@@ -82,7 +111,7 @@ public class MongoDBService: Service {
82111 } else {
83112 uriValue = uris. first
84113 }
85-
114+
86115 guard let stringURL = uriValue, stringURL. characters. count > 0 ,
87116 let url = URL ( string: stringURL) ,
88117 let host = url. host,
@@ -92,13 +121,13 @@ public class MongoDBService: Service {
92121 let certificate = credentials [ " ca_certificate_base64 " ] as? String else {
93122 return nil
94123 }
95-
124+
96125 self . host = host
97126 self . username = username
98127 self . password = password
99128 self . port = port
100129 self . certificate = certificate
101-
130+
102131 super. init ( name: service. name,
103132 label: service. label,
104133 plan: service. plan,
@@ -110,13 +139,13 @@ public class MongoDBService: Service {
110139
111140
112141public class RedisService : Service {
113-
142+
114143 public let host : String
115144 public let password : String
116145 public let port : Int
117146
118147 public init ? ( withService service: Service ) {
119-
148+
120149 guard let credentials = service. credentials,
121150 let uri = credentials [ " uri " ] as? String ,
122151 let url = URL ( string: uri) ,
@@ -129,7 +158,7 @@ public class RedisService: Service {
129158 self . host = host
130159 self . password = password
131160 self . port = port
132-
161+
133162 super. init ( name: service. name,
134163 label: service. label,
135164 plan: service. plan,
@@ -139,14 +168,14 @@ public class RedisService: Service {
139168}
140169
141170public class PostgreSQLService : Service {
142-
171+
143172 public let host : String
144173 public let port : Int
145174 public let username : String
146175 public let password : String
147-
176+
148177 public init ? ( withService service: Service ) {
149-
178+
150179 guard let credentials = service. credentials,
151180 let uri = credentials [ " uri " ] as? String ,
152181 let url = URL ( string: uri) ,
@@ -156,12 +185,12 @@ public class PostgreSQLService: Service {
156185 let password = url. password else {
157186 return nil
158187 }
159-
188+
160189 self . host = host
161190 self . port = port
162191 self . username = username
163192 self . password = password
164-
193+
165194 super. init ( name: service. name,
166195 label: service. label,
167196 plan: service. plan,
@@ -172,13 +201,13 @@ public class PostgreSQLService: Service {
172201}
173202
174203public class MySQLService : Service {
175-
204+
176205 public let database : String
177206 public let host : String
178207 public let username : String
179208 public let password : String
180209 public let port : Int
181-
210+
182211 public init ? ( withService service: Service ) {
183212
184213 guard let credentials = service. credentials,
@@ -196,26 +225,26 @@ public class MySQLService: Service {
196225 self . username = username
197226 self . password = password
198227 self . port = port
199-
228+
200229 super. init ( name: service. name,
201230 label: service. label,
202231 plan: service. plan,
203232 tags: service. tags,
204233 credentials: service. credentials)
205234 }
206-
235+
207236}
208237
209238public class DB2Service : Service {
210-
239+
211240 public let database : String
212241 public let host : String
213242 public let port : Int
214243 public let uid : String
215244 public let pwd : String
216-
245+
217246 public init ? ( withService service: Service ) {
218-
247+
219248 guard let credentials = service. credentials,
220249 let database = credentials [ " db " ] as? String ,
221250 let host = credentials [ " host " ] as? String ,
@@ -224,19 +253,19 @@ public class DB2Service: Service {
224253 let pwd = credentials [ " password " ] as? String else {
225254 return nil
226255 }
227-
256+
228257 self . database = database
229258 self . host = host
230259 self . port = port
231260 self . uid = uid
232261 self . pwd = pwd
233-
262+
234263 super. init ( name: service. name,
235264 label: service. label,
236265 plan: service. plan,
237266 tags: service. tags,
238267 credentials: service. credentials)
239-
268+
240269 }
241-
270+
242271}
0 commit comments