{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Redshift.DescribeAuthenticationProfiles
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes an authentication profile.
module Amazonka.Redshift.DescribeAuthenticationProfiles
  ( -- * Creating a Request
    DescribeAuthenticationProfiles (..),
    newDescribeAuthenticationProfiles,

    -- * Request Lenses
    describeAuthenticationProfiles_authenticationProfileName,

    -- * Destructuring the Response
    DescribeAuthenticationProfilesResponse (..),
    newDescribeAuthenticationProfilesResponse,

    -- * Response Lenses
    describeAuthenticationProfilesResponse_authenticationProfiles,
    describeAuthenticationProfilesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAuthenticationProfiles' smart constructor.
data DescribeAuthenticationProfiles = DescribeAuthenticationProfiles'
  { -- | The name of the authentication profile to describe. If not specified
    -- then all authentication profiles owned by the account are listed.
    DescribeAuthenticationProfiles -> Maybe Text
authenticationProfileName :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeAuthenticationProfiles
-> DescribeAuthenticationProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAuthenticationProfiles
-> DescribeAuthenticationProfiles -> Bool
$c/= :: DescribeAuthenticationProfiles
-> DescribeAuthenticationProfiles -> Bool
== :: DescribeAuthenticationProfiles
-> DescribeAuthenticationProfiles -> Bool
$c== :: DescribeAuthenticationProfiles
-> DescribeAuthenticationProfiles -> Bool
Prelude.Eq, ReadPrec [DescribeAuthenticationProfiles]
ReadPrec DescribeAuthenticationProfiles
Int -> ReadS DescribeAuthenticationProfiles
ReadS [DescribeAuthenticationProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAuthenticationProfiles]
$creadListPrec :: ReadPrec [DescribeAuthenticationProfiles]
readPrec :: ReadPrec DescribeAuthenticationProfiles
$creadPrec :: ReadPrec DescribeAuthenticationProfiles
readList :: ReadS [DescribeAuthenticationProfiles]
$creadList :: ReadS [DescribeAuthenticationProfiles]
readsPrec :: Int -> ReadS DescribeAuthenticationProfiles
$creadsPrec :: Int -> ReadS DescribeAuthenticationProfiles
Prelude.Read, Int -> DescribeAuthenticationProfiles -> ShowS
[DescribeAuthenticationProfiles] -> ShowS
DescribeAuthenticationProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAuthenticationProfiles] -> ShowS
$cshowList :: [DescribeAuthenticationProfiles] -> ShowS
show :: DescribeAuthenticationProfiles -> String
$cshow :: DescribeAuthenticationProfiles -> String
showsPrec :: Int -> DescribeAuthenticationProfiles -> ShowS
$cshowsPrec :: Int -> DescribeAuthenticationProfiles -> ShowS
Prelude.Show, forall x.
Rep DescribeAuthenticationProfiles x
-> DescribeAuthenticationProfiles
forall x.
DescribeAuthenticationProfiles
-> Rep DescribeAuthenticationProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAuthenticationProfiles x
-> DescribeAuthenticationProfiles
$cfrom :: forall x.
DescribeAuthenticationProfiles
-> Rep DescribeAuthenticationProfiles x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAuthenticationProfiles' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'authenticationProfileName', 'describeAuthenticationProfiles_authenticationProfileName' - The name of the authentication profile to describe. If not specified
-- then all authentication profiles owned by the account are listed.
newDescribeAuthenticationProfiles ::
  DescribeAuthenticationProfiles
newDescribeAuthenticationProfiles :: DescribeAuthenticationProfiles
newDescribeAuthenticationProfiles =
  DescribeAuthenticationProfiles'
    { $sel:authenticationProfileName:DescribeAuthenticationProfiles' :: Maybe Text
authenticationProfileName =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the authentication profile to describe. If not specified
-- then all authentication profiles owned by the account are listed.
describeAuthenticationProfiles_authenticationProfileName :: Lens.Lens' DescribeAuthenticationProfiles (Prelude.Maybe Prelude.Text)
describeAuthenticationProfiles_authenticationProfileName :: Lens' DescribeAuthenticationProfiles (Maybe Text)
describeAuthenticationProfiles_authenticationProfileName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuthenticationProfiles' {Maybe Text
authenticationProfileName :: Maybe Text
$sel:authenticationProfileName:DescribeAuthenticationProfiles' :: DescribeAuthenticationProfiles -> Maybe Text
authenticationProfileName} -> Maybe Text
authenticationProfileName) (\s :: DescribeAuthenticationProfiles
s@DescribeAuthenticationProfiles' {} Maybe Text
a -> DescribeAuthenticationProfiles
s {$sel:authenticationProfileName:DescribeAuthenticationProfiles' :: Maybe Text
authenticationProfileName = Maybe Text
a} :: DescribeAuthenticationProfiles)

instance
  Core.AWSRequest
    DescribeAuthenticationProfiles
  where
  type
    AWSResponse DescribeAuthenticationProfiles =
      DescribeAuthenticationProfilesResponse
  request :: (Service -> Service)
-> DescribeAuthenticationProfiles
-> Request DescribeAuthenticationProfiles
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAuthenticationProfiles
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeAuthenticationProfiles)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeAuthenticationProfilesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [AuthenticationProfile]
-> Int -> DescribeAuthenticationProfilesResponse
DescribeAuthenticationProfilesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x
                            forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"AuthenticationProfiles"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                            forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"member")
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    DescribeAuthenticationProfiles
  where
  hashWithSalt :: Int -> DescribeAuthenticationProfiles -> Int
hashWithSalt
    Int
_salt
    DescribeAuthenticationProfiles' {Maybe Text
authenticationProfileName :: Maybe Text
$sel:authenticationProfileName:DescribeAuthenticationProfiles' :: DescribeAuthenticationProfiles -> Maybe Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
authenticationProfileName

instance
  Prelude.NFData
    DescribeAuthenticationProfiles
  where
  rnf :: DescribeAuthenticationProfiles -> ()
rnf DescribeAuthenticationProfiles' {Maybe Text
authenticationProfileName :: Maybe Text
$sel:authenticationProfileName:DescribeAuthenticationProfiles' :: DescribeAuthenticationProfiles -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
authenticationProfileName

instance
  Data.ToHeaders
    DescribeAuthenticationProfiles
  where
  toHeaders :: DescribeAuthenticationProfiles -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath DescribeAuthenticationProfiles where
  toPath :: DescribeAuthenticationProfiles -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DescribeAuthenticationProfiles where
  toQuery :: DescribeAuthenticationProfiles -> QueryString
toQuery DescribeAuthenticationProfiles' {Maybe Text
authenticationProfileName :: Maybe Text
$sel:authenticationProfileName:DescribeAuthenticationProfiles' :: DescribeAuthenticationProfiles -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"DescribeAuthenticationProfiles" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"AuthenticationProfileName"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
authenticationProfileName
      ]

-- | /See:/ 'newDescribeAuthenticationProfilesResponse' smart constructor.
data DescribeAuthenticationProfilesResponse = DescribeAuthenticationProfilesResponse'
  { -- | The list of authentication profiles.
    DescribeAuthenticationProfilesResponse
-> Maybe [AuthenticationProfile]
authenticationProfiles :: Prelude.Maybe [AuthenticationProfile],
    -- | The response's http status code.
    DescribeAuthenticationProfilesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAuthenticationProfilesResponse
-> DescribeAuthenticationProfilesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAuthenticationProfilesResponse
-> DescribeAuthenticationProfilesResponse -> Bool
$c/= :: DescribeAuthenticationProfilesResponse
-> DescribeAuthenticationProfilesResponse -> Bool
== :: DescribeAuthenticationProfilesResponse
-> DescribeAuthenticationProfilesResponse -> Bool
$c== :: DescribeAuthenticationProfilesResponse
-> DescribeAuthenticationProfilesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAuthenticationProfilesResponse]
ReadPrec DescribeAuthenticationProfilesResponse
Int -> ReadS DescribeAuthenticationProfilesResponse
ReadS [DescribeAuthenticationProfilesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAuthenticationProfilesResponse]
$creadListPrec :: ReadPrec [DescribeAuthenticationProfilesResponse]
readPrec :: ReadPrec DescribeAuthenticationProfilesResponse
$creadPrec :: ReadPrec DescribeAuthenticationProfilesResponse
readList :: ReadS [DescribeAuthenticationProfilesResponse]
$creadList :: ReadS [DescribeAuthenticationProfilesResponse]
readsPrec :: Int -> ReadS DescribeAuthenticationProfilesResponse
$creadsPrec :: Int -> ReadS DescribeAuthenticationProfilesResponse
Prelude.Read, Int -> DescribeAuthenticationProfilesResponse -> ShowS
[DescribeAuthenticationProfilesResponse] -> ShowS
DescribeAuthenticationProfilesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAuthenticationProfilesResponse] -> ShowS
$cshowList :: [DescribeAuthenticationProfilesResponse] -> ShowS
show :: DescribeAuthenticationProfilesResponse -> String
$cshow :: DescribeAuthenticationProfilesResponse -> String
showsPrec :: Int -> DescribeAuthenticationProfilesResponse -> ShowS
$cshowsPrec :: Int -> DescribeAuthenticationProfilesResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeAuthenticationProfilesResponse x
-> DescribeAuthenticationProfilesResponse
forall x.
DescribeAuthenticationProfilesResponse
-> Rep DescribeAuthenticationProfilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAuthenticationProfilesResponse x
-> DescribeAuthenticationProfilesResponse
$cfrom :: forall x.
DescribeAuthenticationProfilesResponse
-> Rep DescribeAuthenticationProfilesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAuthenticationProfilesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'authenticationProfiles', 'describeAuthenticationProfilesResponse_authenticationProfiles' - The list of authentication profiles.
--
-- 'httpStatus', 'describeAuthenticationProfilesResponse_httpStatus' - The response's http status code.
newDescribeAuthenticationProfilesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAuthenticationProfilesResponse
newDescribeAuthenticationProfilesResponse :: Int -> DescribeAuthenticationProfilesResponse
newDescribeAuthenticationProfilesResponse
  Int
pHttpStatus_ =
    DescribeAuthenticationProfilesResponse'
      { $sel:authenticationProfiles:DescribeAuthenticationProfilesResponse' :: Maybe [AuthenticationProfile]
authenticationProfiles =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DescribeAuthenticationProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The list of authentication profiles.
describeAuthenticationProfilesResponse_authenticationProfiles :: Lens.Lens' DescribeAuthenticationProfilesResponse (Prelude.Maybe [AuthenticationProfile])
describeAuthenticationProfilesResponse_authenticationProfiles :: Lens'
  DescribeAuthenticationProfilesResponse
  (Maybe [AuthenticationProfile])
describeAuthenticationProfilesResponse_authenticationProfiles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuthenticationProfilesResponse' {Maybe [AuthenticationProfile]
authenticationProfiles :: Maybe [AuthenticationProfile]
$sel:authenticationProfiles:DescribeAuthenticationProfilesResponse' :: DescribeAuthenticationProfilesResponse
-> Maybe [AuthenticationProfile]
authenticationProfiles} -> Maybe [AuthenticationProfile]
authenticationProfiles) (\s :: DescribeAuthenticationProfilesResponse
s@DescribeAuthenticationProfilesResponse' {} Maybe [AuthenticationProfile]
a -> DescribeAuthenticationProfilesResponse
s {$sel:authenticationProfiles:DescribeAuthenticationProfilesResponse' :: Maybe [AuthenticationProfile]
authenticationProfiles = Maybe [AuthenticationProfile]
a} :: DescribeAuthenticationProfilesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeAuthenticationProfilesResponse_httpStatus :: Lens.Lens' DescribeAuthenticationProfilesResponse Prelude.Int
describeAuthenticationProfilesResponse_httpStatus :: Lens' DescribeAuthenticationProfilesResponse Int
describeAuthenticationProfilesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAuthenticationProfilesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeAuthenticationProfilesResponse' :: DescribeAuthenticationProfilesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeAuthenticationProfilesResponse
s@DescribeAuthenticationProfilesResponse' {} Int
a -> DescribeAuthenticationProfilesResponse
s {$sel:httpStatus:DescribeAuthenticationProfilesResponse' :: Int
httpStatus = Int
a} :: DescribeAuthenticationProfilesResponse)

instance
  Prelude.NFData
    DescribeAuthenticationProfilesResponse
  where
  rnf :: DescribeAuthenticationProfilesResponse -> ()
rnf DescribeAuthenticationProfilesResponse' {Int
Maybe [AuthenticationProfile]
httpStatus :: Int
authenticationProfiles :: Maybe [AuthenticationProfile]
$sel:httpStatus:DescribeAuthenticationProfilesResponse' :: DescribeAuthenticationProfilesResponse -> Int
$sel:authenticationProfiles:DescribeAuthenticationProfilesResponse' :: DescribeAuthenticationProfilesResponse
-> Maybe [AuthenticationProfile]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AuthenticationProfile]
authenticationProfiles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus