{-# 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.CodeStarConnections.DeleteHost
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The host to be deleted. Before you delete a host, all connections
-- associated to the host must be deleted.
--
-- A host cannot be deleted if it is in the VPC_CONFIG_INITIALIZING or
-- VPC_CONFIG_DELETING state.
module Amazonka.CodeStarConnections.DeleteHost
  ( -- * Creating a Request
    DeleteHost (..),
    newDeleteHost,

    -- * Request Lenses
    deleteHost_hostArn,

    -- * Destructuring the Response
    DeleteHostResponse (..),
    newDeleteHostResponse,

    -- * Response Lenses
    deleteHostResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteHost' smart constructor.
data DeleteHost = DeleteHost'
  { -- | The Amazon Resource Name (ARN) of the host to be deleted.
    DeleteHost -> Text
hostArn :: Prelude.Text
  }
  deriving (DeleteHost -> DeleteHost -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteHost -> DeleteHost -> Bool
$c/= :: DeleteHost -> DeleteHost -> Bool
== :: DeleteHost -> DeleteHost -> Bool
$c== :: DeleteHost -> DeleteHost -> Bool
Prelude.Eq, ReadPrec [DeleteHost]
ReadPrec DeleteHost
Int -> ReadS DeleteHost
ReadS [DeleteHost]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteHost]
$creadListPrec :: ReadPrec [DeleteHost]
readPrec :: ReadPrec DeleteHost
$creadPrec :: ReadPrec DeleteHost
readList :: ReadS [DeleteHost]
$creadList :: ReadS [DeleteHost]
readsPrec :: Int -> ReadS DeleteHost
$creadsPrec :: Int -> ReadS DeleteHost
Prelude.Read, Int -> DeleteHost -> ShowS
[DeleteHost] -> ShowS
DeleteHost -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteHost] -> ShowS
$cshowList :: [DeleteHost] -> ShowS
show :: DeleteHost -> String
$cshow :: DeleteHost -> String
showsPrec :: Int -> DeleteHost -> ShowS
$cshowsPrec :: Int -> DeleteHost -> ShowS
Prelude.Show, forall x. Rep DeleteHost x -> DeleteHost
forall x. DeleteHost -> Rep DeleteHost x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteHost x -> DeleteHost
$cfrom :: forall x. DeleteHost -> Rep DeleteHost x
Prelude.Generic)

-- |
-- Create a value of 'DeleteHost' 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:
--
-- 'hostArn', 'deleteHost_hostArn' - The Amazon Resource Name (ARN) of the host to be deleted.
newDeleteHost ::
  -- | 'hostArn'
  Prelude.Text ->
  DeleteHost
newDeleteHost :: Text -> DeleteHost
newDeleteHost Text
pHostArn_ =
  DeleteHost' {$sel:hostArn:DeleteHost' :: Text
hostArn = Text
pHostArn_}

-- | The Amazon Resource Name (ARN) of the host to be deleted.
deleteHost_hostArn :: Lens.Lens' DeleteHost Prelude.Text
deleteHost_hostArn :: Lens' DeleteHost Text
deleteHost_hostArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteHost' {Text
hostArn :: Text
$sel:hostArn:DeleteHost' :: DeleteHost -> Text
hostArn} -> Text
hostArn) (\s :: DeleteHost
s@DeleteHost' {} Text
a -> DeleteHost
s {$sel:hostArn:DeleteHost' :: Text
hostArn = Text
a} :: DeleteHost)

instance Core.AWSRequest DeleteHost where
  type AWSResponse DeleteHost = DeleteHostResponse
  request :: (Service -> Service) -> DeleteHost -> Request DeleteHost
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 DeleteHost
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHost)))
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 -> DeleteHostResponse
DeleteHostResponse'
            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 DeleteHost where
  hashWithSalt :: Int -> DeleteHost -> Int
hashWithSalt Int
_salt DeleteHost' {Text
hostArn :: Text
$sel:hostArn:DeleteHost' :: DeleteHost -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hostArn

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

instance Data.ToHeaders DeleteHost where
  toHeaders :: DeleteHost -> ResponseHeaders
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 -> ResponseHeaders
Data.=# ( ByteString
"com.amazonaws.codestar.connections.CodeStar_connections_20191201.DeleteHost" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

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

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

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