{-# 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.Route53AutoNaming.GetService
-- 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)
--
-- Gets the settings for a specified service.
module Amazonka.Route53AutoNaming.GetService
  ( -- * Creating a Request
    GetService (..),
    newGetService,

    -- * Request Lenses
    getService_id,

    -- * Destructuring the Response
    GetServiceResponse (..),
    newGetServiceResponse,

    -- * Response Lenses
    getServiceResponse_service,
    getServiceResponse_httpStatus,
  )
where

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
import Amazonka.Route53AutoNaming.Types

-- | /See:/ 'newGetService' smart constructor.
data GetService = GetService'
  { -- | The ID of the service that you want to get settings for.
    GetService -> Text
id :: Prelude.Text
  }
  deriving (GetService -> GetService -> Bool
(GetService -> GetService -> Bool)
-> (GetService -> GetService -> Bool) -> Eq GetService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetService -> GetService -> Bool
$c/= :: GetService -> GetService -> Bool
== :: GetService -> GetService -> Bool
$c== :: GetService -> GetService -> Bool
Prelude.Eq, ReadPrec [GetService]
ReadPrec GetService
Int -> ReadS GetService
ReadS [GetService]
(Int -> ReadS GetService)
-> ReadS [GetService]
-> ReadPrec GetService
-> ReadPrec [GetService]
-> Read GetService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetService]
$creadListPrec :: ReadPrec [GetService]
readPrec :: ReadPrec GetService
$creadPrec :: ReadPrec GetService
readList :: ReadS [GetService]
$creadList :: ReadS [GetService]
readsPrec :: Int -> ReadS GetService
$creadsPrec :: Int -> ReadS GetService
Prelude.Read, Int -> GetService -> ShowS
[GetService] -> ShowS
GetService -> String
(Int -> GetService -> ShowS)
-> (GetService -> String)
-> ([GetService] -> ShowS)
-> Show GetService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetService] -> ShowS
$cshowList :: [GetService] -> ShowS
show :: GetService -> String
$cshow :: GetService -> String
showsPrec :: Int -> GetService -> ShowS
$cshowsPrec :: Int -> GetService -> ShowS
Prelude.Show, (forall x. GetService -> Rep GetService x)
-> (forall x. Rep GetService x -> GetService) -> Generic GetService
forall x. Rep GetService x -> GetService
forall x. GetService -> Rep GetService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetService x -> GetService
$cfrom :: forall x. GetService -> Rep GetService x
Prelude.Generic)

-- |
-- Create a value of 'GetService' 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:
--
-- 'id', 'getService_id' - The ID of the service that you want to get settings for.
newGetService ::
  -- | 'id'
  Prelude.Text ->
  GetService
newGetService :: Text -> GetService
newGetService Text
pId_ = GetService' :: Text -> GetService
GetService' {$sel:id:GetService' :: Text
id = Text
pId_}

-- | The ID of the service that you want to get settings for.
getService_id :: Lens.Lens' GetService Prelude.Text
getService_id :: (Text -> f Text) -> GetService -> f GetService
getService_id = (GetService -> Text)
-> (GetService -> Text -> GetService)
-> Lens GetService GetService Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetService' {Text
id :: Text
$sel:id:GetService' :: GetService -> Text
id} -> Text
id) (\s :: GetService
s@GetService' {} Text
a -> GetService
s {$sel:id:GetService' :: Text
id = Text
a} :: GetService)

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

instance Prelude.NFData GetService

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

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

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

-- | /See:/ 'newGetServiceResponse' smart constructor.
data GetServiceResponse = GetServiceResponse'
  { -- | A complex type that contains information about the service.
    GetServiceResponse -> Maybe ServiceInfo
service :: Prelude.Maybe ServiceInfo,
    -- | The response's http status code.
    GetServiceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetServiceResponse -> GetServiceResponse -> Bool
(GetServiceResponse -> GetServiceResponse -> Bool)
-> (GetServiceResponse -> GetServiceResponse -> Bool)
-> Eq GetServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetServiceResponse -> GetServiceResponse -> Bool
$c/= :: GetServiceResponse -> GetServiceResponse -> Bool
== :: GetServiceResponse -> GetServiceResponse -> Bool
$c== :: GetServiceResponse -> GetServiceResponse -> Bool
Prelude.Eq, ReadPrec [GetServiceResponse]
ReadPrec GetServiceResponse
Int -> ReadS GetServiceResponse
ReadS [GetServiceResponse]
(Int -> ReadS GetServiceResponse)
-> ReadS [GetServiceResponse]
-> ReadPrec GetServiceResponse
-> ReadPrec [GetServiceResponse]
-> Read GetServiceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetServiceResponse]
$creadListPrec :: ReadPrec [GetServiceResponse]
readPrec :: ReadPrec GetServiceResponse
$creadPrec :: ReadPrec GetServiceResponse
readList :: ReadS [GetServiceResponse]
$creadList :: ReadS [GetServiceResponse]
readsPrec :: Int -> ReadS GetServiceResponse
$creadsPrec :: Int -> ReadS GetServiceResponse
Prelude.Read, Int -> GetServiceResponse -> ShowS
[GetServiceResponse] -> ShowS
GetServiceResponse -> String
(Int -> GetServiceResponse -> ShowS)
-> (GetServiceResponse -> String)
-> ([GetServiceResponse] -> ShowS)
-> Show GetServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetServiceResponse] -> ShowS
$cshowList :: [GetServiceResponse] -> ShowS
show :: GetServiceResponse -> String
$cshow :: GetServiceResponse -> String
showsPrec :: Int -> GetServiceResponse -> ShowS
$cshowsPrec :: Int -> GetServiceResponse -> ShowS
Prelude.Show, (forall x. GetServiceResponse -> Rep GetServiceResponse x)
-> (forall x. Rep GetServiceResponse x -> GetServiceResponse)
-> Generic GetServiceResponse
forall x. Rep GetServiceResponse x -> GetServiceResponse
forall x. GetServiceResponse -> Rep GetServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetServiceResponse x -> GetServiceResponse
$cfrom :: forall x. GetServiceResponse -> Rep GetServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetServiceResponse' 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:
--
-- 'service', 'getServiceResponse_service' - A complex type that contains information about the service.
--
-- 'httpStatus', 'getServiceResponse_httpStatus' - The response's http status code.
newGetServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceResponse
newGetServiceResponse :: Int -> GetServiceResponse
newGetServiceResponse Int
pHttpStatus_ =
  GetServiceResponse' :: Maybe ServiceInfo -> Int -> GetServiceResponse
GetServiceResponse'
    { $sel:service:GetServiceResponse' :: Maybe ServiceInfo
service = Maybe ServiceInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A complex type that contains information about the service.
getServiceResponse_service :: Lens.Lens' GetServiceResponse (Prelude.Maybe ServiceInfo)
getServiceResponse_service :: (Maybe ServiceInfo -> f (Maybe ServiceInfo))
-> GetServiceResponse -> f GetServiceResponse
getServiceResponse_service = (GetServiceResponse -> Maybe ServiceInfo)
-> (GetServiceResponse -> Maybe ServiceInfo -> GetServiceResponse)
-> Lens
     GetServiceResponse
     GetServiceResponse
     (Maybe ServiceInfo)
     (Maybe ServiceInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceResponse' {Maybe ServiceInfo
service :: Maybe ServiceInfo
$sel:service:GetServiceResponse' :: GetServiceResponse -> Maybe ServiceInfo
service} -> Maybe ServiceInfo
service) (\s :: GetServiceResponse
s@GetServiceResponse' {} Maybe ServiceInfo
a -> GetServiceResponse
s {$sel:service:GetServiceResponse' :: Maybe ServiceInfo
service = Maybe ServiceInfo
a} :: GetServiceResponse)

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

instance Prelude.NFData GetServiceResponse