{-# 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.GlobalAccelerator.DescribeAccelerator
-- 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)
--
-- Describe an accelerator.
module Amazonka.GlobalAccelerator.DescribeAccelerator
  ( -- * Creating a Request
    DescribeAccelerator (..),
    newDescribeAccelerator,

    -- * Request Lenses
    describeAccelerator_acceleratorArn,

    -- * Destructuring the Response
    DescribeAcceleratorResponse (..),
    newDescribeAcceleratorResponse,

    -- * Response Lenses
    describeAcceleratorResponse_accelerator,
    describeAcceleratorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GlobalAccelerator.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:/ 'newDescribeAccelerator' smart constructor.
data DescribeAccelerator = DescribeAccelerator'
  { -- | The Amazon Resource Name (ARN) of the accelerator to describe.
    DescribeAccelerator -> Text
acceleratorArn :: Prelude.Text
  }
  deriving (DescribeAccelerator -> DescribeAccelerator -> Bool
(DescribeAccelerator -> DescribeAccelerator -> Bool)
-> (DescribeAccelerator -> DescribeAccelerator -> Bool)
-> Eq DescribeAccelerator
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAccelerator -> DescribeAccelerator -> Bool
$c/= :: DescribeAccelerator -> DescribeAccelerator -> Bool
== :: DescribeAccelerator -> DescribeAccelerator -> Bool
$c== :: DescribeAccelerator -> DescribeAccelerator -> Bool
Prelude.Eq, ReadPrec [DescribeAccelerator]
ReadPrec DescribeAccelerator
Int -> ReadS DescribeAccelerator
ReadS [DescribeAccelerator]
(Int -> ReadS DescribeAccelerator)
-> ReadS [DescribeAccelerator]
-> ReadPrec DescribeAccelerator
-> ReadPrec [DescribeAccelerator]
-> Read DescribeAccelerator
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAccelerator]
$creadListPrec :: ReadPrec [DescribeAccelerator]
readPrec :: ReadPrec DescribeAccelerator
$creadPrec :: ReadPrec DescribeAccelerator
readList :: ReadS [DescribeAccelerator]
$creadList :: ReadS [DescribeAccelerator]
readsPrec :: Int -> ReadS DescribeAccelerator
$creadsPrec :: Int -> ReadS DescribeAccelerator
Prelude.Read, Int -> DescribeAccelerator -> ShowS
[DescribeAccelerator] -> ShowS
DescribeAccelerator -> String
(Int -> DescribeAccelerator -> ShowS)
-> (DescribeAccelerator -> String)
-> ([DescribeAccelerator] -> ShowS)
-> Show DescribeAccelerator
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAccelerator] -> ShowS
$cshowList :: [DescribeAccelerator] -> ShowS
show :: DescribeAccelerator -> String
$cshow :: DescribeAccelerator -> String
showsPrec :: Int -> DescribeAccelerator -> ShowS
$cshowsPrec :: Int -> DescribeAccelerator -> ShowS
Prelude.Show, (forall x. DescribeAccelerator -> Rep DescribeAccelerator x)
-> (forall x. Rep DescribeAccelerator x -> DescribeAccelerator)
-> Generic DescribeAccelerator
forall x. Rep DescribeAccelerator x -> DescribeAccelerator
forall x. DescribeAccelerator -> Rep DescribeAccelerator x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAccelerator x -> DescribeAccelerator
$cfrom :: forall x. DescribeAccelerator -> Rep DescribeAccelerator x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAccelerator' 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:
--
-- 'acceleratorArn', 'describeAccelerator_acceleratorArn' - The Amazon Resource Name (ARN) of the accelerator to describe.
newDescribeAccelerator ::
  -- | 'acceleratorArn'
  Prelude.Text ->
  DescribeAccelerator
newDescribeAccelerator :: Text -> DescribeAccelerator
newDescribeAccelerator Text
pAcceleratorArn_ =
  DescribeAccelerator' :: Text -> DescribeAccelerator
DescribeAccelerator'
    { $sel:acceleratorArn:DescribeAccelerator' :: Text
acceleratorArn =
        Text
pAcceleratorArn_
    }

-- | The Amazon Resource Name (ARN) of the accelerator to describe.
describeAccelerator_acceleratorArn :: Lens.Lens' DescribeAccelerator Prelude.Text
describeAccelerator_acceleratorArn :: (Text -> f Text) -> DescribeAccelerator -> f DescribeAccelerator
describeAccelerator_acceleratorArn = (DescribeAccelerator -> Text)
-> (DescribeAccelerator -> Text -> DescribeAccelerator)
-> Lens DescribeAccelerator DescribeAccelerator Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAccelerator' {Text
acceleratorArn :: Text
$sel:acceleratorArn:DescribeAccelerator' :: DescribeAccelerator -> Text
acceleratorArn} -> Text
acceleratorArn) (\s :: DescribeAccelerator
s@DescribeAccelerator' {} Text
a -> DescribeAccelerator
s {$sel:acceleratorArn:DescribeAccelerator' :: Text
acceleratorArn = Text
a} :: DescribeAccelerator)

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

instance Prelude.NFData DescribeAccelerator

instance Core.ToHeaders DescribeAccelerator where
  toHeaders :: DescribeAccelerator -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeAccelerator -> 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
"GlobalAccelerator_V20180706.DescribeAccelerator" ::
                          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 DescribeAccelerator where
  toJSON :: DescribeAccelerator -> Value
toJSON DescribeAccelerator' {Text
acceleratorArn :: Text
$sel:acceleratorArn:DescribeAccelerator' :: DescribeAccelerator -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AcceleratorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
acceleratorArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeAcceleratorResponse' 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:
--
-- 'accelerator', 'describeAcceleratorResponse_accelerator' - The description of the accelerator.
--
-- 'httpStatus', 'describeAcceleratorResponse_httpStatus' - The response's http status code.
newDescribeAcceleratorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAcceleratorResponse
newDescribeAcceleratorResponse :: Int -> DescribeAcceleratorResponse
newDescribeAcceleratorResponse Int
pHttpStatus_ =
  DescribeAcceleratorResponse' :: Maybe Accelerator -> Int -> DescribeAcceleratorResponse
DescribeAcceleratorResponse'
    { $sel:accelerator:DescribeAcceleratorResponse' :: Maybe Accelerator
accelerator =
        Maybe Accelerator
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAcceleratorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The description of the accelerator.
describeAcceleratorResponse_accelerator :: Lens.Lens' DescribeAcceleratorResponse (Prelude.Maybe Accelerator)
describeAcceleratorResponse_accelerator :: (Maybe Accelerator -> f (Maybe Accelerator))
-> DescribeAcceleratorResponse -> f DescribeAcceleratorResponse
describeAcceleratorResponse_accelerator = (DescribeAcceleratorResponse -> Maybe Accelerator)
-> (DescribeAcceleratorResponse
    -> Maybe Accelerator -> DescribeAcceleratorResponse)
-> Lens
     DescribeAcceleratorResponse
     DescribeAcceleratorResponse
     (Maybe Accelerator)
     (Maybe Accelerator)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAcceleratorResponse' {Maybe Accelerator
accelerator :: Maybe Accelerator
$sel:accelerator:DescribeAcceleratorResponse' :: DescribeAcceleratorResponse -> Maybe Accelerator
accelerator} -> Maybe Accelerator
accelerator) (\s :: DescribeAcceleratorResponse
s@DescribeAcceleratorResponse' {} Maybe Accelerator
a -> DescribeAcceleratorResponse
s {$sel:accelerator:DescribeAcceleratorResponse' :: Maybe Accelerator
accelerator = Maybe Accelerator
a} :: DescribeAcceleratorResponse)

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

instance Prelude.NFData DescribeAcceleratorResponse