Skip to content

Commit

Permalink
haddocks
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed Oct 28, 2024
1 parent 005afad commit 5110cf6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions azure-blob-storage/src/Azure/Blob/GetBlob.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ data GetBlob = GetBlob
}
deriving stock (Eq, Generic)

{- | Fetch a blob from blob storage
Errors will be thrown in IO. For variant where error is
caught in a @Left@ branch, see @getBlobObjectEither@
-}
getBlobObject ::
MonadIO m =>
GetBlob ->
Expand All @@ -52,6 +57,7 @@ getBlobObject getBlobReq fp = do
Right r ->
pure r

-- | Fetch a blob from blob storage
getBlobObjectEither ::
MonadIO m =>
GetBlob ->
Expand Down
20 changes: 19 additions & 1 deletion azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,22 @@ import qualified Data.ByteString.Base64 as B64
import qualified Data.ByteString.Char8 as C8
import qualified Data.Text as Text

{- | Generates a Shared Access Token.
Errors will be thrown in IO. For variant where error is
caught in a @Left@ branch, see @generateSasEither@
-}
generateSas ::
MonadIO m =>
-- | Name of the Blob storage account
AccountName ->
-- | Name of the Blob container
ContainerName ->
-- | Name of the blob itself
BlobName ->
-- | Time in seconds for which the Shared Access Token should be valid for
SasTokenExpiry ->
-- | Access Token for making requests
AccessToken ->
m Url
generateSas accountName containerName blobName expiry accessToken = do
Expand All @@ -50,13 +60,21 @@ generateSas accountName containerName blobName expiry accessToken = do
Right url ->
pure url

-- TODO: We need to add support for empty fields here. Eg: signedAuthorizedUserObjectId
{- | Generates a Shared Access Token.
TODO: We need to add support for empty fields here. Eg: signedAuthorizedUserObjectId
-}
generateSasEither ::
MonadIO m =>
-- | Name of the Blob storage account
AccountName ->
-- | Name of the Blob container
ContainerName ->
-- | Name of the blob itself
BlobName ->
-- | Time in seconds for which the Shared Access Token should be valid for
SasTokenExpiry ->
-- | Access Token for making requests
AccessToken ->
m (Either Text Url)
generateSasEither accountName containerName blobName (SasTokenExpiry expiry) accessToken = do
Expand Down
2 changes: 1 addition & 1 deletion azure-blob-storage/src/Azure/Blob/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ newtype Url = Url
}
deriving stock (Eq, Show, Generic)

-- | For an azure action to be turned into a signed url
-- | Represents how long a SAS token should be valid for in seconds.
newtype SasTokenExpiry = SasTokenExpiry
{ unSasTokenExpiry :: Int
}
Expand Down

0 comments on commit 5110cf6

Please sign in to comment.