From c0bea6ab8e84d3dd536efd26c4a5af304fa3f40a Mon Sep 17 00:00:00 2001 From: Nitin Prakash Date: Sun, 4 Aug 2024 13:12:43 +0530 Subject: [PATCH] restructure modules --- azure-blob-storage/azure-blob-storage.cabal | 13 +++++---- azure-blob-storage/src/Azure/Blob.hs | 28 +++++++++++++++++++ .../src/Azure/{ => Blob}/DeleteBlob.hs | 2 +- .../src/Azure/{ => Blob}/GetBlob.hs | 5 +++- .../src/Azure/{ => Blob}/PutBlob.hs | 2 +- .../Azure/{ => Blob}/SharedAccessSignature.hs | 5 ++-- .../src/Azure/{ => Blob}/UserDelegationKey.hs | 2 +- 7 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 azure-blob-storage/src/Azure/Blob.hs rename azure-blob-storage/src/Azure/{ => Blob}/DeleteBlob.hs (98%) rename azure-blob-storage/src/Azure/{ => Blob}/GetBlob.hs (95%) rename azure-blob-storage/src/Azure/{ => Blob}/PutBlob.hs (99%) rename azure-blob-storage/src/Azure/{ => Blob}/SharedAccessSignature.hs (96%) rename azure-blob-storage/src/Azure/{ => Blob}/UserDelegationKey.hs (98%) diff --git a/azure-blob-storage/azure-blob-storage.cabal b/azure-blob-storage/azure-blob-storage.cabal index 81c55f2..81b9160 100644 --- a/azure-blob-storage/azure-blob-storage.cabal +++ b/azure-blob-storage/azure-blob-storage.cabal @@ -51,12 +51,13 @@ common common-options library import: common-options - exposed-modules: Azure.Blob.Types - Azure.GetBlob - Azure.DeleteBlob - Azure.PutBlob - Azure.UserDelegationKey - Azure.SharedAccessSignature + exposed-modules: Azure.Blob + Azure.Blob.GetBlob + Azure.Blob.DeleteBlob + Azure.Blob.Types + Azure.Blob.UserDelegationKey + Azure.Blob.PutBlob + Azure.Blob.SharedAccessSignature build-depends: azure-auth , aeson , base64-bytestring diff --git a/azure-blob-storage/src/Azure/Blob.hs b/azure-blob-storage/src/Azure/Blob.hs new file mode 100644 index 0000000..287bac3 --- /dev/null +++ b/azure-blob-storage/src/Azure/Blob.hs @@ -0,0 +1,28 @@ +module Azure.Blob + ( + -- ** Variants to fetch a blob object + getBlobObject + , getBlobObjectEither + + -- ** Variants to upload a blob to Blob storage + , putBlobObject + , putBlobObjectEither + + -- ** Variants for deleting a blob object + , deleteBlobObject + , deleteBlobObjectEither + + -- ** Generating a Shared Access Signature URI + , generateSas + + -- ** Types for dealing with Blob storage functions + , AccountName (..) + , ContainerName (..) + , BlobName (..) + ) where + +import Azure.Blob.PutBlob +import Azure.Blob.GetBlob +import Azure.Blob.DeleteBlob +import Azure.Blob.SharedAccessSignature +import Azure.Blob.Types diff --git a/azure-blob-storage/src/Azure/DeleteBlob.hs b/azure-blob-storage/src/Azure/Blob/DeleteBlob.hs similarity index 98% rename from azure-blob-storage/src/Azure/DeleteBlob.hs rename to azure-blob-storage/src/Azure/Blob/DeleteBlob.hs index d755210..e5abd11 100644 --- a/azure-blob-storage/src/Azure/DeleteBlob.hs +++ b/azure-blob-storage/src/Azure/Blob/DeleteBlob.hs @@ -5,7 +5,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} -module Azure.DeleteBlob +module Azure.Blob.DeleteBlob ( deleteBlobObject , deleteBlobObjectEither ) where diff --git a/azure-blob-storage/src/Azure/GetBlob.hs b/azure-blob-storage/src/Azure/Blob/GetBlob.hs similarity index 95% rename from azure-blob-storage/src/Azure/GetBlob.hs rename to azure-blob-storage/src/Azure/Blob/GetBlob.hs index ab8056d..5593493 100644 --- a/azure-blob-storage/src/Azure/GetBlob.hs +++ b/azure-blob-storage/src/Azure/Blob/GetBlob.hs @@ -6,7 +6,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} -module Azure.GetBlob +module Azure.Blob.GetBlob ( getBlobObject , getBlobObjectEither ) where @@ -74,6 +74,9 @@ type GetBlobApi = :> Header' '[Required, Strict] "x-ms-version" Text :> Get '[Blob] ByteString +-- TODO: this is more of a test at the moment. +-- GET endpoint should accept any blob that is available and not just +-- rely on certain mime types instance Accept Blob where contentTypes :: Proxy Blob -> NonEmpty MediaType contentTypes _ = diff --git a/azure-blob-storage/src/Azure/PutBlob.hs b/azure-blob-storage/src/Azure/Blob/PutBlob.hs similarity index 99% rename from azure-blob-storage/src/Azure/PutBlob.hs rename to azure-blob-storage/src/Azure/Blob/PutBlob.hs index 3069a1d..32e6381 100644 --- a/azure-blob-storage/src/Azure/PutBlob.hs +++ b/azure-blob-storage/src/Azure/Blob/PutBlob.hs @@ -3,7 +3,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} -module Azure.PutBlob +module Azure.Blob.PutBlob ( putBlobObjectEither , putBlobObject ) where diff --git a/azure-blob-storage/src/Azure/SharedAccessSignature.hs b/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs similarity index 96% rename from azure-blob-storage/src/Azure/SharedAccessSignature.hs rename to azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs index 4b7dcf8..cba27cd 100644 --- a/azure-blob-storage/src/Azure/SharedAccessSignature.hs +++ b/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs @@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} -module Azure.SharedAccessSignature +module Azure.Blob.SharedAccessSignature ( generateSas ) where @@ -19,7 +19,7 @@ import Azure.Blob.Types , sasPermissionsToText , sasResourceToText ) -import Azure.UserDelegationKey (callGetUserDelegationKeyApi, getUserDelegationKeyApi) +import Azure.Blob.UserDelegationKey (callGetUserDelegationKeyApi, getUserDelegationKeyApi) import Crypto.Hash.SHA256 (hmac) import Data.Text (Text) import Data.Text.Encoding (decodeUtf8, encodeUtf8) @@ -36,6 +36,7 @@ import qualified Data.Text as Text blobStorageResourceUrl :: Text blobStorageResourceUrl = "https://storage.azure.com/" +-- TODO: We need to add support for empty fields here. Eg: signedAuthorizedUserObjectId generateSas :: MonadIO m => AccountName -> diff --git a/azure-blob-storage/src/Azure/UserDelegationKey.hs b/azure-blob-storage/src/Azure/Blob/UserDelegationKey.hs similarity index 98% rename from azure-blob-storage/src/Azure/UserDelegationKey.hs rename to azure-blob-storage/src/Azure/Blob/UserDelegationKey.hs index 5197ab8..805e63c 100644 --- a/azure-blob-storage/src/Azure/UserDelegationKey.hs +++ b/azure-blob-storage/src/Azure/Blob/UserDelegationKey.hs @@ -4,7 +4,7 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeOperators #-} -module Azure.UserDelegationKey +module Azure.Blob.UserDelegationKey ( callGetUserDelegationKeyApi , getUserDelegationKeyApi ) where