{-# 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-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)
--
-- 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.Lens as Lens
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
(ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool)
-> (ExportBackupPlanTemplate -> ExportBackupPlanTemplate -> Bool)
-> Eq ExportBackupPlanTemplate
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]
(Int -> ReadS ExportBackupPlanTemplate)
-> ReadS [ExportBackupPlanTemplate]
-> ReadPrec ExportBackupPlanTemplate
-> ReadPrec [ExportBackupPlanTemplate]
-> Read 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
(Int -> ExportBackupPlanTemplate -> ShowS)
-> (ExportBackupPlanTemplate -> String)
-> ([ExportBackupPlanTemplate] -> ShowS)
-> Show ExportBackupPlanTemplate
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.
 ExportBackupPlanTemplate -> Rep ExportBackupPlanTemplate x)
-> (forall x.
    Rep ExportBackupPlanTemplate x -> ExportBackupPlanTemplate)
-> Generic ExportBackupPlanTemplate
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' :: Text -> ExportBackupPlanTemplate
ExportBackupPlanTemplate'
    { $sel:backupPlanId:ExportBackupPlanTemplate' :: Text
backupPlanId =
        Text
pBackupPlanId_
    }

-- | Uniquely identifies a backup plan.
exportBackupPlanTemplate_backupPlanId :: Lens.Lens' ExportBackupPlanTemplate Prelude.Text
exportBackupPlanTemplate_backupPlanId :: (Text -> f Text)
-> ExportBackupPlanTemplate -> f ExportBackupPlanTemplate
exportBackupPlanTemplate_backupPlanId = (ExportBackupPlanTemplate -> Text)
-> (ExportBackupPlanTemplate -> Text -> ExportBackupPlanTemplate)
-> Lens ExportBackupPlanTemplate ExportBackupPlanTemplate Text Text
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 :: ExportBackupPlanTemplate -> Request ExportBackupPlanTemplate
request = Service
-> ExportBackupPlanTemplate -> Request ExportBackupPlanTemplate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ExportBackupPlanTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ExportBackupPlanTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ExportBackupPlanTemplate))
-> Logger
-> Service
-> Proxy ExportBackupPlanTemplate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ExportBackupPlanTemplate)))
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 Text -> Int -> ExportBackupPlanTemplateResponse
ExportBackupPlanTemplateResponse'
            (Maybe Text -> Int -> ExportBackupPlanTemplateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ExportBackupPlanTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"BackupPlanTemplateJson")
            Either String (Int -> ExportBackupPlanTemplateResponse)
-> Either String Int
-> Either String ExportBackupPlanTemplateResponse
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 ExportBackupPlanTemplate

instance Prelude.NFData ExportBackupPlanTemplate

instance Core.ToHeaders ExportBackupPlanTemplate where
  toHeaders :: ExportBackupPlanTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ExportBackupPlanTemplate -> 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 ExportBackupPlanTemplate where
  toPath :: ExportBackupPlanTemplate -> ByteString
toPath ExportBackupPlanTemplate' {Text
backupPlanId :: Text
$sel:backupPlanId:ExportBackupPlanTemplate' :: ExportBackupPlanTemplate -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/backup/plans/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
backupPlanId,
        ByteString
"/toTemplate/"
      ]

instance Core.ToQuery ExportBackupPlanTemplate where
  toQuery :: ExportBackupPlanTemplate -> QueryString
toQuery = QueryString -> ExportBackupPlanTemplate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(ExportBackupPlanTemplateResponse
 -> ExportBackupPlanTemplateResponse -> Bool)
-> (ExportBackupPlanTemplateResponse
    -> ExportBackupPlanTemplateResponse -> Bool)
-> Eq ExportBackupPlanTemplateResponse
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]
(Int -> ReadS ExportBackupPlanTemplateResponse)
-> ReadS [ExportBackupPlanTemplateResponse]
-> ReadPrec ExportBackupPlanTemplateResponse
-> ReadPrec [ExportBackupPlanTemplateResponse]
-> Read 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
(Int -> ExportBackupPlanTemplateResponse -> ShowS)
-> (ExportBackupPlanTemplateResponse -> String)
-> ([ExportBackupPlanTemplateResponse] -> ShowS)
-> Show ExportBackupPlanTemplateResponse
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.
 ExportBackupPlanTemplateResponse
 -> Rep ExportBackupPlanTemplateResponse x)
-> (forall x.
    Rep ExportBackupPlanTemplateResponse x
    -> ExportBackupPlanTemplateResponse)
-> Generic ExportBackupPlanTemplateResponse
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' :: Maybe Text -> Int -> ExportBackupPlanTemplateResponse
ExportBackupPlanTemplateResponse'
    { $sel:backupPlanTemplateJson:ExportBackupPlanTemplateResponse' :: Maybe Text
backupPlanTemplateJson =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> ExportBackupPlanTemplateResponse
-> f ExportBackupPlanTemplateResponse
exportBackupPlanTemplateResponse_backupPlanTemplateJson = (ExportBackupPlanTemplateResponse -> Maybe Text)
-> (ExportBackupPlanTemplateResponse
    -> Maybe Text -> ExportBackupPlanTemplateResponse)
-> Lens
     ExportBackupPlanTemplateResponse
     ExportBackupPlanTemplateResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> ExportBackupPlanTemplateResponse
-> f ExportBackupPlanTemplateResponse
exportBackupPlanTemplateResponse_httpStatus = (ExportBackupPlanTemplateResponse -> Int)
-> (ExportBackupPlanTemplateResponse
    -> Int -> ExportBackupPlanTemplateResponse)
-> Lens
     ExportBackupPlanTemplateResponse
     ExportBackupPlanTemplateResponse
     Int
     Int
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