{-# 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.EFS.DescribeBackupPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the backup policy for the specified EFS file system.
module Amazonka.EFS.DescribeBackupPolicy
  ( -- * Creating a Request
    DescribeBackupPolicy (..),
    newDescribeBackupPolicy,

    -- * Request Lenses
    describeBackupPolicy_fileSystemId,

    -- * Destructuring the Response
    BackupPolicyDescription (..),
    newBackupPolicyDescription,

    -- * Response Lenses
    backupPolicyDescription_backupPolicy,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EFS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeBackupPolicy' smart constructor.
data DescribeBackupPolicy = DescribeBackupPolicy'
  { -- | Specifies which EFS file system to retrieve the @BackupPolicy@ for.
    DescribeBackupPolicy -> Text
fileSystemId :: Prelude.Text
  }
  deriving (DescribeBackupPolicy -> DescribeBackupPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeBackupPolicy -> DescribeBackupPolicy -> Bool
$c/= :: DescribeBackupPolicy -> DescribeBackupPolicy -> Bool
== :: DescribeBackupPolicy -> DescribeBackupPolicy -> Bool
$c== :: DescribeBackupPolicy -> DescribeBackupPolicy -> Bool
Prelude.Eq, ReadPrec [DescribeBackupPolicy]
ReadPrec DescribeBackupPolicy
Int -> ReadS DescribeBackupPolicy
ReadS [DescribeBackupPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeBackupPolicy]
$creadListPrec :: ReadPrec [DescribeBackupPolicy]
readPrec :: ReadPrec DescribeBackupPolicy
$creadPrec :: ReadPrec DescribeBackupPolicy
readList :: ReadS [DescribeBackupPolicy]
$creadList :: ReadS [DescribeBackupPolicy]
readsPrec :: Int -> ReadS DescribeBackupPolicy
$creadsPrec :: Int -> ReadS DescribeBackupPolicy
Prelude.Read, Int -> DescribeBackupPolicy -> ShowS
[DescribeBackupPolicy] -> ShowS
DescribeBackupPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeBackupPolicy] -> ShowS
$cshowList :: [DescribeBackupPolicy] -> ShowS
show :: DescribeBackupPolicy -> String
$cshow :: DescribeBackupPolicy -> String
showsPrec :: Int -> DescribeBackupPolicy -> ShowS
$cshowsPrec :: Int -> DescribeBackupPolicy -> ShowS
Prelude.Show, forall x. Rep DescribeBackupPolicy x -> DescribeBackupPolicy
forall x. DescribeBackupPolicy -> Rep DescribeBackupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeBackupPolicy x -> DescribeBackupPolicy
$cfrom :: forall x. DescribeBackupPolicy -> Rep DescribeBackupPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DescribeBackupPolicy' 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:
--
-- 'fileSystemId', 'describeBackupPolicy_fileSystemId' - Specifies which EFS file system to retrieve the @BackupPolicy@ for.
newDescribeBackupPolicy ::
  -- | 'fileSystemId'
  Prelude.Text ->
  DescribeBackupPolicy
newDescribeBackupPolicy :: Text -> DescribeBackupPolicy
newDescribeBackupPolicy Text
pFileSystemId_ =
  DescribeBackupPolicy'
    { $sel:fileSystemId:DescribeBackupPolicy' :: Text
fileSystemId =
        Text
pFileSystemId_
    }

-- | Specifies which EFS file system to retrieve the @BackupPolicy@ for.
describeBackupPolicy_fileSystemId :: Lens.Lens' DescribeBackupPolicy Prelude.Text
describeBackupPolicy_fileSystemId :: Lens' DescribeBackupPolicy Text
describeBackupPolicy_fileSystemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeBackupPolicy' {Text
fileSystemId :: Text
$sel:fileSystemId:DescribeBackupPolicy' :: DescribeBackupPolicy -> Text
fileSystemId} -> Text
fileSystemId) (\s :: DescribeBackupPolicy
s@DescribeBackupPolicy' {} Text
a -> DescribeBackupPolicy
s {$sel:fileSystemId:DescribeBackupPolicy' :: Text
fileSystemId = Text
a} :: DescribeBackupPolicy)

instance Core.AWSRequest DescribeBackupPolicy where
  type
    AWSResponse DescribeBackupPolicy =
      BackupPolicyDescription
  request :: (Service -> Service)
-> DescribeBackupPolicy -> Request DescribeBackupPolicy
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeBackupPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeBackupPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeBackupPolicy where
  hashWithSalt :: Int -> DescribeBackupPolicy -> Int
hashWithSalt Int
_salt DescribeBackupPolicy' {Text
fileSystemId :: Text
$sel:fileSystemId:DescribeBackupPolicy' :: DescribeBackupPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
fileSystemId

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

instance Data.ToHeaders DescribeBackupPolicy where
  toHeaders :: DescribeBackupPolicy -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath DescribeBackupPolicy where
  toPath :: DescribeBackupPolicy -> ByteString
toPath DescribeBackupPolicy' {Text
fileSystemId :: Text
$sel:fileSystemId:DescribeBackupPolicy' :: DescribeBackupPolicy -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-02-01/file-systems/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
fileSystemId,
        ByteString
"/backup-policy"
      ]

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