{-# 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.ECS.UpdateClusterSettings
-- 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)
--
-- Modifies the settings to use for a cluster.
module Amazonka.ECS.UpdateClusterSettings
  ( -- * Creating a Request
    UpdateClusterSettings (..),
    newUpdateClusterSettings,

    -- * Request Lenses
    updateClusterSettings_cluster,
    updateClusterSettings_settings,

    -- * Destructuring the Response
    UpdateClusterSettingsResponse (..),
    newUpdateClusterSettingsResponse,

    -- * Response Lenses
    updateClusterSettingsResponse_cluster,
    updateClusterSettingsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.ECS.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:/ 'newUpdateClusterSettings' smart constructor.
data UpdateClusterSettings = UpdateClusterSettings'
  { -- | The name of the cluster to modify the settings for.
    UpdateClusterSettings -> Text
cluster :: Prelude.Text,
    -- | The setting to use by default for a cluster. This parameter is used to
    -- enable CloudWatch Container Insights for a cluster. If this value is
    -- specified, it will override the @containerInsights@ value set with
    -- PutAccountSetting or PutAccountSettingDefault.
    UpdateClusterSettings -> [ClusterSetting]
settings :: [ClusterSetting]
  }
  deriving (UpdateClusterSettings -> UpdateClusterSettings -> Bool
(UpdateClusterSettings -> UpdateClusterSettings -> Bool)
-> (UpdateClusterSettings -> UpdateClusterSettings -> Bool)
-> Eq UpdateClusterSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateClusterSettings -> UpdateClusterSettings -> Bool
$c/= :: UpdateClusterSettings -> UpdateClusterSettings -> Bool
== :: UpdateClusterSettings -> UpdateClusterSettings -> Bool
$c== :: UpdateClusterSettings -> UpdateClusterSettings -> Bool
Prelude.Eq, ReadPrec [UpdateClusterSettings]
ReadPrec UpdateClusterSettings
Int -> ReadS UpdateClusterSettings
ReadS [UpdateClusterSettings]
(Int -> ReadS UpdateClusterSettings)
-> ReadS [UpdateClusterSettings]
-> ReadPrec UpdateClusterSettings
-> ReadPrec [UpdateClusterSettings]
-> Read UpdateClusterSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateClusterSettings]
$creadListPrec :: ReadPrec [UpdateClusterSettings]
readPrec :: ReadPrec UpdateClusterSettings
$creadPrec :: ReadPrec UpdateClusterSettings
readList :: ReadS [UpdateClusterSettings]
$creadList :: ReadS [UpdateClusterSettings]
readsPrec :: Int -> ReadS UpdateClusterSettings
$creadsPrec :: Int -> ReadS UpdateClusterSettings
Prelude.Read, Int -> UpdateClusterSettings -> ShowS
[UpdateClusterSettings] -> ShowS
UpdateClusterSettings -> String
(Int -> UpdateClusterSettings -> ShowS)
-> (UpdateClusterSettings -> String)
-> ([UpdateClusterSettings] -> ShowS)
-> Show UpdateClusterSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateClusterSettings] -> ShowS
$cshowList :: [UpdateClusterSettings] -> ShowS
show :: UpdateClusterSettings -> String
$cshow :: UpdateClusterSettings -> String
showsPrec :: Int -> UpdateClusterSettings -> ShowS
$cshowsPrec :: Int -> UpdateClusterSettings -> ShowS
Prelude.Show, (forall x. UpdateClusterSettings -> Rep UpdateClusterSettings x)
-> (forall x. Rep UpdateClusterSettings x -> UpdateClusterSettings)
-> Generic UpdateClusterSettings
forall x. Rep UpdateClusterSettings x -> UpdateClusterSettings
forall x. UpdateClusterSettings -> Rep UpdateClusterSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateClusterSettings x -> UpdateClusterSettings
$cfrom :: forall x. UpdateClusterSettings -> Rep UpdateClusterSettings x
Prelude.Generic)

-- |
-- Create a value of 'UpdateClusterSettings' 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:
--
-- 'cluster', 'updateClusterSettings_cluster' - The name of the cluster to modify the settings for.
--
-- 'settings', 'updateClusterSettings_settings' - The setting to use by default for a cluster. This parameter is used to
-- enable CloudWatch Container Insights for a cluster. If this value is
-- specified, it will override the @containerInsights@ value set with
-- PutAccountSetting or PutAccountSettingDefault.
newUpdateClusterSettings ::
  -- | 'cluster'
  Prelude.Text ->
  UpdateClusterSettings
newUpdateClusterSettings :: Text -> UpdateClusterSettings
newUpdateClusterSettings Text
pCluster_ =
  UpdateClusterSettings' :: Text -> [ClusterSetting] -> UpdateClusterSettings
UpdateClusterSettings'
    { $sel:cluster:UpdateClusterSettings' :: Text
cluster = Text
pCluster_,
      $sel:settings:UpdateClusterSettings' :: [ClusterSetting]
settings = [ClusterSetting]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The name of the cluster to modify the settings for.
updateClusterSettings_cluster :: Lens.Lens' UpdateClusterSettings Prelude.Text
updateClusterSettings_cluster :: (Text -> f Text)
-> UpdateClusterSettings -> f UpdateClusterSettings
updateClusterSettings_cluster = (UpdateClusterSettings -> Text)
-> (UpdateClusterSettings -> Text -> UpdateClusterSettings)
-> Lens UpdateClusterSettings UpdateClusterSettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateClusterSettings' {Text
cluster :: Text
$sel:cluster:UpdateClusterSettings' :: UpdateClusterSettings -> Text
cluster} -> Text
cluster) (\s :: UpdateClusterSettings
s@UpdateClusterSettings' {} Text
a -> UpdateClusterSettings
s {$sel:cluster:UpdateClusterSettings' :: Text
cluster = Text
a} :: UpdateClusterSettings)

-- | The setting to use by default for a cluster. This parameter is used to
-- enable CloudWatch Container Insights for a cluster. If this value is
-- specified, it will override the @containerInsights@ value set with
-- PutAccountSetting or PutAccountSettingDefault.
updateClusterSettings_settings :: Lens.Lens' UpdateClusterSettings [ClusterSetting]
updateClusterSettings_settings :: ([ClusterSetting] -> f [ClusterSetting])
-> UpdateClusterSettings -> f UpdateClusterSettings
updateClusterSettings_settings = (UpdateClusterSettings -> [ClusterSetting])
-> (UpdateClusterSettings
    -> [ClusterSetting] -> UpdateClusterSettings)
-> Lens
     UpdateClusterSettings
     UpdateClusterSettings
     [ClusterSetting]
     [ClusterSetting]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateClusterSettings' {[ClusterSetting]
settings :: [ClusterSetting]
$sel:settings:UpdateClusterSettings' :: UpdateClusterSettings -> [ClusterSetting]
settings} -> [ClusterSetting]
settings) (\s :: UpdateClusterSettings
s@UpdateClusterSettings' {} [ClusterSetting]
a -> UpdateClusterSettings
s {$sel:settings:UpdateClusterSettings' :: [ClusterSetting]
settings = [ClusterSetting]
a} :: UpdateClusterSettings) (([ClusterSetting] -> f [ClusterSetting])
 -> UpdateClusterSettings -> f UpdateClusterSettings)
-> (([ClusterSetting] -> f [ClusterSetting])
    -> [ClusterSetting] -> f [ClusterSetting])
-> ([ClusterSetting] -> f [ClusterSetting])
-> UpdateClusterSettings
-> f UpdateClusterSettings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ClusterSetting] -> f [ClusterSetting])
-> [ClusterSetting] -> f [ClusterSetting]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest UpdateClusterSettings where
  type
    AWSResponse UpdateClusterSettings =
      UpdateClusterSettingsResponse
  request :: UpdateClusterSettings -> Request UpdateClusterSettings
request = Service -> UpdateClusterSettings -> Request UpdateClusterSettings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateClusterSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateClusterSettings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateClusterSettings))
-> Logger
-> Service
-> Proxy UpdateClusterSettings
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateClusterSettings)))
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 ->
          Maybe Cluster -> Int -> UpdateClusterSettingsResponse
UpdateClusterSettingsResponse'
            (Maybe Cluster -> Int -> UpdateClusterSettingsResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> UpdateClusterSettingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Cluster)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"cluster")
            Either String (Int -> UpdateClusterSettingsResponse)
-> Either String Int -> Either String UpdateClusterSettingsResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateClusterSettings

instance Prelude.NFData UpdateClusterSettings

instance Core.ToHeaders UpdateClusterSettings where
  toHeaders :: UpdateClusterSettings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateClusterSettings -> 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
"AmazonEC2ContainerServiceV20141113.UpdateClusterSettings" ::
                          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 UpdateClusterSettings where
  toJSON :: UpdateClusterSettings -> Value
toJSON UpdateClusterSettings' {[ClusterSetting]
Text
settings :: [ClusterSetting]
cluster :: Text
$sel:settings:UpdateClusterSettings' :: UpdateClusterSettings -> [ClusterSetting]
$sel:cluster:UpdateClusterSettings' :: UpdateClusterSettings -> 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
"cluster" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
cluster),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"settings" Text -> [ClusterSetting] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [ClusterSetting]
settings)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateClusterSettingsResponse' 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:
--
-- 'cluster', 'updateClusterSettingsResponse_cluster' - Details about the cluster
--
-- 'httpStatus', 'updateClusterSettingsResponse_httpStatus' - The response's http status code.
newUpdateClusterSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateClusterSettingsResponse
newUpdateClusterSettingsResponse :: Int -> UpdateClusterSettingsResponse
newUpdateClusterSettingsResponse Int
pHttpStatus_ =
  UpdateClusterSettingsResponse' :: Maybe Cluster -> Int -> UpdateClusterSettingsResponse
UpdateClusterSettingsResponse'
    { $sel:cluster:UpdateClusterSettingsResponse' :: Maybe Cluster
cluster =
        Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateClusterSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the cluster
updateClusterSettingsResponse_cluster :: Lens.Lens' UpdateClusterSettingsResponse (Prelude.Maybe Cluster)
updateClusterSettingsResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> UpdateClusterSettingsResponse -> f UpdateClusterSettingsResponse
updateClusterSettingsResponse_cluster = (UpdateClusterSettingsResponse -> Maybe Cluster)
-> (UpdateClusterSettingsResponse
    -> Maybe Cluster -> UpdateClusterSettingsResponse)
-> Lens
     UpdateClusterSettingsResponse
     UpdateClusterSettingsResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateClusterSettingsResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:UpdateClusterSettingsResponse' :: UpdateClusterSettingsResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: UpdateClusterSettingsResponse
s@UpdateClusterSettingsResponse' {} Maybe Cluster
a -> UpdateClusterSettingsResponse
s {$sel:cluster:UpdateClusterSettingsResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: UpdateClusterSettingsResponse)

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

instance Prelude.NFData UpdateClusterSettingsResponse