{-# 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-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)
--
-- In a management account, reject an environment account connection from
-- another environment account.
--
-- After you reject an environment account connection request, you /won’t/
-- be able to accept or use the rejected environment account connection.
--
-- You /can’t/ reject an environment account connection that is connected
-- to an environment.
--
-- For more information, see
-- <https://docs.aws.amazon.com/proton/latest/adminguide/ag-env-account-connections.html Environment account connections>
-- in the /AWS Proton Administrator 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.Lens as Lens
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
(RejectEnvironmentAccountConnection
 -> RejectEnvironmentAccountConnection -> Bool)
-> (RejectEnvironmentAccountConnection
    -> RejectEnvironmentAccountConnection -> Bool)
-> Eq RejectEnvironmentAccountConnection
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]
(Int -> ReadS RejectEnvironmentAccountConnection)
-> ReadS [RejectEnvironmentAccountConnection]
-> ReadPrec RejectEnvironmentAccountConnection
-> ReadPrec [RejectEnvironmentAccountConnection]
-> Read 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
(Int -> RejectEnvironmentAccountConnection -> ShowS)
-> (RejectEnvironmentAccountConnection -> String)
-> ([RejectEnvironmentAccountConnection] -> ShowS)
-> Show RejectEnvironmentAccountConnection
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.
 RejectEnvironmentAccountConnection
 -> Rep RejectEnvironmentAccountConnection x)
-> (forall x.
    Rep RejectEnvironmentAccountConnection x
    -> RejectEnvironmentAccountConnection)
-> Generic RejectEnvironmentAccountConnection
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' :: Text -> RejectEnvironmentAccountConnection
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 :: (Text -> f Text)
-> RejectEnvironmentAccountConnection
-> f RejectEnvironmentAccountConnection
rejectEnvironmentAccountConnection_id = (RejectEnvironmentAccountConnection -> Text)
-> (RejectEnvironmentAccountConnection
    -> Text -> RejectEnvironmentAccountConnection)
-> Lens
     RejectEnvironmentAccountConnection
     RejectEnvironmentAccountConnection
     Text
     Text
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 :: RejectEnvironmentAccountConnection
-> Request RejectEnvironmentAccountConnection
request = Service
-> RejectEnvironmentAccountConnection
-> Request RejectEnvironmentAccountConnection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RejectEnvironmentAccountConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse RejectEnvironmentAccountConnection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RejectEnvironmentAccountConnection))
-> Logger
-> Service
-> Proxy RejectEnvironmentAccountConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse RejectEnvironmentAccountConnection)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int
-> EnvironmentAccountConnection
-> RejectEnvironmentAccountConnectionResponse
RejectEnvironmentAccountConnectionResponse'
            (Int
 -> EnvironmentAccountConnection
 -> RejectEnvironmentAccountConnectionResponse)
-> Either String Int
-> Either
     String
     (EnvironmentAccountConnection
      -> RejectEnvironmentAccountConnectionResponse)
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))
              Either
  String
  (EnvironmentAccountConnection
   -> RejectEnvironmentAccountConnectionResponse)
-> Either String EnvironmentAccountConnection
-> Either String RejectEnvironmentAccountConnectionResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String EnvironmentAccountConnection
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"environmentAccountConnection")
      )

instance
  Prelude.Hashable
    RejectEnvironmentAccountConnection

instance
  Prelude.NFData
    RejectEnvironmentAccountConnection

instance
  Core.ToHeaders
    RejectEnvironmentAccountConnection
  where
  toHeaders :: RejectEnvironmentAccountConnection -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> RejectEnvironmentAccountConnection -> 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
"AwsProton20200720.RejectEnvironmentAccountConnection" ::
                          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
    RejectEnvironmentAccountConnection
  where
  toJSON :: RejectEnvironmentAccountConnection -> Value
toJSON RejectEnvironmentAccountConnection' {Text
id :: Text
$sel:id:RejectEnvironmentAccountConnection' :: RejectEnvironmentAccountConnection -> 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
"id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)])

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

instance
  Core.ToQuery
    RejectEnvironmentAccountConnection
  where
  toQuery :: RejectEnvironmentAccountConnection -> QueryString
toQuery = QueryString -> RejectEnvironmentAccountConnection -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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 AWS
    -- Proton.
    RejectEnvironmentAccountConnectionResponse
-> EnvironmentAccountConnection
environmentAccountConnection :: EnvironmentAccountConnection
  }
  deriving (RejectEnvironmentAccountConnectionResponse
-> RejectEnvironmentAccountConnectionResponse -> Bool
(RejectEnvironmentAccountConnectionResponse
 -> RejectEnvironmentAccountConnectionResponse -> Bool)
-> (RejectEnvironmentAccountConnectionResponse
    -> RejectEnvironmentAccountConnectionResponse -> Bool)
-> Eq RejectEnvironmentAccountConnectionResponse
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]
(Int -> ReadS RejectEnvironmentAccountConnectionResponse)
-> ReadS [RejectEnvironmentAccountConnectionResponse]
-> ReadPrec RejectEnvironmentAccountConnectionResponse
-> ReadPrec [RejectEnvironmentAccountConnectionResponse]
-> Read 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
(Int -> RejectEnvironmentAccountConnectionResponse -> ShowS)
-> (RejectEnvironmentAccountConnectionResponse -> String)
-> ([RejectEnvironmentAccountConnectionResponse] -> ShowS)
-> Show RejectEnvironmentAccountConnectionResponse
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.
 RejectEnvironmentAccountConnectionResponse
 -> Rep RejectEnvironmentAccountConnectionResponse x)
-> (forall x.
    Rep RejectEnvironmentAccountConnectionResponse x
    -> RejectEnvironmentAccountConnectionResponse)
-> Generic RejectEnvironmentAccountConnectionResponse
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 AWS
-- Proton.
newRejectEnvironmentAccountConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environmentAccountConnection'
  EnvironmentAccountConnection ->
  RejectEnvironmentAccountConnectionResponse
newRejectEnvironmentAccountConnectionResponse :: Int
-> EnvironmentAccountConnection
-> RejectEnvironmentAccountConnectionResponse
newRejectEnvironmentAccountConnectionResponse
  Int
pHttpStatus_
  EnvironmentAccountConnection
pEnvironmentAccountConnection_ =
    RejectEnvironmentAccountConnectionResponse' :: Int
-> EnvironmentAccountConnection
-> RejectEnvironmentAccountConnectionResponse
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 :: (Int -> f Int)
-> RejectEnvironmentAccountConnectionResponse
-> f RejectEnvironmentAccountConnectionResponse
rejectEnvironmentAccountConnectionResponse_httpStatus = (RejectEnvironmentAccountConnectionResponse -> Int)
-> (RejectEnvironmentAccountConnectionResponse
    -> Int -> RejectEnvironmentAccountConnectionResponse)
-> Lens
     RejectEnvironmentAccountConnectionResponse
     RejectEnvironmentAccountConnectionResponse
     Int
     Int
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 AWS
-- Proton.
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens.Lens' RejectEnvironmentAccountConnectionResponse EnvironmentAccountConnection
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection :: (EnvironmentAccountConnection -> f EnvironmentAccountConnection)
-> RejectEnvironmentAccountConnectionResponse
-> f RejectEnvironmentAccountConnectionResponse
rejectEnvironmentAccountConnectionResponse_environmentAccountConnection = (RejectEnvironmentAccountConnectionResponse
 -> EnvironmentAccountConnection)
-> (RejectEnvironmentAccountConnectionResponse
    -> EnvironmentAccountConnection
    -> RejectEnvironmentAccountConnectionResponse)
-> Lens
     RejectEnvironmentAccountConnectionResponse
     RejectEnvironmentAccountConnectionResponse
     EnvironmentAccountConnection
     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