{-# 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-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)
--
-- 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.Lens as Lens
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
(UnassignInstance -> UnassignInstance -> Bool)
-> (UnassignInstance -> UnassignInstance -> Bool)
-> Eq UnassignInstance
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]
(Int -> ReadS UnassignInstance)
-> ReadS [UnassignInstance]
-> ReadPrec UnassignInstance
-> ReadPrec [UnassignInstance]
-> Read 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
(Int -> UnassignInstance -> ShowS)
-> (UnassignInstance -> String)
-> ([UnassignInstance] -> ShowS)
-> Show UnassignInstance
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. UnassignInstance -> Rep UnassignInstance x)
-> (forall x. Rep UnassignInstance x -> UnassignInstance)
-> Generic UnassignInstance
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' :: Text -> UnassignInstance
UnassignInstance' {$sel:instanceId:UnassignInstance' :: Text
instanceId = Text
pInstanceId_}

-- | The instance ID.
unassignInstance_instanceId :: Lens.Lens' UnassignInstance Prelude.Text
unassignInstance_instanceId :: (Text -> f Text) -> UnassignInstance -> f UnassignInstance
unassignInstance_instanceId = (UnassignInstance -> Text)
-> (UnassignInstance -> Text -> UnassignInstance)
-> Lens UnassignInstance UnassignInstance Text Text
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 :: UnassignInstance -> Request UnassignInstance
request = Service -> UnassignInstance -> Request UnassignInstance
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UnassignInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnassignInstance)))
response =
    AWSResponse UnassignInstance
-> Logger
-> Service
-> Proxy UnassignInstance
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UnassignInstance)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UnassignInstance
UnassignInstanceResponse
UnassignInstanceResponse'

instance Prelude.Hashable UnassignInstance

instance Prelude.NFData UnassignInstance

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

instance Core.ToJSON UnassignInstance where
  toJSON :: UnassignInstance -> Value
toJSON UnassignInstance' {Text
instanceId :: Text
$sel:instanceId:UnassignInstance' :: UnassignInstance -> 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
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId)]
      )

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

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

-- | /See:/ 'newUnassignInstanceResponse' smart constructor.
data UnassignInstanceResponse = UnassignInstanceResponse'
  {
  }
  deriving (UnassignInstanceResponse -> UnassignInstanceResponse -> Bool
(UnassignInstanceResponse -> UnassignInstanceResponse -> Bool)
-> (UnassignInstanceResponse -> UnassignInstanceResponse -> Bool)
-> Eq UnassignInstanceResponse
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]
(Int -> ReadS UnassignInstanceResponse)
-> ReadS [UnassignInstanceResponse]
-> ReadPrec UnassignInstanceResponse
-> ReadPrec [UnassignInstanceResponse]
-> Read 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
(Int -> UnassignInstanceResponse -> ShowS)
-> (UnassignInstanceResponse -> String)
-> ([UnassignInstanceResponse] -> ShowS)
-> Show UnassignInstanceResponse
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.
 UnassignInstanceResponse -> Rep UnassignInstanceResponse x)
-> (forall x.
    Rep UnassignInstanceResponse x -> UnassignInstanceResponse)
-> Generic UnassignInstanceResponse
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