{-# 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.DescribeInterconnects
-- 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)
--
-- Lists the interconnects owned by the Amazon Web Services account or only
-- the specified interconnect.
module Amazonka.DirectConnect.DescribeInterconnects
  ( -- * Creating a Request
    DescribeInterconnects (..),
    newDescribeInterconnects,

    -- * Request Lenses
    describeInterconnects_interconnectId,

    -- * Destructuring the Response
    DescribeInterconnectsResponse (..),
    newDescribeInterconnectsResponse,

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

-- |
-- Create a value of 'DescribeInterconnects' 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:
--
-- 'interconnectId', 'describeInterconnects_interconnectId' - The ID of the interconnect.
newDescribeInterconnects ::
  DescribeInterconnects
newDescribeInterconnects :: DescribeInterconnects
newDescribeInterconnects =
  DescribeInterconnects' :: Maybe Text -> DescribeInterconnects
DescribeInterconnects'
    { $sel:interconnectId:DescribeInterconnects' :: Maybe Text
interconnectId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the interconnect.
describeInterconnects_interconnectId :: Lens.Lens' DescribeInterconnects (Prelude.Maybe Prelude.Text)
describeInterconnects_interconnectId :: (Maybe Text -> f (Maybe Text))
-> DescribeInterconnects -> f DescribeInterconnects
describeInterconnects_interconnectId = (DescribeInterconnects -> Maybe Text)
-> (DescribeInterconnects -> Maybe Text -> DescribeInterconnects)
-> Lens
     DescribeInterconnects
     DescribeInterconnects
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInterconnects' {Maybe Text
interconnectId :: Maybe Text
$sel:interconnectId:DescribeInterconnects' :: DescribeInterconnects -> Maybe Text
interconnectId} -> Maybe Text
interconnectId) (\s :: DescribeInterconnects
s@DescribeInterconnects' {} Maybe Text
a -> DescribeInterconnects
s {$sel:interconnectId:DescribeInterconnects' :: Maybe Text
interconnectId = Maybe Text
a} :: DescribeInterconnects)

instance Core.AWSRequest DescribeInterconnects where
  type
    AWSResponse DescribeInterconnects =
      DescribeInterconnectsResponse
  request :: DescribeInterconnects -> Request DescribeInterconnects
request = Service -> DescribeInterconnects -> Request DescribeInterconnects
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeInterconnects
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeInterconnects)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeInterconnects))
-> Logger
-> Service
-> Proxy DescribeInterconnects
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeInterconnects)))
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 ->
          Maybe [Interconnect] -> Int -> DescribeInterconnectsResponse
DescribeInterconnectsResponse'
            (Maybe [Interconnect] -> Int -> DescribeInterconnectsResponse)
-> Either String (Maybe [Interconnect])
-> Either String (Int -> DescribeInterconnectsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Interconnect]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"interconnects" Either String (Maybe (Maybe [Interconnect]))
-> Maybe [Interconnect] -> Either String (Maybe [Interconnect])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Interconnect]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DescribeInterconnectsResponse)
-> Either String Int -> Either String DescribeInterconnectsResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable DescribeInterconnects

instance Prelude.NFData DescribeInterconnects

instance Core.ToHeaders DescribeInterconnects where
  toHeaders :: DescribeInterconnects -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeInterconnects -> 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.DescribeInterconnects" ::
                          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 DescribeInterconnects where
  toJSON :: DescribeInterconnects -> Value
toJSON DescribeInterconnects' {Maybe Text
interconnectId :: Maybe Text
$sel:interconnectId:DescribeInterconnects' :: DescribeInterconnects -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"interconnectId" 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
interconnectId
          ]
      )

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

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

-- | /See:/ 'newDescribeInterconnectsResponse' smart constructor.
data DescribeInterconnectsResponse = DescribeInterconnectsResponse'
  { -- | The interconnects.
    DescribeInterconnectsResponse -> Maybe [Interconnect]
interconnects :: Prelude.Maybe [Interconnect],
    -- | The response's http status code.
    DescribeInterconnectsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeInterconnectsResponse
-> DescribeInterconnectsResponse -> Bool
(DescribeInterconnectsResponse
 -> DescribeInterconnectsResponse -> Bool)
-> (DescribeInterconnectsResponse
    -> DescribeInterconnectsResponse -> Bool)
-> Eq DescribeInterconnectsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInterconnectsResponse
-> DescribeInterconnectsResponse -> Bool
$c/= :: DescribeInterconnectsResponse
-> DescribeInterconnectsResponse -> Bool
== :: DescribeInterconnectsResponse
-> DescribeInterconnectsResponse -> Bool
$c== :: DescribeInterconnectsResponse
-> DescribeInterconnectsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeInterconnectsResponse]
ReadPrec DescribeInterconnectsResponse
Int -> ReadS DescribeInterconnectsResponse
ReadS [DescribeInterconnectsResponse]
(Int -> ReadS DescribeInterconnectsResponse)
-> ReadS [DescribeInterconnectsResponse]
-> ReadPrec DescribeInterconnectsResponse
-> ReadPrec [DescribeInterconnectsResponse]
-> Read DescribeInterconnectsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInterconnectsResponse]
$creadListPrec :: ReadPrec [DescribeInterconnectsResponse]
readPrec :: ReadPrec DescribeInterconnectsResponse
$creadPrec :: ReadPrec DescribeInterconnectsResponse
readList :: ReadS [DescribeInterconnectsResponse]
$creadList :: ReadS [DescribeInterconnectsResponse]
readsPrec :: Int -> ReadS DescribeInterconnectsResponse
$creadsPrec :: Int -> ReadS DescribeInterconnectsResponse
Prelude.Read, Int -> DescribeInterconnectsResponse -> ShowS
[DescribeInterconnectsResponse] -> ShowS
DescribeInterconnectsResponse -> String
(Int -> DescribeInterconnectsResponse -> ShowS)
-> (DescribeInterconnectsResponse -> String)
-> ([DescribeInterconnectsResponse] -> ShowS)
-> Show DescribeInterconnectsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInterconnectsResponse] -> ShowS
$cshowList :: [DescribeInterconnectsResponse] -> ShowS
show :: DescribeInterconnectsResponse -> String
$cshow :: DescribeInterconnectsResponse -> String
showsPrec :: Int -> DescribeInterconnectsResponse -> ShowS
$cshowsPrec :: Int -> DescribeInterconnectsResponse -> ShowS
Prelude.Show, (forall x.
 DescribeInterconnectsResponse
 -> Rep DescribeInterconnectsResponse x)
-> (forall x.
    Rep DescribeInterconnectsResponse x
    -> DescribeInterconnectsResponse)
-> Generic DescribeInterconnectsResponse
forall x.
Rep DescribeInterconnectsResponse x
-> DescribeInterconnectsResponse
forall x.
DescribeInterconnectsResponse
-> Rep DescribeInterconnectsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeInterconnectsResponse x
-> DescribeInterconnectsResponse
$cfrom :: forall x.
DescribeInterconnectsResponse
-> Rep DescribeInterconnectsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInterconnectsResponse' 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:
--
-- 'interconnects', 'describeInterconnectsResponse_interconnects' - The interconnects.
--
-- 'httpStatus', 'describeInterconnectsResponse_httpStatus' - The response's http status code.
newDescribeInterconnectsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeInterconnectsResponse
newDescribeInterconnectsResponse :: Int -> DescribeInterconnectsResponse
newDescribeInterconnectsResponse Int
pHttpStatus_ =
  DescribeInterconnectsResponse' :: Maybe [Interconnect] -> Int -> DescribeInterconnectsResponse
DescribeInterconnectsResponse'
    { $sel:interconnects:DescribeInterconnectsResponse' :: Maybe [Interconnect]
interconnects =
        Maybe [Interconnect]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeInterconnectsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The interconnects.
describeInterconnectsResponse_interconnects :: Lens.Lens' DescribeInterconnectsResponse (Prelude.Maybe [Interconnect])
describeInterconnectsResponse_interconnects :: (Maybe [Interconnect] -> f (Maybe [Interconnect]))
-> DescribeInterconnectsResponse -> f DescribeInterconnectsResponse
describeInterconnectsResponse_interconnects = (DescribeInterconnectsResponse -> Maybe [Interconnect])
-> (DescribeInterconnectsResponse
    -> Maybe [Interconnect] -> DescribeInterconnectsResponse)
-> Lens
     DescribeInterconnectsResponse
     DescribeInterconnectsResponse
     (Maybe [Interconnect])
     (Maybe [Interconnect])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInterconnectsResponse' {Maybe [Interconnect]
interconnects :: Maybe [Interconnect]
$sel:interconnects:DescribeInterconnectsResponse' :: DescribeInterconnectsResponse -> Maybe [Interconnect]
interconnects} -> Maybe [Interconnect]
interconnects) (\s :: DescribeInterconnectsResponse
s@DescribeInterconnectsResponse' {} Maybe [Interconnect]
a -> DescribeInterconnectsResponse
s {$sel:interconnects:DescribeInterconnectsResponse' :: Maybe [Interconnect]
interconnects = Maybe [Interconnect]
a} :: DescribeInterconnectsResponse) ((Maybe [Interconnect] -> f (Maybe [Interconnect]))
 -> DescribeInterconnectsResponse
 -> f DescribeInterconnectsResponse)
-> ((Maybe [Interconnect] -> f (Maybe [Interconnect]))
    -> Maybe [Interconnect] -> f (Maybe [Interconnect]))
-> (Maybe [Interconnect] -> f (Maybe [Interconnect]))
-> DescribeInterconnectsResponse
-> f DescribeInterconnectsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Interconnect] [Interconnect] [Interconnect] [Interconnect]
-> Iso
     (Maybe [Interconnect])
     (Maybe [Interconnect])
     (Maybe [Interconnect])
     (Maybe [Interconnect])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Interconnect] [Interconnect] [Interconnect] [Interconnect]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeInterconnectsResponse