{-# 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.OpsWorks.UnassignInstance
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Unassigns a registered instance from all layers that are using the
-- instance. The instance remains in the stack as an unassigned instance,
-- and can be assigned to another layer as needed. You cannot use this
-- action with instances that were created with AWS OpsWorks Stacks.
--
-- __Required Permissions__: To use this action, an IAM user must have a
-- Manage permissions level for the stack or an attached policy that
-- explicitly grants permissions. For more information about user
-- permissions, see
-- <https://docs.aws.amazon.com/opsworks/latest/userguide/opsworks-security-users.html Managing User Permissions>.
module Amazonka.OpsWorks.UnassignInstance
  ( -- * Creating a Request
    UnassignInstance (..),
    newUnassignInstance,

    -- * Request Lenses
    unassignInstance_instanceId,

    -- * Destructuring the Response
    UnassignInstanceResponse (..),
    newUnassignInstanceResponse,
  )
where

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

-- | /See:/ 'newUnassignInstance' smart constructor.
data UnassignInstance = UnassignInstance'
  { -- | The instance ID.
    UnassignInstance -> Text
instanceId :: Prelude.Text
  }
  deriving (UnassignInstance -> UnassignInstance -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnassignInstance -> UnassignInstance -> Bool
$c/= :: UnassignInstance -> UnassignInstance -> Bool
== :: UnassignInstance -> UnassignInstance -> Bool
$c== :: UnassignInstance -> UnassignInstance -> Bool
Prelude.Eq, ReadPrec [UnassignInstance]
ReadPrec UnassignInstance
Int -> ReadS UnassignInstance
ReadS [UnassignInstance]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnassignInstance]
$creadListPrec :: ReadPrec [UnassignInstance]
readPrec :: ReadPrec UnassignInstance
$creadPrec :: ReadPrec UnassignInstance
readList :: ReadS [UnassignInstance]
$creadList :: ReadS [UnassignInstance]
readsPrec :: Int -> ReadS UnassignInstance
$creadsPrec :: Int -> ReadS UnassignInstance
Prelude.Read, Int -> UnassignInstance -> ShowS
[UnassignInstance] -> ShowS
UnassignInstance -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnassignInstance] -> ShowS
$cshowList :: [UnassignInstance] -> ShowS
show :: UnassignInstance -> String
$cshow :: UnassignInstance -> String
showsPrec :: Int -> UnassignInstance -> ShowS
$cshowsPrec :: Int -> UnassignInstance -> ShowS
Prelude.Show, forall x. Rep UnassignInstance x -> UnassignInstance
forall x. UnassignInstance -> Rep UnassignInstance x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnassignInstance x -> UnassignInstance
$cfrom :: forall x. UnassignInstance -> Rep UnassignInstance x
Prelude.Generic)

-- |
-- Create a value of 'UnassignInstance' 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:
--
-- 'instanceId', 'unassignInstance_instanceId' - The instance ID.
newUnassignInstance ::
  -- | 'instanceId'
  Prelude.Text ->
  UnassignInstance
newUnassignInstance :: Text -> UnassignInstance
newUnassignInstance Text
pInstanceId_ =
  UnassignInstance' {$sel:instanceId:UnassignInstance' :: Text
instanceId = Text
pInstanceId_}

-- | The instance ID.
unassignInstance_instanceId :: Lens.Lens' UnassignInstance Prelude.Text
unassignInstance_instanceId :: Lens' UnassignInstance Text
unassignInstance_instanceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UnassignInstance' {Text
instanceId :: Text
$sel:instanceId:UnassignInstance' :: UnassignInstance -> Text
instanceId} -> Text
instanceId) (\s :: UnassignInstance
s@UnassignInstance' {} Text
a -> UnassignInstance
s {$sel:instanceId:UnassignInstance' :: Text
instanceId = Text
a} :: UnassignInstance)

instance Core.AWSRequest UnassignInstance where
  type
    AWSResponse UnassignInstance =
      UnassignInstanceResponse
  request :: (Service -> Service)
-> UnassignInstance -> Request UnassignInstance
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UnassignInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnassignInstance)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UnassignInstanceResponse
UnassignInstanceResponse'

instance Prelude.Hashable UnassignInstance where
  hashWithSalt :: Int -> UnassignInstance -> Int
hashWithSalt Int
_salt UnassignInstance' {Text
instanceId :: Text
$sel:instanceId:UnassignInstance' :: UnassignInstance -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
instanceId

instance Prelude.NFData UnassignInstance where
  rnf :: UnassignInstance -> ()
rnf UnassignInstance' {Text
instanceId :: Text
$sel:instanceId:UnassignInstance' :: UnassignInstance -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
instanceId

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

instance Data.ToJSON UnassignInstance where
  toJSON :: UnassignInstance -> Value
toJSON UnassignInstance' {Text
instanceId :: Text
$sel:instanceId:UnassignInstance' :: UnassignInstance -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"InstanceId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
instanceId)]
      )

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

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

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

-- |
-- Create a value of 'UnassignInstanceResponse' 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.
newUnassignInstanceResponse ::
  UnassignInstanceResponse
newUnassignInstanceResponse :: UnassignInstanceResponse
newUnassignInstanceResponse =
  UnassignInstanceResponse
UnassignInstanceResponse'

instance Prelude.NFData UnassignInstanceResponse where
  rnf :: UnassignInstanceResponse -> ()
rnf UnassignInstanceResponse
_ = ()