{-# 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.DirectConnect.DescribeConnections
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Displays the specified connection or all connections in this Region.
module Amazonka.DirectConnect.DescribeConnections
  ( -- * Creating a Request
    DescribeConnections (..),
    newDescribeConnections,

    -- * Request Lenses
    describeConnections_connectionId,

    -- * Destructuring the Response
    Connections (..),
    newConnections,

    -- * Response Lenses
    connections_connections,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DirectConnect.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeConnections' smart constructor.
data DescribeConnections = DescribeConnections'
  { -- | The ID of the connection.
    DescribeConnections -> Maybe Text
connectionId :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeConnections -> DescribeConnections -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeConnections -> DescribeConnections -> Bool
$c/= :: DescribeConnections -> DescribeConnections -> Bool
== :: DescribeConnections -> DescribeConnections -> Bool
$c== :: DescribeConnections -> DescribeConnections -> Bool
Prelude.Eq, ReadPrec [DescribeConnections]
ReadPrec DescribeConnections
Int -> ReadS DescribeConnections
ReadS [DescribeConnections]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeConnections]
$creadListPrec :: ReadPrec [DescribeConnections]
readPrec :: ReadPrec DescribeConnections
$creadPrec :: ReadPrec DescribeConnections
readList :: ReadS [DescribeConnections]
$creadList :: ReadS [DescribeConnections]
readsPrec :: Int -> ReadS DescribeConnections
$creadsPrec :: Int -> ReadS DescribeConnections
Prelude.Read, Int -> DescribeConnections -> ShowS
[DescribeConnections] -> ShowS
DescribeConnections -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeConnections] -> ShowS
$cshowList :: [DescribeConnections] -> ShowS
show :: DescribeConnections -> String
$cshow :: DescribeConnections -> String
showsPrec :: Int -> DescribeConnections -> ShowS
$cshowsPrec :: Int -> DescribeConnections -> ShowS
Prelude.Show, forall x. Rep DescribeConnections x -> DescribeConnections
forall x. DescribeConnections -> Rep DescribeConnections x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeConnections x -> DescribeConnections
$cfrom :: forall x. DescribeConnections -> Rep DescribeConnections x
Prelude.Generic)

-- |
-- Create a value of 'DescribeConnections' 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:
--
-- 'connectionId', 'describeConnections_connectionId' - The ID of the connection.
newDescribeConnections ::
  DescribeConnections
newDescribeConnections :: DescribeConnections
newDescribeConnections =
  DescribeConnections'
    { $sel:connectionId:DescribeConnections' :: Maybe Text
connectionId =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the connection.
describeConnections_connectionId :: Lens.Lens' DescribeConnections (Prelude.Maybe Prelude.Text)
describeConnections_connectionId :: Lens' DescribeConnections (Maybe Text)
describeConnections_connectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeConnections' {Maybe Text
connectionId :: Maybe Text
$sel:connectionId:DescribeConnections' :: DescribeConnections -> Maybe Text
connectionId} -> Maybe Text
connectionId) (\s :: DescribeConnections
s@DescribeConnections' {} Maybe Text
a -> DescribeConnections
s {$sel:connectionId:DescribeConnections' :: Maybe Text
connectionId = Maybe Text
a} :: DescribeConnections)

instance Core.AWSRequest DescribeConnections where
  type AWSResponse DescribeConnections = Connections
  request :: (Service -> Service)
-> DescribeConnections -> Request DescribeConnections
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 DescribeConnections
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeConnections)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

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

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

instance Data.ToHeaders DescribeConnections where
  toHeaders :: DescribeConnections -> 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
"OvertureService.DescribeConnections" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DescribeConnections where
  toJSON :: DescribeConnections -> Value
toJSON DescribeConnections' {Maybe Text
connectionId :: Maybe Text
$sel:connectionId:DescribeConnections' :: DescribeConnections -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"connectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
connectionId]
      )

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

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