{-# 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.DescribeVirtualGateways
-- 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 virtual private gateways owned by the Amazon Web Services
-- account.
--
-- You can create one or more Direct Connect private virtual interfaces
-- linked to a virtual private gateway.
module Amazonka.DirectConnect.DescribeVirtualGateways
  ( -- * Creating a Request
    DescribeVirtualGateways (..),
    newDescribeVirtualGateways,

    -- * Destructuring the Response
    DescribeVirtualGatewaysResponse (..),
    newDescribeVirtualGatewaysResponse,

    -- * Response Lenses
    describeVirtualGatewaysResponse_virtualGateways,
    describeVirtualGatewaysResponse_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:/ 'newDescribeVirtualGateways' smart constructor.
data DescribeVirtualGateways = DescribeVirtualGateways'
  {
  }
  deriving (DescribeVirtualGateways -> DescribeVirtualGateways -> Bool
(DescribeVirtualGateways -> DescribeVirtualGateways -> Bool)
-> (DescribeVirtualGateways -> DescribeVirtualGateways -> Bool)
-> Eq DescribeVirtualGateways
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeVirtualGateways -> DescribeVirtualGateways -> Bool
$c/= :: DescribeVirtualGateways -> DescribeVirtualGateways -> Bool
== :: DescribeVirtualGateways -> DescribeVirtualGateways -> Bool
$c== :: DescribeVirtualGateways -> DescribeVirtualGateways -> Bool
Prelude.Eq, ReadPrec [DescribeVirtualGateways]
ReadPrec DescribeVirtualGateways
Int -> ReadS DescribeVirtualGateways
ReadS [DescribeVirtualGateways]
(Int -> ReadS DescribeVirtualGateways)
-> ReadS [DescribeVirtualGateways]
-> ReadPrec DescribeVirtualGateways
-> ReadPrec [DescribeVirtualGateways]
-> Read DescribeVirtualGateways
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeVirtualGateways]
$creadListPrec :: ReadPrec [DescribeVirtualGateways]
readPrec :: ReadPrec DescribeVirtualGateways
$creadPrec :: ReadPrec DescribeVirtualGateways
readList :: ReadS [DescribeVirtualGateways]
$creadList :: ReadS [DescribeVirtualGateways]
readsPrec :: Int -> ReadS DescribeVirtualGateways
$creadsPrec :: Int -> ReadS DescribeVirtualGateways
Prelude.Read, Int -> DescribeVirtualGateways -> ShowS
[DescribeVirtualGateways] -> ShowS
DescribeVirtualGateways -> String
(Int -> DescribeVirtualGateways -> ShowS)
-> (DescribeVirtualGateways -> String)
-> ([DescribeVirtualGateways] -> ShowS)
-> Show DescribeVirtualGateways
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeVirtualGateways] -> ShowS
$cshowList :: [DescribeVirtualGateways] -> ShowS
show :: DescribeVirtualGateways -> String
$cshow :: DescribeVirtualGateways -> String
showsPrec :: Int -> DescribeVirtualGateways -> ShowS
$cshowsPrec :: Int -> DescribeVirtualGateways -> ShowS
Prelude.Show, (forall x.
 DescribeVirtualGateways -> Rep DescribeVirtualGateways x)
-> (forall x.
    Rep DescribeVirtualGateways x -> DescribeVirtualGateways)
-> Generic DescribeVirtualGateways
forall x. Rep DescribeVirtualGateways x -> DescribeVirtualGateways
forall x. DescribeVirtualGateways -> Rep DescribeVirtualGateways x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeVirtualGateways x -> DescribeVirtualGateways
$cfrom :: forall x. DescribeVirtualGateways -> Rep DescribeVirtualGateways x
Prelude.Generic)

-- |
-- Create a value of 'DescribeVirtualGateways' 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.
newDescribeVirtualGateways ::
  DescribeVirtualGateways
newDescribeVirtualGateways :: DescribeVirtualGateways
newDescribeVirtualGateways = DescribeVirtualGateways
DescribeVirtualGateways'

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

instance Prelude.NFData DescribeVirtualGateways

instance Core.ToHeaders DescribeVirtualGateways where
  toHeaders :: DescribeVirtualGateways -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeVirtualGateways -> 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.DescribeVirtualGateways" ::
                          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 DescribeVirtualGateways where
  toJSON :: DescribeVirtualGateways -> Value
toJSON = Value -> DescribeVirtualGateways -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

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

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

-- |
-- Create a value of 'DescribeVirtualGatewaysResponse' 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:
--
-- 'virtualGateways', 'describeVirtualGatewaysResponse_virtualGateways' - The virtual private gateways.
--
-- 'httpStatus', 'describeVirtualGatewaysResponse_httpStatus' - The response's http status code.
newDescribeVirtualGatewaysResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeVirtualGatewaysResponse
newDescribeVirtualGatewaysResponse :: Int -> DescribeVirtualGatewaysResponse
newDescribeVirtualGatewaysResponse Int
pHttpStatus_ =
  DescribeVirtualGatewaysResponse' :: Maybe [VirtualGateway] -> Int -> DescribeVirtualGatewaysResponse
DescribeVirtualGatewaysResponse'
    { $sel:virtualGateways:DescribeVirtualGatewaysResponse' :: Maybe [VirtualGateway]
virtualGateways =
        Maybe [VirtualGateway]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeVirtualGatewaysResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The virtual private gateways.
describeVirtualGatewaysResponse_virtualGateways :: Lens.Lens' DescribeVirtualGatewaysResponse (Prelude.Maybe [VirtualGateway])
describeVirtualGatewaysResponse_virtualGateways :: (Maybe [VirtualGateway] -> f (Maybe [VirtualGateway]))
-> DescribeVirtualGatewaysResponse
-> f DescribeVirtualGatewaysResponse
describeVirtualGatewaysResponse_virtualGateways = (DescribeVirtualGatewaysResponse -> Maybe [VirtualGateway])
-> (DescribeVirtualGatewaysResponse
    -> Maybe [VirtualGateway] -> DescribeVirtualGatewaysResponse)
-> Lens
     DescribeVirtualGatewaysResponse
     DescribeVirtualGatewaysResponse
     (Maybe [VirtualGateway])
     (Maybe [VirtualGateway])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVirtualGatewaysResponse' {Maybe [VirtualGateway]
virtualGateways :: Maybe [VirtualGateway]
$sel:virtualGateways:DescribeVirtualGatewaysResponse' :: DescribeVirtualGatewaysResponse -> Maybe [VirtualGateway]
virtualGateways} -> Maybe [VirtualGateway]
virtualGateways) (\s :: DescribeVirtualGatewaysResponse
s@DescribeVirtualGatewaysResponse' {} Maybe [VirtualGateway]
a -> DescribeVirtualGatewaysResponse
s {$sel:virtualGateways:DescribeVirtualGatewaysResponse' :: Maybe [VirtualGateway]
virtualGateways = Maybe [VirtualGateway]
a} :: DescribeVirtualGatewaysResponse) ((Maybe [VirtualGateway] -> f (Maybe [VirtualGateway]))
 -> DescribeVirtualGatewaysResponse
 -> f DescribeVirtualGatewaysResponse)
-> ((Maybe [VirtualGateway] -> f (Maybe [VirtualGateway]))
    -> Maybe [VirtualGateway] -> f (Maybe [VirtualGateway]))
-> (Maybe [VirtualGateway] -> f (Maybe [VirtualGateway]))
-> DescribeVirtualGatewaysResponse
-> f DescribeVirtualGatewaysResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [VirtualGateway] [VirtualGateway] [VirtualGateway] [VirtualGateway]
-> Iso
     (Maybe [VirtualGateway])
     (Maybe [VirtualGateway])
     (Maybe [VirtualGateway])
     (Maybe [VirtualGateway])
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
  [VirtualGateway] [VirtualGateway] [VirtualGateway] [VirtualGateway]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    DescribeVirtualGatewaysResponse