{-# 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.KinesisAnalyticsV2.CreateApplicationSnapshot
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a snapshot of the application\'s state data.
module Amazonka.KinesisAnalyticsV2.CreateApplicationSnapshot
  ( -- * Creating a Request
    CreateApplicationSnapshot (..),
    newCreateApplicationSnapshot,

    -- * Request Lenses
    createApplicationSnapshot_applicationName,
    createApplicationSnapshot_snapshotName,

    -- * Destructuring the Response
    CreateApplicationSnapshotResponse (..),
    newCreateApplicationSnapshotResponse,

    -- * Response Lenses
    createApplicationSnapshotResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateApplicationSnapshot' smart constructor.
data CreateApplicationSnapshot = CreateApplicationSnapshot'
  { -- | The name of an existing application
    CreateApplicationSnapshot -> Text
applicationName :: Prelude.Text,
    -- | An identifier for the application snapshot.
    CreateApplicationSnapshot -> Text
snapshotName :: Prelude.Text
  }
  deriving (CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool
$c/= :: CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool
== :: CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool
$c== :: CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool
Prelude.Eq, ReadPrec [CreateApplicationSnapshot]
ReadPrec CreateApplicationSnapshot
Int -> ReadS CreateApplicationSnapshot
ReadS [CreateApplicationSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApplicationSnapshot]
$creadListPrec :: ReadPrec [CreateApplicationSnapshot]
readPrec :: ReadPrec CreateApplicationSnapshot
$creadPrec :: ReadPrec CreateApplicationSnapshot
readList :: ReadS [CreateApplicationSnapshot]
$creadList :: ReadS [CreateApplicationSnapshot]
readsPrec :: Int -> ReadS CreateApplicationSnapshot
$creadsPrec :: Int -> ReadS CreateApplicationSnapshot
Prelude.Read, Int -> CreateApplicationSnapshot -> ShowS
[CreateApplicationSnapshot] -> ShowS
CreateApplicationSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApplicationSnapshot] -> ShowS
$cshowList :: [CreateApplicationSnapshot] -> ShowS
show :: CreateApplicationSnapshot -> String
$cshow :: CreateApplicationSnapshot -> String
showsPrec :: Int -> CreateApplicationSnapshot -> ShowS
$cshowsPrec :: Int -> CreateApplicationSnapshot -> ShowS
Prelude.Show, forall x.
Rep CreateApplicationSnapshot x -> CreateApplicationSnapshot
forall x.
CreateApplicationSnapshot -> Rep CreateApplicationSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateApplicationSnapshot x -> CreateApplicationSnapshot
$cfrom :: forall x.
CreateApplicationSnapshot -> Rep CreateApplicationSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'CreateApplicationSnapshot' 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:
--
-- 'applicationName', 'createApplicationSnapshot_applicationName' - The name of an existing application
--
-- 'snapshotName', 'createApplicationSnapshot_snapshotName' - An identifier for the application snapshot.
newCreateApplicationSnapshot ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'snapshotName'
  Prelude.Text ->
  CreateApplicationSnapshot
newCreateApplicationSnapshot :: Text -> Text -> CreateApplicationSnapshot
newCreateApplicationSnapshot
  Text
pApplicationName_
  Text
pSnapshotName_ =
    CreateApplicationSnapshot'
      { $sel:applicationName:CreateApplicationSnapshot' :: Text
applicationName =
          Text
pApplicationName_,
        $sel:snapshotName:CreateApplicationSnapshot' :: Text
snapshotName = Text
pSnapshotName_
      }

-- | The name of an existing application
createApplicationSnapshot_applicationName :: Lens.Lens' CreateApplicationSnapshot Prelude.Text
createApplicationSnapshot_applicationName :: Lens' CreateApplicationSnapshot Text
createApplicationSnapshot_applicationName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplicationSnapshot' {Text
applicationName :: Text
$sel:applicationName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
applicationName} -> Text
applicationName) (\s :: CreateApplicationSnapshot
s@CreateApplicationSnapshot' {} Text
a -> CreateApplicationSnapshot
s {$sel:applicationName:CreateApplicationSnapshot' :: Text
applicationName = Text
a} :: CreateApplicationSnapshot)

-- | An identifier for the application snapshot.
createApplicationSnapshot_snapshotName :: Lens.Lens' CreateApplicationSnapshot Prelude.Text
createApplicationSnapshot_snapshotName :: Lens' CreateApplicationSnapshot Text
createApplicationSnapshot_snapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApplicationSnapshot' {Text
snapshotName :: Text
$sel:snapshotName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
snapshotName} -> Text
snapshotName) (\s :: CreateApplicationSnapshot
s@CreateApplicationSnapshot' {} Text
a -> CreateApplicationSnapshot
s {$sel:snapshotName:CreateApplicationSnapshot' :: Text
snapshotName = Text
a} :: CreateApplicationSnapshot)

instance Core.AWSRequest CreateApplicationSnapshot where
  type
    AWSResponse CreateApplicationSnapshot =
      CreateApplicationSnapshotResponse
  request :: (Service -> Service)
-> CreateApplicationSnapshot -> Request CreateApplicationSnapshot
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 CreateApplicationSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateApplicationSnapshot)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateApplicationSnapshotResponse
CreateApplicationSnapshotResponse'
            forall (f :: * -> *) a b. Functor 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 CreateApplicationSnapshot where
  hashWithSalt :: Int -> CreateApplicationSnapshot -> Int
hashWithSalt Int
_salt CreateApplicationSnapshot' {Text
snapshotName :: Text
applicationName :: Text
$sel:snapshotName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
$sel:applicationName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snapshotName

instance Prelude.NFData CreateApplicationSnapshot where
  rnf :: CreateApplicationSnapshot -> ()
rnf CreateApplicationSnapshot' {Text
snapshotName :: Text
applicationName :: Text
$sel:snapshotName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
$sel:applicationName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
applicationName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snapshotName

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

instance Data.ToJSON CreateApplicationSnapshot where
  toJSON :: CreateApplicationSnapshot -> Value
toJSON CreateApplicationSnapshot' {Text
snapshotName :: Text
applicationName :: Text
$sel:snapshotName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
$sel:applicationName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ApplicationName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
applicationName),
            forall a. a -> Maybe a
Prelude.Just (Key
"SnapshotName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
snapshotName)
          ]
      )

instance Data.ToPath CreateApplicationSnapshot where
  toPath :: CreateApplicationSnapshot -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'CreateApplicationSnapshotResponse' 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:
--
-- 'httpStatus', 'createApplicationSnapshotResponse_httpStatus' - The response's http status code.
newCreateApplicationSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateApplicationSnapshotResponse
newCreateApplicationSnapshotResponse :: Int -> CreateApplicationSnapshotResponse
newCreateApplicationSnapshotResponse Int
pHttpStatus_ =
  CreateApplicationSnapshotResponse'
    { $sel:httpStatus:CreateApplicationSnapshotResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    CreateApplicationSnapshotResponse
  where
  rnf :: CreateApplicationSnapshotResponse -> ()
rnf CreateApplicationSnapshotResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateApplicationSnapshotResponse' :: CreateApplicationSnapshotResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus