git.iko.soy/typeable/minio-hs
on master help sign in
47 lines 1.6 kB history raw
1--
2-- MinIO Haskell SDK, (C) 2023 MinIO, Inc.
3--
4-- Licensed under the Apache License, Version 2.0 (the "License");
5-- you may not use this file except in compliance with the License.
6-- You may obtain a copy of the License at
7--
8-- http://www.apache.org/licenses/LICENSE-2.0
9--
10-- Unless required by applicable law or agreed to in writing, software
11-- distributed under the License is distributed on an "AS IS" BASIS,
12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-- See the License for the specific language governing permissions and
14-- limitations under the License.
15--
16{-# LANGUAGE OverloadedStrings #-}
18import Control.Monad.IO.Class (liftIO)
19import Network.Minio
20import Prelude
22main :: IO ()
23main = do
24 -- Use play credentials for example.
25 let assumeRole =
26 STSAssumeRole
27 ( CredentialValue
28 "Q3AM3UQ867SPQQA43P2F"
29 "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
30 Nothing
31 )
32 $ defaultSTSAssumeRoleOptions
33 { saroLocation = Just "us-east-1",
34 saroEndpoint = Just "https://play.min.io:9000"
35 }
37 -- Retrieve temporary credentials and print them.
38 cv <- requestSTSCredential assumeRole
39 print $ "Temporary credentials" ++ show (credentialValueText $ fst cv)
40 print $ "Expiry" ++ show (snd cv)
42 -- Configure 'ConnectInfo' to request temporary credentials on demand.
43 ci <- setSTSCredential assumeRole "https://play.min.io"
44 res <- runMinio ci $ do
45 buckets <- listBuckets
46 liftIO $ print $ "Top 5 buckets: " ++ show (take 5 buckets)
47 print res