{-# 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.AcceptEnvironmentAccountConnection
-- 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, an environment account connection request is
-- accepted. When the environment account connection request is accepted,
-- Proton can use the associated IAM role to provision environment
-- infrastructure resources in the associated environment account.
--
-- 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.AcceptEnvironmentAccountConnection
  ( -- * Creating a Request
    AcceptEnvironmentAccountConnection (..),
    newAcceptEnvironmentAccountConnection,

    -- * Request Lenses
    acceptEnvironmentAccountConnection_id,

    -- * Destructuring the Response
    AcceptEnvironmentAccountConnectionResponse (..),
    newAcceptEnvironmentAccountConnectionResponse,

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

-- |
-- Create a value of 'AcceptEnvironmentAccountConnection' 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', 'acceptEnvironmentAccountConnection_id' - The ID of the environment account connection.
newAcceptEnvironmentAccountConnection ::
  -- | 'id'
  Prelude.Text ->
  AcceptEnvironmentAccountConnection
newAcceptEnvironmentAccountConnection :: Text -> AcceptEnvironmentAccountConnection
newAcceptEnvironmentAccountConnection Text
pId_ =
  AcceptEnvironmentAccountConnection' {$sel:id:AcceptEnvironmentAccountConnection' :: Text
id = Text
pId_}

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

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

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

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

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

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

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

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

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

instance
  Prelude.NFData
    AcceptEnvironmentAccountConnectionResponse
  where
  rnf :: AcceptEnvironmentAccountConnectionResponse -> ()
rnf AcceptEnvironmentAccountConnectionResponse' {Int
EnvironmentAccountConnection
environmentAccountConnection :: EnvironmentAccountConnection
httpStatus :: Int
$sel:environmentAccountConnection:AcceptEnvironmentAccountConnectionResponse' :: AcceptEnvironmentAccountConnectionResponse
-> EnvironmentAccountConnection
$sel:httpStatus:AcceptEnvironmentAccountConnectionResponse' :: AcceptEnvironmentAccountConnectionResponse -> 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