{-# 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.MediaStore.StartAccessLogging
-- 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)
--
-- Starts access logging on the specified container. When you enable access
-- logging on a container, MediaStore delivers access logs for objects
-- stored in that container to Amazon CloudWatch Logs.
module Amazonka.MediaStore.StartAccessLogging
  ( -- * Creating a Request
    StartAccessLogging (..),
    newStartAccessLogging,

    -- * Request Lenses
    startAccessLogging_containerName,

    -- * Destructuring the Response
    StartAccessLoggingResponse (..),
    newStartAccessLoggingResponse,

    -- * Response Lenses
    startAccessLoggingResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStartAccessLogging' smart constructor.
data StartAccessLogging = StartAccessLogging'
  { -- | The name of the container that you want to start access logging on.
    StartAccessLogging -> Text
containerName :: Prelude.Text
  }
  deriving (StartAccessLogging -> StartAccessLogging -> Bool
(StartAccessLogging -> StartAccessLogging -> Bool)
-> (StartAccessLogging -> StartAccessLogging -> Bool)
-> Eq StartAccessLogging
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartAccessLogging -> StartAccessLogging -> Bool
$c/= :: StartAccessLogging -> StartAccessLogging -> Bool
== :: StartAccessLogging -> StartAccessLogging -> Bool
$c== :: StartAccessLogging -> StartAccessLogging -> Bool
Prelude.Eq, ReadPrec [StartAccessLogging]
ReadPrec StartAccessLogging
Int -> ReadS StartAccessLogging
ReadS [StartAccessLogging]
(Int -> ReadS StartAccessLogging)
-> ReadS [StartAccessLogging]
-> ReadPrec StartAccessLogging
-> ReadPrec [StartAccessLogging]
-> Read StartAccessLogging
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartAccessLogging]
$creadListPrec :: ReadPrec [StartAccessLogging]
readPrec :: ReadPrec StartAccessLogging
$creadPrec :: ReadPrec StartAccessLogging
readList :: ReadS [StartAccessLogging]
$creadList :: ReadS [StartAccessLogging]
readsPrec :: Int -> ReadS StartAccessLogging
$creadsPrec :: Int -> ReadS StartAccessLogging
Prelude.Read, Int -> StartAccessLogging -> ShowS
[StartAccessLogging] -> ShowS
StartAccessLogging -> String
(Int -> StartAccessLogging -> ShowS)
-> (StartAccessLogging -> String)
-> ([StartAccessLogging] -> ShowS)
-> Show StartAccessLogging
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartAccessLogging] -> ShowS
$cshowList :: [StartAccessLogging] -> ShowS
show :: StartAccessLogging -> String
$cshow :: StartAccessLogging -> String
showsPrec :: Int -> StartAccessLogging -> ShowS
$cshowsPrec :: Int -> StartAccessLogging -> ShowS
Prelude.Show, (forall x. StartAccessLogging -> Rep StartAccessLogging x)
-> (forall x. Rep StartAccessLogging x -> StartAccessLogging)
-> Generic StartAccessLogging
forall x. Rep StartAccessLogging x -> StartAccessLogging
forall x. StartAccessLogging -> Rep StartAccessLogging x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartAccessLogging x -> StartAccessLogging
$cfrom :: forall x. StartAccessLogging -> Rep StartAccessLogging x
Prelude.Generic)

-- |
-- Create a value of 'StartAccessLogging' 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:
--
-- 'containerName', 'startAccessLogging_containerName' - The name of the container that you want to start access logging on.
newStartAccessLogging ::
  -- | 'containerName'
  Prelude.Text ->
  StartAccessLogging
newStartAccessLogging :: Text -> StartAccessLogging
newStartAccessLogging Text
pContainerName_ =
  StartAccessLogging' :: Text -> StartAccessLogging
StartAccessLogging'
    { $sel:containerName:StartAccessLogging' :: Text
containerName =
        Text
pContainerName_
    }

-- | The name of the container that you want to start access logging on.
startAccessLogging_containerName :: Lens.Lens' StartAccessLogging Prelude.Text
startAccessLogging_containerName :: (Text -> f Text) -> StartAccessLogging -> f StartAccessLogging
startAccessLogging_containerName = (StartAccessLogging -> Text)
-> (StartAccessLogging -> Text -> StartAccessLogging)
-> Lens StartAccessLogging StartAccessLogging Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartAccessLogging' {Text
containerName :: Text
$sel:containerName:StartAccessLogging' :: StartAccessLogging -> Text
containerName} -> Text
containerName) (\s :: StartAccessLogging
s@StartAccessLogging' {} Text
a -> StartAccessLogging
s {$sel:containerName:StartAccessLogging' :: Text
containerName = Text
a} :: StartAccessLogging)

instance Core.AWSRequest StartAccessLogging where
  type
    AWSResponse StartAccessLogging =
      StartAccessLoggingResponse
  request :: StartAccessLogging -> Request StartAccessLogging
request = Service -> StartAccessLogging -> Request StartAccessLogging
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartAccessLogging
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAccessLogging)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartAccessLogging))
-> Logger
-> Service
-> Proxy StartAccessLogging
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAccessLogging)))
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 -> StartAccessLoggingResponse
StartAccessLoggingResponse'
            (Int -> StartAccessLoggingResponse)
-> Either String Int -> Either String StartAccessLoggingResponse
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 StartAccessLogging

instance Prelude.NFData StartAccessLogging

instance Core.ToHeaders StartAccessLogging where
  toHeaders :: StartAccessLogging -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartAccessLogging -> 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
"MediaStore_20170901.StartAccessLogging" ::
                          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 StartAccessLogging where
  toJSON :: StartAccessLogging -> Value
toJSON StartAccessLogging' {Text
containerName :: Text
$sel:containerName:StartAccessLogging' :: StartAccessLogging -> 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
"ContainerName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
containerName)
          ]
      )

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

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

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

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

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

instance Prelude.NFData StartAccessLoggingResponse