{-# 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.Proton.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)
--
-- Get detail data for a service.
module Amazonka.Proton.GetService
  ( -- * Creating a Request
    GetService (..),
    newGetService,

    -- * Request Lenses
    getService_name,

    -- * 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 Amazonka.Proton.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetService' smart constructor.
data GetService = GetService'
  { -- | The name of the service that you want to get the detail data for.
    GetService -> Text
name :: 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:
--
-- 'name', 'getService_name' - The name of the service that you want to get the detail data for.
newGetService ::
  -- | 'name'
  Prelude.Text ->
  GetService
newGetService :: Text -> GetService
newGetService Text
pName_ = GetService' :: Text -> GetService
GetService' {$sel:name:GetService' :: Text
name = Text
pName_}

-- | The name of the service that you want to get the detail data for.
getService_name :: Lens.Lens' GetService Prelude.Text
getService_name :: (Text -> f Text) -> GetService -> f GetService
getService_name = (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
name :: Text
$sel:name:GetService' :: GetService -> Text
name} -> Text
name) (\s :: GetService
s@GetService' {} Text
a -> GetService
s {$sel:name:GetService' :: Text
name = 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 Service -> Int -> GetServiceResponse
GetServiceResponse'
            (Maybe Service -> Int -> GetServiceResponse)
-> Either String (Maybe Service)
-> Either String (Int -> GetServiceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Service)
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
"AwsProton20200720.GetService" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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'
  { -- | The service detail data that\'s returned by AWS Proton.
    GetServiceResponse -> Maybe Service
service :: Prelude.Maybe Service,
    -- | 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, 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' - The service detail data that\'s returned by AWS Proton.
--
-- 'httpStatus', 'getServiceResponse_httpStatus' - The response's http status code.
newGetServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetServiceResponse
newGetServiceResponse :: Int -> GetServiceResponse
newGetServiceResponse Int
pHttpStatus_ =
  GetServiceResponse' :: Maybe Service -> Int -> GetServiceResponse
GetServiceResponse'
    { $sel:service:GetServiceResponse' :: Maybe Service
service = Maybe Service
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetServiceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The service detail data that\'s returned by AWS Proton.
getServiceResponse_service :: Lens.Lens' GetServiceResponse (Prelude.Maybe Service)
getServiceResponse_service :: (Maybe Service -> f (Maybe Service))
-> GetServiceResponse -> f GetServiceResponse
getServiceResponse_service = (GetServiceResponse -> Maybe Service)
-> (GetServiceResponse -> Maybe Service -> GetServiceResponse)
-> Lens
     GetServiceResponse
     GetServiceResponse
     (Maybe Service)
     (Maybe Service)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetServiceResponse' {Maybe Service
service :: Maybe Service
$sel:service:GetServiceResponse' :: GetServiceResponse -> Maybe Service
service} -> Maybe Service
service) (\s :: GetServiceResponse
s@GetServiceResponse' {} Maybe Service
a -> GetServiceResponse
s {$sel:service:GetServiceResponse' :: Maybe Service
service = Maybe Service
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