{-# 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.SSM.UpdateResourceDataSync
-- 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)
--
-- Update a resource data sync. After you create a resource data sync for a
-- Region, you can\'t change the account options for that sync. For
-- example, if you create a sync in the us-east-2 (Ohio) Region and you
-- choose the @Include only the current account@ option, you can\'t edit
-- that sync later and choose the
-- @Include all accounts from my Organizations configuration@ option.
-- Instead, you must delete the first resource data sync, and create a new
-- one.
--
-- This API operation only supports a resource data sync that was created
-- with a SyncFromSource @SyncType@.
module Amazonka.SSM.UpdateResourceDataSync
  ( -- * Creating a Request
    UpdateResourceDataSync (..),
    newUpdateResourceDataSync,

    -- * Request Lenses
    updateResourceDataSync_syncName,
    updateResourceDataSync_syncType,
    updateResourceDataSync_syncSource,

    -- * Destructuring the Response
    UpdateResourceDataSyncResponse (..),
    newUpdateResourceDataSyncResponse,

    -- * Response Lenses
    updateResourceDataSyncResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateResourceDataSync' smart constructor.
data UpdateResourceDataSync = UpdateResourceDataSync'
  { -- | The name of the resource data sync you want to update.
    UpdateResourceDataSync -> Text
syncName :: Prelude.Text,
    -- | The type of resource data sync. The supported @SyncType@ is
    -- SyncFromSource.
    UpdateResourceDataSync -> Text
syncType :: Prelude.Text,
    -- | Specify information about the data sources to synchronize.
    UpdateResourceDataSync -> ResourceDataSyncSource
syncSource :: ResourceDataSyncSource
  }
  deriving (UpdateResourceDataSync -> UpdateResourceDataSync -> Bool
(UpdateResourceDataSync -> UpdateResourceDataSync -> Bool)
-> (UpdateResourceDataSync -> UpdateResourceDataSync -> Bool)
-> Eq UpdateResourceDataSync
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateResourceDataSync -> UpdateResourceDataSync -> Bool
$c/= :: UpdateResourceDataSync -> UpdateResourceDataSync -> Bool
== :: UpdateResourceDataSync -> UpdateResourceDataSync -> Bool
$c== :: UpdateResourceDataSync -> UpdateResourceDataSync -> Bool
Prelude.Eq, ReadPrec [UpdateResourceDataSync]
ReadPrec UpdateResourceDataSync
Int -> ReadS UpdateResourceDataSync
ReadS [UpdateResourceDataSync]
(Int -> ReadS UpdateResourceDataSync)
-> ReadS [UpdateResourceDataSync]
-> ReadPrec UpdateResourceDataSync
-> ReadPrec [UpdateResourceDataSync]
-> Read UpdateResourceDataSync
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateResourceDataSync]
$creadListPrec :: ReadPrec [UpdateResourceDataSync]
readPrec :: ReadPrec UpdateResourceDataSync
$creadPrec :: ReadPrec UpdateResourceDataSync
readList :: ReadS [UpdateResourceDataSync]
$creadList :: ReadS [UpdateResourceDataSync]
readsPrec :: Int -> ReadS UpdateResourceDataSync
$creadsPrec :: Int -> ReadS UpdateResourceDataSync
Prelude.Read, Int -> UpdateResourceDataSync -> ShowS
[UpdateResourceDataSync] -> ShowS
UpdateResourceDataSync -> String
(Int -> UpdateResourceDataSync -> ShowS)
-> (UpdateResourceDataSync -> String)
-> ([UpdateResourceDataSync] -> ShowS)
-> Show UpdateResourceDataSync
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateResourceDataSync] -> ShowS
$cshowList :: [UpdateResourceDataSync] -> ShowS
show :: UpdateResourceDataSync -> String
$cshow :: UpdateResourceDataSync -> String
showsPrec :: Int -> UpdateResourceDataSync -> ShowS
$cshowsPrec :: Int -> UpdateResourceDataSync -> ShowS
Prelude.Show, (forall x. UpdateResourceDataSync -> Rep UpdateResourceDataSync x)
-> (forall x.
    Rep UpdateResourceDataSync x -> UpdateResourceDataSync)
-> Generic UpdateResourceDataSync
forall x. Rep UpdateResourceDataSync x -> UpdateResourceDataSync
forall x. UpdateResourceDataSync -> Rep UpdateResourceDataSync x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateResourceDataSync x -> UpdateResourceDataSync
$cfrom :: forall x. UpdateResourceDataSync -> Rep UpdateResourceDataSync x
Prelude.Generic)

-- |
-- Create a value of 'UpdateResourceDataSync' 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:
--
-- 'syncName', 'updateResourceDataSync_syncName' - The name of the resource data sync you want to update.
--
-- 'syncType', 'updateResourceDataSync_syncType' - The type of resource data sync. The supported @SyncType@ is
-- SyncFromSource.
--
-- 'syncSource', 'updateResourceDataSync_syncSource' - Specify information about the data sources to synchronize.
newUpdateResourceDataSync ::
  -- | 'syncName'
  Prelude.Text ->
  -- | 'syncType'
  Prelude.Text ->
  -- | 'syncSource'
  ResourceDataSyncSource ->
  UpdateResourceDataSync
newUpdateResourceDataSync :: Text -> Text -> ResourceDataSyncSource -> UpdateResourceDataSync
newUpdateResourceDataSync
  Text
pSyncName_
  Text
pSyncType_
  ResourceDataSyncSource
pSyncSource_ =
    UpdateResourceDataSync' :: Text -> Text -> ResourceDataSyncSource -> UpdateResourceDataSync
UpdateResourceDataSync'
      { $sel:syncName:UpdateResourceDataSync' :: Text
syncName = Text
pSyncName_,
        $sel:syncType:UpdateResourceDataSync' :: Text
syncType = Text
pSyncType_,
        $sel:syncSource:UpdateResourceDataSync' :: ResourceDataSyncSource
syncSource = ResourceDataSyncSource
pSyncSource_
      }

-- | The name of the resource data sync you want to update.
updateResourceDataSync_syncName :: Lens.Lens' UpdateResourceDataSync Prelude.Text
updateResourceDataSync_syncName :: (Text -> f Text)
-> UpdateResourceDataSync -> f UpdateResourceDataSync
updateResourceDataSync_syncName = (UpdateResourceDataSync -> Text)
-> (UpdateResourceDataSync -> Text -> UpdateResourceDataSync)
-> Lens UpdateResourceDataSync UpdateResourceDataSync Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceDataSync' {Text
syncName :: Text
$sel:syncName:UpdateResourceDataSync' :: UpdateResourceDataSync -> Text
syncName} -> Text
syncName) (\s :: UpdateResourceDataSync
s@UpdateResourceDataSync' {} Text
a -> UpdateResourceDataSync
s {$sel:syncName:UpdateResourceDataSync' :: Text
syncName = Text
a} :: UpdateResourceDataSync)

-- | The type of resource data sync. The supported @SyncType@ is
-- SyncFromSource.
updateResourceDataSync_syncType :: Lens.Lens' UpdateResourceDataSync Prelude.Text
updateResourceDataSync_syncType :: (Text -> f Text)
-> UpdateResourceDataSync -> f UpdateResourceDataSync
updateResourceDataSync_syncType = (UpdateResourceDataSync -> Text)
-> (UpdateResourceDataSync -> Text -> UpdateResourceDataSync)
-> Lens UpdateResourceDataSync UpdateResourceDataSync Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceDataSync' {Text
syncType :: Text
$sel:syncType:UpdateResourceDataSync' :: UpdateResourceDataSync -> Text
syncType} -> Text
syncType) (\s :: UpdateResourceDataSync
s@UpdateResourceDataSync' {} Text
a -> UpdateResourceDataSync
s {$sel:syncType:UpdateResourceDataSync' :: Text
syncType = Text
a} :: UpdateResourceDataSync)

-- | Specify information about the data sources to synchronize.
updateResourceDataSync_syncSource :: Lens.Lens' UpdateResourceDataSync ResourceDataSyncSource
updateResourceDataSync_syncSource :: (ResourceDataSyncSource -> f ResourceDataSyncSource)
-> UpdateResourceDataSync -> f UpdateResourceDataSync
updateResourceDataSync_syncSource = (UpdateResourceDataSync -> ResourceDataSyncSource)
-> (UpdateResourceDataSync
    -> ResourceDataSyncSource -> UpdateResourceDataSync)
-> Lens
     UpdateResourceDataSync
     UpdateResourceDataSync
     ResourceDataSyncSource
     ResourceDataSyncSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateResourceDataSync' {ResourceDataSyncSource
syncSource :: ResourceDataSyncSource
$sel:syncSource:UpdateResourceDataSync' :: UpdateResourceDataSync -> ResourceDataSyncSource
syncSource} -> ResourceDataSyncSource
syncSource) (\s :: UpdateResourceDataSync
s@UpdateResourceDataSync' {} ResourceDataSyncSource
a -> UpdateResourceDataSync
s {$sel:syncSource:UpdateResourceDataSync' :: ResourceDataSyncSource
syncSource = ResourceDataSyncSource
a} :: UpdateResourceDataSync)

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

instance Prelude.NFData UpdateResourceDataSync

instance Core.ToHeaders UpdateResourceDataSync where
  toHeaders :: UpdateResourceDataSync -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateResourceDataSync -> 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
"AmazonSSM.UpdateResourceDataSync" ::
                          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 UpdateResourceDataSync where
  toJSON :: UpdateResourceDataSync -> Value
toJSON UpdateResourceDataSync' {Text
ResourceDataSyncSource
syncSource :: ResourceDataSyncSource
syncType :: Text
syncName :: Text
$sel:syncSource:UpdateResourceDataSync' :: UpdateResourceDataSync -> ResourceDataSyncSource
$sel:syncType:UpdateResourceDataSync' :: UpdateResourceDataSync -> Text
$sel:syncName:UpdateResourceDataSync' :: UpdateResourceDataSync -> 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
"SyncName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
syncName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SyncType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
syncType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SyncSource" Text -> ResourceDataSyncSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ResourceDataSyncSource
syncSource)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    UpdateResourceDataSyncResponse