{-# 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.RejectEnvironmentAccountConnection
-- 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 a management account, reject an environment account connection from
-- another environment account.
--
-- After you reject an environment account connection request, you /can\'t/
-- accept or use the rejected environment account connection.
--
-- You /can’t/ reject an environment account connection that\'s connected
-- to an environment.
--
-- 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.RejectEnvironmentAccountConnection
  ( -- * Creating a Request
    RejectEnvironmentAccountConnection (..),
    newRejectEnvironmentAccountConnection,

    -- * Request Lenses
    rejectEnvironmentAccountConnection_id,

    -- * Destructuring the Response
    RejectEnvironmentAccountConnectionResponse (..),
    newRejectEnvironmentAccountConnectionResponse,

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

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

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

instance
  Core.AWSRequest
    RejectEnvironmentAccountConnection
  where
  type
    AWSResponse RejectEnvironmentAccountConnection =
      RejectEnvironmentAccountConnectionResponse
  request :: (Service -> Service)
-> RejectEnvironmentAccountConnection
-> Request RejectEnvironmentAccountConnection
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 RejectEnvironmentAccountConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse RejectEnvironmentAccountConnection)))
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 ->
          Int
-> EnvironmentAccountConnection
-> RejectEnvironmentAccountConnectionResponse
RejectEnvironmentAccountConnectionResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"environmentAccountConnection")
      )

instance
  Prelude.Hashable
    RejectEnvironmentAccountConnection
  where
  hashWithSalt :: Int -> RejectEnvironmentAccountConnection -> Int
hashWithSalt
    Int
_salt
    RejectEnvironmentAccountConnection' {Text
id :: Text
$sel:id:RejectEnvironmentAccountConnection' :: RejectEnvironmentAccountConnection -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

instance
  Data.ToHeaders
    RejectEnvironmentAccountConnection
  where
  toHeaders :: RejectEnvironmentAccountConnection -> 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.RejectEnvironmentAccountConnection" ::
                          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
    RejectEnvironmentAccountConnection
  where
  toJSON :: RejectEnvironmentAccountConnection -> Value
toJSON RejectEnvironmentAccountConnection' {Text
id :: Text
$sel:id:RejectEnvironmentAccountConnection' :: RejectEnvironmentAccountConnection -> 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
    RejectEnvironmentAccountConnection
  where
  toPath :: RejectEnvironmentAccountConnection -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'RejectEnvironmentAccountConnectionResponse' 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', 'rejectEnvironmentAccountConnectionResponse_httpStatus' - The response's http status code.
--
-- 'environmentAccountConnection', 'rejectEnvironmentAccountConnectionResponse_environmentAccountConnection' - The environment connection account detail data that\'s returned by
-- Proton.
newRejectEnvironmentAccountConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environmentAccountConnection'
  EnvironmentAccountConnection ->
  RejectEnvironmentAccountConnectionResponse
newRejectEnvironmentAccountConnectionResponse :: Int
-> EnvironmentAccountConnection
-> RejectEnvironmentAccountConnectionResponse
newRejectEnvironmentAccountConnectionResponse
  Int
pHttpStatus_
  EnvironmentAccountConnection
pEnvironmentAccountConnection_ =
    RejectEnvironmentAccountConnectionResponse'
      { $sel:httpStatus:RejectEnvironmentAccountConnectionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:environmentAccountConnection:RejectEnvironmentAccountConnectionResponse' :: EnvironmentAccountConnection
environmentAccountConnection =
          EnvironmentAccountConnection
pEnvironmentAccountConnection_
      }

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

-- | The environment connection account detail data that\'s returned by
-- Proton.
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens.Lens' RejectEnvironmentAccountConnectionResponse EnvironmentAccountConnection
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens'
  RejectEnvironmentAccountConnectionResponse
  EnvironmentAccountConnection
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RejectEnvironmentAccountConnectionResponse' {EnvironmentAccountConnection
environmentAccountConnection :: EnvironmentAccountConnection
$sel:environmentAccountConnection:RejectEnvironmentAccountConnectionResponse' :: RejectEnvironmentAccountConnectionResponse
-> EnvironmentAccountConnection
environmentAccountConnection} -> EnvironmentAccountConnection
environmentAccountConnection) (\s :: RejectEnvironmentAccountConnectionResponse
s@RejectEnvironmentAccountConnectionResponse' {} EnvironmentAccountConnection
a -> RejectEnvironmentAccountConnectionResponse
s {$sel:environmentAccountConnection:RejectEnvironmentAccountConnectionResponse' :: EnvironmentAccountConnection
environmentAccountConnection = EnvironmentAccountConnection
a} :: RejectEnvironmentAccountConnectionResponse)

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