{-# 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.DisassociateIpGroups
-- 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)
--
-- Disassociates the specified IP access control group from the specified
-- directory.
module Amazonka.WorkSpaces.DisassociateIpGroups
  ( -- * Creating a Request
    DisassociateIpGroups (..),
    newDisassociateIpGroups,

    -- * Request Lenses
    disassociateIpGroups_directoryId,
    disassociateIpGroups_groupIds,

    -- * Destructuring the Response
    DisassociateIpGroupsResponse (..),
    newDisassociateIpGroupsResponse,

    -- * Response Lenses
    disassociateIpGroupsResponse_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:/ 'newDisassociateIpGroups' smart constructor.
data DisassociateIpGroups = DisassociateIpGroups'
  { -- | The identifier of the directory.
    DisassociateIpGroups -> Text
directoryId :: Prelude.Text,
    -- | The identifiers of one or more IP access control groups.
    DisassociateIpGroups -> [Text]
groupIds :: [Prelude.Text]
  }
  deriving (DisassociateIpGroups -> DisassociateIpGroups -> Bool
(DisassociateIpGroups -> DisassociateIpGroups -> Bool)
-> (DisassociateIpGroups -> DisassociateIpGroups -> Bool)
-> Eq DisassociateIpGroups
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DisassociateIpGroups -> DisassociateIpGroups -> Bool
$c/= :: DisassociateIpGroups -> DisassociateIpGroups -> Bool
== :: DisassociateIpGroups -> DisassociateIpGroups -> Bool
$c== :: DisassociateIpGroups -> DisassociateIpGroups -> Bool
Prelude.Eq, ReadPrec [DisassociateIpGroups]
ReadPrec DisassociateIpGroups
Int -> ReadS DisassociateIpGroups
ReadS [DisassociateIpGroups]
(Int -> ReadS DisassociateIpGroups)
-> ReadS [DisassociateIpGroups]
-> ReadPrec DisassociateIpGroups
-> ReadPrec [DisassociateIpGroups]
-> Read DisassociateIpGroups
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DisassociateIpGroups]
$creadListPrec :: ReadPrec [DisassociateIpGroups]
readPrec :: ReadPrec DisassociateIpGroups
$creadPrec :: ReadPrec DisassociateIpGroups
readList :: ReadS [DisassociateIpGroups]
$creadList :: ReadS [DisassociateIpGroups]
readsPrec :: Int -> ReadS DisassociateIpGroups
$creadsPrec :: Int -> ReadS DisassociateIpGroups
Prelude.Read, Int -> DisassociateIpGroups -> ShowS
[DisassociateIpGroups] -> ShowS
DisassociateIpGroups -> String
(Int -> DisassociateIpGroups -> ShowS)
-> (DisassociateIpGroups -> String)
-> ([DisassociateIpGroups] -> ShowS)
-> Show DisassociateIpGroups
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DisassociateIpGroups] -> ShowS
$cshowList :: [DisassociateIpGroups] -> ShowS
show :: DisassociateIpGroups -> String
$cshow :: DisassociateIpGroups -> String
showsPrec :: Int -> DisassociateIpGroups -> ShowS
$cshowsPrec :: Int -> DisassociateIpGroups -> ShowS
Prelude.Show, (forall x. DisassociateIpGroups -> Rep DisassociateIpGroups x)
-> (forall x. Rep DisassociateIpGroups x -> DisassociateIpGroups)
-> Generic DisassociateIpGroups
forall x. Rep DisassociateIpGroups x -> DisassociateIpGroups
forall x. DisassociateIpGroups -> Rep DisassociateIpGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DisassociateIpGroups x -> DisassociateIpGroups
$cfrom :: forall x. DisassociateIpGroups -> Rep DisassociateIpGroups x
Prelude.Generic)

-- |
-- Create a value of 'DisassociateIpGroups' 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:
--
-- 'directoryId', 'disassociateIpGroups_directoryId' - The identifier of the directory.
--
-- 'groupIds', 'disassociateIpGroups_groupIds' - The identifiers of one or more IP access control groups.
newDisassociateIpGroups ::
  -- | 'directoryId'
  Prelude.Text ->
  DisassociateIpGroups
newDisassociateIpGroups :: Text -> DisassociateIpGroups
newDisassociateIpGroups Text
pDirectoryId_ =
  DisassociateIpGroups' :: Text -> [Text] -> DisassociateIpGroups
DisassociateIpGroups'
    { $sel:directoryId:DisassociateIpGroups' :: Text
directoryId = Text
pDirectoryId_,
      $sel:groupIds:DisassociateIpGroups' :: [Text]
groupIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The identifier of the directory.
disassociateIpGroups_directoryId :: Lens.Lens' DisassociateIpGroups Prelude.Text
disassociateIpGroups_directoryId :: (Text -> f Text) -> DisassociateIpGroups -> f DisassociateIpGroups
disassociateIpGroups_directoryId = (DisassociateIpGroups -> Text)
-> (DisassociateIpGroups -> Text -> DisassociateIpGroups)
-> Lens DisassociateIpGroups DisassociateIpGroups Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateIpGroups' {Text
directoryId :: Text
$sel:directoryId:DisassociateIpGroups' :: DisassociateIpGroups -> Text
directoryId} -> Text
directoryId) (\s :: DisassociateIpGroups
s@DisassociateIpGroups' {} Text
a -> DisassociateIpGroups
s {$sel:directoryId:DisassociateIpGroups' :: Text
directoryId = Text
a} :: DisassociateIpGroups)

-- | The identifiers of one or more IP access control groups.
disassociateIpGroups_groupIds :: Lens.Lens' DisassociateIpGroups [Prelude.Text]
disassociateIpGroups_groupIds :: ([Text] -> f [Text])
-> DisassociateIpGroups -> f DisassociateIpGroups
disassociateIpGroups_groupIds = (DisassociateIpGroups -> [Text])
-> (DisassociateIpGroups -> [Text] -> DisassociateIpGroups)
-> Lens DisassociateIpGroups DisassociateIpGroups [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DisassociateIpGroups' {[Text]
groupIds :: [Text]
$sel:groupIds:DisassociateIpGroups' :: DisassociateIpGroups -> [Text]
groupIds} -> [Text]
groupIds) (\s :: DisassociateIpGroups
s@DisassociateIpGroups' {} [Text]
a -> DisassociateIpGroups
s {$sel:groupIds:DisassociateIpGroups' :: [Text]
groupIds = [Text]
a} :: DisassociateIpGroups) (([Text] -> f [Text])
 -> DisassociateIpGroups -> f DisassociateIpGroups)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DisassociateIpGroups
-> f DisassociateIpGroups
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 DisassociateIpGroups where
  type
    AWSResponse DisassociateIpGroups =
      DisassociateIpGroupsResponse
  request :: DisassociateIpGroups -> Request DisassociateIpGroups
request = Service -> DisassociateIpGroups -> Request DisassociateIpGroups
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DisassociateIpGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateIpGroups)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DisassociateIpGroups))
-> Logger
-> Service
-> Proxy DisassociateIpGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DisassociateIpGroups)))
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 -> DisassociateIpGroupsResponse
DisassociateIpGroupsResponse'
            (Int -> DisassociateIpGroupsResponse)
-> Either String Int -> Either String DisassociateIpGroupsResponse
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 DisassociateIpGroups

instance Prelude.NFData DisassociateIpGroups

instance Core.ToHeaders DisassociateIpGroups where
  toHeaders :: DisassociateIpGroups -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DisassociateIpGroups -> 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.DisassociateIpGroups" ::
                          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 DisassociateIpGroups where
  toJSON :: DisassociateIpGroups -> Value
toJSON DisassociateIpGroups' {[Text]
Text
groupIds :: [Text]
directoryId :: Text
$sel:groupIds:DisassociateIpGroups' :: DisassociateIpGroups -> [Text]
$sel:directoryId:DisassociateIpGroups' :: DisassociateIpGroups -> 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
"DirectoryId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
directoryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"GroupIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
groupIds)
          ]
      )

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

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

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

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

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

instance Prelude.NFData DisassociateIpGroupsResponse