{-# 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-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)
--
-- 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 Amazonka.KinesisAnalyticsV2.Types
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:/ '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
(CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool)
-> (CreateApplicationSnapshot -> CreateApplicationSnapshot -> Bool)
-> Eq CreateApplicationSnapshot
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]
(Int -> ReadS CreateApplicationSnapshot)
-> ReadS [CreateApplicationSnapshot]
-> ReadPrec CreateApplicationSnapshot
-> ReadPrec [CreateApplicationSnapshot]
-> Read 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
(Int -> CreateApplicationSnapshot -> ShowS)
-> (CreateApplicationSnapshot -> String)
-> ([CreateApplicationSnapshot] -> ShowS)
-> Show CreateApplicationSnapshot
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.
 CreateApplicationSnapshot -> Rep CreateApplicationSnapshot x)
-> (forall x.
    Rep CreateApplicationSnapshot x -> CreateApplicationSnapshot)
-> Generic CreateApplicationSnapshot
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' :: Text -> Text -> CreateApplicationSnapshot
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 :: (Text -> f Text)
-> CreateApplicationSnapshot -> f CreateApplicationSnapshot
createApplicationSnapshot_applicationName = (CreateApplicationSnapshot -> Text)
-> (CreateApplicationSnapshot -> Text -> CreateApplicationSnapshot)
-> Lens
     CreateApplicationSnapshot CreateApplicationSnapshot Text Text
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 :: (Text -> f Text)
-> CreateApplicationSnapshot -> f CreateApplicationSnapshot
createApplicationSnapshot_snapshotName = (CreateApplicationSnapshot -> Text)
-> (CreateApplicationSnapshot -> Text -> CreateApplicationSnapshot)
-> Lens
     CreateApplicationSnapshot CreateApplicationSnapshot Text Text
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 :: CreateApplicationSnapshot -> Request CreateApplicationSnapshot
request = Service
-> CreateApplicationSnapshot -> Request CreateApplicationSnapshot
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateApplicationSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateApplicationSnapshot)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse CreateApplicationSnapshot))
-> Logger
-> Service
-> Proxy CreateApplicationSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateApplicationSnapshot)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> CreateApplicationSnapshotResponse
CreateApplicationSnapshotResponse'
            (Int -> CreateApplicationSnapshotResponse)
-> Either String Int
-> Either String CreateApplicationSnapshotResponse
forall (f :: * -> *) a b. Functor 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 CreateApplicationSnapshot

instance Prelude.NFData CreateApplicationSnapshot

instance Core.ToHeaders CreateApplicationSnapshot where
  toHeaders :: CreateApplicationSnapshot -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateApplicationSnapshot -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"KinesisAnalytics_20180523.CreateApplicationSnapshot" ::
                          Prelude.ByteString
                      ),
            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 CreateApplicationSnapshot where
  toJSON :: CreateApplicationSnapshot -> Value
toJSON CreateApplicationSnapshot' {Text
snapshotName :: Text
applicationName :: Text
$sel:snapshotName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
$sel:applicationName:CreateApplicationSnapshot' :: CreateApplicationSnapshot -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ApplicationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
applicationName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SnapshotName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
snapshotName)
          ]
      )

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

instance Core.ToQuery CreateApplicationSnapshot where
  toQuery :: CreateApplicationSnapshot -> QueryString
toQuery = QueryString -> CreateApplicationSnapshot -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(CreateApplicationSnapshotResponse
 -> CreateApplicationSnapshotResponse -> Bool)
-> (CreateApplicationSnapshotResponse
    -> CreateApplicationSnapshotResponse -> Bool)
-> Eq CreateApplicationSnapshotResponse
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]
(Int -> ReadS CreateApplicationSnapshotResponse)
-> ReadS [CreateApplicationSnapshotResponse]
-> ReadPrec CreateApplicationSnapshotResponse
-> ReadPrec [CreateApplicationSnapshotResponse]
-> Read 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
(Int -> CreateApplicationSnapshotResponse -> ShowS)
-> (CreateApplicationSnapshotResponse -> String)
-> ([CreateApplicationSnapshotResponse] -> ShowS)
-> Show CreateApplicationSnapshotResponse
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.
 CreateApplicationSnapshotResponse
 -> Rep CreateApplicationSnapshotResponse x)
-> (forall x.
    Rep CreateApplicationSnapshotResponse x
    -> CreateApplicationSnapshotResponse)
-> Generic CreateApplicationSnapshotResponse
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' :: Int -> CreateApplicationSnapshotResponse
CreateApplicationSnapshotResponse'
    { $sel:httpStatus:CreateApplicationSnapshotResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
createApplicationSnapshotResponse_httpStatus :: Lens.Lens' CreateApplicationSnapshotResponse Prelude.Int
createApplicationSnapshotResponse_httpStatus :: (Int -> f Int)
-> CreateApplicationSnapshotResponse
-> f CreateApplicationSnapshotResponse
createApplicationSnapshotResponse_httpStatus = (CreateApplicationSnapshotResponse -> Int)
-> (CreateApplicationSnapshotResponse
    -> Int -> CreateApplicationSnapshotResponse)
-> Lens
     CreateApplicationSnapshotResponse
     CreateApplicationSnapshotResponse
     Int
     Int
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