{-# 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.DescribeLags
-- 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)
--
-- Describes all your link aggregation groups (LAG) or the specified LAG.
module Amazonka.DirectConnect.DescribeLags
  ( -- * Creating a Request
    DescribeLags (..),
    newDescribeLags,

    -- * Request Lenses
    describeLags_lagId,

    -- * Destructuring the Response
    DescribeLagsResponse (..),
    newDescribeLagsResponse,

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

-- |
-- Create a value of 'DescribeLags' 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:
--
-- 'lagId', 'describeLags_lagId' - The ID of the LAG.
newDescribeLags ::
  DescribeLags
newDescribeLags :: DescribeLags
newDescribeLags =
  DescribeLags' :: Maybe Text -> DescribeLags
DescribeLags' {$sel:lagId:DescribeLags' :: Maybe Text
lagId = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ID of the LAG.
describeLags_lagId :: Lens.Lens' DescribeLags (Prelude.Maybe Prelude.Text)
describeLags_lagId :: (Maybe Text -> f (Maybe Text)) -> DescribeLags -> f DescribeLags
describeLags_lagId = (DescribeLags -> Maybe Text)
-> (DescribeLags -> Maybe Text -> DescribeLags)
-> Lens DescribeLags DescribeLags (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLags' {Maybe Text
lagId :: Maybe Text
$sel:lagId:DescribeLags' :: DescribeLags -> Maybe Text
lagId} -> Maybe Text
lagId) (\s :: DescribeLags
s@DescribeLags' {} Maybe Text
a -> DescribeLags
s {$sel:lagId:DescribeLags' :: Maybe Text
lagId = Maybe Text
a} :: DescribeLags)

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

instance Prelude.NFData DescribeLags

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

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

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

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

-- |
-- Create a value of 'DescribeLagsResponse' 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:
--
-- 'lags', 'describeLagsResponse_lags' - The LAGs.
--
-- 'httpStatus', 'describeLagsResponse_httpStatus' - The response's http status code.
newDescribeLagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLagsResponse
newDescribeLagsResponse :: Int -> DescribeLagsResponse
newDescribeLagsResponse Int
pHttpStatus_ =
  DescribeLagsResponse' :: Maybe [Lag] -> Int -> DescribeLagsResponse
DescribeLagsResponse'
    { $sel:lags:DescribeLagsResponse' :: Maybe [Lag]
lags = Maybe [Lag]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The LAGs.
describeLagsResponse_lags :: Lens.Lens' DescribeLagsResponse (Prelude.Maybe [Lag])
describeLagsResponse_lags :: (Maybe [Lag] -> f (Maybe [Lag]))
-> DescribeLagsResponse -> f DescribeLagsResponse
describeLagsResponse_lags = (DescribeLagsResponse -> Maybe [Lag])
-> (DescribeLagsResponse -> Maybe [Lag] -> DescribeLagsResponse)
-> Lens
     DescribeLagsResponse
     DescribeLagsResponse
     (Maybe [Lag])
     (Maybe [Lag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLagsResponse' {Maybe [Lag]
lags :: Maybe [Lag]
$sel:lags:DescribeLagsResponse' :: DescribeLagsResponse -> Maybe [Lag]
lags} -> Maybe [Lag]
lags) (\s :: DescribeLagsResponse
s@DescribeLagsResponse' {} Maybe [Lag]
a -> DescribeLagsResponse
s {$sel:lags:DescribeLagsResponse' :: Maybe [Lag]
lags = Maybe [Lag]
a} :: DescribeLagsResponse) ((Maybe [Lag] -> f (Maybe [Lag]))
 -> DescribeLagsResponse -> f DescribeLagsResponse)
-> ((Maybe [Lag] -> f (Maybe [Lag]))
    -> Maybe [Lag] -> f (Maybe [Lag]))
-> (Maybe [Lag] -> f (Maybe [Lag]))
-> DescribeLagsResponse
-> f DescribeLagsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Lag] [Lag] [Lag] [Lag]
-> Iso (Maybe [Lag]) (Maybe [Lag]) (Maybe [Lag]) (Maybe [Lag])
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 [Lag] [Lag] [Lag] [Lag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DescribeLagsResponse