{-# 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.GetLifecyclePolicy
-- 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)
--
-- Retrieves the object lifecycle policy that is assigned to a container.
module Amazonka.MediaStore.GetLifecyclePolicy
  ( -- * Creating a Request
    GetLifecyclePolicy (..),
    newGetLifecyclePolicy,

    -- * Request Lenses
    getLifecyclePolicy_containerName,

    -- * Destructuring the Response
    GetLifecyclePolicyResponse (..),
    newGetLifecyclePolicyResponse,

    -- * Response Lenses
    getLifecyclePolicyResponse_httpStatus,
    getLifecyclePolicyResponse_lifecyclePolicy,
  )
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:/ 'newGetLifecyclePolicy' smart constructor.
data GetLifecyclePolicy = GetLifecyclePolicy'
  { -- | The name of the container that the object lifecycle policy is assigned
    -- to.
    GetLifecyclePolicy -> Text
containerName :: Prelude.Text
  }
  deriving (GetLifecyclePolicy -> GetLifecyclePolicy -> Bool
(GetLifecyclePolicy -> GetLifecyclePolicy -> Bool)
-> (GetLifecyclePolicy -> GetLifecyclePolicy -> Bool)
-> Eq GetLifecyclePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLifecyclePolicy -> GetLifecyclePolicy -> Bool
$c/= :: GetLifecyclePolicy -> GetLifecyclePolicy -> Bool
== :: GetLifecyclePolicy -> GetLifecyclePolicy -> Bool
$c== :: GetLifecyclePolicy -> GetLifecyclePolicy -> Bool
Prelude.Eq, ReadPrec [GetLifecyclePolicy]
ReadPrec GetLifecyclePolicy
Int -> ReadS GetLifecyclePolicy
ReadS [GetLifecyclePolicy]
(Int -> ReadS GetLifecyclePolicy)
-> ReadS [GetLifecyclePolicy]
-> ReadPrec GetLifecyclePolicy
-> ReadPrec [GetLifecyclePolicy]
-> Read GetLifecyclePolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLifecyclePolicy]
$creadListPrec :: ReadPrec [GetLifecyclePolicy]
readPrec :: ReadPrec GetLifecyclePolicy
$creadPrec :: ReadPrec GetLifecyclePolicy
readList :: ReadS [GetLifecyclePolicy]
$creadList :: ReadS [GetLifecyclePolicy]
readsPrec :: Int -> ReadS GetLifecyclePolicy
$creadsPrec :: Int -> ReadS GetLifecyclePolicy
Prelude.Read, Int -> GetLifecyclePolicy -> ShowS
[GetLifecyclePolicy] -> ShowS
GetLifecyclePolicy -> String
(Int -> GetLifecyclePolicy -> ShowS)
-> (GetLifecyclePolicy -> String)
-> ([GetLifecyclePolicy] -> ShowS)
-> Show GetLifecyclePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLifecyclePolicy] -> ShowS
$cshowList :: [GetLifecyclePolicy] -> ShowS
show :: GetLifecyclePolicy -> String
$cshow :: GetLifecyclePolicy -> String
showsPrec :: Int -> GetLifecyclePolicy -> ShowS
$cshowsPrec :: Int -> GetLifecyclePolicy -> ShowS
Prelude.Show, (forall x. GetLifecyclePolicy -> Rep GetLifecyclePolicy x)
-> (forall x. Rep GetLifecyclePolicy x -> GetLifecyclePolicy)
-> Generic GetLifecyclePolicy
forall x. Rep GetLifecyclePolicy x -> GetLifecyclePolicy
forall x. GetLifecyclePolicy -> Rep GetLifecyclePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLifecyclePolicy x -> GetLifecyclePolicy
$cfrom :: forall x. GetLifecyclePolicy -> Rep GetLifecyclePolicy x
Prelude.Generic)

-- |
-- Create a value of 'GetLifecyclePolicy' 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', 'getLifecyclePolicy_containerName' - The name of the container that the object lifecycle policy is assigned
-- to.
newGetLifecyclePolicy ::
  -- | 'containerName'
  Prelude.Text ->
  GetLifecyclePolicy
newGetLifecyclePolicy :: Text -> GetLifecyclePolicy
newGetLifecyclePolicy Text
pContainerName_ =
  GetLifecyclePolicy' :: Text -> GetLifecyclePolicy
GetLifecyclePolicy'
    { $sel:containerName:GetLifecyclePolicy' :: Text
containerName =
        Text
pContainerName_
    }

-- | The name of the container that the object lifecycle policy is assigned
-- to.
getLifecyclePolicy_containerName :: Lens.Lens' GetLifecyclePolicy Prelude.Text
getLifecyclePolicy_containerName :: (Text -> f Text) -> GetLifecyclePolicy -> f GetLifecyclePolicy
getLifecyclePolicy_containerName = (GetLifecyclePolicy -> Text)
-> (GetLifecyclePolicy -> Text -> GetLifecyclePolicy)
-> Lens GetLifecyclePolicy GetLifecyclePolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLifecyclePolicy' {Text
containerName :: Text
$sel:containerName:GetLifecyclePolicy' :: GetLifecyclePolicy -> Text
containerName} -> Text
containerName) (\s :: GetLifecyclePolicy
s@GetLifecyclePolicy' {} Text
a -> GetLifecyclePolicy
s {$sel:containerName:GetLifecyclePolicy' :: Text
containerName = Text
a} :: GetLifecyclePolicy)

instance Core.AWSRequest GetLifecyclePolicy where
  type
    AWSResponse GetLifecyclePolicy =
      GetLifecyclePolicyResponse
  request :: GetLifecyclePolicy -> Request GetLifecyclePolicy
request = Service -> GetLifecyclePolicy -> Request GetLifecyclePolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetLifecyclePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLifecyclePolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetLifecyclePolicy))
-> Logger
-> Service
-> Proxy GetLifecyclePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetLifecyclePolicy)))
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 ->
          Int -> Text -> GetLifecyclePolicyResponse
GetLifecyclePolicyResponse'
            (Int -> Text -> GetLifecyclePolicyResponse)
-> Either String Int
-> Either String (Text -> GetLifecyclePolicyResponse)
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))
            Either String (Text -> GetLifecyclePolicyResponse)
-> Either String Text -> Either String GetLifecyclePolicyResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"LifecyclePolicy")
      )

instance Prelude.Hashable GetLifecyclePolicy

instance Prelude.NFData GetLifecyclePolicy

instance Core.ToHeaders GetLifecyclePolicy where
  toHeaders :: GetLifecyclePolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetLifecyclePolicy -> 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.GetLifecyclePolicy" ::
                          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 GetLifecyclePolicy where
  toJSON :: GetLifecyclePolicy -> Value
toJSON GetLifecyclePolicy' {Text
containerName :: Text
$sel:containerName:GetLifecyclePolicy' :: GetLifecyclePolicy -> 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 GetLifecyclePolicy where
  toPath :: GetLifecyclePolicy -> ByteString
toPath = ByteString -> GetLifecyclePolicy -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'GetLifecyclePolicyResponse' 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', 'getLifecyclePolicyResponse_httpStatus' - The response's http status code.
--
-- 'lifecyclePolicy', 'getLifecyclePolicyResponse_lifecyclePolicy' - The object lifecycle policy that is assigned to the container.
newGetLifecyclePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'lifecyclePolicy'
  Prelude.Text ->
  GetLifecyclePolicyResponse
newGetLifecyclePolicyResponse :: Int -> Text -> GetLifecyclePolicyResponse
newGetLifecyclePolicyResponse
  Int
pHttpStatus_
  Text
pLifecyclePolicy_ =
    GetLifecyclePolicyResponse' :: Int -> Text -> GetLifecyclePolicyResponse
GetLifecyclePolicyResponse'
      { $sel:httpStatus:GetLifecyclePolicyResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:lifecyclePolicy:GetLifecyclePolicyResponse' :: Text
lifecyclePolicy = Text
pLifecyclePolicy_
      }

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

-- | The object lifecycle policy that is assigned to the container.
getLifecyclePolicyResponse_lifecyclePolicy :: Lens.Lens' GetLifecyclePolicyResponse Prelude.Text
getLifecyclePolicyResponse_lifecyclePolicy :: (Text -> f Text)
-> GetLifecyclePolicyResponse -> f GetLifecyclePolicyResponse
getLifecyclePolicyResponse_lifecyclePolicy = (GetLifecyclePolicyResponse -> Text)
-> (GetLifecyclePolicyResponse
    -> Text -> GetLifecyclePolicyResponse)
-> Lens
     GetLifecyclePolicyResponse GetLifecyclePolicyResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLifecyclePolicyResponse' {Text
lifecyclePolicy :: Text
$sel:lifecyclePolicy:GetLifecyclePolicyResponse' :: GetLifecyclePolicyResponse -> Text
lifecyclePolicy} -> Text
lifecyclePolicy) (\s :: GetLifecyclePolicyResponse
s@GetLifecyclePolicyResponse' {} Text
a -> GetLifecyclePolicyResponse
s {$sel:lifecyclePolicy:GetLifecyclePolicyResponse' :: Text
lifecyclePolicy = Text
a} :: GetLifecyclePolicyResponse)

instance Prelude.NFData GetLifecyclePolicyResponse