{-# 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.ModifyMountTargetSecurityGroups
-- 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)
--
-- Modifies the set of security groups in effect for a mount target.
--
-- When you create a mount target, Amazon EFS also creates a new network
-- interface. For more information, see CreateMountTarget. This operation
-- replaces the security groups in effect for the network interface
-- associated with a mount target, with the @SecurityGroups@ provided in
-- the request. 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@.
--
-- The operation requires permissions for the following actions:
--
-- -   @elasticfilesystem:ModifyMountTargetSecurityGroups@ action on the
--     mount target\'s file system.
--
-- -   @ec2:ModifyNetworkInterfaceAttribute@ action on the mount target\'s
--     network interface.
module Amazonka.EFS.ModifyMountTargetSecurityGroups
  ( -- * Creating a Request
    ModifyMountTargetSecurityGroups (..),
    newModifyMountTargetSecurityGroups,

    -- * Request Lenses
    modifyMountTargetSecurityGroups_securityGroups,
    modifyMountTargetSecurityGroups_mountTargetId,

    -- * Destructuring the Response
    ModifyMountTargetSecurityGroupsResponse (..),
    newModifyMountTargetSecurityGroupsResponse,
  )
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:/ 'newModifyMountTargetSecurityGroups' smart constructor.
data ModifyMountTargetSecurityGroups = ModifyMountTargetSecurityGroups'
  { -- | An array of up to five VPC security group IDs.
    ModifyMountTargetSecurityGroups -> Maybe [Text]
securityGroups :: Prelude.Maybe [Prelude.Text],
    -- | The ID of the mount target whose security groups you want to modify.
    ModifyMountTargetSecurityGroups -> Text
mountTargetId :: Prelude.Text
  }
  deriving (ModifyMountTargetSecurityGroups
-> ModifyMountTargetSecurityGroups -> Bool
(ModifyMountTargetSecurityGroups
 -> ModifyMountTargetSecurityGroups -> Bool)
-> (ModifyMountTargetSecurityGroups
    -> ModifyMountTargetSecurityGroups -> Bool)
-> Eq ModifyMountTargetSecurityGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyMountTargetSecurityGroups
-> ModifyMountTargetSecurityGroups -> Bool
$c/= :: ModifyMountTargetSecurityGroups
-> ModifyMountTargetSecurityGroups -> Bool
== :: ModifyMountTargetSecurityGroups
-> ModifyMountTargetSecurityGroups -> Bool
$c== :: ModifyMountTargetSecurityGroups
-> ModifyMountTargetSecurityGroups -> Bool
Prelude.Eq, ReadPrec [ModifyMountTargetSecurityGroups]
ReadPrec ModifyMountTargetSecurityGroups
Int -> ReadS ModifyMountTargetSecurityGroups
ReadS [ModifyMountTargetSecurityGroups]
(Int -> ReadS ModifyMountTargetSecurityGroups)
-> ReadS [ModifyMountTargetSecurityGroups]
-> ReadPrec ModifyMountTargetSecurityGroups
-> ReadPrec [ModifyMountTargetSecurityGroups]
-> Read ModifyMountTargetSecurityGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyMountTargetSecurityGroups]
$creadListPrec :: ReadPrec [ModifyMountTargetSecurityGroups]
readPrec :: ReadPrec ModifyMountTargetSecurityGroups
$creadPrec :: ReadPrec ModifyMountTargetSecurityGroups
readList :: ReadS [ModifyMountTargetSecurityGroups]
$creadList :: ReadS [ModifyMountTargetSecurityGroups]
readsPrec :: Int -> ReadS ModifyMountTargetSecurityGroups
$creadsPrec :: Int -> ReadS ModifyMountTargetSecurityGroups
Prelude.Read, Int -> ModifyMountTargetSecurityGroups -> ShowS
[ModifyMountTargetSecurityGroups] -> ShowS
ModifyMountTargetSecurityGroups -> String
(Int -> ModifyMountTargetSecurityGroups -> ShowS)
-> (ModifyMountTargetSecurityGroups -> String)
-> ([ModifyMountTargetSecurityGroups] -> ShowS)
-> Show ModifyMountTargetSecurityGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyMountTargetSecurityGroups] -> ShowS
$cshowList :: [ModifyMountTargetSecurityGroups] -> ShowS
show :: ModifyMountTargetSecurityGroups -> String
$cshow :: ModifyMountTargetSecurityGroups -> String
showsPrec :: Int -> ModifyMountTargetSecurityGroups -> ShowS
$cshowsPrec :: Int -> ModifyMountTargetSecurityGroups -> ShowS
Prelude.Show, (forall x.
 ModifyMountTargetSecurityGroups
 -> Rep ModifyMountTargetSecurityGroups x)
-> (forall x.
    Rep ModifyMountTargetSecurityGroups x
    -> ModifyMountTargetSecurityGroups)
-> Generic ModifyMountTargetSecurityGroups
forall x.
Rep ModifyMountTargetSecurityGroups x
-> ModifyMountTargetSecurityGroups
forall x.
ModifyMountTargetSecurityGroups
-> Rep ModifyMountTargetSecurityGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifyMountTargetSecurityGroups x
-> ModifyMountTargetSecurityGroups
$cfrom :: forall x.
ModifyMountTargetSecurityGroups
-> Rep ModifyMountTargetSecurityGroups x
Prelude.Generic)

-- |
-- Create a value of 'ModifyMountTargetSecurityGroups' 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:
--
-- 'securityGroups', 'modifyMountTargetSecurityGroups_securityGroups' - An array of up to five VPC security group IDs.
--
-- 'mountTargetId', 'modifyMountTargetSecurityGroups_mountTargetId' - The ID of the mount target whose security groups you want to modify.
newModifyMountTargetSecurityGroups ::
  -- | 'mountTargetId'
  Prelude.Text ->
  ModifyMountTargetSecurityGroups
newModifyMountTargetSecurityGroups :: Text -> ModifyMountTargetSecurityGroups
newModifyMountTargetSecurityGroups Text
pMountTargetId_ =
  ModifyMountTargetSecurityGroups' :: Maybe [Text] -> Text -> ModifyMountTargetSecurityGroups
ModifyMountTargetSecurityGroups'
    { $sel:securityGroups:ModifyMountTargetSecurityGroups' :: Maybe [Text]
securityGroups =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:mountTargetId:ModifyMountTargetSecurityGroups' :: Text
mountTargetId = Text
pMountTargetId_
    }

-- | An array of up to five VPC security group IDs.
modifyMountTargetSecurityGroups_securityGroups :: Lens.Lens' ModifyMountTargetSecurityGroups (Prelude.Maybe [Prelude.Text])
modifyMountTargetSecurityGroups_securityGroups :: (Maybe [Text] -> f (Maybe [Text]))
-> ModifyMountTargetSecurityGroups
-> f ModifyMountTargetSecurityGroups
modifyMountTargetSecurityGroups_securityGroups = (ModifyMountTargetSecurityGroups -> Maybe [Text])
-> (ModifyMountTargetSecurityGroups
    -> Maybe [Text] -> ModifyMountTargetSecurityGroups)
-> Lens
     ModifyMountTargetSecurityGroups
     ModifyMountTargetSecurityGroups
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyMountTargetSecurityGroups' {Maybe [Text]
securityGroups :: Maybe [Text]
$sel:securityGroups:ModifyMountTargetSecurityGroups' :: ModifyMountTargetSecurityGroups -> Maybe [Text]
securityGroups} -> Maybe [Text]
securityGroups) (\s :: ModifyMountTargetSecurityGroups
s@ModifyMountTargetSecurityGroups' {} Maybe [Text]
a -> ModifyMountTargetSecurityGroups
s {$sel:securityGroups:ModifyMountTargetSecurityGroups' :: Maybe [Text]
securityGroups = Maybe [Text]
a} :: ModifyMountTargetSecurityGroups) ((Maybe [Text] -> f (Maybe [Text]))
 -> ModifyMountTargetSecurityGroups
 -> f ModifyMountTargetSecurityGroups)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ModifyMountTargetSecurityGroups
-> f ModifyMountTargetSecurityGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Core.AWSRequest
    ModifyMountTargetSecurityGroups
  where
  type
    AWSResponse ModifyMountTargetSecurityGroups =
      ModifyMountTargetSecurityGroupsResponse
  request :: ModifyMountTargetSecurityGroups
-> Request ModifyMountTargetSecurityGroups
request = Service
-> ModifyMountTargetSecurityGroups
-> Request ModifyMountTargetSecurityGroups
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ModifyMountTargetSecurityGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse ModifyMountTargetSecurityGroups)))
response =
    AWSResponse ModifyMountTargetSecurityGroups
-> Logger
-> Service
-> Proxy ModifyMountTargetSecurityGroups
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse ModifyMountTargetSecurityGroups)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse ModifyMountTargetSecurityGroups
ModifyMountTargetSecurityGroupsResponse
ModifyMountTargetSecurityGroupsResponse'

instance
  Prelude.Hashable
    ModifyMountTargetSecurityGroups

instance
  Prelude.NFData
    ModifyMountTargetSecurityGroups

instance
  Core.ToHeaders
    ModifyMountTargetSecurityGroups
  where
  toHeaders :: ModifyMountTargetSecurityGroups -> [Header]
toHeaders = [Header] -> ModifyMountTargetSecurityGroups -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON ModifyMountTargetSecurityGroups where
  toJSON :: ModifyMountTargetSecurityGroups -> Value
toJSON ModifyMountTargetSecurityGroups' {Maybe [Text]
Text
mountTargetId :: Text
securityGroups :: Maybe [Text]
$sel:mountTargetId:ModifyMountTargetSecurityGroups' :: ModifyMountTargetSecurityGroups -> Text
$sel:securityGroups:ModifyMountTargetSecurityGroups' :: ModifyMountTargetSecurityGroups -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SecurityGroups" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
securityGroups
          ]
      )

instance Core.ToPath ModifyMountTargetSecurityGroups where
  toPath :: ModifyMountTargetSecurityGroups -> ByteString
toPath ModifyMountTargetSecurityGroups' {Maybe [Text]
Text
mountTargetId :: Text
securityGroups :: Maybe [Text]
$sel:mountTargetId:ModifyMountTargetSecurityGroups' :: ModifyMountTargetSecurityGroups -> Text
$sel:securityGroups:ModifyMountTargetSecurityGroups' :: ModifyMountTargetSecurityGroups -> Maybe [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 ModifyMountTargetSecurityGroups where
  toQuery :: ModifyMountTargetSecurityGroups -> QueryString
toQuery = QueryString -> ModifyMountTargetSecurityGroups -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newModifyMountTargetSecurityGroupsResponse' smart constructor.
data ModifyMountTargetSecurityGroupsResponse = ModifyMountTargetSecurityGroupsResponse'
  {
  }
  deriving (ModifyMountTargetSecurityGroupsResponse
-> ModifyMountTargetSecurityGroupsResponse -> Bool
(ModifyMountTargetSecurityGroupsResponse
 -> ModifyMountTargetSecurityGroupsResponse -> Bool)
-> (ModifyMountTargetSecurityGroupsResponse
    -> ModifyMountTargetSecurityGroupsResponse -> Bool)
-> Eq ModifyMountTargetSecurityGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyMountTargetSecurityGroupsResponse
-> ModifyMountTargetSecurityGroupsResponse -> Bool
$c/= :: ModifyMountTargetSecurityGroupsResponse
-> ModifyMountTargetSecurityGroupsResponse -> Bool
== :: ModifyMountTargetSecurityGroupsResponse
-> ModifyMountTargetSecurityGroupsResponse -> Bool
$c== :: ModifyMountTargetSecurityGroupsResponse
-> ModifyMountTargetSecurityGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ModifyMountTargetSecurityGroupsResponse]
ReadPrec ModifyMountTargetSecurityGroupsResponse
Int -> ReadS ModifyMountTargetSecurityGroupsResponse
ReadS [ModifyMountTargetSecurityGroupsResponse]
(Int -> ReadS ModifyMountTargetSecurityGroupsResponse)
-> ReadS [ModifyMountTargetSecurityGroupsResponse]
-> ReadPrec ModifyMountTargetSecurityGroupsResponse
-> ReadPrec [ModifyMountTargetSecurityGroupsResponse]
-> Read ModifyMountTargetSecurityGroupsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyMountTargetSecurityGroupsResponse]
$creadListPrec :: ReadPrec [ModifyMountTargetSecurityGroupsResponse]
readPrec :: ReadPrec ModifyMountTargetSecurityGroupsResponse
$creadPrec :: ReadPrec ModifyMountTargetSecurityGroupsResponse
readList :: ReadS [ModifyMountTargetSecurityGroupsResponse]
$creadList :: ReadS [ModifyMountTargetSecurityGroupsResponse]
readsPrec :: Int -> ReadS ModifyMountTargetSecurityGroupsResponse
$creadsPrec :: Int -> ReadS ModifyMountTargetSecurityGroupsResponse
Prelude.Read, Int -> ModifyMountTargetSecurityGroupsResponse -> ShowS
[ModifyMountTargetSecurityGroupsResponse] -> ShowS
ModifyMountTargetSecurityGroupsResponse -> String
(Int -> ModifyMountTargetSecurityGroupsResponse -> ShowS)
-> (ModifyMountTargetSecurityGroupsResponse -> String)
-> ([ModifyMountTargetSecurityGroupsResponse] -> ShowS)
-> Show ModifyMountTargetSecurityGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyMountTargetSecurityGroupsResponse] -> ShowS
$cshowList :: [ModifyMountTargetSecurityGroupsResponse] -> ShowS
show :: ModifyMountTargetSecurityGroupsResponse -> String
$cshow :: ModifyMountTargetSecurityGroupsResponse -> String
showsPrec :: Int -> ModifyMountTargetSecurityGroupsResponse -> ShowS
$cshowsPrec :: Int -> ModifyMountTargetSecurityGroupsResponse -> ShowS
Prelude.Show, (forall x.
 ModifyMountTargetSecurityGroupsResponse
 -> Rep ModifyMountTargetSecurityGroupsResponse x)
-> (forall x.
    Rep ModifyMountTargetSecurityGroupsResponse x
    -> ModifyMountTargetSecurityGroupsResponse)
-> Generic ModifyMountTargetSecurityGroupsResponse
forall x.
Rep ModifyMountTargetSecurityGroupsResponse x
-> ModifyMountTargetSecurityGroupsResponse
forall x.
ModifyMountTargetSecurityGroupsResponse
-> Rep ModifyMountTargetSecurityGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ModifyMountTargetSecurityGroupsResponse x
-> ModifyMountTargetSecurityGroupsResponse
$cfrom :: forall x.
ModifyMountTargetSecurityGroupsResponse
-> Rep ModifyMountTargetSecurityGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ModifyMountTargetSecurityGroupsResponse' 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.
newModifyMountTargetSecurityGroupsResponse ::
  ModifyMountTargetSecurityGroupsResponse
newModifyMountTargetSecurityGroupsResponse :: ModifyMountTargetSecurityGroupsResponse
newModifyMountTargetSecurityGroupsResponse =
  ModifyMountTargetSecurityGroupsResponse
ModifyMountTargetSecurityGroupsResponse'

instance
  Prelude.NFData
    ModifyMountTargetSecurityGroupsResponse