find :: Text -> AWS (Maybe ServerCertificateMetadata)
find dom = do
    say "Searching for Certificate {}" [dom]
    sendCatch (GetServerCertificate dom) >>= verify
  where
    verify (Right x) = return $ Just (unwrap x)
    verify (Left  e)
        | "NoSuchEntity" == etCode (erError e) = return Nothing
        | otherwise = throwError (toError e)

    unwrap = scServerCertificateMetadata
        . gscrServerCertificate
        . gscrGetServerCertificateResult
find :: Text -> AWS (Maybe ServerCertificateMetadata)
find dom = do
    say "Searching for Certificate {}" [dom]
    sendCatch (GetServerCertificate dom) >>= verify
  where
    verify (Right x) = return $ Just (unwrap x)
    verify (Left  e)
        | "NoSuchEntity" == etCode (erError e) = return Nothing
        | otherwise = throwError (toError e)

    unwrap = scServerCertificateMetadata
        . gscrServerCertificate
        . gscrGetServerCertificateResult
find dom = do
    say "Searching for Certificate {}" [dom]
    sendCatch (GetServerCertificate dom) >>= verify
  where
    verify (Right x) = return $ Just (unwrap x)
    verify (Left  e)
        | "NoSuchEntity" == etCode (erError e) = return Nothing
        | otherwise = throwError (toError e)

    unwrap = scServerCertificateMetadata
        . gscrServerCertificate
        . gscrGetServerCertificateResult