{-# 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.MGN.MarkAsArchived
-- 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)
--
-- Archives specific Source Servers by setting the SourceServer.isArchived
-- property to true for specified SourceServers by ID. This command only
-- works for SourceServers with a lifecycle.state which equals DISCONNECTED
-- or CUTOVER.
module Amazonka.MGN.MarkAsArchived
  ( -- * Creating a Request
    MarkAsArchived (..),
    newMarkAsArchived,

    -- * Request Lenses
    markAsArchived_sourceServerID,

    -- * Destructuring the Response
    SourceServer (..),
    newSourceServer,

    -- * Response Lenses
    sourceServer_sourceProperties,
    sourceServer_arn,
    sourceServer_launchedInstance,
    sourceServer_lifeCycle,
    sourceServer_isArchived,
    sourceServer_dataReplicationInfo,
    sourceServer_sourceServerID,
    sourceServer_tags,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MGN.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newMarkAsArchived' smart constructor.
data MarkAsArchived = MarkAsArchived'
  { -- | Mark as archived by Source Server ID.
    MarkAsArchived -> Text
sourceServerID :: Prelude.Text
  }
  deriving (MarkAsArchived -> MarkAsArchived -> Bool
(MarkAsArchived -> MarkAsArchived -> Bool)
-> (MarkAsArchived -> MarkAsArchived -> Bool) -> Eq MarkAsArchived
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MarkAsArchived -> MarkAsArchived -> Bool
$c/= :: MarkAsArchived -> MarkAsArchived -> Bool
== :: MarkAsArchived -> MarkAsArchived -> Bool
$c== :: MarkAsArchived -> MarkAsArchived -> Bool
Prelude.Eq, ReadPrec [MarkAsArchived]
ReadPrec MarkAsArchived
Int -> ReadS MarkAsArchived
ReadS [MarkAsArchived]
(Int -> ReadS MarkAsArchived)
-> ReadS [MarkAsArchived]
-> ReadPrec MarkAsArchived
-> ReadPrec [MarkAsArchived]
-> Read MarkAsArchived
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MarkAsArchived]
$creadListPrec :: ReadPrec [MarkAsArchived]
readPrec :: ReadPrec MarkAsArchived
$creadPrec :: ReadPrec MarkAsArchived
readList :: ReadS [MarkAsArchived]
$creadList :: ReadS [MarkAsArchived]
readsPrec :: Int -> ReadS MarkAsArchived
$creadsPrec :: Int -> ReadS MarkAsArchived
Prelude.Read, Int -> MarkAsArchived -> ShowS
[MarkAsArchived] -> ShowS
MarkAsArchived -> String
(Int -> MarkAsArchived -> ShowS)
-> (MarkAsArchived -> String)
-> ([MarkAsArchived] -> ShowS)
-> Show MarkAsArchived
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MarkAsArchived] -> ShowS
$cshowList :: [MarkAsArchived] -> ShowS
show :: MarkAsArchived -> String
$cshow :: MarkAsArchived -> String
showsPrec :: Int -> MarkAsArchived -> ShowS
$cshowsPrec :: Int -> MarkAsArchived -> ShowS
Prelude.Show, (forall x. MarkAsArchived -> Rep MarkAsArchived x)
-> (forall x. Rep MarkAsArchived x -> MarkAsArchived)
-> Generic MarkAsArchived
forall x. Rep MarkAsArchived x -> MarkAsArchived
forall x. MarkAsArchived -> Rep MarkAsArchived x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MarkAsArchived x -> MarkAsArchived
$cfrom :: forall x. MarkAsArchived -> Rep MarkAsArchived x
Prelude.Generic)

-- |
-- Create a value of 'MarkAsArchived' 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:
--
-- 'sourceServerID', 'markAsArchived_sourceServerID' - Mark as archived by Source Server ID.
newMarkAsArchived ::
  -- | 'sourceServerID'
  Prelude.Text ->
  MarkAsArchived
newMarkAsArchived :: Text -> MarkAsArchived
newMarkAsArchived Text
pSourceServerID_ =
  MarkAsArchived' :: Text -> MarkAsArchived
MarkAsArchived' {$sel:sourceServerID:MarkAsArchived' :: Text
sourceServerID = Text
pSourceServerID_}

-- | Mark as archived by Source Server ID.
markAsArchived_sourceServerID :: Lens.Lens' MarkAsArchived Prelude.Text
markAsArchived_sourceServerID :: (Text -> f Text) -> MarkAsArchived -> f MarkAsArchived
markAsArchived_sourceServerID = (MarkAsArchived -> Text)
-> (MarkAsArchived -> Text -> MarkAsArchived)
-> Lens MarkAsArchived MarkAsArchived Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MarkAsArchived' {Text
sourceServerID :: Text
$sel:sourceServerID:MarkAsArchived' :: MarkAsArchived -> Text
sourceServerID} -> Text
sourceServerID) (\s :: MarkAsArchived
s@MarkAsArchived' {} Text
a -> MarkAsArchived
s {$sel:sourceServerID:MarkAsArchived' :: Text
sourceServerID = Text
a} :: MarkAsArchived)

instance Core.AWSRequest MarkAsArchived where
  type AWSResponse MarkAsArchived = SourceServer
  request :: MarkAsArchived -> Request MarkAsArchived
request = Service -> MarkAsArchived -> Request MarkAsArchived
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy MarkAsArchived
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MarkAsArchived)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse MarkAsArchived))
-> Logger
-> Service
-> Proxy MarkAsArchived
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse MarkAsArchived)))
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 -> Object -> Either String SourceServer
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable MarkAsArchived

instance Prelude.NFData MarkAsArchived

instance Core.ToHeaders MarkAsArchived where
  toHeaders :: MarkAsArchived -> ResponseHeaders
toHeaders =
    ResponseHeaders -> MarkAsArchived -> 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 MarkAsArchived where
  toJSON :: MarkAsArchived -> Value
toJSON MarkAsArchived' {Text
sourceServerID :: Text
$sel:sourceServerID:MarkAsArchived' :: MarkAsArchived -> 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
"sourceServerID" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
sourceServerID)
          ]
      )

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

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