{-# 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.AssociateDRTLogBucket
-- 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)
--
-- Authorizes the Shield Response Team (SRT) to access the specified Amazon
-- S3 bucket containing log data such as Application Load Balancer access
-- logs, CloudFront logs, or logs from third party sources. You can
-- associate up to 10 Amazon S3 buckets with your subscription.
--
-- To use the services of the SRT and make an @AssociateDRTLogBucket@
-- request, you must be subscribed to the
-- <https://aws.amazon.com/premiumsupport/business-support/ Business Support plan>
-- or the
-- <https://aws.amazon.com/premiumsupport/enterprise-support/ Enterprise Support plan>.
module Amazonka.Shield.AssociateDRTLogBucket
  ( -- * Creating a Request
    AssociateDRTLogBucket (..),
    newAssociateDRTLogBucket,

    -- * Request Lenses
    associateDRTLogBucket_logBucket,

    -- * Destructuring the Response
    AssociateDRTLogBucketResponse (..),
    newAssociateDRTLogBucketResponse,

    -- * Response Lenses
    associateDRTLogBucketResponse_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:/ 'newAssociateDRTLogBucket' smart constructor.
data AssociateDRTLogBucket = AssociateDRTLogBucket'
  { -- | The Amazon S3 bucket that contains the logs that you want to share.
    AssociateDRTLogBucket -> Text
logBucket :: Prelude.Text
  }
  deriving (AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool
(AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool)
-> (AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool)
-> Eq AssociateDRTLogBucket
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool
$c/= :: AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool
== :: AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool
$c== :: AssociateDRTLogBucket -> AssociateDRTLogBucket -> Bool
Prelude.Eq, ReadPrec [AssociateDRTLogBucket]
ReadPrec AssociateDRTLogBucket
Int -> ReadS AssociateDRTLogBucket
ReadS [AssociateDRTLogBucket]
(Int -> ReadS AssociateDRTLogBucket)
-> ReadS [AssociateDRTLogBucket]
-> ReadPrec AssociateDRTLogBucket
-> ReadPrec [AssociateDRTLogBucket]
-> Read AssociateDRTLogBucket
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssociateDRTLogBucket]
$creadListPrec :: ReadPrec [AssociateDRTLogBucket]
readPrec :: ReadPrec AssociateDRTLogBucket
$creadPrec :: ReadPrec AssociateDRTLogBucket
readList :: ReadS [AssociateDRTLogBucket]
$creadList :: ReadS [AssociateDRTLogBucket]
readsPrec :: Int -> ReadS AssociateDRTLogBucket
$creadsPrec :: Int -> ReadS AssociateDRTLogBucket
Prelude.Read, Int -> AssociateDRTLogBucket -> ShowS
[AssociateDRTLogBucket] -> ShowS
AssociateDRTLogBucket -> String
(Int -> AssociateDRTLogBucket -> ShowS)
-> (AssociateDRTLogBucket -> String)
-> ([AssociateDRTLogBucket] -> ShowS)
-> Show AssociateDRTLogBucket
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssociateDRTLogBucket] -> ShowS
$cshowList :: [AssociateDRTLogBucket] -> ShowS
show :: AssociateDRTLogBucket -> String
$cshow :: AssociateDRTLogBucket -> String
showsPrec :: Int -> AssociateDRTLogBucket -> ShowS
$cshowsPrec :: Int -> AssociateDRTLogBucket -> ShowS
Prelude.Show, (forall x. AssociateDRTLogBucket -> Rep AssociateDRTLogBucket x)
-> (forall x. Rep AssociateDRTLogBucket x -> AssociateDRTLogBucket)
-> Generic AssociateDRTLogBucket
forall x. Rep AssociateDRTLogBucket x -> AssociateDRTLogBucket
forall x. AssociateDRTLogBucket -> Rep AssociateDRTLogBucket x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssociateDRTLogBucket x -> AssociateDRTLogBucket
$cfrom :: forall x. AssociateDRTLogBucket -> Rep AssociateDRTLogBucket x
Prelude.Generic)

-- |
-- Create a value of 'AssociateDRTLogBucket' 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:
--
-- 'logBucket', 'associateDRTLogBucket_logBucket' - The Amazon S3 bucket that contains the logs that you want to share.
newAssociateDRTLogBucket ::
  -- | 'logBucket'
  Prelude.Text ->
  AssociateDRTLogBucket
newAssociateDRTLogBucket :: Text -> AssociateDRTLogBucket
newAssociateDRTLogBucket Text
pLogBucket_ =
  AssociateDRTLogBucket' :: Text -> AssociateDRTLogBucket
AssociateDRTLogBucket' {$sel:logBucket:AssociateDRTLogBucket' :: Text
logBucket = Text
pLogBucket_}

-- | The Amazon S3 bucket that contains the logs that you want to share.
associateDRTLogBucket_logBucket :: Lens.Lens' AssociateDRTLogBucket Prelude.Text
associateDRTLogBucket_logBucket :: (Text -> f Text)
-> AssociateDRTLogBucket -> f AssociateDRTLogBucket
associateDRTLogBucket_logBucket = (AssociateDRTLogBucket -> Text)
-> (AssociateDRTLogBucket -> Text -> AssociateDRTLogBucket)
-> Lens AssociateDRTLogBucket AssociateDRTLogBucket Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AssociateDRTLogBucket' {Text
logBucket :: Text
$sel:logBucket:AssociateDRTLogBucket' :: AssociateDRTLogBucket -> Text
logBucket} -> Text
logBucket) (\s :: AssociateDRTLogBucket
s@AssociateDRTLogBucket' {} Text
a -> AssociateDRTLogBucket
s {$sel:logBucket:AssociateDRTLogBucket' :: Text
logBucket = Text
a} :: AssociateDRTLogBucket)

instance Core.AWSRequest AssociateDRTLogBucket where
  type
    AWSResponse AssociateDRTLogBucket =
      AssociateDRTLogBucketResponse
  request :: AssociateDRTLogBucket -> Request AssociateDRTLogBucket
request = Service -> AssociateDRTLogBucket -> Request AssociateDRTLogBucket
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AssociateDRTLogBucket
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateDRTLogBucket)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AssociateDRTLogBucket))
-> Logger
-> Service
-> Proxy AssociateDRTLogBucket
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AssociateDRTLogBucket)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> AssociateDRTLogBucketResponse
AssociateDRTLogBucketResponse'
            (Int -> AssociateDRTLogBucketResponse)
-> Either String Int -> Either String AssociateDRTLogBucketResponse
forall (f :: * -> *) a b. Functor 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 AssociateDRTLogBucket

instance Prelude.NFData AssociateDRTLogBucket

instance Core.ToHeaders AssociateDRTLogBucket where
  toHeaders :: AssociateDRTLogBucket -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateDRTLogBucket -> 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.AssociateDRTLogBucket" ::
                          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 AssociateDRTLogBucket where
  toJSON :: AssociateDRTLogBucket -> Value
toJSON AssociateDRTLogBucket' {Text
logBucket :: Text
$sel:logBucket:AssociateDRTLogBucket' :: AssociateDRTLogBucket -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LogBucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logBucket)]
      )

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

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

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

-- |
-- Create a value of 'AssociateDRTLogBucketResponse' 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:
--
-- 'httpStatus', 'associateDRTLogBucketResponse_httpStatus' - The response's http status code.
newAssociateDRTLogBucketResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AssociateDRTLogBucketResponse
newAssociateDRTLogBucketResponse :: Int -> AssociateDRTLogBucketResponse
newAssociateDRTLogBucketResponse Int
pHttpStatus_ =
  AssociateDRTLogBucketResponse' :: Int -> AssociateDRTLogBucketResponse
AssociateDRTLogBucketResponse'
    { $sel:httpStatus:AssociateDRTLogBucketResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData AssociateDRTLogBucketResponse