{-# 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.Proton.DeleteComponent
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Delete an Proton component resource.
--
-- For more information about components, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
-- in the /Proton User Guide/.
module Amazonka.Proton.DeleteComponent
  ( -- * Creating a Request
    DeleteComponent (..),
    newDeleteComponent,

    -- * Request Lenses
    deleteComponent_name,

    -- * Destructuring the Response
    DeleteComponentResponse (..),
    newDeleteComponentResponse,

    -- * Response Lenses
    deleteComponentResponse_component,
    deleteComponentResponse_httpStatus,
  )
where

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 Amazonka.Proton.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DeleteComponent' 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:
--
-- 'name', 'deleteComponent_name' - The name of the component to delete.
newDeleteComponent ::
  -- | 'name'
  Prelude.Text ->
  DeleteComponent
newDeleteComponent :: Text -> DeleteComponent
newDeleteComponent Text
pName_ =
  DeleteComponent' {$sel:name:DeleteComponent' :: Text
name = Text
pName_}

-- | The name of the component to delete.
deleteComponent_name :: Lens.Lens' DeleteComponent Prelude.Text
deleteComponent_name :: Lens' DeleteComponent Text
deleteComponent_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteComponent' {Text
name :: Text
$sel:name:DeleteComponent' :: DeleteComponent -> Text
name} -> Text
name) (\s :: DeleteComponent
s@DeleteComponent' {} Text
a -> DeleteComponent
s {$sel:name:DeleteComponent' :: Text
name = Text
a} :: DeleteComponent)

instance Core.AWSRequest DeleteComponent where
  type
    AWSResponse DeleteComponent =
      DeleteComponentResponse
  request :: (Service -> Service) -> DeleteComponent -> Request DeleteComponent
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 DeleteComponent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteComponent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Component -> Int -> DeleteComponentResponse
DeleteComponentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"component")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteComponent where
  hashWithSalt :: Int -> DeleteComponent -> Int
hashWithSalt Int
_salt DeleteComponent' {Text
name :: Text
$sel:name:DeleteComponent' :: DeleteComponent -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

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

instance Data.ToHeaders DeleteComponent where
  toHeaders :: DeleteComponent -> 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
"AwsProton20200720.DeleteComponent" ::
                          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 DeleteComponent where
  toJSON :: DeleteComponent -> Value
toJSON DeleteComponent' {Text
name :: Text
$sel:name:DeleteComponent' :: DeleteComponent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

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

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

-- | /See:/ 'newDeleteComponentResponse' smart constructor.
data DeleteComponentResponse = DeleteComponentResponse'
  { -- | The detailed data of the component being deleted.
    DeleteComponentResponse -> Maybe Component
component :: Prelude.Maybe Component,
    -- | The response's http status code.
    DeleteComponentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteComponentResponse -> DeleteComponentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteComponentResponse -> DeleteComponentResponse -> Bool
$c/= :: DeleteComponentResponse -> DeleteComponentResponse -> Bool
== :: DeleteComponentResponse -> DeleteComponentResponse -> Bool
$c== :: DeleteComponentResponse -> DeleteComponentResponse -> Bool
Prelude.Eq, Int -> DeleteComponentResponse -> ShowS
[DeleteComponentResponse] -> ShowS
DeleteComponentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteComponentResponse] -> ShowS
$cshowList :: [DeleteComponentResponse] -> ShowS
show :: DeleteComponentResponse -> String
$cshow :: DeleteComponentResponse -> String
showsPrec :: Int -> DeleteComponentResponse -> ShowS
$cshowsPrec :: Int -> DeleteComponentResponse -> ShowS
Prelude.Show, forall x. Rep DeleteComponentResponse x -> DeleteComponentResponse
forall x. DeleteComponentResponse -> Rep DeleteComponentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteComponentResponse x -> DeleteComponentResponse
$cfrom :: forall x. DeleteComponentResponse -> Rep DeleteComponentResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteComponentResponse' 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:
--
-- 'component', 'deleteComponentResponse_component' - The detailed data of the component being deleted.
--
-- 'httpStatus', 'deleteComponentResponse_httpStatus' - The response's http status code.
newDeleteComponentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteComponentResponse
newDeleteComponentResponse :: Int -> DeleteComponentResponse
newDeleteComponentResponse Int
pHttpStatus_ =
  DeleteComponentResponse'
    { $sel:component:DeleteComponentResponse' :: Maybe Component
component =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteComponentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The detailed data of the component being deleted.
deleteComponentResponse_component :: Lens.Lens' DeleteComponentResponse (Prelude.Maybe Component)
deleteComponentResponse_component :: Lens' DeleteComponentResponse (Maybe Component)
deleteComponentResponse_component = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteComponentResponse' {Maybe Component
component :: Maybe Component
$sel:component:DeleteComponentResponse' :: DeleteComponentResponse -> Maybe Component
component} -> Maybe Component
component) (\s :: DeleteComponentResponse
s@DeleteComponentResponse' {} Maybe Component
a -> DeleteComponentResponse
s {$sel:component:DeleteComponentResponse' :: Maybe Component
component = Maybe Component
a} :: DeleteComponentResponse)

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

instance Prelude.NFData DeleteComponentResponse where
  rnf :: DeleteComponentResponse -> ()
rnf DeleteComponentResponse' {Int
Maybe Component
httpStatus :: Int
component :: Maybe Component
$sel:httpStatus:DeleteComponentResponse' :: DeleteComponentResponse -> Int
$sel:component:DeleteComponentResponse' :: DeleteComponentResponse -> Maybe Component
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Component
component
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus