{-# 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.GetEnvironmentAccountConnection
-- 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, get the detailed data for an environment
-- account 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.GetEnvironmentAccountConnection
  ( -- * Creating a Request
    GetEnvironmentAccountConnection (..),
    newGetEnvironmentAccountConnection,

    -- * Request Lenses
    getEnvironmentAccountConnection_id,

    -- * Destructuring the Response
    GetEnvironmentAccountConnectionResponse (..),
    newGetEnvironmentAccountConnectionResponse,

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

-- |
-- Create a value of 'GetEnvironmentAccountConnection' 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', 'getEnvironmentAccountConnection_id' - The ID of the environment account connection that you want to get the
-- detailed data for.
newGetEnvironmentAccountConnection ::
  -- | 'id'
  Prelude.Text ->
  GetEnvironmentAccountConnection
newGetEnvironmentAccountConnection :: Text -> GetEnvironmentAccountConnection
newGetEnvironmentAccountConnection Text
pId_ =
  GetEnvironmentAccountConnection' {$sel:id:GetEnvironmentAccountConnection' :: Text
id = Text
pId_}

-- | The ID of the environment account connection that you want to get the
-- detailed data for.
getEnvironmentAccountConnection_id :: Lens.Lens' GetEnvironmentAccountConnection Prelude.Text
getEnvironmentAccountConnection_id :: Lens' GetEnvironmentAccountConnection Text
getEnvironmentAccountConnection_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEnvironmentAccountConnection' {Text
id :: Text
$sel:id:GetEnvironmentAccountConnection' :: GetEnvironmentAccountConnection -> Text
id} -> Text
id) (\s :: GetEnvironmentAccountConnection
s@GetEnvironmentAccountConnection' {} Text
a -> GetEnvironmentAccountConnection
s {$sel:id:GetEnvironmentAccountConnection' :: Text
id = Text
a} :: GetEnvironmentAccountConnection)

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

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

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

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

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

-- |
-- Create a value of 'GetEnvironmentAccountConnectionResponse' 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', 'getEnvironmentAccountConnectionResponse_httpStatus' - The response's http status code.
--
-- 'environmentAccountConnection', 'getEnvironmentAccountConnectionResponse_environmentAccountConnection' - The detailed data of the requested environment account connection.
newGetEnvironmentAccountConnectionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environmentAccountConnection'
  EnvironmentAccountConnection ->
  GetEnvironmentAccountConnectionResponse
newGetEnvironmentAccountConnectionResponse :: Int
-> EnvironmentAccountConnection
-> GetEnvironmentAccountConnectionResponse
newGetEnvironmentAccountConnectionResponse
  Int
pHttpStatus_
  EnvironmentAccountConnection
pEnvironmentAccountConnection_ =
    GetEnvironmentAccountConnectionResponse'
      { $sel:httpStatus:GetEnvironmentAccountConnectionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:environmentAccountConnection:GetEnvironmentAccountConnectionResponse' :: EnvironmentAccountConnection
environmentAccountConnection =
          EnvironmentAccountConnection
pEnvironmentAccountConnection_
      }

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

-- | The detailed data of the requested environment account connection.
getEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens.Lens' GetEnvironmentAccountConnectionResponse EnvironmentAccountConnection
getEnvironmentAccountConnectionResponse_environmentAccountConnection :: Lens'
  GetEnvironmentAccountConnectionResponse
  EnvironmentAccountConnection
getEnvironmentAccountConnectionResponse_environmentAccountConnection = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetEnvironmentAccountConnectionResponse' {EnvironmentAccountConnection
environmentAccountConnection :: EnvironmentAccountConnection
$sel:environmentAccountConnection:GetEnvironmentAccountConnectionResponse' :: GetEnvironmentAccountConnectionResponse
-> EnvironmentAccountConnection
environmentAccountConnection} -> EnvironmentAccountConnection
environmentAccountConnection) (\s :: GetEnvironmentAccountConnectionResponse
s@GetEnvironmentAccountConnectionResponse' {} EnvironmentAccountConnection
a -> GetEnvironmentAccountConnectionResponse
s {$sel:environmentAccountConnection:GetEnvironmentAccountConnectionResponse' :: EnvironmentAccountConnection
environmentAccountConnection = EnvironmentAccountConnection
a} :: GetEnvironmentAccountConnectionResponse)

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