{-# 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.DeleteEnvironmentAccountConnection
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- In an environment account, delete an environment account connection.
--
-- After you delete an environment account connection that’s in use by an
-- Proton environment, Proton /can’t/ manage the environment infrastructure
-- resources until a new environment account connection is accepted for the
-- environment account and associated environment. You\'re responsible for
-- cleaning up provisioned resources that remain without an environment
-- connection.
--
-- For more information, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-env-account-connections.html Environment account connections>
-- in the /Proton User guide/.
module Amazonka.Proton.DeleteEnvironmentAccountConnection
  ( -- * Creating a Request
    DeleteEnvironmentAccountConnection (..),
    newDeleteEnvironmentAccountConnection,

    -- * Request Lenses
    deleteEnvironmentAccountConnection_id,

    -- * Destructuring the Response
    DeleteEnvironmentAccountConnectionResponse (..),
    newDeleteEnvironmentAccountConnectionResponse,

    -- * Response Lenses
    deleteEnvironmentAccountConnectionResponse_environmentAccountConnection,
    deleteEnvironmentAccountConnectionResponse_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:/ 'newDeleteEnvironmentAccountConnection' smart constructor.
data DeleteEnvironmentAccountConnection = DeleteEnvironmentAccountConnection'
  { -- | The ID of the environment account connection to delete.
    DeleteEnvironmentAccountConnection -> Text
id :: Prelude.Text
  }
  deriving (DeleteEnvironmentAccountConnection
-> DeleteEnvironmentAccountConnection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteEnvironmentAccountConnection
-> DeleteEnvironmentAccountConnection -> Bool
$c/= :: DeleteEnvironmentAccountConnection
-> DeleteEnvironmentAccountConnection -> Bool
== :: DeleteEnvironmentAccountConnection
-> DeleteEnvironmentAccountConnection -> Bool
$c== :: DeleteEnvironmentAccountConnection
-> DeleteEnvironmentAccountConnection -> Bool
Prelude.Eq, ReadPrec [DeleteEnvironmentAccountConnection]
ReadPrec DeleteEnvironmentAccountConnection
Int -> ReadS DeleteEnvironmentAccountConnection
ReadS [DeleteEnvironmentAccountConnection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteEnvironmentAccountConnection]
$creadListPrec :: ReadPrec [DeleteEnvironmentAccountConnection]
readPrec :: ReadPrec DeleteEnvironmentAccountConnection
$creadPrec :: ReadPrec DeleteEnvironmentAccountConnection
readList :: ReadS [DeleteEnvironmentAccountConnection]
$creadList :: ReadS [DeleteEnvironmentAccountConnection]
readsPrec :: Int -> ReadS DeleteEnvironmentAccountConnection
$creadsPrec :: Int -> ReadS DeleteEnvironmentAccountConnection
Prelude.Read, Int -> DeleteEnvironmentAccountConnection -> ShowS
[DeleteEnvironmentAccountConnection] -> ShowS
DeleteEnvironmentAccountConnection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteEnvironmentAccountConnection] -> ShowS
$cshowList :: [DeleteEnvironmentAccountConnection] -> ShowS
show :: DeleteEnvironmentAccountConnection -> String
$cshow :: DeleteEnvironmentAccountConnection -> String
showsPrec :: Int -> DeleteEnvironmentAccountConnection -> ShowS
$cshowsPrec :: Int -> DeleteEnvironmentAccountConnection -> ShowS
Prelude.Show, forall x.
Rep DeleteEnvironmentAccountConnection x
-> DeleteEnvironmentAccountConnection
forall x.
DeleteEnvironmentAccountConnection
-> Rep DeleteEnvironmentAccountConnection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteEnvironmentAccountConnection x
-> DeleteEnvironmentAccountConnection
$cfrom :: forall x.
DeleteEnvironmentAccountConnection
-> Rep DeleteEnvironmentAccountConnection x
Prelude.Generic)

-- |
-- Create a value of 'DeleteEnvironmentAccountConnection' 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:
--
-- 'id', 'deleteEnvironmentAccountConnection_id' - The ID of the environment account connection to delete.
newDeleteEnvironmentAccountConnection ::
  -- | 'id'
  Prelude.Text ->
  DeleteEnvironmentAccountConnection
newDeleteEnvironmentAccountConnection :: Text -> DeleteEnvironmentAccountConnection
newDeleteEnvironmentAccountConnection Text
pId_ =
  DeleteEnvironmentAccountConnection' {$sel:id:DeleteEnvironmentAccountConnection' :: Text
id = Text
pId_}

-- | The ID of the environment account connection to delete.
deleteEnvironmentAccountConnection_id :: Lens.Lens' DeleteEnvironmentAccountConnection Prelude.Text
deleteEnvironmentAccountConnection_id :: Lens' DeleteEnvironmentAccountConnection Text
deleteEnvironmentAccountConnection_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEnvironmentAccountConnection' {Text
id :: Text
$sel:id:DeleteEnvironmentAccountConnection' :: DeleteEnvironmentAccountConnection -> Text
id} -> Text
id) (\s :: DeleteEnvironmentAccountConnection
s@DeleteEnvironmentAccountConnection' {} Text
a -> DeleteEnvironmentAccountConnection
s {$sel:id:DeleteEnvironmentAccountConnection' :: Text
id = Text
a} :: DeleteEnvironmentAccountConnection)

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

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

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

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

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

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

-- |
-- Create a value of 'DeleteEnvironmentAccountConnectionResponse' 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:
--
-- 'environmentAccountConnection', 'deleteEnvironmentAccountConnectionResponse_environmentAccountConnection' - The detailed data of the environment account connection being deleted.
--
-- 'httpStatus', 'deleteEnvironmentAccountConnectionResponse_httpStatus' - The response's http status code.
newDeleteEnvironmentAccountConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteEnvironmentAccountConnectionResponse
newDeleteEnvironmentAccountConnectionResponse :: Int -> DeleteEnvironmentAccountConnectionResponse
newDeleteEnvironmentAccountConnectionResponse
  Int
pHttpStatus_ =
    DeleteEnvironmentAccountConnectionResponse'
      { $sel:environmentAccountConnection:DeleteEnvironmentAccountConnectionResponse' :: Maybe EnvironmentAccountConnection
environmentAccountConnection =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:DeleteEnvironmentAccountConnectionResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The detailed data of the environment account connection being deleted.
deleteEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens.Lens' DeleteEnvironmentAccountConnectionResponse (Prelude.Maybe EnvironmentAccountConnection)
deleteEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens'
  DeleteEnvironmentAccountConnectionResponse
  (Maybe EnvironmentAccountConnection)
deleteEnvironmentAccountConnectionResponse_environmentAccountConnection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteEnvironmentAccountConnectionResponse' {Maybe EnvironmentAccountConnection
environmentAccountConnection :: Maybe EnvironmentAccountConnection
$sel:environmentAccountConnection:DeleteEnvironmentAccountConnectionResponse' :: DeleteEnvironmentAccountConnectionResponse
-> Maybe EnvironmentAccountConnection
environmentAccountConnection} -> Maybe EnvironmentAccountConnection
environmentAccountConnection) (\s :: DeleteEnvironmentAccountConnectionResponse
s@DeleteEnvironmentAccountConnectionResponse' {} Maybe EnvironmentAccountConnection
a -> DeleteEnvironmentAccountConnectionResponse
s {$sel:environmentAccountConnection:DeleteEnvironmentAccountConnectionResponse' :: Maybe EnvironmentAccountConnection
environmentAccountConnection = Maybe EnvironmentAccountConnection
a} :: DeleteEnvironmentAccountConnectionResponse)

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

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