{-# 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-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)
--
-- 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 Amazonka.EFS.Types
import qualified Amazonka.Lens as Lens
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
(DescribeBackupPolicy -> DescribeBackupPolicy -> Bool)
-> (DescribeBackupPolicy -> DescribeBackupPolicy -> Bool)
-> Eq DescribeBackupPolicy
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]
(Int -> ReadS DescribeBackupPolicy)
-> ReadS [DescribeBackupPolicy]
-> ReadPrec DescribeBackupPolicy
-> ReadPrec [DescribeBackupPolicy]
-> Read 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
(Int -> DescribeBackupPolicy -> ShowS)
-> (DescribeBackupPolicy -> String)
-> ([DescribeBackupPolicy] -> ShowS)
-> Show DescribeBackupPolicy
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. DescribeBackupPolicy -> Rep DescribeBackupPolicy x)
-> (forall x. Rep DescribeBackupPolicy x -> DescribeBackupPolicy)
-> Generic DescribeBackupPolicy
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' :: Text -> DescribeBackupPolicy
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 :: (Text -> f Text) -> DescribeBackupPolicy -> f DescribeBackupPolicy
describeBackupPolicy_fileSystemId = (DescribeBackupPolicy -> Text)
-> (DescribeBackupPolicy -> Text -> DescribeBackupPolicy)
-> Lens DescribeBackupPolicy DescribeBackupPolicy Text Text
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 :: DescribeBackupPolicy -> Request DescribeBackupPolicy
request = Service -> DescribeBackupPolicy -> Request DescribeBackupPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeBackupPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeBackupPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeBackupPolicy))
-> Logger
-> Service
-> Proxy DescribeBackupPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeBackupPolicy)))
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 -> Object -> Either String BackupPolicyDescription
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeBackupPolicy

instance Prelude.NFData DescribeBackupPolicy

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

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

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