{-# 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.IoT.RemoveThingFromThingGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Remove the specified thing from the specified group.
--
-- You must specify either a @thingGroupArn@ or a @thingGroupName@ to
-- identify the thing group and either a @thingArn@ or a @thingName@ to
-- identify the thing to remove from the thing group.
--
-- Requires permission to access the
-- <https://docs.aws.amazon.com/service-authorization/latest/reference/list_awsiot.html#awsiot-actions-as-permissions RemoveThingFromThingGroup>
-- action.
module Amazonka.IoT.RemoveThingFromThingGroup
  ( -- * Creating a Request
    RemoveThingFromThingGroup (..),
    newRemoveThingFromThingGroup,

    -- * Request Lenses
    removeThingFromThingGroup_thingArn,
    removeThingFromThingGroup_thingGroupArn,
    removeThingFromThingGroup_thingGroupName,
    removeThingFromThingGroup_thingName,

    -- * Destructuring the Response
    RemoveThingFromThingGroupResponse (..),
    newRemoveThingFromThingGroupResponse,

    -- * Response Lenses
    removeThingFromThingGroupResponse_httpStatus,
  )
where

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

-- | /See:/ 'newRemoveThingFromThingGroup' smart constructor.
data RemoveThingFromThingGroup = RemoveThingFromThingGroup'
  { -- | The ARN of the thing to remove from the group.
    RemoveThingFromThingGroup -> Maybe Text
thingArn :: Prelude.Maybe Prelude.Text,
    -- | The group ARN.
    RemoveThingFromThingGroup -> Maybe Text
thingGroupArn :: Prelude.Maybe Prelude.Text,
    -- | The group name.
    RemoveThingFromThingGroup -> Maybe Text
thingGroupName :: Prelude.Maybe Prelude.Text,
    -- | The name of the thing to remove from the group.
    RemoveThingFromThingGroup -> Maybe Text
thingName :: Prelude.Maybe Prelude.Text
  }
  deriving (RemoveThingFromThingGroup -> RemoveThingFromThingGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveThingFromThingGroup -> RemoveThingFromThingGroup -> Bool
$c/= :: RemoveThingFromThingGroup -> RemoveThingFromThingGroup -> Bool
== :: RemoveThingFromThingGroup -> RemoveThingFromThingGroup -> Bool
$c== :: RemoveThingFromThingGroup -> RemoveThingFromThingGroup -> Bool
Prelude.Eq, ReadPrec [RemoveThingFromThingGroup]
ReadPrec RemoveThingFromThingGroup
Int -> ReadS RemoveThingFromThingGroup
ReadS [RemoveThingFromThingGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveThingFromThingGroup]
$creadListPrec :: ReadPrec [RemoveThingFromThingGroup]
readPrec :: ReadPrec RemoveThingFromThingGroup
$creadPrec :: ReadPrec RemoveThingFromThingGroup
readList :: ReadS [RemoveThingFromThingGroup]
$creadList :: ReadS [RemoveThingFromThingGroup]
readsPrec :: Int -> ReadS RemoveThingFromThingGroup
$creadsPrec :: Int -> ReadS RemoveThingFromThingGroup
Prelude.Read, Int -> RemoveThingFromThingGroup -> ShowS
[RemoveThingFromThingGroup] -> ShowS
RemoveThingFromThingGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveThingFromThingGroup] -> ShowS
$cshowList :: [RemoveThingFromThingGroup] -> ShowS
show :: RemoveThingFromThingGroup -> String
$cshow :: RemoveThingFromThingGroup -> String
showsPrec :: Int -> RemoveThingFromThingGroup -> ShowS
$cshowsPrec :: Int -> RemoveThingFromThingGroup -> ShowS
Prelude.Show, forall x.
Rep RemoveThingFromThingGroup x -> RemoveThingFromThingGroup
forall x.
RemoveThingFromThingGroup -> Rep RemoveThingFromThingGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveThingFromThingGroup x -> RemoveThingFromThingGroup
$cfrom :: forall x.
RemoveThingFromThingGroup -> Rep RemoveThingFromThingGroup x
Prelude.Generic)

-- |
-- Create a value of 'RemoveThingFromThingGroup' 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:
--
-- 'thingArn', 'removeThingFromThingGroup_thingArn' - The ARN of the thing to remove from the group.
--
-- 'thingGroupArn', 'removeThingFromThingGroup_thingGroupArn' - The group ARN.
--
-- 'thingGroupName', 'removeThingFromThingGroup_thingGroupName' - The group name.
--
-- 'thingName', 'removeThingFromThingGroup_thingName' - The name of the thing to remove from the group.
newRemoveThingFromThingGroup ::
  RemoveThingFromThingGroup
newRemoveThingFromThingGroup :: RemoveThingFromThingGroup
newRemoveThingFromThingGroup =
  RemoveThingFromThingGroup'
    { $sel:thingArn:RemoveThingFromThingGroup' :: Maybe Text
thingArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupArn:RemoveThingFromThingGroup' :: Maybe Text
thingGroupArn = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupName:RemoveThingFromThingGroup' :: Maybe Text
thingGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:thingName:RemoveThingFromThingGroup' :: Maybe Text
thingName = forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the thing to remove from the group.
removeThingFromThingGroup_thingArn :: Lens.Lens' RemoveThingFromThingGroup (Prelude.Maybe Prelude.Text)
removeThingFromThingGroup_thingArn :: Lens' RemoveThingFromThingGroup (Maybe Text)
removeThingFromThingGroup_thingArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveThingFromThingGroup' {Maybe Text
thingArn :: Maybe Text
$sel:thingArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
thingArn} -> Maybe Text
thingArn) (\s :: RemoveThingFromThingGroup
s@RemoveThingFromThingGroup' {} Maybe Text
a -> RemoveThingFromThingGroup
s {$sel:thingArn:RemoveThingFromThingGroup' :: Maybe Text
thingArn = Maybe Text
a} :: RemoveThingFromThingGroup)

-- | The group ARN.
removeThingFromThingGroup_thingGroupArn :: Lens.Lens' RemoveThingFromThingGroup (Prelude.Maybe Prelude.Text)
removeThingFromThingGroup_thingGroupArn :: Lens' RemoveThingFromThingGroup (Maybe Text)
removeThingFromThingGroup_thingGroupArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveThingFromThingGroup' {Maybe Text
thingGroupArn :: Maybe Text
$sel:thingGroupArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
thingGroupArn} -> Maybe Text
thingGroupArn) (\s :: RemoveThingFromThingGroup
s@RemoveThingFromThingGroup' {} Maybe Text
a -> RemoveThingFromThingGroup
s {$sel:thingGroupArn:RemoveThingFromThingGroup' :: Maybe Text
thingGroupArn = Maybe Text
a} :: RemoveThingFromThingGroup)

-- | The group name.
removeThingFromThingGroup_thingGroupName :: Lens.Lens' RemoveThingFromThingGroup (Prelude.Maybe Prelude.Text)
removeThingFromThingGroup_thingGroupName :: Lens' RemoveThingFromThingGroup (Maybe Text)
removeThingFromThingGroup_thingGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveThingFromThingGroup' {Maybe Text
thingGroupName :: Maybe Text
$sel:thingGroupName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
thingGroupName} -> Maybe Text
thingGroupName) (\s :: RemoveThingFromThingGroup
s@RemoveThingFromThingGroup' {} Maybe Text
a -> RemoveThingFromThingGroup
s {$sel:thingGroupName:RemoveThingFromThingGroup' :: Maybe Text
thingGroupName = Maybe Text
a} :: RemoveThingFromThingGroup)

-- | The name of the thing to remove from the group.
removeThingFromThingGroup_thingName :: Lens.Lens' RemoveThingFromThingGroup (Prelude.Maybe Prelude.Text)
removeThingFromThingGroup_thingName :: Lens' RemoveThingFromThingGroup (Maybe Text)
removeThingFromThingGroup_thingName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveThingFromThingGroup' {Maybe Text
thingName :: Maybe Text
$sel:thingName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
thingName} -> Maybe Text
thingName) (\s :: RemoveThingFromThingGroup
s@RemoveThingFromThingGroup' {} Maybe Text
a -> RemoveThingFromThingGroup
s {$sel:thingName:RemoveThingFromThingGroup' :: Maybe Text
thingName = Maybe Text
a} :: RemoveThingFromThingGroup)

instance Core.AWSRequest RemoveThingFromThingGroup where
  type
    AWSResponse RemoveThingFromThingGroup =
      RemoveThingFromThingGroupResponse
  request :: (Service -> Service)
-> RemoveThingFromThingGroup -> Request RemoveThingFromThingGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RemoveThingFromThingGroup
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveThingFromThingGroup)))
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 -> RemoveThingFromThingGroupResponse
RemoveThingFromThingGroupResponse'
            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 RemoveThingFromThingGroup where
  hashWithSalt :: Int -> RemoveThingFromThingGroup -> Int
hashWithSalt Int
_salt RemoveThingFromThingGroup' {Maybe Text
thingName :: Maybe Text
thingGroupName :: Maybe Text
thingGroupArn :: Maybe Text
thingArn :: Maybe Text
$sel:thingName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingName

instance Prelude.NFData RemoveThingFromThingGroup where
  rnf :: RemoveThingFromThingGroup -> ()
rnf RemoveThingFromThingGroup' {Maybe Text
thingName :: Maybe Text
thingGroupName :: Maybe Text
thingGroupArn :: Maybe Text
thingArn :: Maybe Text
$sel:thingName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingName

instance Data.ToHeaders RemoveThingFromThingGroup where
  toHeaders :: RemoveThingFromThingGroup -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON RemoveThingFromThingGroup where
  toJSON :: RemoveThingFromThingGroup -> Value
toJSON RemoveThingFromThingGroup' {Maybe Text
thingName :: Maybe Text
thingGroupName :: Maybe Text
thingGroupArn :: Maybe Text
thingArn :: Maybe Text
$sel:thingName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupName:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingGroupArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
$sel:thingArn:RemoveThingFromThingGroup' :: RemoveThingFromThingGroup -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"thingArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingArn,
            (Key
"thingGroupArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingGroupArn,
            (Key
"thingGroupName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingGroupName,
            (Key
"thingName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingName
          ]
      )

instance Data.ToPath RemoveThingFromThingGroup where
  toPath :: RemoveThingFromThingGroup -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/thing-groups/removeThingFromThingGroup"

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

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

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

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

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