{-# 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.DescribeMountTargetSecurityGroups
-- 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 security groups currently in effect for a mount target. This
-- operation requires that the network interface of the mount target has
-- been created and the lifecycle state of the mount target is not
-- @deleted@.
--
-- This operation requires permissions for the following actions:
--
-- -   @elasticfilesystem:DescribeMountTargetSecurityGroups@ action on the
--     mount target\'s file system.
--
-- -   @ec2:DescribeNetworkInterfaceAttribute@ action on the mount
--     target\'s network interface.
module Amazonka.EFS.DescribeMountTargetSecurityGroups
  ( -- * Creating a Request
    DescribeMountTargetSecurityGroups (..),
    newDescribeMountTargetSecurityGroups,

    -- * Request Lenses
    describeMountTargetSecurityGroups_mountTargetId,

    -- * Destructuring the Response
    DescribeMountTargetSecurityGroupsResponse (..),
    newDescribeMountTargetSecurityGroupsResponse,

    -- * Response Lenses
    describeMountTargetSecurityGroupsResponse_httpStatus,
    describeMountTargetSecurityGroupsResponse_securityGroups,
  )
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:/ 'newDescribeMountTargetSecurityGroups' smart constructor.
data DescribeMountTargetSecurityGroups = DescribeMountTargetSecurityGroups'
  { -- | The ID of the mount target whose security groups you want to retrieve.
    DescribeMountTargetSecurityGroups -> Text
mountTargetId :: Prelude.Text
  }
  deriving (DescribeMountTargetSecurityGroups
-> DescribeMountTargetSecurityGroups -> Bool
(DescribeMountTargetSecurityGroups
 -> DescribeMountTargetSecurityGroups -> Bool)
-> (DescribeMountTargetSecurityGroups
    -> DescribeMountTargetSecurityGroups -> Bool)
-> Eq DescribeMountTargetSecurityGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMountTargetSecurityGroups
-> DescribeMountTargetSecurityGroups -> Bool
$c/= :: DescribeMountTargetSecurityGroups
-> DescribeMountTargetSecurityGroups -> Bool
== :: DescribeMountTargetSecurityGroups
-> DescribeMountTargetSecurityGroups -> Bool
$c== :: DescribeMountTargetSecurityGroups
-> DescribeMountTargetSecurityGroups -> Bool
Prelude.Eq, ReadPrec [DescribeMountTargetSecurityGroups]
ReadPrec DescribeMountTargetSecurityGroups
Int -> ReadS DescribeMountTargetSecurityGroups
ReadS [DescribeMountTargetSecurityGroups]
(Int -> ReadS DescribeMountTargetSecurityGroups)
-> ReadS [DescribeMountTargetSecurityGroups]
-> ReadPrec DescribeMountTargetSecurityGroups
-> ReadPrec [DescribeMountTargetSecurityGroups]
-> Read DescribeMountTargetSecurityGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMountTargetSecurityGroups]
$creadListPrec :: ReadPrec [DescribeMountTargetSecurityGroups]
readPrec :: ReadPrec DescribeMountTargetSecurityGroups
$creadPrec :: ReadPrec DescribeMountTargetSecurityGroups
readList :: ReadS [DescribeMountTargetSecurityGroups]
$creadList :: ReadS [DescribeMountTargetSecurityGroups]
readsPrec :: Int -> ReadS DescribeMountTargetSecurityGroups
$creadsPrec :: Int -> ReadS DescribeMountTargetSecurityGroups
Prelude.Read, Int -> DescribeMountTargetSecurityGroups -> ShowS
[DescribeMountTargetSecurityGroups] -> ShowS
DescribeMountTargetSecurityGroups -> String
(Int -> DescribeMountTargetSecurityGroups -> ShowS)
-> (DescribeMountTargetSecurityGroups -> String)
-> ([DescribeMountTargetSecurityGroups] -> ShowS)
-> Show DescribeMountTargetSecurityGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMountTargetSecurityGroups] -> ShowS
$cshowList :: [DescribeMountTargetSecurityGroups] -> ShowS
show :: DescribeMountTargetSecurityGroups -> String
$cshow :: DescribeMountTargetSecurityGroups -> String
showsPrec :: Int -> DescribeMountTargetSecurityGroups -> ShowS
$cshowsPrec :: Int -> DescribeMountTargetSecurityGroups -> ShowS
Prelude.Show, (forall x.
 DescribeMountTargetSecurityGroups
 -> Rep DescribeMountTargetSecurityGroups x)
-> (forall x.
    Rep DescribeMountTargetSecurityGroups x
    -> DescribeMountTargetSecurityGroups)
-> Generic DescribeMountTargetSecurityGroups
forall x.
Rep DescribeMountTargetSecurityGroups x
-> DescribeMountTargetSecurityGroups
forall x.
DescribeMountTargetSecurityGroups
-> Rep DescribeMountTargetSecurityGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMountTargetSecurityGroups x
-> DescribeMountTargetSecurityGroups
$cfrom :: forall x.
DescribeMountTargetSecurityGroups
-> Rep DescribeMountTargetSecurityGroups x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMountTargetSecurityGroups' 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:
--
-- 'mountTargetId', 'describeMountTargetSecurityGroups_mountTargetId' - The ID of the mount target whose security groups you want to retrieve.
newDescribeMountTargetSecurityGroups ::
  -- | 'mountTargetId'
  Prelude.Text ->
  DescribeMountTargetSecurityGroups
newDescribeMountTargetSecurityGroups :: Text -> DescribeMountTargetSecurityGroups
newDescribeMountTargetSecurityGroups Text
pMountTargetId_ =
  DescribeMountTargetSecurityGroups' :: Text -> DescribeMountTargetSecurityGroups
DescribeMountTargetSecurityGroups'
    { $sel:mountTargetId:DescribeMountTargetSecurityGroups' :: Text
mountTargetId =
        Text
pMountTargetId_
    }

-- | The ID of the mount target whose security groups you want to retrieve.
describeMountTargetSecurityGroups_mountTargetId :: Lens.Lens' DescribeMountTargetSecurityGroups Prelude.Text
describeMountTargetSecurityGroups_mountTargetId :: (Text -> f Text)
-> DescribeMountTargetSecurityGroups
-> f DescribeMountTargetSecurityGroups
describeMountTargetSecurityGroups_mountTargetId = (DescribeMountTargetSecurityGroups -> Text)
-> (DescribeMountTargetSecurityGroups
    -> Text -> DescribeMountTargetSecurityGroups)
-> Lens
     DescribeMountTargetSecurityGroups
     DescribeMountTargetSecurityGroups
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMountTargetSecurityGroups' {Text
mountTargetId :: Text
$sel:mountTargetId:DescribeMountTargetSecurityGroups' :: DescribeMountTargetSecurityGroups -> Text
mountTargetId} -> Text
mountTargetId) (\s :: DescribeMountTargetSecurityGroups
s@DescribeMountTargetSecurityGroups' {} Text
a -> DescribeMountTargetSecurityGroups
s {$sel:mountTargetId:DescribeMountTargetSecurityGroups' :: Text
mountTargetId = Text
a} :: DescribeMountTargetSecurityGroups)

instance
  Core.AWSRequest
    DescribeMountTargetSecurityGroups
  where
  type
    AWSResponse DescribeMountTargetSecurityGroups =
      DescribeMountTargetSecurityGroupsResponse
  request :: DescribeMountTargetSecurityGroups
-> Request DescribeMountTargetSecurityGroups
request = Service
-> DescribeMountTargetSecurityGroups
-> Request DescribeMountTargetSecurityGroups
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeMountTargetSecurityGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeMountTargetSecurityGroups)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeMountTargetSecurityGroups))
-> Logger
-> Service
-> Proxy DescribeMountTargetSecurityGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse DescribeMountTargetSecurityGroups)))
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] -> DescribeMountTargetSecurityGroupsResponse
DescribeMountTargetSecurityGroupsResponse'
            (Int -> [Text] -> DescribeMountTargetSecurityGroupsResponse)
-> Either String Int
-> Either
     String ([Text] -> DescribeMountTargetSecurityGroupsResponse)
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] -> DescribeMountTargetSecurityGroupsResponse)
-> Either String [Text]
-> Either String DescribeMountTargetSecurityGroupsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"SecurityGroups"
                              Either String (Maybe [Text]) -> [Text] -> Either String [Text]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Text]
forall a. Monoid a => a
Prelude.mempty
                          )
      )

instance
  Prelude.Hashable
    DescribeMountTargetSecurityGroups

instance
  Prelude.NFData
    DescribeMountTargetSecurityGroups

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

instance
  Core.ToPath
    DescribeMountTargetSecurityGroups
  where
  toPath :: DescribeMountTargetSecurityGroups -> ByteString
toPath DescribeMountTargetSecurityGroups' {Text
mountTargetId :: Text
$sel:mountTargetId:DescribeMountTargetSecurityGroups' :: DescribeMountTargetSecurityGroups -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2015-02-01/mount-targets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
mountTargetId,
        ByteString
"/security-groups"
      ]

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

-- | /See:/ 'newDescribeMountTargetSecurityGroupsResponse' smart constructor.
data DescribeMountTargetSecurityGroupsResponse = DescribeMountTargetSecurityGroupsResponse'
  { -- | The response's http status code.
    DescribeMountTargetSecurityGroupsResponse -> Int
httpStatus :: Prelude.Int,
    -- | An array of security groups.
    DescribeMountTargetSecurityGroupsResponse -> [Text]
securityGroups :: [Prelude.Text]
  }
  deriving (DescribeMountTargetSecurityGroupsResponse
-> DescribeMountTargetSecurityGroupsResponse -> Bool
(DescribeMountTargetSecurityGroupsResponse
 -> DescribeMountTargetSecurityGroupsResponse -> Bool)
-> (DescribeMountTargetSecurityGroupsResponse
    -> DescribeMountTargetSecurityGroupsResponse -> Bool)
-> Eq DescribeMountTargetSecurityGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeMountTargetSecurityGroupsResponse
-> DescribeMountTargetSecurityGroupsResponse -> Bool
$c/= :: DescribeMountTargetSecurityGroupsResponse
-> DescribeMountTargetSecurityGroupsResponse -> Bool
== :: DescribeMountTargetSecurityGroupsResponse
-> DescribeMountTargetSecurityGroupsResponse -> Bool
$c== :: DescribeMountTargetSecurityGroupsResponse
-> DescribeMountTargetSecurityGroupsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeMountTargetSecurityGroupsResponse]
ReadPrec DescribeMountTargetSecurityGroupsResponse
Int -> ReadS DescribeMountTargetSecurityGroupsResponse
ReadS [DescribeMountTargetSecurityGroupsResponse]
(Int -> ReadS DescribeMountTargetSecurityGroupsResponse)
-> ReadS [DescribeMountTargetSecurityGroupsResponse]
-> ReadPrec DescribeMountTargetSecurityGroupsResponse
-> ReadPrec [DescribeMountTargetSecurityGroupsResponse]
-> Read DescribeMountTargetSecurityGroupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeMountTargetSecurityGroupsResponse]
$creadListPrec :: ReadPrec [DescribeMountTargetSecurityGroupsResponse]
readPrec :: ReadPrec DescribeMountTargetSecurityGroupsResponse
$creadPrec :: ReadPrec DescribeMountTargetSecurityGroupsResponse
readList :: ReadS [DescribeMountTargetSecurityGroupsResponse]
$creadList :: ReadS [DescribeMountTargetSecurityGroupsResponse]
readsPrec :: Int -> ReadS DescribeMountTargetSecurityGroupsResponse
$creadsPrec :: Int -> ReadS DescribeMountTargetSecurityGroupsResponse
Prelude.Read, Int -> DescribeMountTargetSecurityGroupsResponse -> ShowS
[DescribeMountTargetSecurityGroupsResponse] -> ShowS
DescribeMountTargetSecurityGroupsResponse -> String
(Int -> DescribeMountTargetSecurityGroupsResponse -> ShowS)
-> (DescribeMountTargetSecurityGroupsResponse -> String)
-> ([DescribeMountTargetSecurityGroupsResponse] -> ShowS)
-> Show DescribeMountTargetSecurityGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeMountTargetSecurityGroupsResponse] -> ShowS
$cshowList :: [DescribeMountTargetSecurityGroupsResponse] -> ShowS
show :: DescribeMountTargetSecurityGroupsResponse -> String
$cshow :: DescribeMountTargetSecurityGroupsResponse -> String
showsPrec :: Int -> DescribeMountTargetSecurityGroupsResponse -> ShowS
$cshowsPrec :: Int -> DescribeMountTargetSecurityGroupsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeMountTargetSecurityGroupsResponse
 -> Rep DescribeMountTargetSecurityGroupsResponse x)
-> (forall x.
    Rep DescribeMountTargetSecurityGroupsResponse x
    -> DescribeMountTargetSecurityGroupsResponse)
-> Generic DescribeMountTargetSecurityGroupsResponse
forall x.
Rep DescribeMountTargetSecurityGroupsResponse x
-> DescribeMountTargetSecurityGroupsResponse
forall x.
DescribeMountTargetSecurityGroupsResponse
-> Rep DescribeMountTargetSecurityGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeMountTargetSecurityGroupsResponse x
-> DescribeMountTargetSecurityGroupsResponse
$cfrom :: forall x.
DescribeMountTargetSecurityGroupsResponse
-> Rep DescribeMountTargetSecurityGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeMountTargetSecurityGroupsResponse' 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', 'describeMountTargetSecurityGroupsResponse_httpStatus' - The response's http status code.
--
-- 'securityGroups', 'describeMountTargetSecurityGroupsResponse_securityGroups' - An array of security groups.
newDescribeMountTargetSecurityGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeMountTargetSecurityGroupsResponse
newDescribeMountTargetSecurityGroupsResponse :: Int -> DescribeMountTargetSecurityGroupsResponse
newDescribeMountTargetSecurityGroupsResponse
  Int
pHttpStatus_ =
    DescribeMountTargetSecurityGroupsResponse' :: Int -> [Text] -> DescribeMountTargetSecurityGroupsResponse
DescribeMountTargetSecurityGroupsResponse'
      { $sel:httpStatus:DescribeMountTargetSecurityGroupsResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:securityGroups:DescribeMountTargetSecurityGroupsResponse' :: [Text]
securityGroups = [Text]
forall a. Monoid a => a
Prelude.mempty
      }

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

-- | An array of security groups.
describeMountTargetSecurityGroupsResponse_securityGroups :: Lens.Lens' DescribeMountTargetSecurityGroupsResponse [Prelude.Text]
describeMountTargetSecurityGroupsResponse_securityGroups :: ([Text] -> f [Text])
-> DescribeMountTargetSecurityGroupsResponse
-> f DescribeMountTargetSecurityGroupsResponse
describeMountTargetSecurityGroupsResponse_securityGroups = (DescribeMountTargetSecurityGroupsResponse -> [Text])
-> (DescribeMountTargetSecurityGroupsResponse
    -> [Text] -> DescribeMountTargetSecurityGroupsResponse)
-> Lens
     DescribeMountTargetSecurityGroupsResponse
     DescribeMountTargetSecurityGroupsResponse
     [Text]
     [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMountTargetSecurityGroupsResponse' {[Text]
securityGroups :: [Text]
$sel:securityGroups:DescribeMountTargetSecurityGroupsResponse' :: DescribeMountTargetSecurityGroupsResponse -> [Text]
securityGroups} -> [Text]
securityGroups) (\s :: DescribeMountTargetSecurityGroupsResponse
s@DescribeMountTargetSecurityGroupsResponse' {} [Text]
a -> DescribeMountTargetSecurityGroupsResponse
s {$sel:securityGroups:DescribeMountTargetSecurityGroupsResponse' :: [Text]
securityGroups = [Text]
a} :: DescribeMountTargetSecurityGroupsResponse) (([Text] -> f [Text])
 -> DescribeMountTargetSecurityGroupsResponse
 -> f DescribeMountTargetSecurityGroupsResponse)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DescribeMountTargetSecurityGroupsResponse
-> f DescribeMountTargetSecurityGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    DescribeMountTargetSecurityGroupsResponse