{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteHost -> DeleteHost -> Bool)
-> (DeleteHost -> DeleteHost -> Bool) -> Eq DeleteHost
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]
(Int -> ReadS DeleteHost)
-> ReadS [DeleteHost]
-> ReadPrec DeleteHost
-> ReadPrec [DeleteHost]
-> Read 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
(Int -> DeleteHost -> ShowS)
-> (DeleteHost -> String)
-> ([DeleteHost] -> ShowS)
-> Show DeleteHost
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. DeleteHost -> Rep DeleteHost x)
-> (forall x. Rep DeleteHost x -> DeleteHost) -> Generic DeleteHost
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' :: Text -> DeleteHost
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 :: (Text -> f Text) -> DeleteHost -> f DeleteHost
deleteHost_hostArn = (DeleteHost -> Text)
-> (DeleteHost -> Text -> DeleteHost)
-> Lens DeleteHost DeleteHost Text Text
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 :: DeleteHost -> Request DeleteHost
request = Service -> DeleteHost -> Request DeleteHost
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteHost
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHost)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse DeleteHost))
-> Logger
-> Service
-> Proxy DeleteHost
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteHost)))
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 -> DeleteHostResponse
DeleteHostResponse'
            (Int -> DeleteHostResponse)
-> Either String Int -> Either String DeleteHostResponse
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 DeleteHost

instance Prelude.NFData DeleteHost

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

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

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

instance Core.ToQuery DeleteHost where
  toQuery :: DeleteHost -> QueryString
toQuery = QueryString -> DeleteHost -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteHostResponse -> DeleteHostResponse -> Bool)
-> (DeleteHostResponse -> DeleteHostResponse -> Bool)
-> Eq DeleteHostResponse
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]
(Int -> ReadS DeleteHostResponse)
-> ReadS [DeleteHostResponse]
-> ReadPrec DeleteHostResponse
-> ReadPrec [DeleteHostResponse]
-> Read 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
(Int -> DeleteHostResponse -> ShowS)
-> (DeleteHostResponse -> String)
-> ([DeleteHostResponse] -> ShowS)
-> Show DeleteHostResponse
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. DeleteHostResponse -> Rep DeleteHostResponse x)
-> (forall x. Rep DeleteHostResponse x -> DeleteHostResponse)
-> Generic DeleteHostResponse
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' :: Int -> DeleteHostResponse
DeleteHostResponse' {$sel:httpStatus:DeleteHostResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteHostResponse_httpStatus :: Lens.Lens' DeleteHostResponse Prelude.Int
deleteHostResponse_httpStatus :: (Int -> f Int) -> DeleteHostResponse -> f DeleteHostResponse
deleteHostResponse_httpStatus = (DeleteHostResponse -> Int)
-> (DeleteHostResponse -> Int -> DeleteHostResponse)
-> Lens DeleteHostResponse DeleteHostResponse Int Int
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