A music player that connects to your cloud/distributed storage.
at main 6.4 kB view raw
1module Sources.Services exposing (initialData, keyToType, labels, makeTrackUrl, makeTree, parseErrorResponse, parsePreparationResponse, parseTreeResponse, postProcessTree, prepare, properties, typeToKey) 2 3{-| Service functions used in other modules. 4-} 5 6import Http 7import Sources exposing (..) 8import Sources.Processing exposing (..) 9import Sources.Services.AmazonS3 as AmazonS3 10import Sources.Services.AzureBlob as AzureBlob 11import Sources.Services.AzureFile as AzureFile 12import Sources.Services.Dropbox as Dropbox 13import Sources.Services.Google as Google 14import Sources.Services.Ipfs as Ipfs 15import Sources.Services.WebDav as WebDav 16import Time 17 18 19 20-- FUNCTIONS 21 22 23initialData : Service -> SourceData 24initialData service = 25 case service of 26 AmazonS3 -> 27 AmazonS3.initialData 28 29 AzureBlob -> 30 AzureBlob.initialData 31 32 AzureFile -> 33 AzureFile.initialData 34 35 Dropbox -> 36 Dropbox.initialData 37 38 Google -> 39 Google.initialData 40 41 Ipfs -> 42 Ipfs.initialData 43 44 WebDav -> 45 WebDav.initialData 46 47 48makeTrackUrl : Service -> Time.Posix -> String -> SourceData -> HttpMethod -> String -> String 49makeTrackUrl service = 50 case service of 51 AmazonS3 -> 52 AmazonS3.makeTrackUrl 53 54 AzureBlob -> 55 AzureBlob.makeTrackUrl 56 57 AzureFile -> 58 AzureFile.makeTrackUrl 59 60 Dropbox -> 61 Dropbox.makeTrackUrl 62 63 Google -> 64 Google.makeTrackUrl 65 66 Ipfs -> 67 Ipfs.makeTrackUrl 68 69 WebDav -> 70 WebDav.makeTrackUrl 71 72 73makeTree : 74 Service 75 -> SourceData 76 -> Marker 77 -> Time.Posix 78 -> (Result Http.Error String -> msg) 79 -> Cmd msg 80makeTree service = 81 case service of 82 AmazonS3 -> 83 AmazonS3.makeTree 84 85 AzureBlob -> 86 AzureBlob.makeTree 87 88 AzureFile -> 89 AzureFile.makeTree 90 91 Dropbox -> 92 Dropbox.makeTree 93 94 Google -> 95 Google.makeTree 96 97 Ipfs -> 98 Ipfs.makeTree 99 100 WebDav -> 101 WebDav.makeTree 102 103 104parseErrorResponse : Service -> String -> Maybe String 105parseErrorResponse service = 106 case service of 107 AmazonS3 -> 108 AmazonS3.parseErrorResponse 109 110 AzureBlob -> 111 AzureBlob.parseErrorResponse 112 113 AzureFile -> 114 AzureFile.parseErrorResponse 115 116 Dropbox -> 117 Dropbox.parseErrorResponse 118 119 Google -> 120 Google.parseErrorResponse 121 122 Ipfs -> 123 Ipfs.parseErrorResponse 124 125 WebDav -> 126 WebDav.parseErrorResponse 127 128 129parsePreparationResponse : Service -> String -> Time.Posix -> SourceData -> Marker -> PrepationAnswer Marker 130parsePreparationResponse service = 131 case service of 132 AmazonS3 -> 133 AmazonS3.parsePreparationResponse 134 135 AzureBlob -> 136 AzureBlob.parsePreparationResponse 137 138 AzureFile -> 139 AzureFile.parsePreparationResponse 140 141 Dropbox -> 142 Dropbox.parsePreparationResponse 143 144 Google -> 145 Google.parsePreparationResponse 146 147 Ipfs -> 148 Ipfs.parsePreparationResponse 149 150 WebDav -> 151 WebDav.parsePreparationResponse 152 153 154parseTreeResponse : Service -> String -> Marker -> TreeAnswer Marker 155parseTreeResponse service = 156 case service of 157 AmazonS3 -> 158 AmazonS3.parseTreeResponse 159 160 AzureBlob -> 161 AzureBlob.parseTreeResponse 162 163 AzureFile -> 164 AzureFile.parseTreeResponse 165 166 Dropbox -> 167 Dropbox.parseTreeResponse 168 169 Google -> 170 Google.parseTreeResponse 171 172 Ipfs -> 173 Ipfs.parseTreeResponse 174 175 WebDav -> 176 WebDav.parseTreeResponse 177 178 179postProcessTree : Service -> List String -> List String 180postProcessTree service = 181 case service of 182 AmazonS3 -> 183 AmazonS3.postProcessTree 184 185 AzureBlob -> 186 AzureBlob.postProcessTree 187 188 AzureFile -> 189 AzureFile.postProcessTree 190 191 Dropbox -> 192 Dropbox.postProcessTree 193 194 Google -> 195 Google.postProcessTree 196 197 Ipfs -> 198 Ipfs.postProcessTree 199 200 WebDav -> 201 WebDav.postProcessTree 202 203 204prepare : 205 Service 206 -> String 207 -> SourceData 208 -> Marker 209 -> (Result Http.Error String -> msg) 210 -> Maybe (Cmd msg) 211prepare service = 212 case service of 213 AmazonS3 -> 214 AmazonS3.prepare 215 216 AzureBlob -> 217 AzureBlob.prepare 218 219 AzureFile -> 220 AzureFile.prepare 221 222 Dropbox -> 223 Dropbox.prepare 224 225 Google -> 226 Google.prepare 227 228 Ipfs -> 229 Ipfs.prepare 230 231 WebDav -> 232 WebDav.prepare 233 234 235properties : Service -> List Property 236properties service = 237 case service of 238 AmazonS3 -> 239 AmazonS3.properties 240 241 AzureBlob -> 242 AzureBlob.properties 243 244 AzureFile -> 245 AzureFile.properties 246 247 Dropbox -> 248 Dropbox.properties 249 250 Google -> 251 Google.properties 252 253 Ipfs -> 254 Ipfs.properties 255 256 WebDav -> 257 WebDav.properties 258 259 260 261-- KEYS & LABELS 262 263 264keyToType : String -> Maybe Service 265keyToType str = 266 case str of 267 "AmazonS3" -> 268 Just AmazonS3 269 270 "AzureBlob" -> 271 Just AzureBlob 272 273 "AzureFile" -> 274 Just AzureFile 275 276 "Dropbox" -> 277 Just Dropbox 278 279 "Google" -> 280 Just Google 281 282 "Ipfs" -> 283 Just Ipfs 284 285 "WebDav" -> 286 Just WebDav 287 288 _ -> 289 Nothing 290 291 292typeToKey : Service -> String 293typeToKey service = 294 case service of 295 AmazonS3 -> 296 "AmazonS3" 297 298 AzureBlob -> 299 "AzureBlob" 300 301 AzureFile -> 302 "AzureFile" 303 304 Dropbox -> 305 "Dropbox" 306 307 Google -> 308 "Google" 309 310 Ipfs -> 311 "Ipfs" 312 313 WebDav -> 314 "WebDav" 315 316 317{-| Service labels. 318Maps a service key to a label. 319-} 320labels : List ( String, String ) 321labels = 322 [ ( typeToKey AmazonS3, "Amazon S3" ) 323 , ( typeToKey AzureBlob, "Azure Blob Storage" ) 324 , ( typeToKey AzureFile, "Azure File Storage" ) 325 , ( typeToKey Dropbox, "Dropbox" ) 326 , ( typeToKey Ipfs, "IPFS" ) 327 , ( typeToKey WebDav, "WebDAV" ) 328 ]