{-# 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.Shield.DescribeDRTAccess
-- 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 the current role and list of Amazon S3 log buckets used by the
-- Shield Response Team (SRT) to access your Amazon Web Services account
-- while assisting with attack mitigation.
module Amazonka.Shield.DescribeDRTAccess
  ( -- * Creating a Request
    DescribeDRTAccess (..),
    newDescribeDRTAccess,

    -- * Destructuring the Response
    DescribeDRTAccessResponse (..),
    newDescribeDRTAccessResponse,

    -- * Response Lenses
    describeDRTAccessResponse_logBucketList,
    describeDRTAccessResponse_roleArn,
    describeDRTAccessResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DescribeDRTAccess' 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.
newDescribeDRTAccess ::
  DescribeDRTAccess
newDescribeDRTAccess :: DescribeDRTAccess
newDescribeDRTAccess = DescribeDRTAccess
DescribeDRTAccess'

instance Core.AWSRequest DescribeDRTAccess where
  type
    AWSResponse DescribeDRTAccess =
      DescribeDRTAccessResponse
  request :: DescribeDRTAccess -> Request DescribeDRTAccess
request = Service -> DescribeDRTAccess -> Request DescribeDRTAccess
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeDRTAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeDRTAccess)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeDRTAccess))
-> Logger
-> Service
-> Proxy DescribeDRTAccess
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeDRTAccess)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Text] -> Maybe Text -> Int -> DescribeDRTAccessResponse
DescribeDRTAccessResponse'
            (Maybe [Text] -> Maybe Text -> Int -> DescribeDRTAccessResponse)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> Int -> DescribeDRTAccessResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LogBucketList" Either String (Maybe (Maybe [Text]))
-> Maybe [Text] -> Either String (Maybe [Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Maybe Text -> Int -> DescribeDRTAccessResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeDRTAccessResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RoleArn")
            Either String (Int -> DescribeDRTAccessResponse)
-> Either String Int -> Either String DescribeDRTAccessResponse
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 DescribeDRTAccess

instance Prelude.NFData DescribeDRTAccess

instance Core.ToHeaders DescribeDRTAccess where
  toHeaders :: DescribeDRTAccess -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeDRTAccess -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSShield_20160616.DescribeDRTAccess" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeDRTAccess where
  toJSON :: DescribeDRTAccess -> Value
toJSON = Value -> DescribeDRTAccess -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

instance Core.ToQuery DescribeDRTAccess where
  toQuery :: DescribeDRTAccess -> QueryString
toQuery = QueryString -> DescribeDRTAccess -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeDRTAccessResponse' smart constructor.
data DescribeDRTAccessResponse = DescribeDRTAccessResponse'
  { -- | The list of Amazon S3 buckets accessed by the SRT.
    DescribeDRTAccessResponse -> Maybe [Text]
logBucketList :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the role the SRT used to access your
    -- Amazon Web Services account.
    DescribeDRTAccessResponse -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeDRTAccessResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool
(DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool)
-> (DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool)
-> Eq DescribeDRTAccessResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool
$c/= :: DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool
== :: DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool
$c== :: DescribeDRTAccessResponse -> DescribeDRTAccessResponse -> Bool
Prelude.Eq, ReadPrec [DescribeDRTAccessResponse]
ReadPrec DescribeDRTAccessResponse
Int -> ReadS DescribeDRTAccessResponse
ReadS [DescribeDRTAccessResponse]
(Int -> ReadS DescribeDRTAccessResponse)
-> ReadS [DescribeDRTAccessResponse]
-> ReadPrec DescribeDRTAccessResponse
-> ReadPrec [DescribeDRTAccessResponse]
-> Read DescribeDRTAccessResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeDRTAccessResponse]
$creadListPrec :: ReadPrec [DescribeDRTAccessResponse]
readPrec :: ReadPrec DescribeDRTAccessResponse
$creadPrec :: ReadPrec DescribeDRTAccessResponse
readList :: ReadS [DescribeDRTAccessResponse]
$creadList :: ReadS [DescribeDRTAccessResponse]
readsPrec :: Int -> ReadS DescribeDRTAccessResponse
$creadsPrec :: Int -> ReadS DescribeDRTAccessResponse
Prelude.Read, Int -> DescribeDRTAccessResponse -> ShowS
[DescribeDRTAccessResponse] -> ShowS
DescribeDRTAccessResponse -> String
(Int -> DescribeDRTAccessResponse -> ShowS)
-> (DescribeDRTAccessResponse -> String)
-> ([DescribeDRTAccessResponse] -> ShowS)
-> Show DescribeDRTAccessResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeDRTAccessResponse] -> ShowS
$cshowList :: [DescribeDRTAccessResponse] -> ShowS
show :: DescribeDRTAccessResponse -> String
$cshow :: DescribeDRTAccessResponse -> String
showsPrec :: Int -> DescribeDRTAccessResponse -> ShowS
$cshowsPrec :: Int -> DescribeDRTAccessResponse -> ShowS
Prelude.Show, (forall x.
 DescribeDRTAccessResponse -> Rep DescribeDRTAccessResponse x)
-> (forall x.
    Rep DescribeDRTAccessResponse x -> DescribeDRTAccessResponse)
-> Generic DescribeDRTAccessResponse
forall x.
Rep DescribeDRTAccessResponse x -> DescribeDRTAccessResponse
forall x.
DescribeDRTAccessResponse -> Rep DescribeDRTAccessResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeDRTAccessResponse x -> DescribeDRTAccessResponse
$cfrom :: forall x.
DescribeDRTAccessResponse -> Rep DescribeDRTAccessResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeDRTAccessResponse' 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:
--
-- 'logBucketList', 'describeDRTAccessResponse_logBucketList' - The list of Amazon S3 buckets accessed by the SRT.
--
-- 'roleArn', 'describeDRTAccessResponse_roleArn' - The Amazon Resource Name (ARN) of the role the SRT used to access your
-- Amazon Web Services account.
--
-- 'httpStatus', 'describeDRTAccessResponse_httpStatus' - The response's http status code.
newDescribeDRTAccessResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeDRTAccessResponse
newDescribeDRTAccessResponse :: Int -> DescribeDRTAccessResponse
newDescribeDRTAccessResponse Int
pHttpStatus_ =
  DescribeDRTAccessResponse' :: Maybe [Text] -> Maybe Text -> Int -> DescribeDRTAccessResponse
DescribeDRTAccessResponse'
    { $sel:logBucketList:DescribeDRTAccessResponse' :: Maybe [Text]
logBucketList =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:DescribeDRTAccessResponse' :: Maybe Text
roleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeDRTAccessResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of Amazon S3 buckets accessed by the SRT.
describeDRTAccessResponse_logBucketList :: Lens.Lens' DescribeDRTAccessResponse (Prelude.Maybe [Prelude.Text])
describeDRTAccessResponse_logBucketList :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeDRTAccessResponse -> f DescribeDRTAccessResponse
describeDRTAccessResponse_logBucketList = (DescribeDRTAccessResponse -> Maybe [Text])
-> (DescribeDRTAccessResponse
    -> Maybe [Text] -> DescribeDRTAccessResponse)
-> Lens
     DescribeDRTAccessResponse
     DescribeDRTAccessResponse
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDRTAccessResponse' {Maybe [Text]
logBucketList :: Maybe [Text]
$sel:logBucketList:DescribeDRTAccessResponse' :: DescribeDRTAccessResponse -> Maybe [Text]
logBucketList} -> Maybe [Text]
logBucketList) (\s :: DescribeDRTAccessResponse
s@DescribeDRTAccessResponse' {} Maybe [Text]
a -> DescribeDRTAccessResponse
s {$sel:logBucketList:DescribeDRTAccessResponse' :: Maybe [Text]
logBucketList = Maybe [Text]
a} :: DescribeDRTAccessResponse) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeDRTAccessResponse -> f DescribeDRTAccessResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeDRTAccessResponse
-> f DescribeDRTAccessResponse
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

-- | The Amazon Resource Name (ARN) of the role the SRT used to access your
-- Amazon Web Services account.
describeDRTAccessResponse_roleArn :: Lens.Lens' DescribeDRTAccessResponse (Prelude.Maybe Prelude.Text)
describeDRTAccessResponse_roleArn :: (Maybe Text -> f (Maybe Text))
-> DescribeDRTAccessResponse -> f DescribeDRTAccessResponse
describeDRTAccessResponse_roleArn = (DescribeDRTAccessResponse -> Maybe Text)
-> (DescribeDRTAccessResponse
    -> Maybe Text -> DescribeDRTAccessResponse)
-> Lens
     DescribeDRTAccessResponse
     DescribeDRTAccessResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeDRTAccessResponse' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:DescribeDRTAccessResponse' :: DescribeDRTAccessResponse -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: DescribeDRTAccessResponse
s@DescribeDRTAccessResponse' {} Maybe Text
a -> DescribeDRTAccessResponse
s {$sel:roleArn:DescribeDRTAccessResponse' :: Maybe Text
roleArn = Maybe Text
a} :: DescribeDRTAccessResponse)

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

instance Prelude.NFData DescribeDRTAccessResponse