{-# 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.IoTAnalytics.UpdateChannel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Used to update the settings of a channel.
module Amazonka.IoTAnalytics.UpdateChannel
  ( -- * Creating a Request
    UpdateChannel (..),
    newUpdateChannel,

    -- * Request Lenses
    updateChannel_channelStorage,
    updateChannel_retentionPeriod,
    updateChannel_channelName,

    -- * Destructuring the Response
    UpdateChannelResponse (..),
    newUpdateChannelResponse,
  )
where

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

-- | /See:/ 'newUpdateChannel' smart constructor.
data UpdateChannel = UpdateChannel'
  { -- | Where channel data is stored. You can choose one of @serviceManagedS3@
    -- or @customerManagedS3@ storage. If not specified, the default is
    -- @serviceManagedS3@. You can\'t change this storage option after the
    -- channel is created.
    UpdateChannel -> Maybe ChannelStorage
channelStorage :: Prelude.Maybe ChannelStorage,
    -- | How long, in days, message data is kept for the channel. The retention
    -- period can\'t be updated if the channel\'s Amazon S3 storage is
    -- customer-managed.
    UpdateChannel -> Maybe RetentionPeriod
retentionPeriod :: Prelude.Maybe RetentionPeriod,
    -- | The name of the channel to be updated.
    UpdateChannel -> Text
channelName :: Prelude.Text
  }
  deriving (UpdateChannel -> UpdateChannel -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateChannel -> UpdateChannel -> Bool
$c/= :: UpdateChannel -> UpdateChannel -> Bool
== :: UpdateChannel -> UpdateChannel -> Bool
$c== :: UpdateChannel -> UpdateChannel -> Bool
Prelude.Eq, ReadPrec [UpdateChannel]
ReadPrec UpdateChannel
Int -> ReadS UpdateChannel
ReadS [UpdateChannel]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateChannel]
$creadListPrec :: ReadPrec [UpdateChannel]
readPrec :: ReadPrec UpdateChannel
$creadPrec :: ReadPrec UpdateChannel
readList :: ReadS [UpdateChannel]
$creadList :: ReadS [UpdateChannel]
readsPrec :: Int -> ReadS UpdateChannel
$creadsPrec :: Int -> ReadS UpdateChannel
Prelude.Read, Int -> UpdateChannel -> ShowS
[UpdateChannel] -> ShowS
UpdateChannel -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateChannel] -> ShowS
$cshowList :: [UpdateChannel] -> ShowS
show :: UpdateChannel -> String
$cshow :: UpdateChannel -> String
showsPrec :: Int -> UpdateChannel -> ShowS
$cshowsPrec :: Int -> UpdateChannel -> ShowS
Prelude.Show, forall x. Rep UpdateChannel x -> UpdateChannel
forall x. UpdateChannel -> Rep UpdateChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateChannel x -> UpdateChannel
$cfrom :: forall x. UpdateChannel -> Rep UpdateChannel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateChannel' 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:
--
-- 'channelStorage', 'updateChannel_channelStorage' - Where channel data is stored. You can choose one of @serviceManagedS3@
-- or @customerManagedS3@ storage. If not specified, the default is
-- @serviceManagedS3@. You can\'t change this storage option after the
-- channel is created.
--
-- 'retentionPeriod', 'updateChannel_retentionPeriod' - How long, in days, message data is kept for the channel. The retention
-- period can\'t be updated if the channel\'s Amazon S3 storage is
-- customer-managed.
--
-- 'channelName', 'updateChannel_channelName' - The name of the channel to be updated.
newUpdateChannel ::
  -- | 'channelName'
  Prelude.Text ->
  UpdateChannel
newUpdateChannel :: Text -> UpdateChannel
newUpdateChannel Text
pChannelName_ =
  UpdateChannel'
    { $sel:channelStorage:UpdateChannel' :: Maybe ChannelStorage
channelStorage = forall a. Maybe a
Prelude.Nothing,
      $sel:retentionPeriod:UpdateChannel' :: Maybe RetentionPeriod
retentionPeriod = forall a. Maybe a
Prelude.Nothing,
      $sel:channelName:UpdateChannel' :: Text
channelName = Text
pChannelName_
    }

-- | Where channel data is stored. You can choose one of @serviceManagedS3@
-- or @customerManagedS3@ storage. If not specified, the default is
-- @serviceManagedS3@. You can\'t change this storage option after the
-- channel is created.
updateChannel_channelStorage :: Lens.Lens' UpdateChannel (Prelude.Maybe ChannelStorage)
updateChannel_channelStorage :: Lens' UpdateChannel (Maybe ChannelStorage)
updateChannel_channelStorage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannel' {Maybe ChannelStorage
channelStorage :: Maybe ChannelStorage
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
channelStorage} -> Maybe ChannelStorage
channelStorage) (\s :: UpdateChannel
s@UpdateChannel' {} Maybe ChannelStorage
a -> UpdateChannel
s {$sel:channelStorage:UpdateChannel' :: Maybe ChannelStorage
channelStorage = Maybe ChannelStorage
a} :: UpdateChannel)

-- | How long, in days, message data is kept for the channel. The retention
-- period can\'t be updated if the channel\'s Amazon S3 storage is
-- customer-managed.
updateChannel_retentionPeriod :: Lens.Lens' UpdateChannel (Prelude.Maybe RetentionPeriod)
updateChannel_retentionPeriod :: Lens' UpdateChannel (Maybe RetentionPeriod)
updateChannel_retentionPeriod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannel' {Maybe RetentionPeriod
retentionPeriod :: Maybe RetentionPeriod
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
retentionPeriod} -> Maybe RetentionPeriod
retentionPeriod) (\s :: UpdateChannel
s@UpdateChannel' {} Maybe RetentionPeriod
a -> UpdateChannel
s {$sel:retentionPeriod:UpdateChannel' :: Maybe RetentionPeriod
retentionPeriod = Maybe RetentionPeriod
a} :: UpdateChannel)

-- | The name of the channel to be updated.
updateChannel_channelName :: Lens.Lens' UpdateChannel Prelude.Text
updateChannel_channelName :: Lens' UpdateChannel Text
updateChannel_channelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannel' {Text
channelName :: Text
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
channelName} -> Text
channelName) (\s :: UpdateChannel
s@UpdateChannel' {} Text
a -> UpdateChannel
s {$sel:channelName:UpdateChannel' :: Text
channelName = Text
a} :: UpdateChannel)

instance Core.AWSRequest UpdateChannel where
  type
    AWSResponse UpdateChannel =
      UpdateChannelResponse
  request :: (Service -> Service) -> UpdateChannel -> Request UpdateChannel
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateChannel)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateChannelResponse
UpdateChannelResponse'

instance Prelude.Hashable UpdateChannel where
  hashWithSalt :: Int -> UpdateChannel -> Int
hashWithSalt Int
_salt UpdateChannel' {Maybe RetentionPeriod
Maybe ChannelStorage
Text
channelName :: Text
retentionPeriod :: Maybe RetentionPeriod
channelStorage :: Maybe ChannelStorage
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ChannelStorage
channelStorage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RetentionPeriod
retentionPeriod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelName

instance Prelude.NFData UpdateChannel where
  rnf :: UpdateChannel -> ()
rnf UpdateChannel' {Maybe RetentionPeriod
Maybe ChannelStorage
Text
channelName :: Text
retentionPeriod :: Maybe RetentionPeriod
channelStorage :: Maybe ChannelStorage
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ChannelStorage
channelStorage
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RetentionPeriod
retentionPeriod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
channelName

instance Data.ToHeaders UpdateChannel where
  toHeaders :: UpdateChannel -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToJSON UpdateChannel where
  toJSON :: UpdateChannel -> Value
toJSON UpdateChannel' {Maybe RetentionPeriod
Maybe ChannelStorage
Text
channelName :: Text
retentionPeriod :: Maybe RetentionPeriod
channelStorage :: Maybe ChannelStorage
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"channelStorage" 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 ChannelStorage
channelStorage,
            (Key
"retentionPeriod" 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 RetentionPeriod
retentionPeriod
          ]
      )

instance Data.ToPath UpdateChannel where
  toPath :: UpdateChannel -> ByteString
toPath UpdateChannel' {Maybe RetentionPeriod
Maybe ChannelStorage
Text
channelName :: Text
retentionPeriod :: Maybe RetentionPeriod
channelStorage :: Maybe ChannelStorage
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/channels/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
channelName]

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

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

-- |
-- Create a value of 'UpdateChannelResponse' 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.
newUpdateChannelResponse ::
  UpdateChannelResponse
newUpdateChannelResponse :: UpdateChannelResponse
newUpdateChannelResponse = UpdateChannelResponse
UpdateChannelResponse'

instance Prelude.NFData UpdateChannelResponse where
  rnf :: UpdateChannelResponse -> ()
rnf UpdateChannelResponse
_ = ()