{-# 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.DocDbElastic.CreateClusterSnapshot
-- 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 a cluster.
module Amazonka.DocDbElastic.CreateClusterSnapshot
  ( -- * Creating a Request
    CreateClusterSnapshot (..),
    newCreateClusterSnapshot,

    -- * Request Lenses
    createClusterSnapshot_tags,
    createClusterSnapshot_clusterArn,
    createClusterSnapshot_snapshotName,

    -- * Destructuring the Response
    CreateClusterSnapshotResponse (..),
    newCreateClusterSnapshotResponse,

    -- * Response Lenses
    createClusterSnapshotResponse_httpStatus,
    createClusterSnapshotResponse_snapshot,
  )
where

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

-- | /See:/ 'newCreateClusterSnapshot' smart constructor.
data CreateClusterSnapshot = CreateClusterSnapshot'
  { -- | The tags to be assigned to the new Elastic DocumentDB snapshot.
    CreateClusterSnapshot -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The arn of the Elastic DocumentDB cluster that the snapshot will be
    -- taken from.
    CreateClusterSnapshot -> Text
clusterArn :: Prelude.Text,
    -- | The name of the Elastic DocumentDB snapshot.
    CreateClusterSnapshot -> Text
snapshotName :: Prelude.Text
  }
  deriving (CreateClusterSnapshot -> CreateClusterSnapshot -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateClusterSnapshot -> CreateClusterSnapshot -> Bool
$c/= :: CreateClusterSnapshot -> CreateClusterSnapshot -> Bool
== :: CreateClusterSnapshot -> CreateClusterSnapshot -> Bool
$c== :: CreateClusterSnapshot -> CreateClusterSnapshot -> Bool
Prelude.Eq, ReadPrec [CreateClusterSnapshot]
ReadPrec CreateClusterSnapshot
Int -> ReadS CreateClusterSnapshot
ReadS [CreateClusterSnapshot]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateClusterSnapshot]
$creadListPrec :: ReadPrec [CreateClusterSnapshot]
readPrec :: ReadPrec CreateClusterSnapshot
$creadPrec :: ReadPrec CreateClusterSnapshot
readList :: ReadS [CreateClusterSnapshot]
$creadList :: ReadS [CreateClusterSnapshot]
readsPrec :: Int -> ReadS CreateClusterSnapshot
$creadsPrec :: Int -> ReadS CreateClusterSnapshot
Prelude.Read, Int -> CreateClusterSnapshot -> ShowS
[CreateClusterSnapshot] -> ShowS
CreateClusterSnapshot -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateClusterSnapshot] -> ShowS
$cshowList :: [CreateClusterSnapshot] -> ShowS
show :: CreateClusterSnapshot -> String
$cshow :: CreateClusterSnapshot -> String
showsPrec :: Int -> CreateClusterSnapshot -> ShowS
$cshowsPrec :: Int -> CreateClusterSnapshot -> ShowS
Prelude.Show, forall x. Rep CreateClusterSnapshot x -> CreateClusterSnapshot
forall x. CreateClusterSnapshot -> Rep CreateClusterSnapshot x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateClusterSnapshot x -> CreateClusterSnapshot
$cfrom :: forall x. CreateClusterSnapshot -> Rep CreateClusterSnapshot x
Prelude.Generic)

-- |
-- Create a value of 'CreateClusterSnapshot' 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:
--
-- 'tags', 'createClusterSnapshot_tags' - The tags to be assigned to the new Elastic DocumentDB snapshot.
--
-- 'clusterArn', 'createClusterSnapshot_clusterArn' - The arn of the Elastic DocumentDB cluster that the snapshot will be
-- taken from.
--
-- 'snapshotName', 'createClusterSnapshot_snapshotName' - The name of the Elastic DocumentDB snapshot.
newCreateClusterSnapshot ::
  -- | 'clusterArn'
  Prelude.Text ->
  -- | 'snapshotName'
  Prelude.Text ->
  CreateClusterSnapshot
newCreateClusterSnapshot :: Text -> Text -> CreateClusterSnapshot
newCreateClusterSnapshot Text
pClusterArn_ Text
pSnapshotName_ =
  CreateClusterSnapshot'
    { $sel:tags:CreateClusterSnapshot' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:clusterArn:CreateClusterSnapshot' :: Text
clusterArn = Text
pClusterArn_,
      $sel:snapshotName:CreateClusterSnapshot' :: Text
snapshotName = Text
pSnapshotName_
    }

-- | The tags to be assigned to the new Elastic DocumentDB snapshot.
createClusterSnapshot_tags :: Lens.Lens' CreateClusterSnapshot (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createClusterSnapshot_tags :: Lens' CreateClusterSnapshot (Maybe (HashMap Text Text))
createClusterSnapshot_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterSnapshot' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateClusterSnapshot' :: CreateClusterSnapshot -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateClusterSnapshot
s@CreateClusterSnapshot' {} Maybe (HashMap Text Text)
a -> CreateClusterSnapshot
s {$sel:tags:CreateClusterSnapshot' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateClusterSnapshot) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The arn of the Elastic DocumentDB cluster that the snapshot will be
-- taken from.
createClusterSnapshot_clusterArn :: Lens.Lens' CreateClusterSnapshot Prelude.Text
createClusterSnapshot_clusterArn :: Lens' CreateClusterSnapshot Text
createClusterSnapshot_clusterArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterSnapshot' {Text
clusterArn :: Text
$sel:clusterArn:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
clusterArn} -> Text
clusterArn) (\s :: CreateClusterSnapshot
s@CreateClusterSnapshot' {} Text
a -> CreateClusterSnapshot
s {$sel:clusterArn:CreateClusterSnapshot' :: Text
clusterArn = Text
a} :: CreateClusterSnapshot)

-- | The name of the Elastic DocumentDB snapshot.
createClusterSnapshot_snapshotName :: Lens.Lens' CreateClusterSnapshot Prelude.Text
createClusterSnapshot_snapshotName :: Lens' CreateClusterSnapshot Text
createClusterSnapshot_snapshotName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterSnapshot' {Text
snapshotName :: Text
$sel:snapshotName:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
snapshotName} -> Text
snapshotName) (\s :: CreateClusterSnapshot
s@CreateClusterSnapshot' {} Text
a -> CreateClusterSnapshot
s {$sel:snapshotName:CreateClusterSnapshot' :: Text
snapshotName = Text
a} :: CreateClusterSnapshot)

instance Core.AWSRequest CreateClusterSnapshot where
  type
    AWSResponse CreateClusterSnapshot =
      CreateClusterSnapshotResponse
  request :: (Service -> Service)
-> CreateClusterSnapshot -> Request CreateClusterSnapshot
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 CreateClusterSnapshot
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateClusterSnapshot)))
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 ->
          Int -> ClusterSnapshot -> CreateClusterSnapshotResponse
CreateClusterSnapshotResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"snapshot")
      )

instance Prelude.Hashable CreateClusterSnapshot where
  hashWithSalt :: Int -> CreateClusterSnapshot -> Int
hashWithSalt Int
_salt CreateClusterSnapshot' {Maybe (HashMap Text Text)
Text
snapshotName :: Text
clusterArn :: Text
tags :: Maybe (HashMap Text Text)
$sel:snapshotName:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:clusterArn:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:tags:CreateClusterSnapshot' :: CreateClusterSnapshot -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
snapshotName

instance Prelude.NFData CreateClusterSnapshot where
  rnf :: CreateClusterSnapshot -> ()
rnf CreateClusterSnapshot' {Maybe (HashMap Text Text)
Text
snapshotName :: Text
clusterArn :: Text
tags :: Maybe (HashMap Text Text)
$sel:snapshotName:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:clusterArn:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:tags:CreateClusterSnapshot' :: CreateClusterSnapshot -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
clusterArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
snapshotName

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

instance Data.ToJSON CreateClusterSnapshot where
  toJSON :: CreateClusterSnapshot -> Value
toJSON CreateClusterSnapshot' {Maybe (HashMap Text Text)
Text
snapshotName :: Text
clusterArn :: Text
tags :: Maybe (HashMap Text Text)
$sel:snapshotName:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:clusterArn:CreateClusterSnapshot' :: CreateClusterSnapshot -> Text
$sel:tags:CreateClusterSnapshot' :: CreateClusterSnapshot -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"clusterArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clusterArn),
            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 CreateClusterSnapshot where
  toPath :: CreateClusterSnapshot -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/cluster-snapshot"

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

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

-- |
-- Create a value of 'CreateClusterSnapshotResponse' 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', 'createClusterSnapshotResponse_httpStatus' - The response's http status code.
--
-- 'snapshot', 'createClusterSnapshotResponse_snapshot' - Returns information about the new Elastic DocumentDB snapshot.
newCreateClusterSnapshotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'snapshot'
  ClusterSnapshot ->
  CreateClusterSnapshotResponse
newCreateClusterSnapshotResponse :: Int -> ClusterSnapshot -> CreateClusterSnapshotResponse
newCreateClusterSnapshotResponse
  Int
pHttpStatus_
  ClusterSnapshot
pSnapshot_ =
    CreateClusterSnapshotResponse'
      { $sel:httpStatus:CreateClusterSnapshotResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:snapshot:CreateClusterSnapshotResponse' :: ClusterSnapshot
snapshot = ClusterSnapshot
pSnapshot_
      }

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

-- | Returns information about the new Elastic DocumentDB snapshot.
createClusterSnapshotResponse_snapshot :: Lens.Lens' CreateClusterSnapshotResponse ClusterSnapshot
createClusterSnapshotResponse_snapshot :: Lens' CreateClusterSnapshotResponse ClusterSnapshot
createClusterSnapshotResponse_snapshot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateClusterSnapshotResponse' {ClusterSnapshot
snapshot :: ClusterSnapshot
$sel:snapshot:CreateClusterSnapshotResponse' :: CreateClusterSnapshotResponse -> ClusterSnapshot
snapshot} -> ClusterSnapshot
snapshot) (\s :: CreateClusterSnapshotResponse
s@CreateClusterSnapshotResponse' {} ClusterSnapshot
a -> CreateClusterSnapshotResponse
s {$sel:snapshot:CreateClusterSnapshotResponse' :: ClusterSnapshot
snapshot = ClusterSnapshot
a} :: CreateClusterSnapshotResponse)

instance Prelude.NFData CreateClusterSnapshotResponse where
  rnf :: CreateClusterSnapshotResponse -> ()
rnf CreateClusterSnapshotResponse' {Int
ClusterSnapshot
snapshot :: ClusterSnapshot
httpStatus :: Int
$sel:snapshot:CreateClusterSnapshotResponse' :: CreateClusterSnapshotResponse -> ClusterSnapshot
$sel:httpStatus:CreateClusterSnapshotResponse' :: CreateClusterSnapshotResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ClusterSnapshot
snapshot