From 849b4be3ff2b8051c619aaa5c34d19a606221347 Mon Sep 17 00:00:00 2001 From: Nitin Prakash Date: Fri, 28 Jun 2024 22:12:58 +0530 Subject: [PATCH] Blob storage boilerplate --- azure-blob-storage/CHANGELOG.md | 5 ++ azure-blob-storage/LICENSE | 21 ++++++ azure-blob-storage/app/Main.hs | 8 +++ azure-blob-storage/azure-blob-storage.cabal | 80 +++++++++++++++++++++ azure-blob-storage/src/Azure/Types.hs | 33 +++++++++ azure-blob-storage/test/Main.hs | 4 ++ 6 files changed, 151 insertions(+) create mode 100644 azure-blob-storage/CHANGELOG.md create mode 100644 azure-blob-storage/LICENSE create mode 100644 azure-blob-storage/app/Main.hs create mode 100644 azure-blob-storage/azure-blob-storage.cabal create mode 100644 azure-blob-storage/src/Azure/Types.hs create mode 100644 azure-blob-storage/test/Main.hs diff --git a/azure-blob-storage/CHANGELOG.md b/azure-blob-storage/CHANGELOG.md new file mode 100644 index 0000000..94fa3bc --- /dev/null +++ b/azure-blob-storage/CHANGELOG.md @@ -0,0 +1,5 @@ +# Revision history for azure-blob-storage + +## 0.1.0.0 -- YYYY-mm-dd + +* First version. Released on an unsuspecting world. diff --git a/azure-blob-storage/LICENSE b/azure-blob-storage/LICENSE new file mode 100644 index 0000000..1f229d7 --- /dev/null +++ b/azure-blob-storage/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Holmusk + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/azure-blob-storage/app/Main.hs b/azure-blob-storage/app/Main.hs new file mode 100644 index 0000000..4a4d28e --- /dev/null +++ b/azure-blob-storage/app/Main.hs @@ -0,0 +1,8 @@ +module Main where + +import qualified Blob (someFunc) + +main :: IO () +main = do + putStrLn "Hello, Haskell!" + Blob.someFunc diff --git a/azure-blob-storage/azure-blob-storage.cabal b/azure-blob-storage/azure-blob-storage.cabal new file mode 100644 index 0000000..eccb338 --- /dev/null +++ b/azure-blob-storage/azure-blob-storage.cabal @@ -0,0 +1,80 @@ +cabal-version: 3.0 +name: azure-blob-storage +version: 0.1.0.0 +license: MIT +license-file: LICENSE +synopsis: Boilerplace/startkit for azure in Haskell (using servant) +description: This provides from useful functionalities for starting out with Azure in Haskell. + This includes authentication, Key vault, Blob storage and email communication related APIs. +author: Holmusk +maintainer: tech@holmusk.com +category: Azure +build-type: Simple +extra-doc-files: CHANGELOG.md +tested-with: GHC == 9.0.2 + GHC == 9.2.8 + GHC == 9.4.8 + GHC == 9.6.3 + GHC == 9.8.2 + +common common-options + ghc-options: -Wall + -Wincomplete-uni-patterns + -Wincomplete-record-updates + -Wcompat + -Widentities + -Wredundant-constraints + -fhide-source-paths + -Wpartial-fields + -Wunrecognised-pragmas + -Wmissing-deriving-strategies + -Wunticked-promoted-constructors + -Winvalid-haddock + -Woperator-whitespace + -Wredundant-bang-patterns + -Wunused-packages + build-depends: base >= 4.7 && <5 + default-language: GHC2021 + default-extensions: DataKinds + DerivingStrategies + DerivingVia + LambdaCase + NoImportQualifiedPost + NoGeneralisedNewtypeDeriving + OverloadedStrings + OverloadedLabels + RecordWildCards + TypeFamilies + ViewPatterns + if os(linux) + ghc-options: -optl-fuse-ld=gold + ld-options: -fuse-ld=gold + +library + import: common-options + exposed-modules: Azure.Types + build-depends: aeson + , azure-auth + , bytestring + , http-client + , http-client-tls + , http-types + , servant + , servant-client + , text + , time + , unliftio + hs-source-dirs: src + default-language: Haskell2010 + +test-suite azure-blob-storage-test + import: common-options + default-language: Haskell2010 + -- other-modules: + -- other-extensions: + type: exitcode-stdio-1.0 + hs-source-dirs: test + main-is: Main.hs + build-depends: + base ^>=4.7 && <5, + azure-blob-storage diff --git a/azure-blob-storage/src/Azure/Types.hs b/azure-blob-storage/src/Azure/Types.hs new file mode 100644 index 0000000..2834527 --- /dev/null +++ b/azure-blob-storage/src/Azure/Types.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeOperators #-} + +-- Introduce blob storage functions that run in IO +module Azure.Types + ( BlobName (..) + , ContainerName (..) + , AccountName (..) + ) where + +import Data.ByteString.Lazy (ByteString) +import Data.Text (Text) +import GHC.Generics (Generic) +import Servant.API (ToHttpApiData) + +newtype AccountName = AccountName + { unAccountName :: Text + } + deriving stock (Eq, Show, Generic) + deriving (ToHttpApiData) via Text + +newtype ContainerName = ContainerName + { unContainerName :: Text + } + deriving stock (Eq, Show, Generic) + deriving (ToHttpApiData) via Text + +newtype BlobName = BlobName + { unBlobName :: Text + } + deriving stock (Eq, Show, Generic) + deriving (ToHttpApiData) via Text diff --git a/azure-blob-storage/test/Main.hs b/azure-blob-storage/test/Main.hs new file mode 100644 index 0000000..3e2059e --- /dev/null +++ b/azure-blob-storage/test/Main.hs @@ -0,0 +1,4 @@ +module Main (main) where + +main :: IO () +main = putStrLn "Test suite not yet implemented."