{-# 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.DescribeFileSystemPolicy
-- 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 @FileSystemPolicy@ for the specified EFS file system.
--
-- This operation requires permissions for the
-- @elasticfilesystem:DescribeFileSystemPolicy@ action.
module Amazonka.EFS.DescribeFileSystemPolicy
  ( -- * Creating a Request
    DescribeFileSystemPolicy (..),
    newDescribeFileSystemPolicy,

    -- * Request Lenses
    describeFileSystemPolicy_fileSystemId,

    -- * Destructuring the Response
    FileSystemPolicyDescription (..),
    newFileSystemPolicyDescription,

    -- * Response Lenses
    fileSystemPolicyDescription_fileSystemId,
    fileSystemPolicyDescription_policy,
  )
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:/ 'newDescribeFileSystemPolicy' smart constructor.
data DescribeFileSystemPolicy = DescribeFileSystemPolicy'
  { -- | Specifies which EFS file system to retrieve the @FileSystemPolicy@ for.
    DescribeFileSystemPolicy -> Text
fileSystemId :: Prelude.Text
  }
  deriving (DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool
(DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool)
-> (DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool)
-> Eq DescribeFileSystemPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool
$c/= :: DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool
== :: DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool
$c== :: DescribeFileSystemPolicy -> DescribeFileSystemPolicy -> Bool
Prelude.Eq, ReadPrec [DescribeFileSystemPolicy]
ReadPrec DescribeFileSystemPolicy
Int -> ReadS DescribeFileSystemPolicy
ReadS [DescribeFileSystemPolicy]
(Int -> ReadS DescribeFileSystemPolicy)
-> ReadS [DescribeFileSystemPolicy]
-> ReadPrec DescribeFileSystemPolicy
-> ReadPrec [DescribeFileSystemPolicy]
-> Read DescribeFileSystemPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeFileSystemPolicy]
$creadListPrec :: ReadPrec [DescribeFileSystemPolicy]
readPrec :: ReadPrec DescribeFileSystemPolicy
$creadPrec :: ReadPrec DescribeFileSystemPolicy
readList :: ReadS [DescribeFileSystemPolicy]
$creadList :: ReadS [DescribeFileSystemPolicy]
readsPrec :: Int -> ReadS DescribeFileSystemPolicy
$creadsPrec :: Int -> ReadS DescribeFileSystemPolicy
Prelude.Read, Int -> DescribeFileSystemPolicy -> ShowS
[DescribeFileSystemPolicy] -> ShowS
DescribeFileSystemPolicy -> String
(Int -> DescribeFileSystemPolicy -> ShowS)
-> (DescribeFileSystemPolicy -> String)
-> ([DescribeFileSystemPolicy] -> ShowS)
-> Show DescribeFileSystemPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeFileSystemPolicy] -> ShowS
$cshowList :: [DescribeFileSystemPolicy] -> ShowS
show :: DescribeFileSystemPolicy -> String
$cshow :: DescribeFileSystemPolicy -> String
showsPrec :: Int -> DescribeFileSystemPolicy -> ShowS
$cshowsPrec :: Int -> DescribeFileSystemPolicy -> ShowS
Prelude.Show, (forall x.
 DescribeFileSystemPolicy -> Rep DescribeFileSystemPolicy x)
-> (forall x.
    Rep DescribeFileSystemPolicy x -> DescribeFileSystemPolicy)
-> Generic DescribeFileSystemPolicy
forall x.
Rep DescribeFileSystemPolicy x -> DescribeFileSystemPolicy
forall x.
DescribeFileSystemPolicy -> Rep DescribeFileSystemPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeFileSystemPolicy x -> DescribeFileSystemPolicy
$cfrom :: forall x.
DescribeFileSystemPolicy -> Rep DescribeFileSystemPolicy x
Prelude.Generic)

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

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

instance Core.AWSRequest DescribeFileSystemPolicy where
  type
    AWSResponse DescribeFileSystemPolicy =
      FileSystemPolicyDescription
  request :: DescribeFileSystemPolicy -> Request DescribeFileSystemPolicy
request = Service
-> DescribeFileSystemPolicy -> Request DescribeFileSystemPolicy
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeFileSystemPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeFileSystemPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeFileSystemPolicy))
-> Logger
-> Service
-> Proxy DescribeFileSystemPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeFileSystemPolicy)))
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 FileSystemPolicyDescription
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeFileSystemPolicy

instance Prelude.NFData DescribeFileSystemPolicy

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

instance Core.ToPath DescribeFileSystemPolicy where
  toPath :: DescribeFileSystemPolicy -> ByteString
toPath DescribeFileSystemPolicy' {Text
fileSystemId :: Text
$sel:fileSystemId:DescribeFileSystemPolicy' :: DescribeFileSystemPolicy -> 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
"/policy"
      ]

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