{-# 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.QuickSight.RestoreAnalysis
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Restores an analysis.
module Amazonka.QuickSight.RestoreAnalysis
  ( -- * Creating a Request
    RestoreAnalysis (..),
    newRestoreAnalysis,

    -- * Request Lenses
    restoreAnalysis_awsAccountId,
    restoreAnalysis_analysisId,

    -- * Destructuring the Response
    RestoreAnalysisResponse (..),
    newRestoreAnalysisResponse,

    -- * Response Lenses
    restoreAnalysisResponse_analysisId,
    restoreAnalysisResponse_arn,
    restoreAnalysisResponse_requestId,
    restoreAnalysisResponse_status,
  )
where

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 Amazonka.QuickSight.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRestoreAnalysis' smart constructor.
data RestoreAnalysis = RestoreAnalysis'
  { -- | The ID of the Amazon Web Services account that contains the analysis.
    RestoreAnalysis -> Text
awsAccountId :: Prelude.Text,
    -- | The ID of the analysis that you\'re restoring.
    RestoreAnalysis -> Text
analysisId :: Prelude.Text
  }
  deriving (RestoreAnalysis -> RestoreAnalysis -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreAnalysis -> RestoreAnalysis -> Bool
$c/= :: RestoreAnalysis -> RestoreAnalysis -> Bool
== :: RestoreAnalysis -> RestoreAnalysis -> Bool
$c== :: RestoreAnalysis -> RestoreAnalysis -> Bool
Prelude.Eq, ReadPrec [RestoreAnalysis]
ReadPrec RestoreAnalysis
Int -> ReadS RestoreAnalysis
ReadS [RestoreAnalysis]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreAnalysis]
$creadListPrec :: ReadPrec [RestoreAnalysis]
readPrec :: ReadPrec RestoreAnalysis
$creadPrec :: ReadPrec RestoreAnalysis
readList :: ReadS [RestoreAnalysis]
$creadList :: ReadS [RestoreAnalysis]
readsPrec :: Int -> ReadS RestoreAnalysis
$creadsPrec :: Int -> ReadS RestoreAnalysis
Prelude.Read, Int -> RestoreAnalysis -> ShowS
[RestoreAnalysis] -> ShowS
RestoreAnalysis -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreAnalysis] -> ShowS
$cshowList :: [RestoreAnalysis] -> ShowS
show :: RestoreAnalysis -> String
$cshow :: RestoreAnalysis -> String
showsPrec :: Int -> RestoreAnalysis -> ShowS
$cshowsPrec :: Int -> RestoreAnalysis -> ShowS
Prelude.Show, forall x. Rep RestoreAnalysis x -> RestoreAnalysis
forall x. RestoreAnalysis -> Rep RestoreAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreAnalysis x -> RestoreAnalysis
$cfrom :: forall x. RestoreAnalysis -> Rep RestoreAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'RestoreAnalysis' 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:
--
-- 'awsAccountId', 'restoreAnalysis_awsAccountId' - The ID of the Amazon Web Services account that contains the analysis.
--
-- 'analysisId', 'restoreAnalysis_analysisId' - The ID of the analysis that you\'re restoring.
newRestoreAnalysis ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'analysisId'
  Prelude.Text ->
  RestoreAnalysis
newRestoreAnalysis :: Text -> Text -> RestoreAnalysis
newRestoreAnalysis Text
pAwsAccountId_ Text
pAnalysisId_ =
  RestoreAnalysis'
    { $sel:awsAccountId:RestoreAnalysis' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:analysisId:RestoreAnalysis' :: Text
analysisId = Text
pAnalysisId_
    }

-- | The ID of the Amazon Web Services account that contains the analysis.
restoreAnalysis_awsAccountId :: Lens.Lens' RestoreAnalysis Prelude.Text
restoreAnalysis_awsAccountId :: Lens' RestoreAnalysis Text
restoreAnalysis_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysis' {Text
awsAccountId :: Text
$sel:awsAccountId:RestoreAnalysis' :: RestoreAnalysis -> Text
awsAccountId} -> Text
awsAccountId) (\s :: RestoreAnalysis
s@RestoreAnalysis' {} Text
a -> RestoreAnalysis
s {$sel:awsAccountId:RestoreAnalysis' :: Text
awsAccountId = Text
a} :: RestoreAnalysis)

-- | The ID of the analysis that you\'re restoring.
restoreAnalysis_analysisId :: Lens.Lens' RestoreAnalysis Prelude.Text
restoreAnalysis_analysisId :: Lens' RestoreAnalysis Text
restoreAnalysis_analysisId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysis' {Text
analysisId :: Text
$sel:analysisId:RestoreAnalysis' :: RestoreAnalysis -> Text
analysisId} -> Text
analysisId) (\s :: RestoreAnalysis
s@RestoreAnalysis' {} Text
a -> RestoreAnalysis
s {$sel:analysisId:RestoreAnalysis' :: Text
analysisId = Text
a} :: RestoreAnalysis)

instance Core.AWSRequest RestoreAnalysis where
  type
    AWSResponse RestoreAnalysis =
      RestoreAnalysisResponse
  request :: (Service -> Service) -> RestoreAnalysis -> Request RestoreAnalysis
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RestoreAnalysis
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RestoreAnalysis)))
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
-> Maybe Text -> Maybe Text -> Int -> RestoreAnalysisResponse
RestoreAnalysisResponse'
            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
"AnalysisId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Arn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RequestId")
            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 RestoreAnalysis where
  hashWithSalt :: Int -> RestoreAnalysis -> Int
hashWithSalt Int
_salt RestoreAnalysis' {Text
analysisId :: Text
awsAccountId :: Text
$sel:analysisId:RestoreAnalysis' :: RestoreAnalysis -> Text
$sel:awsAccountId:RestoreAnalysis' :: RestoreAnalysis -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
analysisId

instance Prelude.NFData RestoreAnalysis where
  rnf :: RestoreAnalysis -> ()
rnf RestoreAnalysis' {Text
analysisId :: Text
awsAccountId :: Text
$sel:analysisId:RestoreAnalysis' :: RestoreAnalysis -> Text
$sel:awsAccountId:RestoreAnalysis' :: RestoreAnalysis -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
analysisId

instance Data.ToHeaders RestoreAnalysis where
  toHeaders :: RestoreAnalysis -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON RestoreAnalysis where
  toJSON :: RestoreAnalysis -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath RestoreAnalysis where
  toPath :: RestoreAnalysis -> ByteString
toPath RestoreAnalysis' {Text
analysisId :: Text
awsAccountId :: Text
$sel:analysisId:RestoreAnalysis' :: RestoreAnalysis -> Text
$sel:awsAccountId:RestoreAnalysis' :: RestoreAnalysis -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/restore/analyses/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
analysisId
      ]

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

-- | /See:/ 'newRestoreAnalysisResponse' smart constructor.
data RestoreAnalysisResponse = RestoreAnalysisResponse'
  { -- | The ID of the analysis that you\'re restoring.
    RestoreAnalysisResponse -> Maybe Text
analysisId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the analysis that you\'re restoring.
    RestoreAnalysisResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services request ID for this operation.
    RestoreAnalysisResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    RestoreAnalysisResponse -> Int
status :: Prelude.Int
  }
  deriving (RestoreAnalysisResponse -> RestoreAnalysisResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestoreAnalysisResponse -> RestoreAnalysisResponse -> Bool
$c/= :: RestoreAnalysisResponse -> RestoreAnalysisResponse -> Bool
== :: RestoreAnalysisResponse -> RestoreAnalysisResponse -> Bool
$c== :: RestoreAnalysisResponse -> RestoreAnalysisResponse -> Bool
Prelude.Eq, ReadPrec [RestoreAnalysisResponse]
ReadPrec RestoreAnalysisResponse
Int -> ReadS RestoreAnalysisResponse
ReadS [RestoreAnalysisResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestoreAnalysisResponse]
$creadListPrec :: ReadPrec [RestoreAnalysisResponse]
readPrec :: ReadPrec RestoreAnalysisResponse
$creadPrec :: ReadPrec RestoreAnalysisResponse
readList :: ReadS [RestoreAnalysisResponse]
$creadList :: ReadS [RestoreAnalysisResponse]
readsPrec :: Int -> ReadS RestoreAnalysisResponse
$creadsPrec :: Int -> ReadS RestoreAnalysisResponse
Prelude.Read, Int -> RestoreAnalysisResponse -> ShowS
[RestoreAnalysisResponse] -> ShowS
RestoreAnalysisResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestoreAnalysisResponse] -> ShowS
$cshowList :: [RestoreAnalysisResponse] -> ShowS
show :: RestoreAnalysisResponse -> String
$cshow :: RestoreAnalysisResponse -> String
showsPrec :: Int -> RestoreAnalysisResponse -> ShowS
$cshowsPrec :: Int -> RestoreAnalysisResponse -> ShowS
Prelude.Show, forall x. Rep RestoreAnalysisResponse x -> RestoreAnalysisResponse
forall x. RestoreAnalysisResponse -> Rep RestoreAnalysisResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestoreAnalysisResponse x -> RestoreAnalysisResponse
$cfrom :: forall x. RestoreAnalysisResponse -> Rep RestoreAnalysisResponse x
Prelude.Generic)

-- |
-- Create a value of 'RestoreAnalysisResponse' 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:
--
-- 'analysisId', 'restoreAnalysisResponse_analysisId' - The ID of the analysis that you\'re restoring.
--
-- 'arn', 'restoreAnalysisResponse_arn' - The Amazon Resource Name (ARN) of the analysis that you\'re restoring.
--
-- 'requestId', 'restoreAnalysisResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'status', 'restoreAnalysisResponse_status' - The HTTP status of the request.
newRestoreAnalysisResponse ::
  -- | 'status'
  Prelude.Int ->
  RestoreAnalysisResponse
newRestoreAnalysisResponse :: Int -> RestoreAnalysisResponse
newRestoreAnalysisResponse Int
pStatus_ =
  RestoreAnalysisResponse'
    { $sel:analysisId:RestoreAnalysisResponse' :: Maybe Text
analysisId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:arn:RestoreAnalysisResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:RestoreAnalysisResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:RestoreAnalysisResponse' :: Int
status = Int
pStatus_
    }

-- | The ID of the analysis that you\'re restoring.
restoreAnalysisResponse_analysisId :: Lens.Lens' RestoreAnalysisResponse (Prelude.Maybe Prelude.Text)
restoreAnalysisResponse_analysisId :: Lens' RestoreAnalysisResponse (Maybe Text)
restoreAnalysisResponse_analysisId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysisResponse' {Maybe Text
analysisId :: Maybe Text
$sel:analysisId:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
analysisId} -> Maybe Text
analysisId) (\s :: RestoreAnalysisResponse
s@RestoreAnalysisResponse' {} Maybe Text
a -> RestoreAnalysisResponse
s {$sel:analysisId:RestoreAnalysisResponse' :: Maybe Text
analysisId = Maybe Text
a} :: RestoreAnalysisResponse)

-- | The Amazon Resource Name (ARN) of the analysis that you\'re restoring.
restoreAnalysisResponse_arn :: Lens.Lens' RestoreAnalysisResponse (Prelude.Maybe Prelude.Text)
restoreAnalysisResponse_arn :: Lens' RestoreAnalysisResponse (Maybe Text)
restoreAnalysisResponse_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysisResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: RestoreAnalysisResponse
s@RestoreAnalysisResponse' {} Maybe Text
a -> RestoreAnalysisResponse
s {$sel:arn:RestoreAnalysisResponse' :: Maybe Text
arn = Maybe Text
a} :: RestoreAnalysisResponse)

-- | The Amazon Web Services request ID for this operation.
restoreAnalysisResponse_requestId :: Lens.Lens' RestoreAnalysisResponse (Prelude.Maybe Prelude.Text)
restoreAnalysisResponse_requestId :: Lens' RestoreAnalysisResponse (Maybe Text)
restoreAnalysisResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysisResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: RestoreAnalysisResponse
s@RestoreAnalysisResponse' {} Maybe Text
a -> RestoreAnalysisResponse
s {$sel:requestId:RestoreAnalysisResponse' :: Maybe Text
requestId = Maybe Text
a} :: RestoreAnalysisResponse)

-- | The HTTP status of the request.
restoreAnalysisResponse_status :: Lens.Lens' RestoreAnalysisResponse Prelude.Int
restoreAnalysisResponse_status :: Lens' RestoreAnalysisResponse Int
restoreAnalysisResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestoreAnalysisResponse' {Int
status :: Int
$sel:status:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Int
status} -> Int
status) (\s :: RestoreAnalysisResponse
s@RestoreAnalysisResponse' {} Int
a -> RestoreAnalysisResponse
s {$sel:status:RestoreAnalysisResponse' :: Int
status = Int
a} :: RestoreAnalysisResponse)

instance Prelude.NFData RestoreAnalysisResponse where
  rnf :: RestoreAnalysisResponse -> ()
rnf RestoreAnalysisResponse' {Int
Maybe Text
status :: Int
requestId :: Maybe Text
arn :: Maybe Text
analysisId :: Maybe Text
$sel:status:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Int
$sel:requestId:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
$sel:arn:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
$sel:analysisId:RestoreAnalysisResponse' :: RestoreAnalysisResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
analysisId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
status