{-# 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.GroundStation.UpdateConfig
-- 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)
--
-- Updates the @Config@ used when scheduling contacts.
--
-- Updating a @Config@ will not update the execution parameters for
-- existing future contacts scheduled with this @Config@.
module Amazonka.GroundStation.UpdateConfig
  ( -- * Creating a Request
    UpdateConfig (..),
    newUpdateConfig,

    -- * Request Lenses
    updateConfig_configData,
    updateConfig_configId,
    updateConfig_configType,
    updateConfig_name,

    -- * Destructuring the Response
    ConfigIdResponse (..),
    newConfigIdResponse,

    -- * Response Lenses
    configIdResponse_configArn,
    configIdResponse_configId,
    configIdResponse_configType,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GroundStation.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:/ 'newUpdateConfig' smart constructor.
data UpdateConfig = UpdateConfig'
  { -- | Parameters of a @Config@.
    UpdateConfig -> ConfigTypeData
configData :: ConfigTypeData,
    -- | UUID of a @Config@.
    UpdateConfig -> Text
configId :: Prelude.Text,
    -- | Type of a @Config@.
    UpdateConfig -> ConfigCapabilityType
configType :: ConfigCapabilityType,
    -- | Name of a @Config@.
    UpdateConfig -> Text
name :: Prelude.Text
  }
  deriving (UpdateConfig -> UpdateConfig -> Bool
(UpdateConfig -> UpdateConfig -> Bool)
-> (UpdateConfig -> UpdateConfig -> Bool) -> Eq UpdateConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateConfig -> UpdateConfig -> Bool
$c/= :: UpdateConfig -> UpdateConfig -> Bool
== :: UpdateConfig -> UpdateConfig -> Bool
$c== :: UpdateConfig -> UpdateConfig -> Bool
Prelude.Eq, ReadPrec [UpdateConfig]
ReadPrec UpdateConfig
Int -> ReadS UpdateConfig
ReadS [UpdateConfig]
(Int -> ReadS UpdateConfig)
-> ReadS [UpdateConfig]
-> ReadPrec UpdateConfig
-> ReadPrec [UpdateConfig]
-> Read UpdateConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateConfig]
$creadListPrec :: ReadPrec [UpdateConfig]
readPrec :: ReadPrec UpdateConfig
$creadPrec :: ReadPrec UpdateConfig
readList :: ReadS [UpdateConfig]
$creadList :: ReadS [UpdateConfig]
readsPrec :: Int -> ReadS UpdateConfig
$creadsPrec :: Int -> ReadS UpdateConfig
Prelude.Read, Int -> UpdateConfig -> ShowS
[UpdateConfig] -> ShowS
UpdateConfig -> String
(Int -> UpdateConfig -> ShowS)
-> (UpdateConfig -> String)
-> ([UpdateConfig] -> ShowS)
-> Show UpdateConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateConfig] -> ShowS
$cshowList :: [UpdateConfig] -> ShowS
show :: UpdateConfig -> String
$cshow :: UpdateConfig -> String
showsPrec :: Int -> UpdateConfig -> ShowS
$cshowsPrec :: Int -> UpdateConfig -> ShowS
Prelude.Show, (forall x. UpdateConfig -> Rep UpdateConfig x)
-> (forall x. Rep UpdateConfig x -> UpdateConfig)
-> Generic UpdateConfig
forall x. Rep UpdateConfig x -> UpdateConfig
forall x. UpdateConfig -> Rep UpdateConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateConfig x -> UpdateConfig
$cfrom :: forall x. UpdateConfig -> Rep UpdateConfig x
Prelude.Generic)

-- |
-- Create a value of 'UpdateConfig' 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:
--
-- 'configData', 'updateConfig_configData' - Parameters of a @Config@.
--
-- 'configId', 'updateConfig_configId' - UUID of a @Config@.
--
-- 'configType', 'updateConfig_configType' - Type of a @Config@.
--
-- 'name', 'updateConfig_name' - Name of a @Config@.
newUpdateConfig ::
  -- | 'configData'
  ConfigTypeData ->
  -- | 'configId'
  Prelude.Text ->
  -- | 'configType'
  ConfigCapabilityType ->
  -- | 'name'
  Prelude.Text ->
  UpdateConfig
newUpdateConfig :: ConfigTypeData
-> Text -> ConfigCapabilityType -> Text -> UpdateConfig
newUpdateConfig
  ConfigTypeData
pConfigData_
  Text
pConfigId_
  ConfigCapabilityType
pConfigType_
  Text
pName_ =
    UpdateConfig' :: ConfigTypeData
-> Text -> ConfigCapabilityType -> Text -> UpdateConfig
UpdateConfig'
      { $sel:configData:UpdateConfig' :: ConfigTypeData
configData = ConfigTypeData
pConfigData_,
        $sel:configId:UpdateConfig' :: Text
configId = Text
pConfigId_,
        $sel:configType:UpdateConfig' :: ConfigCapabilityType
configType = ConfigCapabilityType
pConfigType_,
        $sel:name:UpdateConfig' :: Text
name = Text
pName_
      }

-- | Parameters of a @Config@.
updateConfig_configData :: Lens.Lens' UpdateConfig ConfigTypeData
updateConfig_configData :: (ConfigTypeData -> f ConfigTypeData)
-> UpdateConfig -> f UpdateConfig
updateConfig_configData = (UpdateConfig -> ConfigTypeData)
-> (UpdateConfig -> ConfigTypeData -> UpdateConfig)
-> Lens UpdateConfig UpdateConfig ConfigTypeData ConfigTypeData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfig' {ConfigTypeData
configData :: ConfigTypeData
$sel:configData:UpdateConfig' :: UpdateConfig -> ConfigTypeData
configData} -> ConfigTypeData
configData) (\s :: UpdateConfig
s@UpdateConfig' {} ConfigTypeData
a -> UpdateConfig
s {$sel:configData:UpdateConfig' :: ConfigTypeData
configData = ConfigTypeData
a} :: UpdateConfig)

-- | UUID of a @Config@.
updateConfig_configId :: Lens.Lens' UpdateConfig Prelude.Text
updateConfig_configId :: (Text -> f Text) -> UpdateConfig -> f UpdateConfig
updateConfig_configId = (UpdateConfig -> Text)
-> (UpdateConfig -> Text -> UpdateConfig)
-> Lens UpdateConfig UpdateConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfig' {Text
configId :: Text
$sel:configId:UpdateConfig' :: UpdateConfig -> Text
configId} -> Text
configId) (\s :: UpdateConfig
s@UpdateConfig' {} Text
a -> UpdateConfig
s {$sel:configId:UpdateConfig' :: Text
configId = Text
a} :: UpdateConfig)

-- | Type of a @Config@.
updateConfig_configType :: Lens.Lens' UpdateConfig ConfigCapabilityType
updateConfig_configType :: (ConfigCapabilityType -> f ConfigCapabilityType)
-> UpdateConfig -> f UpdateConfig
updateConfig_configType = (UpdateConfig -> ConfigCapabilityType)
-> (UpdateConfig -> ConfigCapabilityType -> UpdateConfig)
-> Lens
     UpdateConfig UpdateConfig ConfigCapabilityType ConfigCapabilityType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfig' {ConfigCapabilityType
configType :: ConfigCapabilityType
$sel:configType:UpdateConfig' :: UpdateConfig -> ConfigCapabilityType
configType} -> ConfigCapabilityType
configType) (\s :: UpdateConfig
s@UpdateConfig' {} ConfigCapabilityType
a -> UpdateConfig
s {$sel:configType:UpdateConfig' :: ConfigCapabilityType
configType = ConfigCapabilityType
a} :: UpdateConfig)

-- | Name of a @Config@.
updateConfig_name :: Lens.Lens' UpdateConfig Prelude.Text
updateConfig_name :: (Text -> f Text) -> UpdateConfig -> f UpdateConfig
updateConfig_name = (UpdateConfig -> Text)
-> (UpdateConfig -> Text -> UpdateConfig)
-> Lens UpdateConfig UpdateConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateConfig' {Text
name :: Text
$sel:name:UpdateConfig' :: UpdateConfig -> Text
name} -> Text
name) (\s :: UpdateConfig
s@UpdateConfig' {} Text
a -> UpdateConfig
s {$sel:name:UpdateConfig' :: Text
name = Text
a} :: UpdateConfig)

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

instance Prelude.Hashable UpdateConfig

instance Prelude.NFData UpdateConfig

instance Core.ToHeaders UpdateConfig where
  toHeaders :: UpdateConfig -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateConfig -> 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 UpdateConfig where
  toJSON :: UpdateConfig -> Value
toJSON UpdateConfig' {Text
ConfigCapabilityType
ConfigTypeData
name :: Text
configType :: ConfigCapabilityType
configId :: Text
configData :: ConfigTypeData
$sel:name:UpdateConfig' :: UpdateConfig -> Text
$sel:configType:UpdateConfig' :: UpdateConfig -> ConfigCapabilityType
$sel:configId:UpdateConfig' :: UpdateConfig -> Text
$sel:configData:UpdateConfig' :: UpdateConfig -> ConfigTypeData
..} =
    [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
"configData" Text -> ConfigTypeData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ConfigTypeData
configData),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

instance Core.ToPath UpdateConfig where
  toPath :: UpdateConfig -> ByteString
toPath UpdateConfig' {Text
ConfigCapabilityType
ConfigTypeData
name :: Text
configType :: ConfigCapabilityType
configId :: Text
configData :: ConfigTypeData
$sel:name:UpdateConfig' :: UpdateConfig -> Text
$sel:configType:UpdateConfig' :: UpdateConfig -> ConfigCapabilityType
$sel:configId:UpdateConfig' :: UpdateConfig -> Text
$sel:configData:UpdateConfig' :: UpdateConfig -> ConfigTypeData
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/config/",
        ConfigCapabilityType -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS ConfigCapabilityType
configType,
        ByteString
"/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
configId
      ]

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