{-# 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.AlexaBusiness.GetGateway
-- 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)
--
-- Retrieves the details of a gateway.
module Amazonka.AlexaBusiness.GetGateway
  ( -- * Creating a Request
    GetGateway (..),
    newGetGateway,

    -- * Request Lenses
    getGateway_gatewayArn,

    -- * Destructuring the Response
    GetGatewayResponse (..),
    newGetGatewayResponse,

    -- * Response Lenses
    getGatewayResponse_gateway,
    getGatewayResponse_httpStatus,
  )
where

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

-- |
-- Create a value of 'GetGateway' 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:
--
-- 'gatewayArn', 'getGateway_gatewayArn' - The ARN of the gateway to get.
newGetGateway ::
  -- | 'gatewayArn'
  Prelude.Text ->
  GetGateway
newGetGateway :: Text -> GetGateway
newGetGateway Text
pGatewayArn_ =
  GetGateway' :: Text -> GetGateway
GetGateway' {$sel:gatewayArn:GetGateway' :: Text
gatewayArn = Text
pGatewayArn_}

-- | The ARN of the gateway to get.
getGateway_gatewayArn :: Lens.Lens' GetGateway Prelude.Text
getGateway_gatewayArn :: (Text -> f Text) -> GetGateway -> f GetGateway
getGateway_gatewayArn = (GetGateway -> Text)
-> (GetGateway -> Text -> GetGateway)
-> Lens GetGateway GetGateway Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGateway' {Text
gatewayArn :: Text
$sel:gatewayArn:GetGateway' :: GetGateway -> Text
gatewayArn} -> Text
gatewayArn) (\s :: GetGateway
s@GetGateway' {} Text
a -> GetGateway
s {$sel:gatewayArn:GetGateway' :: Text
gatewayArn = Text
a} :: GetGateway)

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

instance Prelude.NFData GetGateway

instance Core.ToHeaders GetGateway where
  toHeaders :: GetGateway -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetGateway -> 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
"AlexaForBusiness.GetGateway" ::
                          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 GetGateway where
  toJSON :: GetGateway -> Value
toJSON GetGateway' {Text
gatewayArn :: Text
$sel:gatewayArn:GetGateway' :: GetGateway -> 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
"GatewayArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayArn)]
      )

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

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

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

-- |
-- Create a value of 'GetGatewayResponse' 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:
--
-- 'gateway', 'getGatewayResponse_gateway' - The details of the gateway.
--
-- 'httpStatus', 'getGatewayResponse_httpStatus' - The response's http status code.
newGetGatewayResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetGatewayResponse
newGetGatewayResponse :: Int -> GetGatewayResponse
newGetGatewayResponse Int
pHttpStatus_ =
  GetGatewayResponse' :: Maybe Gateway -> Int -> GetGatewayResponse
GetGatewayResponse'
    { $sel:gateway:GetGatewayResponse' :: Maybe Gateway
gateway = Maybe Gateway
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The details of the gateway.
getGatewayResponse_gateway :: Lens.Lens' GetGatewayResponse (Prelude.Maybe Gateway)
getGatewayResponse_gateway :: (Maybe Gateway -> f (Maybe Gateway))
-> GetGatewayResponse -> f GetGatewayResponse
getGatewayResponse_gateway = (GetGatewayResponse -> Maybe Gateway)
-> (GetGatewayResponse -> Maybe Gateway -> GetGatewayResponse)
-> Lens
     GetGatewayResponse
     GetGatewayResponse
     (Maybe Gateway)
     (Maybe Gateway)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetGatewayResponse' {Maybe Gateway
gateway :: Maybe Gateway
$sel:gateway:GetGatewayResponse' :: GetGatewayResponse -> Maybe Gateway
gateway} -> Maybe Gateway
gateway) (\s :: GetGatewayResponse
s@GetGatewayResponse' {} Maybe Gateway
a -> GetGatewayResponse
s {$sel:gateway:GetGatewayResponse' :: Maybe Gateway
gateway = Maybe Gateway
a} :: GetGatewayResponse)

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

instance Prelude.NFData GetGatewayResponse