{-# 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.UpdateCluster
-- 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 cluster.
module Amazonka.ECS.UpdateCluster
  ( -- * Creating a Request
    UpdateCluster (..),
    newUpdateCluster,

    -- * Request Lenses
    updateCluster_settings,
    updateCluster_configuration,
    updateCluster_cluster,

    -- * Destructuring the Response
    UpdateClusterResponse (..),
    newUpdateClusterResponse,

    -- * Response Lenses
    updateClusterResponse_cluster,
    updateClusterResponse_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:/ 'newUpdateCluster' smart constructor.
data UpdateCluster = UpdateCluster'
  { -- | The cluster settings for your cluster.
    UpdateCluster -> Maybe [ClusterSetting]
settings :: Prelude.Maybe [ClusterSetting],
    -- | The execute command configuration for the cluster.
    UpdateCluster -> Maybe ClusterConfiguration
configuration :: Prelude.Maybe ClusterConfiguration,
    -- | The name of the cluster to modify the settings for.
    UpdateCluster -> Text
cluster :: Prelude.Text
  }
  deriving (UpdateCluster -> UpdateCluster -> Bool
(UpdateCluster -> UpdateCluster -> Bool)
-> (UpdateCluster -> UpdateCluster -> Bool) -> Eq UpdateCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCluster -> UpdateCluster -> Bool
$c/= :: UpdateCluster -> UpdateCluster -> Bool
== :: UpdateCluster -> UpdateCluster -> Bool
$c== :: UpdateCluster -> UpdateCluster -> Bool
Prelude.Eq, ReadPrec [UpdateCluster]
ReadPrec UpdateCluster
Int -> ReadS UpdateCluster
ReadS [UpdateCluster]
(Int -> ReadS UpdateCluster)
-> ReadS [UpdateCluster]
-> ReadPrec UpdateCluster
-> ReadPrec [UpdateCluster]
-> Read UpdateCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCluster]
$creadListPrec :: ReadPrec [UpdateCluster]
readPrec :: ReadPrec UpdateCluster
$creadPrec :: ReadPrec UpdateCluster
readList :: ReadS [UpdateCluster]
$creadList :: ReadS [UpdateCluster]
readsPrec :: Int -> ReadS UpdateCluster
$creadsPrec :: Int -> ReadS UpdateCluster
Prelude.Read, Int -> UpdateCluster -> ShowS
[UpdateCluster] -> ShowS
UpdateCluster -> String
(Int -> UpdateCluster -> ShowS)
-> (UpdateCluster -> String)
-> ([UpdateCluster] -> ShowS)
-> Show UpdateCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCluster] -> ShowS
$cshowList :: [UpdateCluster] -> ShowS
show :: UpdateCluster -> String
$cshow :: UpdateCluster -> String
showsPrec :: Int -> UpdateCluster -> ShowS
$cshowsPrec :: Int -> UpdateCluster -> ShowS
Prelude.Show, (forall x. UpdateCluster -> Rep UpdateCluster x)
-> (forall x. Rep UpdateCluster x -> UpdateCluster)
-> Generic UpdateCluster
forall x. Rep UpdateCluster x -> UpdateCluster
forall x. UpdateCluster -> Rep UpdateCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCluster x -> UpdateCluster
$cfrom :: forall x. UpdateCluster -> Rep UpdateCluster x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCluster' 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:
--
-- 'settings', 'updateCluster_settings' - The cluster settings for your cluster.
--
-- 'configuration', 'updateCluster_configuration' - The execute command configuration for the cluster.
--
-- 'cluster', 'updateCluster_cluster' - The name of the cluster to modify the settings for.
newUpdateCluster ::
  -- | 'cluster'
  Prelude.Text ->
  UpdateCluster
newUpdateCluster :: Text -> UpdateCluster
newUpdateCluster Text
pCluster_ =
  UpdateCluster' :: Maybe [ClusterSetting]
-> Maybe ClusterConfiguration -> Text -> UpdateCluster
UpdateCluster'
    { $sel:settings:UpdateCluster' :: Maybe [ClusterSetting]
settings = Maybe [ClusterSetting]
forall a. Maybe a
Prelude.Nothing,
      $sel:configuration:UpdateCluster' :: Maybe ClusterConfiguration
configuration = Maybe ClusterConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:cluster:UpdateCluster' :: Text
cluster = Text
pCluster_
    }

-- | The cluster settings for your cluster.
updateCluster_settings :: Lens.Lens' UpdateCluster (Prelude.Maybe [ClusterSetting])
updateCluster_settings :: (Maybe [ClusterSetting] -> f (Maybe [ClusterSetting]))
-> UpdateCluster -> f UpdateCluster
updateCluster_settings = (UpdateCluster -> Maybe [ClusterSetting])
-> (UpdateCluster -> Maybe [ClusterSetting] -> UpdateCluster)
-> Lens
     UpdateCluster
     UpdateCluster
     (Maybe [ClusterSetting])
     (Maybe [ClusterSetting])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCluster' {Maybe [ClusterSetting]
settings :: Maybe [ClusterSetting]
$sel:settings:UpdateCluster' :: UpdateCluster -> Maybe [ClusterSetting]
settings} -> Maybe [ClusterSetting]
settings) (\s :: UpdateCluster
s@UpdateCluster' {} Maybe [ClusterSetting]
a -> UpdateCluster
s {$sel:settings:UpdateCluster' :: Maybe [ClusterSetting]
settings = Maybe [ClusterSetting]
a} :: UpdateCluster) ((Maybe [ClusterSetting] -> f (Maybe [ClusterSetting]))
 -> UpdateCluster -> f UpdateCluster)
-> ((Maybe [ClusterSetting] -> f (Maybe [ClusterSetting]))
    -> Maybe [ClusterSetting] -> f (Maybe [ClusterSetting]))
-> (Maybe [ClusterSetting] -> f (Maybe [ClusterSetting]))
-> UpdateCluster
-> f UpdateCluster
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ClusterSetting] [ClusterSetting] [ClusterSetting] [ClusterSetting]
-> Iso
     (Maybe [ClusterSetting])
     (Maybe [ClusterSetting])
     (Maybe [ClusterSetting])
     (Maybe [ClusterSetting])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [ClusterSetting] [ClusterSetting] [ClusterSetting] [ClusterSetting]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The execute command configuration for the cluster.
updateCluster_configuration :: Lens.Lens' UpdateCluster (Prelude.Maybe ClusterConfiguration)
updateCluster_configuration :: (Maybe ClusterConfiguration -> f (Maybe ClusterConfiguration))
-> UpdateCluster -> f UpdateCluster
updateCluster_configuration = (UpdateCluster -> Maybe ClusterConfiguration)
-> (UpdateCluster -> Maybe ClusterConfiguration -> UpdateCluster)
-> Lens
     UpdateCluster
     UpdateCluster
     (Maybe ClusterConfiguration)
     (Maybe ClusterConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCluster' {Maybe ClusterConfiguration
configuration :: Maybe ClusterConfiguration
$sel:configuration:UpdateCluster' :: UpdateCluster -> Maybe ClusterConfiguration
configuration} -> Maybe ClusterConfiguration
configuration) (\s :: UpdateCluster
s@UpdateCluster' {} Maybe ClusterConfiguration
a -> UpdateCluster
s {$sel:configuration:UpdateCluster' :: Maybe ClusterConfiguration
configuration = Maybe ClusterConfiguration
a} :: UpdateCluster)

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

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

instance Prelude.NFData UpdateCluster

instance Core.ToHeaders UpdateCluster where
  toHeaders :: UpdateCluster -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateCluster -> 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.UpdateCluster" ::
                          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 UpdateCluster where
  toJSON :: UpdateCluster -> Value
toJSON UpdateCluster' {Maybe [ClusterSetting]
Maybe ClusterConfiguration
Text
cluster :: Text
configuration :: Maybe ClusterConfiguration
settings :: Maybe [ClusterSetting]
$sel:cluster:UpdateCluster' :: UpdateCluster -> Text
$sel:configuration:UpdateCluster' :: UpdateCluster -> Maybe ClusterConfiguration
$sel:settings:UpdateCluster' :: UpdateCluster -> Maybe [ClusterSetting]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"settings" Text -> [ClusterSetting] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([ClusterSetting] -> Pair) -> Maybe [ClusterSetting] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [ClusterSetting]
settings,
            (Text
"configuration" Text -> ClusterConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ClusterConfiguration -> Pair)
-> Maybe ClusterConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ClusterConfiguration
configuration,
            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)
          ]
      )

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

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

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

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

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

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

instance Prelude.NFData UpdateClusterResponse