{-# 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.DescribeAccountAttributes
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of attributes attached to an account
module Amazonka.Redshift.DescribeAccountAttributes
  ( -- * Creating a Request
    DescribeAccountAttributes (..),
    newDescribeAccountAttributes,

    -- * Request Lenses
    describeAccountAttributes_attributeNames,

    -- * Destructuring the Response
    DescribeAccountAttributesResponse (..),
    newDescribeAccountAttributesResponse,

    -- * Response Lenses
    describeAccountAttributesResponse_accountAttributes,
    describeAccountAttributesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDescribeAccountAttributes' smart constructor.
data DescribeAccountAttributes = DescribeAccountAttributes'
  { -- | A list of attribute names.
    DescribeAccountAttributes -> Maybe [Text]
attributeNames :: Prelude.Maybe [Prelude.Text]
  }
  deriving (DescribeAccountAttributes -> DescribeAccountAttributes -> Bool
(DescribeAccountAttributes -> DescribeAccountAttributes -> Bool)
-> (DescribeAccountAttributes -> DescribeAccountAttributes -> Bool)
-> Eq DescribeAccountAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccountAttributes -> DescribeAccountAttributes -> Bool
$c/= :: DescribeAccountAttributes -> DescribeAccountAttributes -> Bool
== :: DescribeAccountAttributes -> DescribeAccountAttributes -> Bool
$c== :: DescribeAccountAttributes -> DescribeAccountAttributes -> Bool
Prelude.Eq, ReadPrec [DescribeAccountAttributes]
ReadPrec DescribeAccountAttributes
Int -> ReadS DescribeAccountAttributes
ReadS [DescribeAccountAttributes]
(Int -> ReadS DescribeAccountAttributes)
-> ReadS [DescribeAccountAttributes]
-> ReadPrec DescribeAccountAttributes
-> ReadPrec [DescribeAccountAttributes]
-> Read DescribeAccountAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccountAttributes]
$creadListPrec :: ReadPrec [DescribeAccountAttributes]
readPrec :: ReadPrec DescribeAccountAttributes
$creadPrec :: ReadPrec DescribeAccountAttributes
readList :: ReadS [DescribeAccountAttributes]
$creadList :: ReadS [DescribeAccountAttributes]
readsPrec :: Int -> ReadS DescribeAccountAttributes
$creadsPrec :: Int -> ReadS DescribeAccountAttributes
Prelude.Read, Int -> DescribeAccountAttributes -> ShowS
[DescribeAccountAttributes] -> ShowS
DescribeAccountAttributes -> String
(Int -> DescribeAccountAttributes -> ShowS)
-> (DescribeAccountAttributes -> String)
-> ([DescribeAccountAttributes] -> ShowS)
-> Show DescribeAccountAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccountAttributes] -> ShowS
$cshowList :: [DescribeAccountAttributes] -> ShowS
show :: DescribeAccountAttributes -> String
$cshow :: DescribeAccountAttributes -> String
showsPrec :: Int -> DescribeAccountAttributes -> ShowS
$cshowsPrec :: Int -> DescribeAccountAttributes -> ShowS
Prelude.Show, (forall x.
 DescribeAccountAttributes -> Rep DescribeAccountAttributes x)
-> (forall x.
    Rep DescribeAccountAttributes x -> DescribeAccountAttributes)
-> Generic DescribeAccountAttributes
forall x.
Rep DescribeAccountAttributes x -> DescribeAccountAttributes
forall x.
DescribeAccountAttributes -> Rep DescribeAccountAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAccountAttributes x -> DescribeAccountAttributes
$cfrom :: forall x.
DescribeAccountAttributes -> Rep DescribeAccountAttributes x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccountAttributes' 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:
--
-- 'attributeNames', 'describeAccountAttributes_attributeNames' - A list of attribute names.
newDescribeAccountAttributes ::
  DescribeAccountAttributes
newDescribeAccountAttributes :: DescribeAccountAttributes
newDescribeAccountAttributes =
  DescribeAccountAttributes' :: Maybe [Text] -> DescribeAccountAttributes
DescribeAccountAttributes'
    { $sel:attributeNames:DescribeAccountAttributes' :: Maybe [Text]
attributeNames =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of attribute names.
describeAccountAttributes_attributeNames :: Lens.Lens' DescribeAccountAttributes (Prelude.Maybe [Prelude.Text])
describeAccountAttributes_attributeNames :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAccountAttributes -> f DescribeAccountAttributes
describeAccountAttributes_attributeNames = (DescribeAccountAttributes -> Maybe [Text])
-> (DescribeAccountAttributes
    -> Maybe [Text] -> DescribeAccountAttributes)
-> Lens
     DescribeAccountAttributes
     DescribeAccountAttributes
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccountAttributes' {Maybe [Text]
attributeNames :: Maybe [Text]
$sel:attributeNames:DescribeAccountAttributes' :: DescribeAccountAttributes -> Maybe [Text]
attributeNames} -> Maybe [Text]
attributeNames) (\s :: DescribeAccountAttributes
s@DescribeAccountAttributes' {} Maybe [Text]
a -> DescribeAccountAttributes
s {$sel:attributeNames:DescribeAccountAttributes' :: Maybe [Text]
attributeNames = Maybe [Text]
a} :: DescribeAccountAttributes) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeAccountAttributes -> f DescribeAccountAttributes)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeAccountAttributes
-> f DescribeAccountAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable DescribeAccountAttributes

instance Prelude.NFData DescribeAccountAttributes

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

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

instance Core.ToQuery DescribeAccountAttributes where
  toQuery :: DescribeAccountAttributes -> QueryString
toQuery DescribeAccountAttributes' {Maybe [Text]
attributeNames :: Maybe [Text]
$sel:attributeNames:DescribeAccountAttributes' :: DescribeAccountAttributes -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeAccountAttributes" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"AttributeNames"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"AttributeName"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
attributeNames
            )
      ]

-- | /See:/ 'newDescribeAccountAttributesResponse' smart constructor.
data DescribeAccountAttributesResponse = DescribeAccountAttributesResponse'
  { -- | A list of attributes assigned to an account.
    DescribeAccountAttributesResponse -> Maybe [AccountAttribute]
accountAttributes :: Prelude.Maybe [AccountAttribute],
    -- | The response's http status code.
    DescribeAccountAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAccountAttributesResponse
-> DescribeAccountAttributesResponse -> Bool
(DescribeAccountAttributesResponse
 -> DescribeAccountAttributesResponse -> Bool)
-> (DescribeAccountAttributesResponse
    -> DescribeAccountAttributesResponse -> Bool)
-> Eq DescribeAccountAttributesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccountAttributesResponse
-> DescribeAccountAttributesResponse -> Bool
$c/= :: DescribeAccountAttributesResponse
-> DescribeAccountAttributesResponse -> Bool
== :: DescribeAccountAttributesResponse
-> DescribeAccountAttributesResponse -> Bool
$c== :: DescribeAccountAttributesResponse
-> DescribeAccountAttributesResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAccountAttributesResponse]
ReadPrec DescribeAccountAttributesResponse
Int -> ReadS DescribeAccountAttributesResponse
ReadS [DescribeAccountAttributesResponse]
(Int -> ReadS DescribeAccountAttributesResponse)
-> ReadS [DescribeAccountAttributesResponse]
-> ReadPrec DescribeAccountAttributesResponse
-> ReadPrec [DescribeAccountAttributesResponse]
-> Read DescribeAccountAttributesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccountAttributesResponse]
$creadListPrec :: ReadPrec [DescribeAccountAttributesResponse]
readPrec :: ReadPrec DescribeAccountAttributesResponse
$creadPrec :: ReadPrec DescribeAccountAttributesResponse
readList :: ReadS [DescribeAccountAttributesResponse]
$creadList :: ReadS [DescribeAccountAttributesResponse]
readsPrec :: Int -> ReadS DescribeAccountAttributesResponse
$creadsPrec :: Int -> ReadS DescribeAccountAttributesResponse
Prelude.Read, Int -> DescribeAccountAttributesResponse -> ShowS
[DescribeAccountAttributesResponse] -> ShowS
DescribeAccountAttributesResponse -> String
(Int -> DescribeAccountAttributesResponse -> ShowS)
-> (DescribeAccountAttributesResponse -> String)
-> ([DescribeAccountAttributesResponse] -> ShowS)
-> Show DescribeAccountAttributesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccountAttributesResponse] -> ShowS
$cshowList :: [DescribeAccountAttributesResponse] -> ShowS
show :: DescribeAccountAttributesResponse -> String
$cshow :: DescribeAccountAttributesResponse -> String
showsPrec :: Int -> DescribeAccountAttributesResponse -> ShowS
$cshowsPrec :: Int -> DescribeAccountAttributesResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAccountAttributesResponse
 -> Rep DescribeAccountAttributesResponse x)
-> (forall x.
    Rep DescribeAccountAttributesResponse x
    -> DescribeAccountAttributesResponse)
-> Generic DescribeAccountAttributesResponse
forall x.
Rep DescribeAccountAttributesResponse x
-> DescribeAccountAttributesResponse
forall x.
DescribeAccountAttributesResponse
-> Rep DescribeAccountAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeAccountAttributesResponse x
-> DescribeAccountAttributesResponse
$cfrom :: forall x.
DescribeAccountAttributesResponse
-> Rep DescribeAccountAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccountAttributesResponse' 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:
--
-- 'accountAttributes', 'describeAccountAttributesResponse_accountAttributes' - A list of attributes assigned to an account.
--
-- 'httpStatus', 'describeAccountAttributesResponse_httpStatus' - The response's http status code.
newDescribeAccountAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAccountAttributesResponse
newDescribeAccountAttributesResponse :: Int -> DescribeAccountAttributesResponse
newDescribeAccountAttributesResponse Int
pHttpStatus_ =
  DescribeAccountAttributesResponse' :: Maybe [AccountAttribute]
-> Int -> DescribeAccountAttributesResponse
DescribeAccountAttributesResponse'
    { $sel:accountAttributes:DescribeAccountAttributesResponse' :: Maybe [AccountAttribute]
accountAttributes =
        Maybe [AccountAttribute]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAccountAttributesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of attributes assigned to an account.
describeAccountAttributesResponse_accountAttributes :: Lens.Lens' DescribeAccountAttributesResponse (Prelude.Maybe [AccountAttribute])
describeAccountAttributesResponse_accountAttributes :: (Maybe [AccountAttribute] -> f (Maybe [AccountAttribute]))
-> DescribeAccountAttributesResponse
-> f DescribeAccountAttributesResponse
describeAccountAttributesResponse_accountAttributes = (DescribeAccountAttributesResponse -> Maybe [AccountAttribute])
-> (DescribeAccountAttributesResponse
    -> Maybe [AccountAttribute] -> DescribeAccountAttributesResponse)
-> Lens
     DescribeAccountAttributesResponse
     DescribeAccountAttributesResponse
     (Maybe [AccountAttribute])
     (Maybe [AccountAttribute])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccountAttributesResponse' {Maybe [AccountAttribute]
accountAttributes :: Maybe [AccountAttribute]
$sel:accountAttributes:DescribeAccountAttributesResponse' :: DescribeAccountAttributesResponse -> Maybe [AccountAttribute]
accountAttributes} -> Maybe [AccountAttribute]
accountAttributes) (\s :: DescribeAccountAttributesResponse
s@DescribeAccountAttributesResponse' {} Maybe [AccountAttribute]
a -> DescribeAccountAttributesResponse
s {$sel:accountAttributes:DescribeAccountAttributesResponse' :: Maybe [AccountAttribute]
accountAttributes = Maybe [AccountAttribute]
a} :: DescribeAccountAttributesResponse) ((Maybe [AccountAttribute] -> f (Maybe [AccountAttribute]))
 -> DescribeAccountAttributesResponse
 -> f DescribeAccountAttributesResponse)
-> ((Maybe [AccountAttribute] -> f (Maybe [AccountAttribute]))
    -> Maybe [AccountAttribute] -> f (Maybe [AccountAttribute]))
-> (Maybe [AccountAttribute] -> f (Maybe [AccountAttribute]))
-> DescribeAccountAttributesResponse
-> f DescribeAccountAttributesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AccountAttribute]
  [AccountAttribute]
  [AccountAttribute]
  [AccountAttribute]
-> Iso
     (Maybe [AccountAttribute])
     (Maybe [AccountAttribute])
     (Maybe [AccountAttribute])
     (Maybe [AccountAttribute])
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 AnIso
  [AccountAttribute]
  [AccountAttribute]
  [AccountAttribute]
  [AccountAttribute]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeAccountAttributesResponse