{-# 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-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, an environment account connection request is
-- accepted. When the environment account connection request is accepted,
-- AWS 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/adminguide/ag-env-account-connections.html Environment account connections>
-- in the /AWS Proton Administrator 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.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:/ 'newAcceptEnvironmentAccountConnection' smart constructor.
data AcceptEnvironmentAccountConnection = AcceptEnvironmentAccountConnection'
  { -- | The ID of the environment account connection.
    AcceptEnvironmentAccountConnection -> Text
id :: Prelude.Text
  }
  deriving (AcceptEnvironmentAccountConnection
-> AcceptEnvironmentAccountConnection -> Bool
(AcceptEnvironmentAccountConnection
 -> AcceptEnvironmentAccountConnection -> Bool)
-> (AcceptEnvironmentAccountConnection
    -> AcceptEnvironmentAccountConnection -> Bool)
-> Eq AcceptEnvironmentAccountConnection
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]
(Int -> ReadS AcceptEnvironmentAccountConnection)
-> ReadS [AcceptEnvironmentAccountConnection]
-> ReadPrec AcceptEnvironmentAccountConnection
-> ReadPrec [AcceptEnvironmentAccountConnection]
-> Read 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
(Int -> AcceptEnvironmentAccountConnection -> ShowS)
-> (AcceptEnvironmentAccountConnection -> String)
-> ([AcceptEnvironmentAccountConnection] -> ShowS)
-> Show AcceptEnvironmentAccountConnection
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.
 AcceptEnvironmentAccountConnection
 -> Rep AcceptEnvironmentAccountConnection x)
-> (forall x.
    Rep AcceptEnvironmentAccountConnection x
    -> AcceptEnvironmentAccountConnection)
-> Generic AcceptEnvironmentAccountConnection
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' :: Text -> AcceptEnvironmentAccountConnection
AcceptEnvironmentAccountConnection' {$sel:id:AcceptEnvironmentAccountConnection' :: Text
id = Text
pId_}

-- | The ID of the environment account connection.
acceptEnvironmentAccountConnection_id :: Lens.Lens' AcceptEnvironmentAccountConnection Prelude.Text
acceptEnvironmentAccountConnection_id :: (Text -> f Text)
-> AcceptEnvironmentAccountConnection
-> f AcceptEnvironmentAccountConnection
acceptEnvironmentAccountConnection_id = (AcceptEnvironmentAccountConnection -> Text)
-> (AcceptEnvironmentAccountConnection
    -> Text -> AcceptEnvironmentAccountConnection)
-> Lens
     AcceptEnvironmentAccountConnection
     AcceptEnvironmentAccountConnection
     Text
     Text
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 :: AcceptEnvironmentAccountConnection
-> Request AcceptEnvironmentAccountConnection
request = Service
-> AcceptEnvironmentAccountConnection
-> Request AcceptEnvironmentAccountConnection
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AcceptEnvironmentAccountConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AcceptEnvironmentAccountConnection)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse AcceptEnvironmentAccountConnection))
-> Logger
-> Service
-> Proxy AcceptEnvironmentAccountConnection
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse AcceptEnvironmentAccountConnection)))
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
-> AcceptEnvironmentAccountConnectionResponse
AcceptEnvironmentAccountConnectionResponse'
            (Int
 -> EnvironmentAccountConnection
 -> AcceptEnvironmentAccountConnectionResponse)
-> Either String Int
-> Either
     String
     (EnvironmentAccountConnection
      -> AcceptEnvironmentAccountConnectionResponse)
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
   -> AcceptEnvironmentAccountConnectionResponse)
-> Either String EnvironmentAccountConnection
-> Either String AcceptEnvironmentAccountConnectionResponse
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
    AcceptEnvironmentAccountConnection

instance
  Prelude.NFData
    AcceptEnvironmentAccountConnection

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

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