{-# 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.Synthetics.GetCanary
-- 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 complete information about one canary. You must specify the
-- name of the canary that you want. To get a list of canaries and their
-- names, use
-- <https://docs.aws.amazon.com/AmazonSynthetics/latest/APIReference/API_DescribeCanaries.html DescribeCanaries>.
module Amazonka.Synthetics.GetCanary
  ( -- * Creating a Request
    GetCanary (..),
    newGetCanary,

    -- * Request Lenses
    getCanary_name,

    -- * Destructuring the Response
    GetCanaryResponse (..),
    newGetCanaryResponse,

    -- * Response Lenses
    getCanaryResponse_canary,
    getCanaryResponse_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.Synthetics.Types

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

-- |
-- Create a value of 'GetCanary' 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', 'getCanary_name' - The name of the canary that you want details for.
newGetCanary ::
  -- | 'name'
  Prelude.Text ->
  GetCanary
newGetCanary :: Text -> GetCanary
newGetCanary Text
pName_ = GetCanary' :: Text -> GetCanary
GetCanary' {$sel:name:GetCanary' :: Text
name = Text
pName_}

-- | The name of the canary that you want details for.
getCanary_name :: Lens.Lens' GetCanary Prelude.Text
getCanary_name :: (Text -> f Text) -> GetCanary -> f GetCanary
getCanary_name = (GetCanary -> Text)
-> (GetCanary -> Text -> GetCanary)
-> Lens GetCanary GetCanary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCanary' {Text
name :: Text
$sel:name:GetCanary' :: GetCanary -> Text
name} -> Text
name) (\s :: GetCanary
s@GetCanary' {} Text
a -> GetCanary
s {$sel:name:GetCanary' :: Text
name = Text
a} :: GetCanary)

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

instance Prelude.NFData GetCanary

instance Core.ToHeaders GetCanary where
  toHeaders :: GetCanary -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetCanary -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath GetCanary where
  toPath :: GetCanary -> ByteString
toPath GetCanary' {Text
name :: Text
$sel:name:GetCanary' :: GetCanary -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/canary/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name]

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

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

-- |
-- Create a value of 'GetCanaryResponse' 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:
--
-- 'canary', 'getCanaryResponse_canary' - A strucure that contains the full information about the canary.
--
-- 'httpStatus', 'getCanaryResponse_httpStatus' - The response's http status code.
newGetCanaryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCanaryResponse
newGetCanaryResponse :: Int -> GetCanaryResponse
newGetCanaryResponse Int
pHttpStatus_ =
  GetCanaryResponse' :: Maybe Canary -> Int -> GetCanaryResponse
GetCanaryResponse'
    { $sel:canary:GetCanaryResponse' :: Maybe Canary
canary = Maybe Canary
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCanaryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A strucure that contains the full information about the canary.
getCanaryResponse_canary :: Lens.Lens' GetCanaryResponse (Prelude.Maybe Canary)
getCanaryResponse_canary :: (Maybe Canary -> f (Maybe Canary))
-> GetCanaryResponse -> f GetCanaryResponse
getCanaryResponse_canary = (GetCanaryResponse -> Maybe Canary)
-> (GetCanaryResponse -> Maybe Canary -> GetCanaryResponse)
-> Lens
     GetCanaryResponse GetCanaryResponse (Maybe Canary) (Maybe Canary)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCanaryResponse' {Maybe Canary
canary :: Maybe Canary
$sel:canary:GetCanaryResponse' :: GetCanaryResponse -> Maybe Canary
canary} -> Maybe Canary
canary) (\s :: GetCanaryResponse
s@GetCanaryResponse' {} Maybe Canary
a -> GetCanaryResponse
s {$sel:canary:GetCanaryResponse' :: Maybe Canary
canary = Maybe Canary
a} :: GetCanaryResponse)

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

instance Prelude.NFData GetCanaryResponse