{-# 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.WorkSpaces.RevokeIpRules
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes one or more rules from the specified IP access control group.
module Amazonka.WorkSpaces.RevokeIpRules
  ( -- * Creating a Request
    RevokeIpRules (..),
    newRevokeIpRules,

    -- * Request Lenses
    revokeIpRules_groupId,
    revokeIpRules_userRules,

    -- * Destructuring the Response
    RevokeIpRulesResponse (..),
    newRevokeIpRulesResponse,

    -- * Response Lenses
    revokeIpRulesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newRevokeIpRules' smart constructor.
data RevokeIpRules = RevokeIpRules'
  { -- | The identifier of the group.
    RevokeIpRules -> Text
groupId :: Prelude.Text,
    -- | The rules to remove from the group.
    RevokeIpRules -> [Text]
userRules :: [Prelude.Text]
  }
  deriving (RevokeIpRules -> RevokeIpRules -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevokeIpRules -> RevokeIpRules -> Bool
$c/= :: RevokeIpRules -> RevokeIpRules -> Bool
== :: RevokeIpRules -> RevokeIpRules -> Bool
$c== :: RevokeIpRules -> RevokeIpRules -> Bool
Prelude.Eq, ReadPrec [RevokeIpRules]
ReadPrec RevokeIpRules
Int -> ReadS RevokeIpRules
ReadS [RevokeIpRules]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevokeIpRules]
$creadListPrec :: ReadPrec [RevokeIpRules]
readPrec :: ReadPrec RevokeIpRules
$creadPrec :: ReadPrec RevokeIpRules
readList :: ReadS [RevokeIpRules]
$creadList :: ReadS [RevokeIpRules]
readsPrec :: Int -> ReadS RevokeIpRules
$creadsPrec :: Int -> ReadS RevokeIpRules
Prelude.Read, Int -> RevokeIpRules -> ShowS
[RevokeIpRules] -> ShowS
RevokeIpRules -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevokeIpRules] -> ShowS
$cshowList :: [RevokeIpRules] -> ShowS
show :: RevokeIpRules -> String
$cshow :: RevokeIpRules -> String
showsPrec :: Int -> RevokeIpRules -> ShowS
$cshowsPrec :: Int -> RevokeIpRules -> ShowS
Prelude.Show, forall x. Rep RevokeIpRules x -> RevokeIpRules
forall x. RevokeIpRules -> Rep RevokeIpRules x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevokeIpRules x -> RevokeIpRules
$cfrom :: forall x. RevokeIpRules -> Rep RevokeIpRules x
Prelude.Generic)

-- |
-- Create a value of 'RevokeIpRules' 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:
--
-- 'groupId', 'revokeIpRules_groupId' - The identifier of the group.
--
-- 'userRules', 'revokeIpRules_userRules' - The rules to remove from the group.
newRevokeIpRules ::
  -- | 'groupId'
  Prelude.Text ->
  RevokeIpRules
newRevokeIpRules :: Text -> RevokeIpRules
newRevokeIpRules Text
pGroupId_ =
  RevokeIpRules'
    { $sel:groupId:RevokeIpRules' :: Text
groupId = Text
pGroupId_,
      $sel:userRules:RevokeIpRules' :: [Text]
userRules = forall a. Monoid a => a
Prelude.mempty
    }

-- | The identifier of the group.
revokeIpRules_groupId :: Lens.Lens' RevokeIpRules Prelude.Text
revokeIpRules_groupId :: Lens' RevokeIpRules Text
revokeIpRules_groupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeIpRules' {Text
groupId :: Text
$sel:groupId:RevokeIpRules' :: RevokeIpRules -> Text
groupId} -> Text
groupId) (\s :: RevokeIpRules
s@RevokeIpRules' {} Text
a -> RevokeIpRules
s {$sel:groupId:RevokeIpRules' :: Text
groupId = Text
a} :: RevokeIpRules)

-- | The rules to remove from the group.
revokeIpRules_userRules :: Lens.Lens' RevokeIpRules [Prelude.Text]
revokeIpRules_userRules :: Lens' RevokeIpRules [Text]
revokeIpRules_userRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevokeIpRules' {[Text]
userRules :: [Text]
$sel:userRules:RevokeIpRules' :: RevokeIpRules -> [Text]
userRules} -> [Text]
userRules) (\s :: RevokeIpRules
s@RevokeIpRules' {} [Text]
a -> RevokeIpRules
s {$sel:userRules:RevokeIpRules' :: [Text]
userRules = [Text]
a} :: RevokeIpRules) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest RevokeIpRules where
  type
    AWSResponse RevokeIpRules =
      RevokeIpRulesResponse
  request :: (Service -> Service) -> RevokeIpRules -> Request RevokeIpRules
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RevokeIpRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RevokeIpRules)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RevokeIpRulesResponse
RevokeIpRulesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable RevokeIpRules where
  hashWithSalt :: Int -> RevokeIpRules -> Int
hashWithSalt Int
_salt RevokeIpRules' {[Text]
Text
userRules :: [Text]
groupId :: Text
$sel:userRules:RevokeIpRules' :: RevokeIpRules -> [Text]
$sel:groupId:RevokeIpRules' :: RevokeIpRules -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
groupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
userRules

instance Prelude.NFData RevokeIpRules where
  rnf :: RevokeIpRules -> ()
rnf RevokeIpRules' {[Text]
Text
userRules :: [Text]
groupId :: Text
$sel:userRules:RevokeIpRules' :: RevokeIpRules -> [Text]
$sel:groupId:RevokeIpRules' :: RevokeIpRules -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
groupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
userRules

instance Data.ToHeaders RevokeIpRules where
  toHeaders :: RevokeIpRules -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"WorkspacesService.RevokeIpRules" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON RevokeIpRules where
  toJSON :: RevokeIpRules -> Value
toJSON RevokeIpRules' {[Text]
Text
userRules :: [Text]
groupId :: Text
$sel:userRules:RevokeIpRules' :: RevokeIpRules -> [Text]
$sel:groupId:RevokeIpRules' :: RevokeIpRules -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"GroupId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
groupId),
            forall a. a -> Maybe a
Prelude.Just (Key
"UserRules" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
userRules)
          ]
      )

instance Data.ToPath RevokeIpRules where
  toPath :: RevokeIpRules -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'RevokeIpRulesResponse' 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', 'revokeIpRulesResponse_httpStatus' - The response's http status code.
newRevokeIpRulesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RevokeIpRulesResponse
newRevokeIpRulesResponse :: Int -> RevokeIpRulesResponse
newRevokeIpRulesResponse Int
pHttpStatus_ =
  RevokeIpRulesResponse' {$sel:httpStatus:RevokeIpRulesResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData RevokeIpRulesResponse where
  rnf :: RevokeIpRulesResponse -> ()
rnf RevokeIpRulesResponse' {Int
httpStatus :: Int
$sel:httpStatus:RevokeIpRulesResponse' :: RevokeIpRulesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus