{-# 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-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)
--
-- Used to update the settings of a channel.
module Amazonka.IoTAnalytics.UpdateChannel
  ( -- * Creating a Request
    UpdateChannel (..),
    newUpdateChannel,

    -- * Request Lenses
    updateChannel_retentionPeriod,
    updateChannel_channelStorage,
    updateChannel_channelName,

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

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.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:/ 'newUpdateChannel' smart constructor.
data UpdateChannel = 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 -> Maybe RetentionPeriod
retentionPeriod :: Prelude.Maybe RetentionPeriod,
    -- | 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,
    -- | The name of the channel to be updated.
    UpdateChannel -> Text
channelName :: Prelude.Text
  }
  deriving (UpdateChannel -> UpdateChannel -> Bool
(UpdateChannel -> UpdateChannel -> Bool)
-> (UpdateChannel -> UpdateChannel -> Bool) -> Eq UpdateChannel
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]
(Int -> ReadS UpdateChannel)
-> ReadS [UpdateChannel]
-> ReadPrec UpdateChannel
-> ReadPrec [UpdateChannel]
-> Read 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
(Int -> UpdateChannel -> ShowS)
-> (UpdateChannel -> String)
-> ([UpdateChannel] -> ShowS)
-> Show UpdateChannel
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. UpdateChannel -> Rep UpdateChannel x)
-> (forall x. Rep UpdateChannel x -> UpdateChannel)
-> Generic UpdateChannel
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:
--
-- '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.
--
-- '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.
--
-- 'channelName', 'updateChannel_channelName' - The name of the channel to be updated.
newUpdateChannel ::
  -- | 'channelName'
  Prelude.Text ->
  UpdateChannel
newUpdateChannel :: Text -> UpdateChannel
newUpdateChannel Text
pChannelName_ =
  UpdateChannel' :: Maybe RetentionPeriod
-> Maybe ChannelStorage -> Text -> UpdateChannel
UpdateChannel'
    { $sel:retentionPeriod:UpdateChannel' :: Maybe RetentionPeriod
retentionPeriod = Maybe RetentionPeriod
forall a. Maybe a
Prelude.Nothing,
      $sel:channelStorage:UpdateChannel' :: Maybe ChannelStorage
channelStorage = Maybe ChannelStorage
forall a. Maybe a
Prelude.Nothing,
      $sel:channelName:UpdateChannel' :: Text
channelName = Text
pChannelName_
    }

-- | 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 :: (Maybe RetentionPeriod -> f (Maybe RetentionPeriod))
-> UpdateChannel -> f UpdateChannel
updateChannel_retentionPeriod = (UpdateChannel -> Maybe RetentionPeriod)
-> (UpdateChannel -> Maybe RetentionPeriod -> UpdateChannel)
-> Lens
     UpdateChannel
     UpdateChannel
     (Maybe RetentionPeriod)
     (Maybe 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)

-- | 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 :: (Maybe ChannelStorage -> f (Maybe ChannelStorage))
-> UpdateChannel -> f UpdateChannel
updateChannel_channelStorage = (UpdateChannel -> Maybe ChannelStorage)
-> (UpdateChannel -> Maybe ChannelStorage -> UpdateChannel)
-> Lens
     UpdateChannel
     UpdateChannel
     (Maybe ChannelStorage)
     (Maybe 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)

-- | The name of the channel to be updated.
updateChannel_channelName :: Lens.Lens' UpdateChannel Prelude.Text
updateChannel_channelName :: (Text -> f Text) -> UpdateChannel -> f UpdateChannel
updateChannel_channelName = (UpdateChannel -> Text)
-> (UpdateChannel -> Text -> UpdateChannel)
-> Lens UpdateChannel UpdateChannel Text Text
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 :: UpdateChannel -> Request UpdateChannel
request = Service -> UpdateChannel -> Request UpdateChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateChannel)))
response =
    AWSResponse UpdateChannel
-> Logger
-> Service
-> Proxy UpdateChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateChannel)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateChannel
UpdateChannelResponse
UpdateChannelResponse'

instance Prelude.Hashable UpdateChannel

instance Prelude.NFData UpdateChannel

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

instance Core.ToJSON UpdateChannel where
  toJSON :: UpdateChannel -> Value
toJSON UpdateChannel' {Maybe RetentionPeriod
Maybe ChannelStorage
Text
channelName :: Text
channelStorage :: Maybe ChannelStorage
retentionPeriod :: Maybe RetentionPeriod
$sel:channelName:UpdateChannel' :: UpdateChannel -> Text
$sel:channelStorage:UpdateChannel' :: UpdateChannel -> Maybe ChannelStorage
$sel:retentionPeriod:UpdateChannel' :: UpdateChannel -> Maybe RetentionPeriod
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"retentionPeriod" Text -> RetentionPeriod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RetentionPeriod -> Pair) -> Maybe RetentionPeriod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetentionPeriod
retentionPeriod,
            (Text
"channelStorage" Text -> ChannelStorage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ChannelStorage -> Pair) -> Maybe ChannelStorage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ChannelStorage
channelStorage
          ]
      )

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

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

-- | /See:/ 'newUpdateChannelResponse' smart constructor.
data UpdateChannelResponse = UpdateChannelResponse'
  {
  }
  deriving (UpdateChannelResponse -> UpdateChannelResponse -> Bool
(UpdateChannelResponse -> UpdateChannelResponse -> Bool)
-> (UpdateChannelResponse -> UpdateChannelResponse -> Bool)
-> Eq UpdateChannelResponse
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]
(Int -> ReadS UpdateChannelResponse)
-> ReadS [UpdateChannelResponse]
-> ReadPrec UpdateChannelResponse
-> ReadPrec [UpdateChannelResponse]
-> Read 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
(Int -> UpdateChannelResponse -> ShowS)
-> (UpdateChannelResponse -> String)
-> ([UpdateChannelResponse] -> ShowS)
-> Show UpdateChannelResponse
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. UpdateChannelResponse -> Rep UpdateChannelResponse x)
-> (forall x. Rep UpdateChannelResponse x -> UpdateChannelResponse)
-> Generic UpdateChannelResponse
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