{-# 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-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)
--
-- 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 Amazonka.DirectConnect.Types
import qualified Amazonka.Lens as Lens
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
(DescribeConnections -> DescribeConnections -> Bool)
-> (DescribeConnections -> DescribeConnections -> Bool)
-> Eq DescribeConnections
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]
(Int -> ReadS DescribeConnections)
-> ReadS [DescribeConnections]
-> ReadPrec DescribeConnections
-> ReadPrec [DescribeConnections]
-> Read 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
(Int -> DescribeConnections -> ShowS)
-> (DescribeConnections -> String)
-> ([DescribeConnections] -> ShowS)
-> Show DescribeConnections
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. DescribeConnections -> Rep DescribeConnections x)
-> (forall x. Rep DescribeConnections x -> DescribeConnections)
-> Generic DescribeConnections
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' :: Maybe Text -> DescribeConnections
DescribeConnections'
    { $sel:connectionId:DescribeConnections' :: Maybe Text
connectionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the connection.
describeConnections_connectionId :: Lens.Lens' DescribeConnections (Prelude.Maybe Prelude.Text)
describeConnections_connectionId :: (Maybe Text -> f (Maybe Text))
-> DescribeConnections -> f DescribeConnections
describeConnections_connectionId = (DescribeConnections -> Maybe Text)
-> (DescribeConnections -> Maybe Text -> DescribeConnections)
-> Lens
     DescribeConnections DescribeConnections (Maybe Text) (Maybe Text)
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 :: DescribeConnections -> Request DescribeConnections
request = Service -> DescribeConnections -> Request DescribeConnections
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeConnections
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeConnections)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeConnections))
-> Logger
-> Service
-> Proxy DescribeConnections
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeConnections)))
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 -> Object -> Either String Connections
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable DescribeConnections

instance Prelude.NFData DescribeConnections

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

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

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

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