{-# 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-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)
--
-- 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.Lens as Lens
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
(RevokeIpRules -> RevokeIpRules -> Bool)
-> (RevokeIpRules -> RevokeIpRules -> Bool) -> Eq RevokeIpRules
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]
(Int -> ReadS RevokeIpRules)
-> ReadS [RevokeIpRules]
-> ReadPrec RevokeIpRules
-> ReadPrec [RevokeIpRules]
-> Read 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
(Int -> RevokeIpRules -> ShowS)
-> (RevokeIpRules -> String)
-> ([RevokeIpRules] -> ShowS)
-> Show RevokeIpRules
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. RevokeIpRules -> Rep RevokeIpRules x)
-> (forall x. Rep RevokeIpRules x -> RevokeIpRules)
-> Generic RevokeIpRules
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' :: Text -> [Text] -> RevokeIpRules
RevokeIpRules'
    { $sel:groupId:RevokeIpRules' :: Text
groupId = Text
pGroupId_,
      $sel:userRules:RevokeIpRules' :: [Text]
userRules = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The identifier of the group.
revokeIpRules_groupId :: Lens.Lens' RevokeIpRules Prelude.Text
revokeIpRules_groupId :: (Text -> f Text) -> RevokeIpRules -> f RevokeIpRules
revokeIpRules_groupId = (RevokeIpRules -> Text)
-> (RevokeIpRules -> Text -> RevokeIpRules)
-> Lens RevokeIpRules RevokeIpRules Text Text
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 :: ([Text] -> f [Text]) -> RevokeIpRules -> f RevokeIpRules
revokeIpRules_userRules = (RevokeIpRules -> [Text])
-> (RevokeIpRules -> [Text] -> RevokeIpRules)
-> Lens RevokeIpRules RevokeIpRules [Text] [Text]
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) (([Text] -> f [Text]) -> RevokeIpRules -> f RevokeIpRules)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> RevokeIpRules
-> f RevokeIpRules
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 Core.AWSRequest RevokeIpRules where
  type
    AWSResponse RevokeIpRules =
      RevokeIpRulesResponse
  request :: RevokeIpRules -> Request RevokeIpRules
request = Service -> RevokeIpRules -> Request RevokeIpRules
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RevokeIpRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RevokeIpRules)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RevokeIpRules))
-> Logger
-> Service
-> Proxy RevokeIpRules
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RevokeIpRules)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RevokeIpRulesResponse
RevokeIpRulesResponse'
            (Int -> RevokeIpRulesResponse)
-> Either String Int -> Either String RevokeIpRulesResponse
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))
      )

instance Prelude.Hashable RevokeIpRules

instance Prelude.NFData RevokeIpRules

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

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserRules" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
userRules)
          ]
      )

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

instance Core.ToQuery RevokeIpRules where
  toQuery :: RevokeIpRules -> QueryString
toQuery = QueryString -> RevokeIpRules -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(RevokeIpRulesResponse -> RevokeIpRulesResponse -> Bool)
-> (RevokeIpRulesResponse -> RevokeIpRulesResponse -> Bool)
-> Eq RevokeIpRulesResponse
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]
(Int -> ReadS RevokeIpRulesResponse)
-> ReadS [RevokeIpRulesResponse]
-> ReadPrec RevokeIpRulesResponse
-> ReadPrec [RevokeIpRulesResponse]
-> Read 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
(Int -> RevokeIpRulesResponse -> ShowS)
-> (RevokeIpRulesResponse -> String)
-> ([RevokeIpRulesResponse] -> ShowS)
-> Show RevokeIpRulesResponse
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. RevokeIpRulesResponse -> Rep RevokeIpRulesResponse x)
-> (forall x. Rep RevokeIpRulesResponse x -> RevokeIpRulesResponse)
-> Generic RevokeIpRulesResponse
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' :: Int -> RevokeIpRulesResponse
RevokeIpRulesResponse' {$sel:httpStatus:RevokeIpRulesResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
revokeIpRulesResponse_httpStatus :: Lens.Lens' RevokeIpRulesResponse Prelude.Int
revokeIpRulesResponse_httpStatus :: (Int -> f Int) -> RevokeIpRulesResponse -> f RevokeIpRulesResponse
revokeIpRulesResponse_httpStatus = (RevokeIpRulesResponse -> Int)
-> (RevokeIpRulesResponse -> Int -> RevokeIpRulesResponse)
-> Lens RevokeIpRulesResponse RevokeIpRulesResponse Int Int
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