{-# 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.Backup.ExportBackupPlanTemplate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the backup plan that is specified by the plan ID as a backup
-- template.
module Amazonka.Backup.ExportBackupPlanTemplate
  ( -- * Creating a Request
    ExportBackupPlanTemplate (..),
    newExportBackupPlanTemplate,

    -- * Request Lenses
    exportBackupPlanTemplate_backupPlanId,

    -- * Destructuring the Response
    ExportBackupPlanTemplateResponse (..),
    newExportBackupPlanTemplateResponse,

    -- * Response Lenses
    exportBackupPlanTemplateResponse_backupPlanTemplateJson,
    exportBackupPlanTemplateResponse_httpStatus,
  )
where

import Amazonka.Backup.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newExportBackupPlanTemplate' smart constructor.
data ExportBackupPlanTemplate = ExportBackupPlanTemplate'
  { -- | Uniquely identifies a backup plan.
    ExportBackupPlanTemplate -> Text
backupPlanId :: Prelude.Text
  }
  deriving (ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool
$c/= :: ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool
== :: ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool
$c== :: ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool
Prelude.Eq, ReadPrec [ExportBackupPlanTemplate]
ReadPrec ExportBackupPlanTemplate
Int -> ReadS ExportBackupPlanTemplate
ReadS [ExportBackupPlanTemplate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportBackupPlanTemplate]
$creadListPrec :: ReadPrec [ExportBackupPlanTemplate]
readPrec :: ReadPrec ExportBackupPlanTemplate
$creadPrec :: ReadPrec ExportBackupPlanTemplate
readList :: ReadS [ExportBackupPlanTemplate]
$creadList :: ReadS [ExportBackupPlanTemplate]
readsPrec :: Int -> ReadS ExportBackupPlanTemplate
$creadsPrec :: Int -> ReadS ExportBackupPlanTemplate
Prelude.Read, Int -> ExportBackupPlanTemplate -> ShowS
[ExportBackupPlanTemplate] -> ShowS
ExportBackupPlanTemplate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportBackupPlanTemplate] -> ShowS
$cshowList :: [ExportBackupPlanTemplate] -> ShowS
show :: ExportBackupPlanTemplate -> String
$cshow :: ExportBackupPlanTemplate -> String
showsPrec :: Int -> ExportBackupPlanTemplate -> ShowS
$cshowsPrec :: Int -> ExportBackupPlanTemplate -> ShowS
Prelude.Show, forall x.
Rep ExportBackupPlanTemplate x -> ExportBackupPlanTemplate
forall x.
ExportBackupPlanTemplate -> Rep ExportBackupPlanTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExportBackupPlanTemplate x -> ExportBackupPlanTemplate
$cfrom :: forall x.
ExportBackupPlanTemplate -> Rep ExportBackupPlanTemplate x
Prelude.Generic)

-- |
-- Create a value of 'ExportBackupPlanTemplate' 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:
--
-- 'backupPlanId', 'exportBackupPlanTemplate_backupPlanId' - Uniquely identifies a backup plan.
newExportBackupPlanTemplate ::
  -- | 'backupPlanId'
  Prelude.Text ->
  ExportBackupPlanTemplate
newExportBackupPlanTemplate :: Text -> ExportBackupPlanTemplate
newExportBackupPlanTemplate Text
pBackupPlanId_ =
  ExportBackupPlanTemplate'
    { $sel:backupPlanId:ExportBackupPlanTemplate' :: Text
backupPlanId =
        Text
pBackupPlanId_
    }

-- | Uniquely identifies a backup plan.
exportBackupPlanTemplate_backupPlanId :: Lens.Lens' ExportBackupPlanTemplate Prelude.Text
exportBackupPlanTemplate_backupPlanId :: Lens' ExportBackupPlanTemplate Text
exportBackupPlanTemplate_backupPlanId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportBackupPlanTemplate' {Text
backupPlanId :: Text
$sel:backupPlanId:ExportBackupPlanTemplate' :: ExportBackupPlanTemplate -> Text
backupPlanId} -> Text
backupPlanId) (\s :: ExportBackupPlanTemplate
s@ExportBackupPlanTemplate' {} Text
a -> ExportBackupPlanTemplate
s {$sel:backupPlanId:ExportBackupPlanTemplate' :: Text
backupPlanId = Text
a} :: ExportBackupPlanTemplate)

instance Core.AWSRequest ExportBackupPlanTemplate where
  type
    AWSResponse ExportBackupPlanTemplate =
      ExportBackupPlanTemplateResponse
  request :: (Service -> Service)
-> ExportBackupPlanTemplate -> Request ExportBackupPlanTemplate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ExportBackupPlanTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ExportBackupPlanTemplate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> ExportBackupPlanTemplateResponse
ExportBackupPlanTemplateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"BackupPlanTemplateJson")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ExportBackupPlanTemplate where
  hashWithSalt :: Int -> ExportBackupPlanTemplate -> Int
hashWithSalt Int
_salt ExportBackupPlanTemplate' {Text
backupPlanId :: Text
$sel:backupPlanId:ExportBackupPlanTemplate' :: ExportBackupPlanTemplate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
backupPlanId

instance Prelude.NFData ExportBackupPlanTemplate where
  rnf :: ExportBackupPlanTemplate -> ()
rnf ExportBackupPlanTemplate' {Text
backupPlanId :: Text
$sel:backupPlanId:ExportBackupPlanTemplate' :: ExportBackupPlanTemplate -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
backupPlanId

instance Data.ToHeaders ExportBackupPlanTemplate where
  toHeaders :: ExportBackupPlanTemplate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ExportBackupPlanTemplate where
  toPath :: ExportBackupPlanTemplate -> ByteString
toPath ExportBackupPlanTemplate' {Text
backupPlanId :: Text
$sel:backupPlanId:ExportBackupPlanTemplate' :: ExportBackupPlanTemplate -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/backup/plans/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
backupPlanId,
        ByteString
"/toTemplate/"
      ]

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

-- | /See:/ 'newExportBackupPlanTemplateResponse' smart constructor.
data ExportBackupPlanTemplateResponse = ExportBackupPlanTemplateResponse'
  { -- | The body of a backup plan template in JSON format.
    --
    -- This is a signed JSON document that cannot be modified before being
    -- passed to @GetBackupPlanFromJSON.@
    ExportBackupPlanTemplateResponse -> Maybe Text
backupPlanTemplateJson :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ExportBackupPlanTemplateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ExportBackupPlanTemplateResponse
-> ExportBackupPlanTemplateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportBackupPlanTemplateResponse
-> ExportBackupPlanTemplateResponse -> Bool
$c/= :: ExportBackupPlanTemplateResponse
-> ExportBackupPlanTemplateResponse -> Bool
== :: ExportBackupPlanTemplateResponse
-> ExportBackupPlanTemplateResponse -> Bool
$c== :: ExportBackupPlanTemplateResponse
-> ExportBackupPlanTemplateResponse -> Bool
Prelude.Eq, ReadPrec [ExportBackupPlanTemplateResponse]
ReadPrec ExportBackupPlanTemplateResponse
Int -> ReadS ExportBackupPlanTemplateResponse
ReadS [ExportBackupPlanTemplateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportBackupPlanTemplateResponse]
$creadListPrec :: ReadPrec [ExportBackupPlanTemplateResponse]
readPrec :: ReadPrec ExportBackupPlanTemplateResponse
$creadPrec :: ReadPrec ExportBackupPlanTemplateResponse
readList :: ReadS [ExportBackupPlanTemplateResponse]
$creadList :: ReadS [ExportBackupPlanTemplateResponse]
readsPrec :: Int -> ReadS ExportBackupPlanTemplateResponse
$creadsPrec :: Int -> ReadS ExportBackupPlanTemplateResponse
Prelude.Read, Int -> ExportBackupPlanTemplateResponse -> ShowS
[ExportBackupPlanTemplateResponse] -> ShowS
ExportBackupPlanTemplateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportBackupPlanTemplateResponse] -> ShowS
$cshowList :: [ExportBackupPlanTemplateResponse] -> ShowS
show :: ExportBackupPlanTemplateResponse -> String
$cshow :: ExportBackupPlanTemplateResponse -> String
showsPrec :: Int -> ExportBackupPlanTemplateResponse -> ShowS
$cshowsPrec :: Int -> ExportBackupPlanTemplateResponse -> ShowS
Prelude.Show, forall x.
Rep ExportBackupPlanTemplateResponse x
-> ExportBackupPlanTemplateResponse
forall x.
ExportBackupPlanTemplateResponse
-> Rep ExportBackupPlanTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExportBackupPlanTemplateResponse x
-> ExportBackupPlanTemplateResponse
$cfrom :: forall x.
ExportBackupPlanTemplateResponse
-> Rep ExportBackupPlanTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'ExportBackupPlanTemplateResponse' 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:
--
-- 'backupPlanTemplateJson', 'exportBackupPlanTemplateResponse_backupPlanTemplateJson' - The body of a backup plan template in JSON format.
--
-- This is a signed JSON document that cannot be modified before being
-- passed to @GetBackupPlanFromJSON.@
--
-- 'httpStatus', 'exportBackupPlanTemplateResponse_httpStatus' - The response's http status code.
newExportBackupPlanTemplateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ExportBackupPlanTemplateResponse
newExportBackupPlanTemplateResponse :: Int -> ExportBackupPlanTemplateResponse
newExportBackupPlanTemplateResponse Int
pHttpStatus_ =
  ExportBackupPlanTemplateResponse'
    { $sel:backupPlanTemplateJson:ExportBackupPlanTemplateResponse' :: Maybe Text
backupPlanTemplateJson =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ExportBackupPlanTemplateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The body of a backup plan template in JSON format.
--
-- This is a signed JSON document that cannot be modified before being
-- passed to @GetBackupPlanFromJSON.@
exportBackupPlanTemplateResponse_backupPlanTemplateJson :: Lens.Lens' ExportBackupPlanTemplateResponse (Prelude.Maybe Prelude.Text)
exportBackupPlanTemplateResponse_backupPlanTemplateJson :: Lens' ExportBackupPlanTemplateResponse (Maybe Text)
exportBackupPlanTemplateResponse_backupPlanTemplateJson = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportBackupPlanTemplateResponse' {Maybe Text
backupPlanTemplateJson :: Maybe Text
$sel:backupPlanTemplateJson:ExportBackupPlanTemplateResponse' :: ExportBackupPlanTemplateResponse -> Maybe Text
backupPlanTemplateJson} -> Maybe Text
backupPlanTemplateJson) (\s :: ExportBackupPlanTemplateResponse
s@ExportBackupPlanTemplateResponse' {} Maybe Text
a -> ExportBackupPlanTemplateResponse
s {$sel:backupPlanTemplateJson:ExportBackupPlanTemplateResponse' :: Maybe Text
backupPlanTemplateJson = Maybe Text
a} :: ExportBackupPlanTemplateResponse)

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

instance
  Prelude.NFData
    ExportBackupPlanTemplateResponse
  where
  rnf :: ExportBackupPlanTemplateResponse -> ()
rnf ExportBackupPlanTemplateResponse' {Int
Maybe Text
httpStatus :: Int
backupPlanTemplateJson :: Maybe Text
$sel:httpStatus:ExportBackupPlanTemplateResponse' :: ExportBackupPlanTemplateResponse -> Int
$sel:backupPlanTemplateJson:ExportBackupPlanTemplateResponse' :: ExportBackupPlanTemplateResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
backupPlanTemplateJson
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus