{-# 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.IoTThingsGraph.DissociateEntityFromThing
-- 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)
--
-- Dissociates a device entity from a concrete thing. The action takes only
-- the type of the entity that you need to dissociate because only one
-- entity of a particular type can be associated with a thing.
module Amazonka.IoTThingsGraph.DissociateEntityFromThing
  ( -- * Creating a Request
    DissociateEntityFromThing (..),
    newDissociateEntityFromThing,

    -- * Request Lenses
    dissociateEntityFromThing_thingName,
    dissociateEntityFromThing_entityType,

    -- * Destructuring the Response
    DissociateEntityFromThingResponse (..),
    newDissociateEntityFromThingResponse,

    -- * Response Lenses
    dissociateEntityFromThingResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTThingsGraph.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDissociateEntityFromThing' smart constructor.
data DissociateEntityFromThing = DissociateEntityFromThing'
  { -- | The name of the thing to disassociate.
    DissociateEntityFromThing -> Text
thingName :: Prelude.Text,
    -- | The entity type from which to disassociate the thing.
    DissociateEntityFromThing -> EntityType
entityType :: EntityType
  }
  deriving (DissociateEntityFromThing -> DissociateEntityFromThing -> Bool
(DissociateEntityFromThing -> DissociateEntityFromThing -> Bool)
-> (DissociateEntityFromThing -> DissociateEntityFromThing -> Bool)
-> Eq DissociateEntityFromThing
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DissociateEntityFromThing -> DissociateEntityFromThing -> Bool
$c/= :: DissociateEntityFromThing -> DissociateEntityFromThing -> Bool
== :: DissociateEntityFromThing -> DissociateEntityFromThing -> Bool
$c== :: DissociateEntityFromThing -> DissociateEntityFromThing -> Bool
Prelude.Eq, ReadPrec [DissociateEntityFromThing]
ReadPrec DissociateEntityFromThing
Int -> ReadS DissociateEntityFromThing
ReadS [DissociateEntityFromThing]
(Int -> ReadS DissociateEntityFromThing)
-> ReadS [DissociateEntityFromThing]
-> ReadPrec DissociateEntityFromThing
-> ReadPrec [DissociateEntityFromThing]
-> Read DissociateEntityFromThing
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DissociateEntityFromThing]
$creadListPrec :: ReadPrec [DissociateEntityFromThing]
readPrec :: ReadPrec DissociateEntityFromThing
$creadPrec :: ReadPrec DissociateEntityFromThing
readList :: ReadS [DissociateEntityFromThing]
$creadList :: ReadS [DissociateEntityFromThing]
readsPrec :: Int -> ReadS DissociateEntityFromThing
$creadsPrec :: Int -> ReadS DissociateEntityFromThing
Prelude.Read, Int -> DissociateEntityFromThing -> ShowS
[DissociateEntityFromThing] -> ShowS
DissociateEntityFromThing -> String
(Int -> DissociateEntityFromThing -> ShowS)
-> (DissociateEntityFromThing -> String)
-> ([DissociateEntityFromThing] -> ShowS)
-> Show DissociateEntityFromThing
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DissociateEntityFromThing] -> ShowS
$cshowList :: [DissociateEntityFromThing] -> ShowS
show :: DissociateEntityFromThing -> String
$cshow :: DissociateEntityFromThing -> String
showsPrec :: Int -> DissociateEntityFromThing -> ShowS
$cshowsPrec :: Int -> DissociateEntityFromThing -> ShowS
Prelude.Show, (forall x.
 DissociateEntityFromThing -> Rep DissociateEntityFromThing x)
-> (forall x.
    Rep DissociateEntityFromThing x -> DissociateEntityFromThing)
-> Generic DissociateEntityFromThing
forall x.
Rep DissociateEntityFromThing x -> DissociateEntityFromThing
forall x.
DissociateEntityFromThing -> Rep DissociateEntityFromThing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DissociateEntityFromThing x -> DissociateEntityFromThing
$cfrom :: forall x.
DissociateEntityFromThing -> Rep DissociateEntityFromThing x
Prelude.Generic)

-- |
-- Create a value of 'DissociateEntityFromThing' 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:
--
-- 'thingName', 'dissociateEntityFromThing_thingName' - The name of the thing to disassociate.
--
-- 'entityType', 'dissociateEntityFromThing_entityType' - The entity type from which to disassociate the thing.
newDissociateEntityFromThing ::
  -- | 'thingName'
  Prelude.Text ->
  -- | 'entityType'
  EntityType ->
  DissociateEntityFromThing
newDissociateEntityFromThing :: Text -> EntityType -> DissociateEntityFromThing
newDissociateEntityFromThing Text
pThingName_ EntityType
pEntityType_ =
  DissociateEntityFromThing' :: Text -> EntityType -> DissociateEntityFromThing
DissociateEntityFromThing'
    { $sel:thingName:DissociateEntityFromThing' :: Text
thingName = Text
pThingName_,
      $sel:entityType:DissociateEntityFromThing' :: EntityType
entityType = EntityType
pEntityType_
    }

-- | The name of the thing to disassociate.
dissociateEntityFromThing_thingName :: Lens.Lens' DissociateEntityFromThing Prelude.Text
dissociateEntityFromThing_thingName :: (Text -> f Text)
-> DissociateEntityFromThing -> f DissociateEntityFromThing
dissociateEntityFromThing_thingName = (DissociateEntityFromThing -> Text)
-> (DissociateEntityFromThing -> Text -> DissociateEntityFromThing)
-> Lens
     DissociateEntityFromThing DissociateEntityFromThing Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DissociateEntityFromThing' {Text
thingName :: Text
$sel:thingName:DissociateEntityFromThing' :: DissociateEntityFromThing -> Text
thingName} -> Text
thingName) (\s :: DissociateEntityFromThing
s@DissociateEntityFromThing' {} Text
a -> DissociateEntityFromThing
s {$sel:thingName:DissociateEntityFromThing' :: Text
thingName = Text
a} :: DissociateEntityFromThing)

-- | The entity type from which to disassociate the thing.
dissociateEntityFromThing_entityType :: Lens.Lens' DissociateEntityFromThing EntityType
dissociateEntityFromThing_entityType :: (EntityType -> f EntityType)
-> DissociateEntityFromThing -> f DissociateEntityFromThing
dissociateEntityFromThing_entityType = (DissociateEntityFromThing -> EntityType)
-> (DissociateEntityFromThing
    -> EntityType -> DissociateEntityFromThing)
-> Lens
     DissociateEntityFromThing
     DissociateEntityFromThing
     EntityType
     EntityType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DissociateEntityFromThing' {EntityType
entityType :: EntityType
$sel:entityType:DissociateEntityFromThing' :: DissociateEntityFromThing -> EntityType
entityType} -> EntityType
entityType) (\s :: DissociateEntityFromThing
s@DissociateEntityFromThing' {} EntityType
a -> DissociateEntityFromThing
s {$sel:entityType:DissociateEntityFromThing' :: EntityType
entityType = EntityType
a} :: DissociateEntityFromThing)

instance Core.AWSRequest DissociateEntityFromThing where
  type
    AWSResponse DissociateEntityFromThing =
      DissociateEntityFromThingResponse
  request :: DissociateEntityFromThing -> Request DissociateEntityFromThing
request = Service
-> DissociateEntityFromThing -> Request DissociateEntityFromThing
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DissociateEntityFromThing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DissociateEntityFromThing)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DissociateEntityFromThing))
-> Logger
-> Service
-> Proxy DissociateEntityFromThing
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DissociateEntityFromThing)))
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 -> DissociateEntityFromThingResponse
DissociateEntityFromThingResponse'
            (Int -> DissociateEntityFromThingResponse)
-> Either String Int
-> Either String DissociateEntityFromThingResponse
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 DissociateEntityFromThing

instance Prelude.NFData DissociateEntityFromThing

instance Core.ToHeaders DissociateEntityFromThing where
  toHeaders :: DissociateEntityFromThing -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DissociateEntityFromThing -> 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
"IotThingsGraphFrontEndService.DissociateEntityFromThing" ::
                          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 DissociateEntityFromThing where
  toJSON :: DissociateEntityFromThing -> Value
toJSON DissociateEntityFromThing' {Text
EntityType
entityType :: EntityType
thingName :: Text
$sel:entityType:DissociateEntityFromThing' :: DissociateEntityFromThing -> EntityType
$sel:thingName:DissociateEntityFromThing' :: DissociateEntityFromThing -> 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
"thingName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
thingName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"entityType" Text -> EntityType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EntityType
entityType)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    DissociateEntityFromThingResponse