goggles-gcs-0.1.1: `goggles` interface to Google Cloud Storage

Safe HaskellNone
LanguageHaskell2010

Network.Goggles.GCS

Description

Dependencies

The examples require the following declarations (which in turn mean that the req and bytestring libraries are imported by the user's project). You will also need the OverloadedStrings language extension :

import qualified Data.ByteString.Lazy as LB
import Network.HTTP.Req (responseBody)
import Network.Goggles

Examples

This first example, listBucket, reads content from a cloud storage bucket:

  1. it loads the GCP credentials (username and RSA key),
  2. retrieves a token via OAuth2,
  3. performs a single call to the Cloud Storage API endpoint that lists the metadata related to the contents of a storage bucket, and
  4. returns the raw API data to the user as a lazy ByteString.
listBucket :: IO LB.ByteString
listBucket = do
  let usr = "...iam.gserviceaccount.com"
      bucket = "<my-gcs-bucket>"
      key = "<rsa_key>"
  pvtkey <- parseRSAPrivateKey key
  let creds = GCPServiceAccount pvtkey usr Nothing ""
  hdl <- createHandle creds scopesDefault
  responseBody <$> evalWebApiIO hdl (listObjects bucket)

Synopsis

Documentation

data GCP Source #

Instances

HasCredentials GCP Source # 

Associated Types

type Credentials GCP :: * #

HasToken GCP Source # 

Associated Types

type TokenContent GCP :: * #

type Options GCP :: * #

Show (Token GCP) Source # 
MonadHttp (WebApiM GCP) Source #

We can provide a custom http exception handler rather than throwing exceptions with this instance

type Credentials GCP Source # 
type Options GCP Source # 
type TokenContent GCP Source # 

scopesDefault :: [Text] Source #

OAuth2 scopes for the various Google Cloud Platform services.

Please refer to

https://developers.google.com/identity/protocols/googlescopes

for the full list

getObject :: Text -> Text -> WebApiM GCP LbsResponse Source #

`getObject b p` retrieves the contents of a GCS object (of full path p) in bucket b

getObjectMetadata :: Text -> Text -> WebApiM GCP LbsResponse Source #

`getObjectMetadata b p` retrieves the metadata of a GCS object (of full path p) in bucket b

listObjects :: Text -> WebApiM GCP LbsResponse Source #

`listObjects b` retrieves a list of objects stored in bucket b

putObject :: Text -> Text -> ByteString -> WebApiM GCP LbsResponse Source #

`putObject b p body` uploads a bytestring body into a GCS object (of full path p) in bucket b