{-# 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.CloudFront.GetInvalidation
-- 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 the information about an invalidation.
module Amazonka.CloudFront.GetInvalidation
  ( -- * Creating a Request
    GetInvalidation (..),
    newGetInvalidation,

    -- * Request Lenses
    getInvalidation_distributionId,
    getInvalidation_id,

    -- * Destructuring the Response
    GetInvalidationResponse (..),
    newGetInvalidationResponse,

    -- * Response Lenses
    getInvalidationResponse_invalidation,
    getInvalidationResponse_httpStatus,
  )
where

import Amazonka.CloudFront.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

-- | The request to get an invalidation\'s information.
--
-- /See:/ 'newGetInvalidation' smart constructor.
data GetInvalidation = GetInvalidation'
  { -- | The distribution\'s ID.
    GetInvalidation -> Text
distributionId :: Prelude.Text,
    -- | The identifier for the invalidation request, for example,
    -- @IDFDVBD632BHDS5@.
    GetInvalidation -> Text
id :: Prelude.Text
  }
  deriving (GetInvalidation -> GetInvalidation -> Bool
(GetInvalidation -> GetInvalidation -> Bool)
-> (GetInvalidation -> GetInvalidation -> Bool)
-> Eq GetInvalidation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInvalidation -> GetInvalidation -> Bool
$c/= :: GetInvalidation -> GetInvalidation -> Bool
== :: GetInvalidation -> GetInvalidation -> Bool
$c== :: GetInvalidation -> GetInvalidation -> Bool
Prelude.Eq, ReadPrec [GetInvalidation]
ReadPrec GetInvalidation
Int -> ReadS GetInvalidation
ReadS [GetInvalidation]
(Int -> ReadS GetInvalidation)
-> ReadS [GetInvalidation]
-> ReadPrec GetInvalidation
-> ReadPrec [GetInvalidation]
-> Read GetInvalidation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInvalidation]
$creadListPrec :: ReadPrec [GetInvalidation]
readPrec :: ReadPrec GetInvalidation
$creadPrec :: ReadPrec GetInvalidation
readList :: ReadS [GetInvalidation]
$creadList :: ReadS [GetInvalidation]
readsPrec :: Int -> ReadS GetInvalidation
$creadsPrec :: Int -> ReadS GetInvalidation
Prelude.Read, Int -> GetInvalidation -> ShowS
[GetInvalidation] -> ShowS
GetInvalidation -> String
(Int -> GetInvalidation -> ShowS)
-> (GetInvalidation -> String)
-> ([GetInvalidation] -> ShowS)
-> Show GetInvalidation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInvalidation] -> ShowS
$cshowList :: [GetInvalidation] -> ShowS
show :: GetInvalidation -> String
$cshow :: GetInvalidation -> String
showsPrec :: Int -> GetInvalidation -> ShowS
$cshowsPrec :: Int -> GetInvalidation -> ShowS
Prelude.Show, (forall x. GetInvalidation -> Rep GetInvalidation x)
-> (forall x. Rep GetInvalidation x -> GetInvalidation)
-> Generic GetInvalidation
forall x. Rep GetInvalidation x -> GetInvalidation
forall x. GetInvalidation -> Rep GetInvalidation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInvalidation x -> GetInvalidation
$cfrom :: forall x. GetInvalidation -> Rep GetInvalidation x
Prelude.Generic)

-- |
-- Create a value of 'GetInvalidation' 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:
--
-- 'distributionId', 'getInvalidation_distributionId' - The distribution\'s ID.
--
-- 'id', 'getInvalidation_id' - The identifier for the invalidation request, for example,
-- @IDFDVBD632BHDS5@.
newGetInvalidation ::
  -- | 'distributionId'
  Prelude.Text ->
  -- | 'id'
  Prelude.Text ->
  GetInvalidation
newGetInvalidation :: Text -> Text -> GetInvalidation
newGetInvalidation Text
pDistributionId_ Text
pId_ =
  GetInvalidation' :: Text -> Text -> GetInvalidation
GetInvalidation'
    { $sel:distributionId:GetInvalidation' :: Text
distributionId = Text
pDistributionId_,
      $sel:id:GetInvalidation' :: Text
id = Text
pId_
    }

-- | The distribution\'s ID.
getInvalidation_distributionId :: Lens.Lens' GetInvalidation Prelude.Text
getInvalidation_distributionId :: (Text -> f Text) -> GetInvalidation -> f GetInvalidation
getInvalidation_distributionId = (GetInvalidation -> Text)
-> (GetInvalidation -> Text -> GetInvalidation)
-> Lens GetInvalidation GetInvalidation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInvalidation' {Text
distributionId :: Text
$sel:distributionId:GetInvalidation' :: GetInvalidation -> Text
distributionId} -> Text
distributionId) (\s :: GetInvalidation
s@GetInvalidation' {} Text
a -> GetInvalidation
s {$sel:distributionId:GetInvalidation' :: Text
distributionId = Text
a} :: GetInvalidation)

-- | The identifier for the invalidation request, for example,
-- @IDFDVBD632BHDS5@.
getInvalidation_id :: Lens.Lens' GetInvalidation Prelude.Text
getInvalidation_id :: (Text -> f Text) -> GetInvalidation -> f GetInvalidation
getInvalidation_id = (GetInvalidation -> Text)
-> (GetInvalidation -> Text -> GetInvalidation)
-> Lens GetInvalidation GetInvalidation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInvalidation' {Text
id :: Text
$sel:id:GetInvalidation' :: GetInvalidation -> Text
id} -> Text
id) (\s :: GetInvalidation
s@GetInvalidation' {} Text
a -> GetInvalidation
s {$sel:id:GetInvalidation' :: Text
id = Text
a} :: GetInvalidation)

instance Core.AWSRequest GetInvalidation where
  type
    AWSResponse GetInvalidation =
      GetInvalidationResponse
  request :: GetInvalidation -> Request GetInvalidation
request = Service -> GetInvalidation -> Request GetInvalidation
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetInvalidation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetInvalidation)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse GetInvalidation))
-> Logger
-> Service
-> Proxy GetInvalidation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetInvalidation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Invalidation -> Int -> GetInvalidationResponse
GetInvalidationResponse'
            (Maybe Invalidation -> Int -> GetInvalidationResponse)
-> Either String (Maybe Invalidation)
-> Either String (Int -> GetInvalidationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe Invalidation)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either String (Int -> GetInvalidationResponse)
-> Either String Int -> Either String GetInvalidationResponse
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 GetInvalidation

instance Prelude.NFData GetInvalidation

instance Core.ToHeaders GetInvalidation where
  toHeaders :: GetInvalidation -> ResponseHeaders
toHeaders = ResponseHeaders -> GetInvalidation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath GetInvalidation where
  toPath :: GetInvalidation -> ByteString
toPath GetInvalidation' {Text
id :: Text
distributionId :: Text
$sel:id:GetInvalidation' :: GetInvalidation -> Text
$sel:distributionId:GetInvalidation' :: GetInvalidation -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-05-31/distribution/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
distributionId,
        ByteString
"/invalidation/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id
      ]

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

-- | The returned result of the corresponding request.
--
-- /See:/ 'newGetInvalidationResponse' smart constructor.
data GetInvalidationResponse = GetInvalidationResponse'
  { -- | The invalidation\'s information. For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/InvalidationDatatype.html Invalidation Complex Type>.
    GetInvalidationResponse -> Maybe Invalidation
invalidation :: Prelude.Maybe Invalidation,
    -- | The response's http status code.
    GetInvalidationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetInvalidationResponse -> GetInvalidationResponse -> Bool
(GetInvalidationResponse -> GetInvalidationResponse -> Bool)
-> (GetInvalidationResponse -> GetInvalidationResponse -> Bool)
-> Eq GetInvalidationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetInvalidationResponse -> GetInvalidationResponse -> Bool
$c/= :: GetInvalidationResponse -> GetInvalidationResponse -> Bool
== :: GetInvalidationResponse -> GetInvalidationResponse -> Bool
$c== :: GetInvalidationResponse -> GetInvalidationResponse -> Bool
Prelude.Eq, ReadPrec [GetInvalidationResponse]
ReadPrec GetInvalidationResponse
Int -> ReadS GetInvalidationResponse
ReadS [GetInvalidationResponse]
(Int -> ReadS GetInvalidationResponse)
-> ReadS [GetInvalidationResponse]
-> ReadPrec GetInvalidationResponse
-> ReadPrec [GetInvalidationResponse]
-> Read GetInvalidationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetInvalidationResponse]
$creadListPrec :: ReadPrec [GetInvalidationResponse]
readPrec :: ReadPrec GetInvalidationResponse
$creadPrec :: ReadPrec GetInvalidationResponse
readList :: ReadS [GetInvalidationResponse]
$creadList :: ReadS [GetInvalidationResponse]
readsPrec :: Int -> ReadS GetInvalidationResponse
$creadsPrec :: Int -> ReadS GetInvalidationResponse
Prelude.Read, Int -> GetInvalidationResponse -> ShowS
[GetInvalidationResponse] -> ShowS
GetInvalidationResponse -> String
(Int -> GetInvalidationResponse -> ShowS)
-> (GetInvalidationResponse -> String)
-> ([GetInvalidationResponse] -> ShowS)
-> Show GetInvalidationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetInvalidationResponse] -> ShowS
$cshowList :: [GetInvalidationResponse] -> ShowS
show :: GetInvalidationResponse -> String
$cshow :: GetInvalidationResponse -> String
showsPrec :: Int -> GetInvalidationResponse -> ShowS
$cshowsPrec :: Int -> GetInvalidationResponse -> ShowS
Prelude.Show, (forall x.
 GetInvalidationResponse -> Rep GetInvalidationResponse x)
-> (forall x.
    Rep GetInvalidationResponse x -> GetInvalidationResponse)
-> Generic GetInvalidationResponse
forall x. Rep GetInvalidationResponse x -> GetInvalidationResponse
forall x. GetInvalidationResponse -> Rep GetInvalidationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetInvalidationResponse x -> GetInvalidationResponse
$cfrom :: forall x. GetInvalidationResponse -> Rep GetInvalidationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetInvalidationResponse' 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:
--
-- 'invalidation', 'getInvalidationResponse_invalidation' - The invalidation\'s information. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/InvalidationDatatype.html Invalidation Complex Type>.
--
-- 'httpStatus', 'getInvalidationResponse_httpStatus' - The response's http status code.
newGetInvalidationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetInvalidationResponse
newGetInvalidationResponse :: Int -> GetInvalidationResponse
newGetInvalidationResponse Int
pHttpStatus_ =
  GetInvalidationResponse' :: Maybe Invalidation -> Int -> GetInvalidationResponse
GetInvalidationResponse'
    { $sel:invalidation:GetInvalidationResponse' :: Maybe Invalidation
invalidation =
        Maybe Invalidation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetInvalidationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The invalidation\'s information. For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/InvalidationDatatype.html Invalidation Complex Type>.
getInvalidationResponse_invalidation :: Lens.Lens' GetInvalidationResponse (Prelude.Maybe Invalidation)
getInvalidationResponse_invalidation :: (Maybe Invalidation -> f (Maybe Invalidation))
-> GetInvalidationResponse -> f GetInvalidationResponse
getInvalidationResponse_invalidation = (GetInvalidationResponse -> Maybe Invalidation)
-> (GetInvalidationResponse
    -> Maybe Invalidation -> GetInvalidationResponse)
-> Lens
     GetInvalidationResponse
     GetInvalidationResponse
     (Maybe Invalidation)
     (Maybe Invalidation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetInvalidationResponse' {Maybe Invalidation
invalidation :: Maybe Invalidation
$sel:invalidation:GetInvalidationResponse' :: GetInvalidationResponse -> Maybe Invalidation
invalidation} -> Maybe Invalidation
invalidation) (\s :: GetInvalidationResponse
s@GetInvalidationResponse' {} Maybe Invalidation
a -> GetInvalidationResponse
s {$sel:invalidation:GetInvalidationResponse' :: Maybe Invalidation
invalidation = Maybe Invalidation
a} :: GetInvalidationResponse)

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

instance Prelude.NFData GetInvalidationResponse