{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' StartAccessLogging Text
startAccessLogging_containerName = 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 :: (Service -> Service)
-> StartAccessLogging -> Request StartAccessLogging
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartAccessLogging
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAccessLogging)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartAccessLoggingResponse
StartAccessLoggingResponse'
            forall (f :: * -> *) a b. Functor 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 StartAccessLogging where
  hashWithSalt :: Int -> StartAccessLogging -> Int
hashWithSalt Int
_salt StartAccessLogging' {Text
containerName :: Text
$sel:containerName:StartAccessLogging' :: StartAccessLogging -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
containerName

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

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

instance Data.ToJSON StartAccessLogging where
  toJSON :: StartAccessLogging -> Value
toJSON StartAccessLogging' {Text
containerName :: Text
$sel:containerName:StartAccessLogging' :: StartAccessLogging -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ContainerName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
containerName)
          ]
      )

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

instance Data.ToQuery StartAccessLogging where
  toQuery :: StartAccessLogging -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:httpStatus:StartAccessLoggingResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
startAccessLoggingResponse_httpStatus :: Lens.Lens' StartAccessLoggingResponse Prelude.Int
startAccessLoggingResponse_httpStatus :: Lens' StartAccessLoggingResponse Int
startAccessLoggingResponse_httpStatus = 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 where
  rnf :: StartAccessLoggingResponse -> ()
rnf StartAccessLoggingResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartAccessLoggingResponse' :: StartAccessLoggingResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus