-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A Minio Haskell Library for Amazon S3 compatible cloud
--   storage.
--   
--   The Minio Haskell client library provides simple APIs to access Minio,
--   Amazon S3 and other API compatible cloud storage servers.
@package minio-hs
@version 1.0.1

module Network.Minio.S3API

-- | Represents a region TODO: This could be a Sum Type with all defined
--   regions for AWS.
type Region = Text

-- | Fetch bucket location (region)
getLocation :: Bucket -> Minio Region

-- | Fetch all buckets from the service.
getService :: Minio [BucketInfo]

-- | Represents result from a listing of objects in a bucket.
data ListObjectsResult
ListObjectsResult :: Bool -> Maybe Text -> [ObjectInfo] -> [Text] -> ListObjectsResult
[lorHasMore] :: ListObjectsResult -> Bool
[lorNextToken] :: ListObjectsResult -> Maybe Text
[lorObjects] :: ListObjectsResult -> [ObjectInfo]
[lorCPrefixes] :: ListObjectsResult -> [Text]

-- | Represents result from a listing of objects version 1 in a bucket.
data ListObjectsV1Result
ListObjectsV1Result :: Bool -> Maybe Text -> [ObjectInfo] -> [Text] -> ListObjectsV1Result
[lorHasMore'] :: ListObjectsV1Result -> Bool
[lorNextMarker] :: ListObjectsV1Result -> Maybe Text
[lorObjects'] :: ListObjectsV1Result -> [ObjectInfo]
[lorCPrefixes'] :: ListObjectsV1Result -> [Text]

-- | List objects in a bucket matching prefix up to delimiter, starting
--   from nextToken.
listObjects' :: Bucket -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Int -> Minio ListObjectsResult

-- | List objects in a bucket matching prefix up to delimiter, starting
--   from nextMarker.
listObjectsV1' :: Bucket -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Int -> Minio ListObjectsV1Result

-- | Query the object store if a given bucket exists.
headBucket :: Bucket -> Minio Bool

-- | GET an object from the service and return the response headers and a
--   conduit source for the object content
getObject' :: Bucket -> Object -> Query -> [Header] -> Minio ([Header], ConduitM () ByteString Minio ())

-- | Get metadata of an object.
headObject :: Bucket -> Object -> Minio ObjectInfo

-- | Creates a bucket via a PUT bucket call.
putBucket :: Bucket -> Region -> Minio ()

-- | A type alias to represent an Entity-Tag returned by S3-compatible
--   APIs.
type ETag = Text
putObjectSingle' :: Bucket -> Object -> [Header] -> ByteString -> Minio ETag

-- | PUT an object into the service. This function performs a single PUT
--   object call, and so can only transfer objects upto 5GiB.
putObjectSingle :: Bucket -> Object -> [Header] -> Handle -> Int64 -> Int64 -> Minio ETag

-- | Performs server-side copy of an object that is upto 5GiB in size. If
--   the object is greater than 5GiB, this function throws the error
--   returned by the server.
copyObjectSingle :: Bucket -> Object -> SourceInfo -> [Header] -> Minio (ETag, UTCTime)

-- | A type alias to represent an upload-id for multipart upload
type UploadId = Text

-- | A type to represent a part-number and etag.
type PartTuple = (PartNumber, ETag)

-- | Represents different kinds of payload that are used with S3 API
--   requests.
data Payload
PayloadBS :: ByteString -> Payload
PayloadH :: Handle -> Int64 -> Int64 -> Payload

-- | A type alias to represent a part-number for multipart upload
type PartNumber = Int16

-- | Create a new multipart upload.
newMultipartUpload :: Bucket -> Object -> [Header] -> Minio UploadId

-- | PUT a part of an object as part of a multipart upload.
putObjectPart :: Bucket -> Object -> UploadId -> PartNumber -> [Header] -> Payload -> Minio PartTuple

-- | Performs server-side copy of an object or part of an object as an
--   upload part of an ongoing multi-part upload.
copyObjectPart :: DestinationInfo -> SourceInfo -> UploadId -> PartNumber -> [Header] -> Minio (ETag, UTCTime)

-- | Complete a multipart upload.
completeMultipartUpload :: Bucket -> Object -> UploadId -> [PartTuple] -> Minio ETag

-- | Abort a multipart upload.
abortMultipartUpload :: Bucket -> Object -> UploadId -> Minio ()

-- | Represents result from a listing of incomplete uploads to a bucket.
data ListUploadsResult
ListUploadsResult :: Bool -> Maybe Text -> Maybe Text -> [(Object, UploadId, UTCTime)] -> [Text] -> ListUploadsResult
[lurHasMore] :: ListUploadsResult -> Bool
[lurNextKey] :: ListUploadsResult -> Maybe Text
[lurNextUpload] :: ListUploadsResult -> Maybe Text
[lurUploads] :: ListUploadsResult -> [(Object, UploadId, UTCTime)]
[lurCPrefixes] :: ListUploadsResult -> [Text]

-- | List incomplete multipart uploads.
listIncompleteUploads' :: Bucket -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Int -> Minio ListUploadsResult

-- | Represents result from a listing of object parts of an ongoing
--   multipart upload.
data ListPartsResult
ListPartsResult :: Bool -> Maybe Int -> [ObjectPartInfo] -> ListPartsResult
[lprHasMore] :: ListPartsResult -> Bool
[lprNextPart] :: ListPartsResult -> Maybe Int
[lprParts] :: ListPartsResult -> [ObjectPartInfo]

-- | List parts of an ongoing multipart upload.
listIncompleteParts' :: Bucket -> Object -> UploadId -> Maybe Text -> Maybe Text -> Minio ListPartsResult

-- | DELETE a bucket from the service.
deleteBucket :: Bucket -> Minio ()

-- | DELETE an object from the service.
deleteObject :: Bucket -> Object -> Minio ()

-- | Time to expire for a presigned URL. It interpreted as a number of
--   seconds. The maximum duration that can be specified is 7 days.
type UrlExpiry = Int

-- | Generate a presigned URL. This function allows for advanced usage -
--   for simple cases prefer the `presigned*Url` functions.
--   
--   If region is Nothing, it is picked up from the connection information
--   (no check of bucket existence is performed).
--   
--   All extra query parameters or headers are signed, and therefore are
--   required to be sent when the generated URL is actually used.
makePresignedUrl :: UrlExpiry -> Method -> Maybe Bucket -> Maybe Object -> Maybe Region -> Query -> RequestHeaders -> Minio ByteString

-- | Generate a URL with authentication signature to PUT (upload) an
--   object. Any extra headers if passed, are signed, and so they are
--   required when the URL is used to upload data. This could be used, for
--   example, to set user-metadata on the object.
--   
--   For a list of possible headers to pass, please refer to the PUT object
--   REST API AWS S3 documentation.
presignedPutObjectUrl :: Bucket -> Object -> UrlExpiry -> RequestHeaders -> Minio ByteString

-- | Generate a URL with authentication signature to GET (download) an
--   object. All extra query parameters and headers passed here will be
--   signed and are required when the generated URL is used. Query
--   parameters could be used to change the response headers sent by the
--   server. Headers can be used to set Etag match conditions among others.
--   
--   For a list of possible request parameters and headers, please refer to
--   the GET object REST API AWS S3 documentation.
presignedGetObjectUrl :: Bucket -> Object -> UrlExpiry -> Query -> RequestHeaders -> Minio ByteString

-- | Generate a URL with authentication signature to make a HEAD request on
--   an object. This is used to fetch metadata about an object. All extra
--   headers passed here will be signed and are required when the generated
--   URL is used.
--   
--   For a list of possible headers to pass, please refer to the HEAD
--   object REST API AWS S3 documentation.
presignedHeadObjectUrl :: Bucket -> Object -> UrlExpiry -> RequestHeaders -> Minio ByteString

-- | Represents individual conditions in a Post Policy document.
data PostPolicyCondition
PPCStartsWith :: Text -> Text -> PostPolicyCondition
PPCEquals :: Text -> Text -> PostPolicyCondition
PPCRange :: Text -> Int64 -> Int64 -> PostPolicyCondition

-- | Set the bucket name that the upload should use.
ppCondBucket :: Bucket -> PostPolicyCondition

-- | Set the content length range constraint with minimum and maximum byte
--   count values.
ppCondContentLengthRange :: Int64 -> Int64 -> PostPolicyCondition

-- | Set the content-type header for the upload.
ppCondContentType :: Text -> PostPolicyCondition

-- | Set the object name constraint for the upload.
ppCondKey :: Object -> PostPolicyCondition

-- | Set the object name prefix constraint for the upload.
ppCondKeyStartsWith :: Object -> PostPolicyCondition

-- | Status code that the S3-server should send on a successful POST upload
ppCondSuccessActionStatus :: Int -> PostPolicyCondition

-- | A PostPolicy is required to perform uploads via browser forms.
data PostPolicy
PostPolicy :: UTCTime -> [PostPolicyCondition] -> PostPolicy
[expiration] :: PostPolicy -> UTCTime
[conditions] :: PostPolicy -> [PostPolicyCondition]

-- | Possible validation errors when creating a PostPolicy.
data PostPolicyError
PPEKeyNotSpecified :: PostPolicyError
PPEBucketNotSpecified :: PostPolicyError
PPEConditionKeyEmpty :: PostPolicyError
PPERangeInvalid :: PostPolicyError

-- | This function creates a PostPolicy after validating its arguments.
newPostPolicy :: UTCTime -> [PostPolicyCondition] -> Either PostPolicyError PostPolicy

-- | Convert Post Policy to a string (e.g. for printing).
showPostPolicy :: PostPolicy -> ByteString

-- | Generate a presigned URL and POST policy to upload files via a
--   browser. On success, this function returns a URL and POST form-data.
presignedPostPolicy :: PostPolicy -> Minio (ByteString, Map Text ByteString)

-- | Fetch the policy if any on a bucket.
getBucketPolicy :: Bucket -> Minio Text

-- | Set a new policy on a bucket. As a special condition if the policy is
--   empty then we treat it as policy DELETE operation.
setBucketPolicy :: Bucket -> Text -> Minio ()

-- | A data-type to represent bucket notification configuration. It is a
--   collection of queue, topic or lambda function configurations. The
--   structure of the types follow closely the XML representation described
--   at
--   <a>https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html</a>
data Notification
Notification :: [NotificationConfig] -> [NotificationConfig] -> [NotificationConfig] -> Notification
[nQueueConfigurations] :: Notification -> [NotificationConfig]
[nTopicConfigurations] :: Notification -> [NotificationConfig]
[nCloudFunctionConfigurations] :: Notification -> [NotificationConfig]

-- | A data-type representing the configuration for a particular
--   notification system. It could represent a Queue, Topic or Lambda
--   Function configuration.
data NotificationConfig
NotificationConfig :: Text -> Arn -> [Event] -> Filter -> NotificationConfig
[ncId] :: NotificationConfig -> Text
[ncArn] :: NotificationConfig -> Arn
[ncEvents] :: NotificationConfig -> [Event]
[ncFilter] :: NotificationConfig -> Filter
type Arn = Text

-- | A data-type for events that can occur in the object storage server.
--   Reference:
--   <a>https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types</a>
data Event
ObjectCreated :: Event
ObjectCreatedPut :: Event
ObjectCreatedPost :: Event
ObjectCreatedCopy :: Event
ObjectCreatedMultipartUpload :: Event
ObjectRemoved :: Event
ObjectRemovedDelete :: Event
ObjectRemovedDeleteMarkerCreated :: Event
ReducedRedundancyLostObject :: Event
data Filter
Filter :: FilterKey -> Filter
[fFilter] :: Filter -> FilterKey
data FilterKey
FilterKey :: FilterRules -> FilterKey
[fkKey] :: FilterKey -> FilterRules
data FilterRules
FilterRules :: [FilterRule] -> FilterRules
[frFilterRules] :: FilterRules -> [FilterRule]

-- | A filter rule that can act based on the suffix or prefix of an object.
--   As an example, let's create two filter rules:
--   
--   <pre>
--   let suffixRule = FilterRule "suffix" ".jpg"
--   let prefixRule = FilterRule "prefix" "images/"
--   </pre>
--   
--   The <tt>suffixRule</tt> restricts the notification to be triggered
--   only for objects having a suffix of ".jpg", and the
--   <tt>prefixRule</tt> restricts it to objects having a prefix of
--   "images/".
data FilterRule
FilterRule :: Text -> Text -> FilterRule
[frName] :: FilterRule -> Text
[frValue] :: FilterRule -> Text

-- | Retrieve the notification configuration on a bucket.
getBucketNotification :: Bucket -> Minio Notification

-- | Set the notification configuration on a bucket.
putBucketNotification :: Bucket -> Notification -> Minio ()

-- | Remove all notifications configured on a bucket.
removeAllBucketNotification :: Bucket -> Minio ()

module Network.Minio

-- | Connection Info data type. To create a <a>ConnectInfo</a> value, use
--   one of the provided smart constructors or override fields of the
--   Default instance.
data ConnectInfo
ConnectInfo :: Text -> Int -> Text -> Text -> Bool -> Region -> Bool -> ConnectInfo
[connectHost] :: ConnectInfo -> Text
[connectPort] :: ConnectInfo -> Int
[connectAccessKey] :: ConnectInfo -> Text
[connectSecretKey] :: ConnectInfo -> Text
[connectIsSecure] :: ConnectInfo -> Bool
[connectRegion] :: ConnectInfo -> Region
[connectAutoDiscoverRegion] :: ConnectInfo -> Bool

-- | Default AWS ConnectInfo. Connects to "us-east-1". Credentials should
--   be supplied before use, for e.g.:
--   
--   <pre>
--   awsCI {
--     connectAccessKey = "my-access-key"
--   , connectSecretKey = "my-secret-key"
--   }
--   </pre>
awsCI :: ConnectInfo

-- | AWS ConnectInfo with a specified region. It can optionally disable the
--   automatic discovery of a bucket's region via the Boolean argument.
--   
--   <pre>
--   awsWithRegionCI "us-west-1" False {
--     connectAccessKey = "my-access-key"
--   , connectSecretKey = "my-secret-key"
--   }
--   </pre>
--   
--   This restricts all operations to the "us-west-1" region and does not
--   perform any bucket location requests.
awsWithRegionCI :: Region -> Bool -> ConnectInfo

-- | <a>Minio Play Server</a> ConnectInfo. Credentials are already filled
--   in.
minioPlayCI :: ConnectInfo

-- | ConnectInfo for Minio server. Takes hostname, port and a Boolean to
--   enable TLS.
--   
--   <pre>
--   minioCI "minio.example.com" 9000 True {
--     connectAccessKey = "my-access-key"
--   , connectSecretKey = "my-secret-key"
--   }
--   </pre>
--   
--   This connects to a Minio server at the given hostname and port over
--   HTTPS.
minioCI :: Text -> Int -> Bool -> ConnectInfo
data Minio a

-- | Run the Minio action and return the result or an error.
runMinio :: ConnectInfo -> Minio a -> IO (Either MinioErr a)

-- | The default value for this type.
def :: Default a => a

-- | Represents a bucket in the object store
type Bucket = Text

-- | Creates a new bucket in the object store. The Region can be optionally
--   specified. If not specified, it will use the region configured in
--   ConnectInfo, which is by default, the US Standard Region.
makeBucket :: Bucket -> Maybe Region -> Minio ()

-- | Removes a bucket from the object store.
removeBucket :: Bucket -> Minio ()

-- | Query the object store if a given bucket is present.
bucketExists :: Bucket -> Minio Bool

-- | Represents a region TODO: This could be a Sum Type with all defined
--   regions for AWS.
type Region = Text

-- | Fetch bucket location (region)
getLocation :: Bucket -> Minio Region

-- | BucketInfo returned for list buckets call
data BucketInfo
BucketInfo :: Bucket -> UTCTime -> BucketInfo
[biName] :: BucketInfo -> Bucket
[biCreationDate] :: BucketInfo -> UTCTime

-- | Lists buckets.
listBuckets :: Minio [BucketInfo]

-- | Represents information about an object.
data ObjectInfo
oiObject :: ObjectInfo -> Object
oiModTime :: ObjectInfo -> UTCTime
oiETag :: ObjectInfo -> ETag
oiSize :: ObjectInfo -> Int64
oiMetadata :: ObjectInfo -> Map Text Text

-- | List objects in a bucket matching the given prefix. If recurse is set
--   to True objects matching prefix are recursively listed.
listObjects :: Bucket -> Maybe Text -> Bool -> ConduitM () ObjectInfo Minio ()

-- | List objects in a bucket matching the given prefix. If recurse is set
--   to True objects matching prefix are recursively listed.
listObjectsV1 :: Bucket -> Maybe Text -> Bool -> ConduitM () ObjectInfo Minio ()

-- | A type alias to represent an upload-id for multipart upload
type UploadId = Text

-- | Represents information about a multipart upload.
data UploadInfo
UploadInfo :: Object -> UploadId -> UTCTime -> Int64 -> UploadInfo
[uiKey] :: UploadInfo -> Object
[uiUploadId] :: UploadInfo -> UploadId
[uiInitTime] :: UploadInfo -> UTCTime
[uiSize] :: UploadInfo -> Int64

-- | List incomplete uploads in a bucket matching the given prefix. If
--   recurse is set to True incomplete uploads for the given prefix are
--   recursively listed.
listIncompleteUploads :: Bucket -> Maybe Text -> Bool -> ConduitM () UploadInfo Minio ()

-- | Represents information about an object part in an ongoing multipart
--   upload.
data ObjectPartInfo
ObjectPartInfo :: PartNumber -> ETag -> Int64 -> UTCTime -> ObjectPartInfo
[opiNumber] :: ObjectPartInfo -> PartNumber
[opiETag] :: ObjectPartInfo -> ETag
[opiSize] :: ObjectPartInfo -> Int64
[opiModTime] :: ObjectPartInfo -> UTCTime

-- | List object parts of an ongoing multipart upload for given bucket,
--   object and uploadId.
listIncompleteParts :: Bucket -> Object -> UploadId -> ConduitM () ObjectPartInfo Minio ()

-- | A data-type to represent bucket notification configuration. It is a
--   collection of queue, topic or lambda function configurations. The
--   structure of the types follow closely the XML representation described
--   at
--   <a>https://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketPUTnotification.html</a>
data Notification
Notification :: [NotificationConfig] -> [NotificationConfig] -> [NotificationConfig] -> Notification
[nQueueConfigurations] :: Notification -> [NotificationConfig]
[nTopicConfigurations] :: Notification -> [NotificationConfig]
[nCloudFunctionConfigurations] :: Notification -> [NotificationConfig]

-- | A data-type representing the configuration for a particular
--   notification system. It could represent a Queue, Topic or Lambda
--   Function configuration.
data NotificationConfig
NotificationConfig :: Text -> Arn -> [Event] -> Filter -> NotificationConfig
[ncId] :: NotificationConfig -> Text
[ncArn] :: NotificationConfig -> Arn
[ncEvents] :: NotificationConfig -> [Event]
[ncFilter] :: NotificationConfig -> Filter
type Arn = Text

-- | A data-type for events that can occur in the object storage server.
--   Reference:
--   <a>https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#supported-notification-event-types</a>
data Event
ObjectCreated :: Event
ObjectCreatedPut :: Event
ObjectCreatedPost :: Event
ObjectCreatedCopy :: Event
ObjectCreatedMultipartUpload :: Event
ObjectRemoved :: Event
ObjectRemovedDelete :: Event
ObjectRemovedDeleteMarkerCreated :: Event
ReducedRedundancyLostObject :: Event
data Filter
Filter :: FilterKey -> Filter
[fFilter] :: Filter -> FilterKey
data FilterKey
FilterKey :: FilterRules -> FilterKey
[fkKey] :: FilterKey -> FilterRules
data FilterRules
FilterRules :: [FilterRule] -> FilterRules
[frFilterRules] :: FilterRules -> [FilterRule]

-- | A filter rule that can act based on the suffix or prefix of an object.
--   As an example, let's create two filter rules:
--   
--   <pre>
--   let suffixRule = FilterRule "suffix" ".jpg"
--   let prefixRule = FilterRule "prefix" "images/"
--   </pre>
--   
--   The <tt>suffixRule</tt> restricts the notification to be triggered
--   only for objects having a suffix of ".jpg", and the
--   <tt>prefixRule</tt> restricts it to objects having a prefix of
--   "images/".
data FilterRule
FilterRule :: Text -> Text -> FilterRule
[frName] :: FilterRule -> Text
[frValue] :: FilterRule -> Text

-- | Retrieve the notification configuration on a bucket.
getBucketNotification :: Bucket -> Minio Notification

-- | Set the notification configuration on a bucket.
putBucketNotification :: Bucket -> Notification -> Minio ()

-- | Remove all notifications configured on a bucket.
removeAllBucketNotification :: Bucket -> Minio ()

-- | Represents an object name
type Object = Text

-- | Fetch the object and write it to the given file safely. The object is
--   first written to a temporary file in the same directory and then moved
--   to the given path.
fGetObject :: Bucket -> Object -> FilePath -> GetObjectOptions -> Minio ()

-- | Upload the given file to the given object.
fPutObject :: Bucket -> Object -> FilePath -> PutObjectOptions -> Minio ()

-- | Put an object from a conduit source. The size can be provided if
--   known; this helps the library select optimal part sizes to perform a
--   multipart upload. If not specified, it is assumed that the object can
--   be potentially 5TiB and selects multipart sizes appropriately.
putObject :: Bucket -> Object -> ConduitM () ByteString Minio () -> Maybe Int64 -> PutObjectOptions -> Minio ()

-- | Data type represents various options specified for PutObject call. To
--   specify PutObject options use the poo* accessors.
data PutObjectOptions
pooContentType :: PutObjectOptions -> Maybe Text
pooContentEncoding :: PutObjectOptions -> Maybe Text
pooContentDisposition :: PutObjectOptions -> Maybe Text
pooContentLanguage :: PutObjectOptions -> Maybe Text
pooCacheControl :: PutObjectOptions -> Maybe Text
pooStorageClass :: PutObjectOptions -> Maybe Text
pooUserMetadata :: PutObjectOptions -> [(Text, Text)]
pooNumThreads :: PutObjectOptions -> Maybe Word

-- | Get an object from the object store as a resumable source (conduit).
getObject :: Bucket -> Object -> GetObjectOptions -> Minio (ConduitM () ByteString Minio ())
data GetObjectOptions

-- | <ul>
--   <li><i>ByteRangeFromTo 0 9</i> means first ten bytes of the source
--   object.</li>
--   </ul>
gooRange :: GetObjectOptions -> Maybe ByteRange
gooIfMatch :: GetObjectOptions -> Maybe ETag
gooIfNoneMatch :: GetObjectOptions -> Maybe ETag
gooIfModifiedSince :: GetObjectOptions -> Maybe UTCTime
gooIfUnmodifiedSince :: GetObjectOptions -> Maybe UTCTime

-- | Perform a server-side copy operation to create an object based on the
--   destination specification in DestinationInfo from the source
--   specification in SourceInfo. This function performs a multipart copy
--   operation if the new object is to be greater than 5GiB in size.
copyObject :: DestinationInfo -> SourceInfo -> Minio ()

-- | Represents source object in server-side copy object
data SourceInfo
srcBucket :: SourceInfo -> Text
srcObject :: SourceInfo -> Text
srcRange :: SourceInfo -> Maybe (Int64, Int64)
srcIfMatch :: SourceInfo -> Maybe Text
srcIfNoneMatch :: SourceInfo -> Maybe Text
srcIfModifiedSince :: SourceInfo -> Maybe UTCTime
srcIfUnmodifiedSince :: SourceInfo -> Maybe UTCTime

-- | Represents destination object in server-side copy object
data DestinationInfo
dstBucket :: DestinationInfo -> Text
dstObject :: DestinationInfo -> Text

-- | Get an object's metadata from the object store.
statObject :: Bucket -> Object -> Minio ObjectInfo

-- | Remove an object from the object store.
removeObject :: Bucket -> Object -> Minio ()

-- | Removes an ongoing multipart upload of an object.
removeIncompleteUpload :: Bucket -> Object -> Minio ()

-- | Time to expire for a presigned URL. It interpreted as a number of
--   seconds. The maximum duration that can be specified is 7 days.
type UrlExpiry = Int

-- | Generate a URL with authentication signature to PUT (upload) an
--   object. Any extra headers if passed, are signed, and so they are
--   required when the URL is used to upload data. This could be used, for
--   example, to set user-metadata on the object.
--   
--   For a list of possible headers to pass, please refer to the PUT object
--   REST API AWS S3 documentation.
presignedPutObjectUrl :: Bucket -> Object -> UrlExpiry -> RequestHeaders -> Minio ByteString

-- | Generate a URL with authentication signature to GET (download) an
--   object. All extra query parameters and headers passed here will be
--   signed and are required when the generated URL is used. Query
--   parameters could be used to change the response headers sent by the
--   server. Headers can be used to set Etag match conditions among others.
--   
--   For a list of possible request parameters and headers, please refer to
--   the GET object REST API AWS S3 documentation.
presignedGetObjectUrl :: Bucket -> Object -> UrlExpiry -> Query -> RequestHeaders -> Minio ByteString

-- | Generate a URL with authentication signature to make a HEAD request on
--   an object. This is used to fetch metadata about an object. All extra
--   headers passed here will be signed and are required when the generated
--   URL is used.
--   
--   For a list of possible headers to pass, please refer to the HEAD
--   object REST API AWS S3 documentation.
presignedHeadObjectUrl :: Bucket -> Object -> UrlExpiry -> RequestHeaders -> Minio ByteString

-- | A PostPolicy is required to perform uploads via browser forms.
data PostPolicy

-- | Possible validation errors when creating a PostPolicy.
data PostPolicyError
PPEKeyNotSpecified :: PostPolicyError
PPEBucketNotSpecified :: PostPolicyError
PPEConditionKeyEmpty :: PostPolicyError
PPERangeInvalid :: PostPolicyError

-- | This function creates a PostPolicy after validating its arguments.
newPostPolicy :: UTCTime -> [PostPolicyCondition] -> Either PostPolicyError PostPolicy

-- | Generate a presigned URL and POST policy to upload files via a
--   browser. On success, this function returns a URL and POST form-data.
presignedPostPolicy :: PostPolicy -> Minio (ByteString, Map Text ByteString)

-- | Convert Post Policy to a string (e.g. for printing).
showPostPolicy :: PostPolicy -> ByteString

-- | Represents individual conditions in a Post Policy document.
data PostPolicyCondition

-- | Set the bucket name that the upload should use.
ppCondBucket :: Bucket -> PostPolicyCondition

-- | Set the content length range constraint with minimum and maximum byte
--   count values.
ppCondContentLengthRange :: Int64 -> Int64 -> PostPolicyCondition

-- | Set the content-type header for the upload.
ppCondContentType :: Text -> PostPolicyCondition

-- | Set the object name constraint for the upload.
ppCondKey :: Object -> PostPolicyCondition

-- | Set the object name prefix constraint for the upload.
ppCondKeyStartsWith :: Object -> PostPolicyCondition

-- | Status code that the S3-server should send on a successful POST upload
ppCondSuccessActionStatus :: Int -> PostPolicyCondition

-- | Errors thrown by the library
data MinioErr
MErrHTTP :: HttpException -> MinioErr
MErrIO :: IOException -> MinioErr
MErrService :: ServiceErr -> MinioErr
MErrValidation :: MErrV -> MinioErr

-- | Various validation errors
data MErrV
MErrVSinglePUTSizeExceeded :: Int64 -> MErrV
MErrVPutSizeExceeded :: Int64 -> MErrV
MErrVETagHeaderNotFound :: MErrV
MErrVInvalidObjectInfoResponse :: MErrV
MErrVInvalidSrcObjSpec :: Text -> MErrV
MErrVInvalidSrcObjByteRange :: (Int64, Int64) -> MErrV
MErrVCopyObjSingleNoRangeAccepted :: MErrV
MErrVRegionNotSupported :: Text -> MErrV
MErrVXmlParse :: Text -> MErrV
MErrVInvalidBucketName :: Text -> MErrV
MErrVInvalidObjectName :: Text -> MErrV
MErrVInvalidUrlExpiry :: Int -> MErrV

-- | Errors returned by S3 compatible service
data ServiceErr
BucketAlreadyExists :: ServiceErr
BucketAlreadyOwnedByYou :: ServiceErr
NoSuchBucket :: ServiceErr
InvalidBucketName :: ServiceErr
NoSuchKey :: ServiceErr
ServiceErr :: Text -> Text -> ServiceErr
