{-# 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.StartRestoreJob
-- 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)
--
-- Recovers the saved resource identified by an Amazon Resource Name (ARN).
module Amazonka.Backup.StartRestoreJob
  ( -- * Creating a Request
    StartRestoreJob (..),
    newStartRestoreJob,

    -- * Request Lenses
    startRestoreJob_idempotencyToken,
    startRestoreJob_resourceType,
    startRestoreJob_recoveryPointArn,
    startRestoreJob_metadata,
    startRestoreJob_iamRoleArn,

    -- * Destructuring the Response
    StartRestoreJobResponse (..),
    newStartRestoreJobResponse,

    -- * Response Lenses
    startRestoreJobResponse_restoreJobId,
    startRestoreJobResponse_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:/ 'newStartRestoreJob' smart constructor.
data StartRestoreJob = StartRestoreJob'
  { -- | A customer-chosen string that you can use to distinguish between
    -- otherwise identical calls to @StartRestoreJob@. Retrying a successful
    -- request with the same idempotency token results in a success message
    -- with no action taken.
    StartRestoreJob -> Maybe Text
idempotencyToken :: Prelude.Maybe Prelude.Text,
    -- | Starts a job to restore a recovery point for one of the following
    -- resources:
    --
    -- -   @DynamoDB@ for Amazon DynamoDB
    --
    -- -   @EBS@ for Amazon Elastic Block Store
    --
    -- -   @EC2@ for Amazon Elastic Compute Cloud
    --
    -- -   @EFS@ for Amazon Elastic File System
    --
    -- -   @RDS@ for Amazon Relational Database Service
    --
    -- -   @Aurora@ for Amazon Aurora
    --
    -- -   @Storage Gateway@ for Storage Gateway
    StartRestoreJob -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | An ARN that uniquely identifies a recovery point; for example,
    -- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
    StartRestoreJob -> Text
recoveryPointArn :: Prelude.Text,
    -- | A set of metadata key-value pairs. Contains information, such as a
    -- resource name, required to restore a recovery point.
    --
    -- You can get configuration metadata about a resource at the time it was
    -- backed up by calling @GetRecoveryPointRestoreMetadata@. However, values
    -- in addition to those provided by @GetRecoveryPointRestoreMetadata@ might
    -- be required to restore a resource. For example, you might need to
    -- provide a new resource name if the original already exists.
    --
    -- You need to specify specific metadata to restore an Amazon Elastic File
    -- System (Amazon EFS) instance:
    --
    -- -   @file-system-id@: The ID of the Amazon EFS file system that is
    --     backed up by Backup. Returned in @GetRecoveryPointRestoreMetadata@.
    --
    -- -   @Encrypted@: A Boolean value that, if true, specifies that the file
    --     system is encrypted. If @KmsKeyId@ is specified, @Encrypted@ must be
    --     set to @true@.
    --
    -- -   @KmsKeyId@: Specifies the Amazon Web Services KMS key that is used
    --     to encrypt the restored file system. You can specify a key from
    --     another Amazon Web Services account provided that key it is properly
    --     shared with your account via Amazon Web Services KMS.
    --
    -- -   @PerformanceMode@: Specifies the throughput mode of the file system.
    --
    -- -   @CreationToken@: A user-supplied value that ensures the uniqueness
    --     (idempotency) of the request.
    --
    -- -   @newFileSystem@: A Boolean value that, if true, specifies that the
    --     recovery point is restored to a new Amazon EFS file system.
    --
    -- -   @ItemsToRestore@: An array of one to five strings where each string
    --     is a file path. Use @ItemsToRestore@ to restore specific files or
    --     directories rather than the entire file system. This parameter is
    --     optional. For example, @\"itemsToRestore\":\"[\\\"\/my.test\\\"]\"@.
    StartRestoreJob -> Sensitive (HashMap Text Text)
metadata :: Core.Sensitive (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The Amazon Resource Name (ARN) of the IAM role that Backup uses to
    -- create the target recovery point; for example,
    -- @arn:aws:iam::123456789012:role\/S3Access@.
    StartRestoreJob -> Text
iamRoleArn :: Prelude.Text
  }
  deriving (StartRestoreJob -> StartRestoreJob -> Bool
(StartRestoreJob -> StartRestoreJob -> Bool)
-> (StartRestoreJob -> StartRestoreJob -> Bool)
-> Eq StartRestoreJob
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartRestoreJob -> StartRestoreJob -> Bool
$c/= :: StartRestoreJob -> StartRestoreJob -> Bool
== :: StartRestoreJob -> StartRestoreJob -> Bool
$c== :: StartRestoreJob -> StartRestoreJob -> Bool
Prelude.Eq, Int -> StartRestoreJob -> ShowS
[StartRestoreJob] -> ShowS
StartRestoreJob -> String
(Int -> StartRestoreJob -> ShowS)
-> (StartRestoreJob -> String)
-> ([StartRestoreJob] -> ShowS)
-> Show StartRestoreJob
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartRestoreJob] -> ShowS
$cshowList :: [StartRestoreJob] -> ShowS
show :: StartRestoreJob -> String
$cshow :: StartRestoreJob -> String
showsPrec :: Int -> StartRestoreJob -> ShowS
$cshowsPrec :: Int -> StartRestoreJob -> ShowS
Prelude.Show, (forall x. StartRestoreJob -> Rep StartRestoreJob x)
-> (forall x. Rep StartRestoreJob x -> StartRestoreJob)
-> Generic StartRestoreJob
forall x. Rep StartRestoreJob x -> StartRestoreJob
forall x. StartRestoreJob -> Rep StartRestoreJob x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartRestoreJob x -> StartRestoreJob
$cfrom :: forall x. StartRestoreJob -> Rep StartRestoreJob x
Prelude.Generic)

-- |
-- Create a value of 'StartRestoreJob' 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:
--
-- 'idempotencyToken', 'startRestoreJob_idempotencyToken' - A customer-chosen string that you can use to distinguish between
-- otherwise identical calls to @StartRestoreJob@. Retrying a successful
-- request with the same idempotency token results in a success message
-- with no action taken.
--
-- 'resourceType', 'startRestoreJob_resourceType' - Starts a job to restore a recovery point for one of the following
-- resources:
--
-- -   @DynamoDB@ for Amazon DynamoDB
--
-- -   @EBS@ for Amazon Elastic Block Store
--
-- -   @EC2@ for Amazon Elastic Compute Cloud
--
-- -   @EFS@ for Amazon Elastic File System
--
-- -   @RDS@ for Amazon Relational Database Service
--
-- -   @Aurora@ for Amazon Aurora
--
-- -   @Storage Gateway@ for Storage Gateway
--
-- 'recoveryPointArn', 'startRestoreJob_recoveryPointArn' - An ARN that uniquely identifies a recovery point; for example,
-- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
--
-- 'metadata', 'startRestoreJob_metadata' - A set of metadata key-value pairs. Contains information, such as a
-- resource name, required to restore a recovery point.
--
-- You can get configuration metadata about a resource at the time it was
-- backed up by calling @GetRecoveryPointRestoreMetadata@. However, values
-- in addition to those provided by @GetRecoveryPointRestoreMetadata@ might
-- be required to restore a resource. For example, you might need to
-- provide a new resource name if the original already exists.
--
-- You need to specify specific metadata to restore an Amazon Elastic File
-- System (Amazon EFS) instance:
--
-- -   @file-system-id@: The ID of the Amazon EFS file system that is
--     backed up by Backup. Returned in @GetRecoveryPointRestoreMetadata@.
--
-- -   @Encrypted@: A Boolean value that, if true, specifies that the file
--     system is encrypted. If @KmsKeyId@ is specified, @Encrypted@ must be
--     set to @true@.
--
-- -   @KmsKeyId@: Specifies the Amazon Web Services KMS key that is used
--     to encrypt the restored file system. You can specify a key from
--     another Amazon Web Services account provided that key it is properly
--     shared with your account via Amazon Web Services KMS.
--
-- -   @PerformanceMode@: Specifies the throughput mode of the file system.
--
-- -   @CreationToken@: A user-supplied value that ensures the uniqueness
--     (idempotency) of the request.
--
-- -   @newFileSystem@: A Boolean value that, if true, specifies that the
--     recovery point is restored to a new Amazon EFS file system.
--
-- -   @ItemsToRestore@: An array of one to five strings where each string
--     is a file path. Use @ItemsToRestore@ to restore specific files or
--     directories rather than the entire file system. This parameter is
--     optional. For example, @\"itemsToRestore\":\"[\\\"\/my.test\\\"]\"@.
--
-- 'iamRoleArn', 'startRestoreJob_iamRoleArn' - The Amazon Resource Name (ARN) of the IAM role that Backup uses to
-- create the target recovery point; for example,
-- @arn:aws:iam::123456789012:role\/S3Access@.
newStartRestoreJob ::
  -- | 'recoveryPointArn'
  Prelude.Text ->
  -- | 'iamRoleArn'
  Prelude.Text ->
  StartRestoreJob
newStartRestoreJob :: Text -> Text -> StartRestoreJob
newStartRestoreJob Text
pRecoveryPointArn_ Text
pIamRoleArn_ =
  StartRestoreJob' :: Maybe Text
-> Maybe Text
-> Text
-> Sensitive (HashMap Text Text)
-> Text
-> StartRestoreJob
StartRestoreJob'
    { $sel:idempotencyToken:StartRestoreJob' :: Maybe Text
idempotencyToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:StartRestoreJob' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recoveryPointArn:StartRestoreJob' :: Text
recoveryPointArn = Text
pRecoveryPointArn_,
      $sel:metadata:StartRestoreJob' :: Sensitive (HashMap Text Text)
metadata = Sensitive (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty,
      $sel:iamRoleArn:StartRestoreJob' :: Text
iamRoleArn = Text
pIamRoleArn_
    }

-- | A customer-chosen string that you can use to distinguish between
-- otherwise identical calls to @StartRestoreJob@. Retrying a successful
-- request with the same idempotency token results in a success message
-- with no action taken.
startRestoreJob_idempotencyToken :: Lens.Lens' StartRestoreJob (Prelude.Maybe Prelude.Text)
startRestoreJob_idempotencyToken :: (Maybe Text -> f (Maybe Text))
-> StartRestoreJob -> f StartRestoreJob
startRestoreJob_idempotencyToken = (StartRestoreJob -> Maybe Text)
-> (StartRestoreJob -> Maybe Text -> StartRestoreJob)
-> Lens StartRestoreJob StartRestoreJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJob' {Maybe Text
idempotencyToken :: Maybe Text
$sel:idempotencyToken:StartRestoreJob' :: StartRestoreJob -> Maybe Text
idempotencyToken} -> Maybe Text
idempotencyToken) (\s :: StartRestoreJob
s@StartRestoreJob' {} Maybe Text
a -> StartRestoreJob
s {$sel:idempotencyToken:StartRestoreJob' :: Maybe Text
idempotencyToken = Maybe Text
a} :: StartRestoreJob)

-- | Starts a job to restore a recovery point for one of the following
-- resources:
--
-- -   @DynamoDB@ for Amazon DynamoDB
--
-- -   @EBS@ for Amazon Elastic Block Store
--
-- -   @EC2@ for Amazon Elastic Compute Cloud
--
-- -   @EFS@ for Amazon Elastic File System
--
-- -   @RDS@ for Amazon Relational Database Service
--
-- -   @Aurora@ for Amazon Aurora
--
-- -   @Storage Gateway@ for Storage Gateway
startRestoreJob_resourceType :: Lens.Lens' StartRestoreJob (Prelude.Maybe Prelude.Text)
startRestoreJob_resourceType :: (Maybe Text -> f (Maybe Text))
-> StartRestoreJob -> f StartRestoreJob
startRestoreJob_resourceType = (StartRestoreJob -> Maybe Text)
-> (StartRestoreJob -> Maybe Text -> StartRestoreJob)
-> Lens StartRestoreJob StartRestoreJob (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJob' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:StartRestoreJob' :: StartRestoreJob -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: StartRestoreJob
s@StartRestoreJob' {} Maybe Text
a -> StartRestoreJob
s {$sel:resourceType:StartRestoreJob' :: Maybe Text
resourceType = Maybe Text
a} :: StartRestoreJob)

-- | An ARN that uniquely identifies a recovery point; for example,
-- @arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45@.
startRestoreJob_recoveryPointArn :: Lens.Lens' StartRestoreJob Prelude.Text
startRestoreJob_recoveryPointArn :: (Text -> f Text) -> StartRestoreJob -> f StartRestoreJob
startRestoreJob_recoveryPointArn = (StartRestoreJob -> Text)
-> (StartRestoreJob -> Text -> StartRestoreJob)
-> Lens StartRestoreJob StartRestoreJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJob' {Text
recoveryPointArn :: Text
$sel:recoveryPointArn:StartRestoreJob' :: StartRestoreJob -> Text
recoveryPointArn} -> Text
recoveryPointArn) (\s :: StartRestoreJob
s@StartRestoreJob' {} Text
a -> StartRestoreJob
s {$sel:recoveryPointArn:StartRestoreJob' :: Text
recoveryPointArn = Text
a} :: StartRestoreJob)

-- | A set of metadata key-value pairs. Contains information, such as a
-- resource name, required to restore a recovery point.
--
-- You can get configuration metadata about a resource at the time it was
-- backed up by calling @GetRecoveryPointRestoreMetadata@. However, values
-- in addition to those provided by @GetRecoveryPointRestoreMetadata@ might
-- be required to restore a resource. For example, you might need to
-- provide a new resource name if the original already exists.
--
-- You need to specify specific metadata to restore an Amazon Elastic File
-- System (Amazon EFS) instance:
--
-- -   @file-system-id@: The ID of the Amazon EFS file system that is
--     backed up by Backup. Returned in @GetRecoveryPointRestoreMetadata@.
--
-- -   @Encrypted@: A Boolean value that, if true, specifies that the file
--     system is encrypted. If @KmsKeyId@ is specified, @Encrypted@ must be
--     set to @true@.
--
-- -   @KmsKeyId@: Specifies the Amazon Web Services KMS key that is used
--     to encrypt the restored file system. You can specify a key from
--     another Amazon Web Services account provided that key it is properly
--     shared with your account via Amazon Web Services KMS.
--
-- -   @PerformanceMode@: Specifies the throughput mode of the file system.
--
-- -   @CreationToken@: A user-supplied value that ensures the uniqueness
--     (idempotency) of the request.
--
-- -   @newFileSystem@: A Boolean value that, if true, specifies that the
--     recovery point is restored to a new Amazon EFS file system.
--
-- -   @ItemsToRestore@: An array of one to five strings where each string
--     is a file path. Use @ItemsToRestore@ to restore specific files or
--     directories rather than the entire file system. This parameter is
--     optional. For example, @\"itemsToRestore\":\"[\\\"\/my.test\\\"]\"@.
startRestoreJob_metadata :: Lens.Lens' StartRestoreJob (Prelude.HashMap Prelude.Text Prelude.Text)
startRestoreJob_metadata :: (HashMap Text Text -> f (HashMap Text Text))
-> StartRestoreJob -> f StartRestoreJob
startRestoreJob_metadata = (StartRestoreJob -> Sensitive (HashMap Text Text))
-> (StartRestoreJob
    -> Sensitive (HashMap Text Text) -> StartRestoreJob)
-> Lens
     StartRestoreJob
     StartRestoreJob
     (Sensitive (HashMap Text Text))
     (Sensitive (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJob' {Sensitive (HashMap Text Text)
metadata :: Sensitive (HashMap Text Text)
$sel:metadata:StartRestoreJob' :: StartRestoreJob -> Sensitive (HashMap Text Text)
metadata} -> Sensitive (HashMap Text Text)
metadata) (\s :: StartRestoreJob
s@StartRestoreJob' {} Sensitive (HashMap Text Text)
a -> StartRestoreJob
s {$sel:metadata:StartRestoreJob' :: Sensitive (HashMap Text Text)
metadata = Sensitive (HashMap Text Text)
a} :: StartRestoreJob) ((Sensitive (HashMap Text Text)
  -> f (Sensitive (HashMap Text Text)))
 -> StartRestoreJob -> f StartRestoreJob)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> Sensitive (HashMap Text Text)
    -> f (Sensitive (HashMap Text Text)))
-> (HashMap Text Text -> f (HashMap Text Text))
-> StartRestoreJob
-> f StartRestoreJob
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> Sensitive (HashMap Text Text)
-> f (Sensitive (HashMap Text Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive ((HashMap Text Text -> f (HashMap Text Text))
 -> Sensitive (HashMap Text Text)
 -> f (Sensitive (HashMap Text Text)))
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> Sensitive (HashMap Text Text)
-> f (Sensitive (HashMap Text Text))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the IAM role that Backup uses to
-- create the target recovery point; for example,
-- @arn:aws:iam::123456789012:role\/S3Access@.
startRestoreJob_iamRoleArn :: Lens.Lens' StartRestoreJob Prelude.Text
startRestoreJob_iamRoleArn :: (Text -> f Text) -> StartRestoreJob -> f StartRestoreJob
startRestoreJob_iamRoleArn = (StartRestoreJob -> Text)
-> (StartRestoreJob -> Text -> StartRestoreJob)
-> Lens StartRestoreJob StartRestoreJob Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJob' {Text
iamRoleArn :: Text
$sel:iamRoleArn:StartRestoreJob' :: StartRestoreJob -> Text
iamRoleArn} -> Text
iamRoleArn) (\s :: StartRestoreJob
s@StartRestoreJob' {} Text
a -> StartRestoreJob
s {$sel:iamRoleArn:StartRestoreJob' :: Text
iamRoleArn = Text
a} :: StartRestoreJob)

instance Core.AWSRequest StartRestoreJob where
  type
    AWSResponse StartRestoreJob =
      StartRestoreJobResponse
  request :: StartRestoreJob -> Request StartRestoreJob
request = Service -> StartRestoreJob -> Request StartRestoreJob
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartRestoreJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartRestoreJob)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartRestoreJob))
-> Logger
-> Service
-> Proxy StartRestoreJob
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartRestoreJob)))
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 -> StartRestoreJobResponse
StartRestoreJobResponse'
            (Maybe Text -> Int -> StartRestoreJobResponse)
-> Either String (Maybe Text)
-> Either String (Int -> StartRestoreJobResponse)
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
"RestoreJobId")
            Either String (Int -> StartRestoreJobResponse)
-> Either String Int -> Either String StartRestoreJobResponse
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 StartRestoreJob

instance Prelude.NFData StartRestoreJob

instance Core.ToHeaders StartRestoreJob where
  toHeaders :: StartRestoreJob -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartRestoreJob -> 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.ToJSON StartRestoreJob where
  toJSON :: StartRestoreJob -> Value
toJSON StartRestoreJob' {Maybe Text
Text
Sensitive (HashMap Text Text)
iamRoleArn :: Text
metadata :: Sensitive (HashMap Text Text)
recoveryPointArn :: Text
resourceType :: Maybe Text
idempotencyToken :: Maybe Text
$sel:iamRoleArn:StartRestoreJob' :: StartRestoreJob -> Text
$sel:metadata:StartRestoreJob' :: StartRestoreJob -> Sensitive (HashMap Text Text)
$sel:recoveryPointArn:StartRestoreJob' :: StartRestoreJob -> Text
$sel:resourceType:StartRestoreJob' :: StartRestoreJob -> Maybe Text
$sel:idempotencyToken:StartRestoreJob' :: StartRestoreJob -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IdempotencyToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
idempotencyToken,
            (Text
"ResourceType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
resourceType,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RecoveryPointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
recoveryPointArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Metadata" Text -> Sensitive (HashMap Text Text) -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive (HashMap Text Text)
metadata),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"IamRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
iamRoleArn)
          ]
      )

instance Core.ToPath StartRestoreJob where
  toPath :: StartRestoreJob -> ByteString
toPath = ByteString -> StartRestoreJob -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/restore-jobs"

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

-- | /See:/ 'newStartRestoreJobResponse' smart constructor.
data StartRestoreJobResponse = StartRestoreJobResponse'
  { -- | Uniquely identifies the job that restores a recovery point.
    StartRestoreJobResponse -> Maybe Text
restoreJobId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartRestoreJobResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartRestoreJobResponse -> StartRestoreJobResponse -> Bool
(StartRestoreJobResponse -> StartRestoreJobResponse -> Bool)
-> (StartRestoreJobResponse -> StartRestoreJobResponse -> Bool)
-> Eq StartRestoreJobResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartRestoreJobResponse -> StartRestoreJobResponse -> Bool
$c/= :: StartRestoreJobResponse -> StartRestoreJobResponse -> Bool
== :: StartRestoreJobResponse -> StartRestoreJobResponse -> Bool
$c== :: StartRestoreJobResponse -> StartRestoreJobResponse -> Bool
Prelude.Eq, ReadPrec [StartRestoreJobResponse]
ReadPrec StartRestoreJobResponse
Int -> ReadS StartRestoreJobResponse
ReadS [StartRestoreJobResponse]
(Int -> ReadS StartRestoreJobResponse)
-> ReadS [StartRestoreJobResponse]
-> ReadPrec StartRestoreJobResponse
-> ReadPrec [StartRestoreJobResponse]
-> Read StartRestoreJobResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartRestoreJobResponse]
$creadListPrec :: ReadPrec [StartRestoreJobResponse]
readPrec :: ReadPrec StartRestoreJobResponse
$creadPrec :: ReadPrec StartRestoreJobResponse
readList :: ReadS [StartRestoreJobResponse]
$creadList :: ReadS [StartRestoreJobResponse]
readsPrec :: Int -> ReadS StartRestoreJobResponse
$creadsPrec :: Int -> ReadS StartRestoreJobResponse
Prelude.Read, Int -> StartRestoreJobResponse -> ShowS
[StartRestoreJobResponse] -> ShowS
StartRestoreJobResponse -> String
(Int -> StartRestoreJobResponse -> ShowS)
-> (StartRestoreJobResponse -> String)
-> ([StartRestoreJobResponse] -> ShowS)
-> Show StartRestoreJobResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartRestoreJobResponse] -> ShowS
$cshowList :: [StartRestoreJobResponse] -> ShowS
show :: StartRestoreJobResponse -> String
$cshow :: StartRestoreJobResponse -> String
showsPrec :: Int -> StartRestoreJobResponse -> ShowS
$cshowsPrec :: Int -> StartRestoreJobResponse -> ShowS
Prelude.Show, (forall x.
 StartRestoreJobResponse -> Rep StartRestoreJobResponse x)
-> (forall x.
    Rep StartRestoreJobResponse x -> StartRestoreJobResponse)
-> Generic StartRestoreJobResponse
forall x. Rep StartRestoreJobResponse x -> StartRestoreJobResponse
forall x. StartRestoreJobResponse -> Rep StartRestoreJobResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartRestoreJobResponse x -> StartRestoreJobResponse
$cfrom :: forall x. StartRestoreJobResponse -> Rep StartRestoreJobResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartRestoreJobResponse' 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:
--
-- 'restoreJobId', 'startRestoreJobResponse_restoreJobId' - Uniquely identifies the job that restores a recovery point.
--
-- 'httpStatus', 'startRestoreJobResponse_httpStatus' - The response's http status code.
newStartRestoreJobResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartRestoreJobResponse
newStartRestoreJobResponse :: Int -> StartRestoreJobResponse
newStartRestoreJobResponse Int
pHttpStatus_ =
  StartRestoreJobResponse' :: Maybe Text -> Int -> StartRestoreJobResponse
StartRestoreJobResponse'
    { $sel:restoreJobId:StartRestoreJobResponse' :: Maybe Text
restoreJobId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartRestoreJobResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Uniquely identifies the job that restores a recovery point.
startRestoreJobResponse_restoreJobId :: Lens.Lens' StartRestoreJobResponse (Prelude.Maybe Prelude.Text)
startRestoreJobResponse_restoreJobId :: (Maybe Text -> f (Maybe Text))
-> StartRestoreJobResponse -> f StartRestoreJobResponse
startRestoreJobResponse_restoreJobId = (StartRestoreJobResponse -> Maybe Text)
-> (StartRestoreJobResponse
    -> Maybe Text -> StartRestoreJobResponse)
-> Lens
     StartRestoreJobResponse
     StartRestoreJobResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartRestoreJobResponse' {Maybe Text
restoreJobId :: Maybe Text
$sel:restoreJobId:StartRestoreJobResponse' :: StartRestoreJobResponse -> Maybe Text
restoreJobId} -> Maybe Text
restoreJobId) (\s :: StartRestoreJobResponse
s@StartRestoreJobResponse' {} Maybe Text
a -> StartRestoreJobResponse
s {$sel:restoreJobId:StartRestoreJobResponse' :: Maybe Text
restoreJobId = Maybe Text
a} :: StartRestoreJobResponse)

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

instance Prelude.NFData StartRestoreJobResponse