{-# 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.AssociateIpGroups
-- 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)
--
-- Associates the specified IP access control group with the specified
-- directory.
module Amazonka.WorkSpaces.AssociateIpGroups
  ( -- * Creating a Request
    AssociateIpGroups (..),
    newAssociateIpGroups,

    -- * Request Lenses
    associateIpGroups_directoryId,
    associateIpGroups_groupIds,

    -- * Destructuring the Response
    AssociateIpGroupsResponse (..),
    newAssociateIpGroupsResponse,

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

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

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

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

instance Prelude.NFData AssociateIpGroups

instance Core.ToHeaders AssociateIpGroups where
  toHeaders :: AssociateIpGroups -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AssociateIpGroups -> 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.AssociateIpGroups" ::
                          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 AssociateIpGroups where
  toJSON :: AssociateIpGroups -> Value
toJSON AssociateIpGroups' {[Text]
Text
groupIds :: [Text]
directoryId :: Text
$sel:groupIds:AssociateIpGroups' :: AssociateIpGroups -> [Text]
$sel:directoryId:AssociateIpGroups' :: AssociateIpGroups -> 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 AssociateIpGroups where
  toPath :: AssociateIpGroups -> ByteString
toPath = ByteString -> AssociateIpGroups -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData AssociateIpGroupsResponse