diff --git a/azure-blob-storage/src/Azure/Blob/GetBlob.hs b/azure-blob-storage/src/Azure/Blob/GetBlob.hs index d7179cd..8653aad 100644 --- a/azure-blob-storage/src/Azure/Blob/GetBlob.hs +++ b/azure-blob-storage/src/Azure/Blob/GetBlob.hs @@ -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 -> @@ -52,6 +57,7 @@ getBlobObject getBlobReq fp = do Right r -> pure r +-- | Fetch a blob from blob storage getBlobObjectEither :: MonadIO m => GetBlob -> diff --git a/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs b/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs index d3ab069..645727e 100644 --- a/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs +++ b/azure-blob-storage/src/Azure/Blob/SharedAccessSignature.hs @@ -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 @@ -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 diff --git a/azure-blob-storage/src/Azure/Blob/Types.hs b/azure-blob-storage/src/Azure/Blob/Types.hs index 6034586..cd64387 100644 --- a/azure-blob-storage/src/Azure/Blob/Types.hs +++ b/azure-blob-storage/src/Azure/Blob/Types.hs @@ -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 }