{-# 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.UpdateCapacityProvider
-- 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 parameters for a capacity provider.
module Amazonka.ECS.UpdateCapacityProvider
  ( -- * Creating a Request
    UpdateCapacityProvider (..),
    newUpdateCapacityProvider,

    -- * Request Lenses
    updateCapacityProvider_name,
    updateCapacityProvider_autoScalingGroupProvider,

    -- * Destructuring the Response
    UpdateCapacityProviderResponse (..),
    newUpdateCapacityProviderResponse,

    -- * Response Lenses
    updateCapacityProviderResponse_capacityProvider,
    updateCapacityProviderResponse_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:/ 'newUpdateCapacityProvider' smart constructor.
data UpdateCapacityProvider = UpdateCapacityProvider'
  { -- | The name of the capacity provider to update.
    UpdateCapacityProvider -> Text
name :: Prelude.Text,
    -- | An object representing the parameters to update for the Auto Scaling
    -- group capacity provider.
    UpdateCapacityProvider -> AutoScalingGroupProviderUpdate
autoScalingGroupProvider :: AutoScalingGroupProviderUpdate
  }
  deriving (UpdateCapacityProvider -> UpdateCapacityProvider -> Bool
(UpdateCapacityProvider -> UpdateCapacityProvider -> Bool)
-> (UpdateCapacityProvider -> UpdateCapacityProvider -> Bool)
-> Eq UpdateCapacityProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCapacityProvider -> UpdateCapacityProvider -> Bool
$c/= :: UpdateCapacityProvider -> UpdateCapacityProvider -> Bool
== :: UpdateCapacityProvider -> UpdateCapacityProvider -> Bool
$c== :: UpdateCapacityProvider -> UpdateCapacityProvider -> Bool
Prelude.Eq, ReadPrec [UpdateCapacityProvider]
ReadPrec UpdateCapacityProvider
Int -> ReadS UpdateCapacityProvider
ReadS [UpdateCapacityProvider]
(Int -> ReadS UpdateCapacityProvider)
-> ReadS [UpdateCapacityProvider]
-> ReadPrec UpdateCapacityProvider
-> ReadPrec [UpdateCapacityProvider]
-> Read UpdateCapacityProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCapacityProvider]
$creadListPrec :: ReadPrec [UpdateCapacityProvider]
readPrec :: ReadPrec UpdateCapacityProvider
$creadPrec :: ReadPrec UpdateCapacityProvider
readList :: ReadS [UpdateCapacityProvider]
$creadList :: ReadS [UpdateCapacityProvider]
readsPrec :: Int -> ReadS UpdateCapacityProvider
$creadsPrec :: Int -> ReadS UpdateCapacityProvider
Prelude.Read, Int -> UpdateCapacityProvider -> ShowS
[UpdateCapacityProvider] -> ShowS
UpdateCapacityProvider -> String
(Int -> UpdateCapacityProvider -> ShowS)
-> (UpdateCapacityProvider -> String)
-> ([UpdateCapacityProvider] -> ShowS)
-> Show UpdateCapacityProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCapacityProvider] -> ShowS
$cshowList :: [UpdateCapacityProvider] -> ShowS
show :: UpdateCapacityProvider -> String
$cshow :: UpdateCapacityProvider -> String
showsPrec :: Int -> UpdateCapacityProvider -> ShowS
$cshowsPrec :: Int -> UpdateCapacityProvider -> ShowS
Prelude.Show, (forall x. UpdateCapacityProvider -> Rep UpdateCapacityProvider x)
-> (forall x.
    Rep UpdateCapacityProvider x -> UpdateCapacityProvider)
-> Generic UpdateCapacityProvider
forall x. Rep UpdateCapacityProvider x -> UpdateCapacityProvider
forall x. UpdateCapacityProvider -> Rep UpdateCapacityProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateCapacityProvider x -> UpdateCapacityProvider
$cfrom :: forall x. UpdateCapacityProvider -> Rep UpdateCapacityProvider x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCapacityProvider' 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:
--
-- 'name', 'updateCapacityProvider_name' - The name of the capacity provider to update.
--
-- 'autoScalingGroupProvider', 'updateCapacityProvider_autoScalingGroupProvider' - An object representing the parameters to update for the Auto Scaling
-- group capacity provider.
newUpdateCapacityProvider ::
  -- | 'name'
  Prelude.Text ->
  -- | 'autoScalingGroupProvider'
  AutoScalingGroupProviderUpdate ->
  UpdateCapacityProvider
newUpdateCapacityProvider :: Text -> AutoScalingGroupProviderUpdate -> UpdateCapacityProvider
newUpdateCapacityProvider
  Text
pName_
  AutoScalingGroupProviderUpdate
pAutoScalingGroupProvider_ =
    UpdateCapacityProvider' :: Text -> AutoScalingGroupProviderUpdate -> UpdateCapacityProvider
UpdateCapacityProvider'
      { $sel:name:UpdateCapacityProvider' :: Text
name = Text
pName_,
        $sel:autoScalingGroupProvider:UpdateCapacityProvider' :: AutoScalingGroupProviderUpdate
autoScalingGroupProvider =
          AutoScalingGroupProviderUpdate
pAutoScalingGroupProvider_
      }

-- | The name of the capacity provider to update.
updateCapacityProvider_name :: Lens.Lens' UpdateCapacityProvider Prelude.Text
updateCapacityProvider_name :: (Text -> f Text)
-> UpdateCapacityProvider -> f UpdateCapacityProvider
updateCapacityProvider_name = (UpdateCapacityProvider -> Text)
-> (UpdateCapacityProvider -> Text -> UpdateCapacityProvider)
-> Lens UpdateCapacityProvider UpdateCapacityProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCapacityProvider' {Text
name :: Text
$sel:name:UpdateCapacityProvider' :: UpdateCapacityProvider -> Text
name} -> Text
name) (\s :: UpdateCapacityProvider
s@UpdateCapacityProvider' {} Text
a -> UpdateCapacityProvider
s {$sel:name:UpdateCapacityProvider' :: Text
name = Text
a} :: UpdateCapacityProvider)

-- | An object representing the parameters to update for the Auto Scaling
-- group capacity provider.
updateCapacityProvider_autoScalingGroupProvider :: Lens.Lens' UpdateCapacityProvider AutoScalingGroupProviderUpdate
updateCapacityProvider_autoScalingGroupProvider :: (AutoScalingGroupProviderUpdate
 -> f AutoScalingGroupProviderUpdate)
-> UpdateCapacityProvider -> f UpdateCapacityProvider
updateCapacityProvider_autoScalingGroupProvider = (UpdateCapacityProvider -> AutoScalingGroupProviderUpdate)
-> (UpdateCapacityProvider
    -> AutoScalingGroupProviderUpdate -> UpdateCapacityProvider)
-> Lens
     UpdateCapacityProvider
     UpdateCapacityProvider
     AutoScalingGroupProviderUpdate
     AutoScalingGroupProviderUpdate
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCapacityProvider' {AutoScalingGroupProviderUpdate
autoScalingGroupProvider :: AutoScalingGroupProviderUpdate
$sel:autoScalingGroupProvider:UpdateCapacityProvider' :: UpdateCapacityProvider -> AutoScalingGroupProviderUpdate
autoScalingGroupProvider} -> AutoScalingGroupProviderUpdate
autoScalingGroupProvider) (\s :: UpdateCapacityProvider
s@UpdateCapacityProvider' {} AutoScalingGroupProviderUpdate
a -> UpdateCapacityProvider
s {$sel:autoScalingGroupProvider:UpdateCapacityProvider' :: AutoScalingGroupProviderUpdate
autoScalingGroupProvider = AutoScalingGroupProviderUpdate
a} :: UpdateCapacityProvider)

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

instance Prelude.NFData UpdateCapacityProvider

instance Core.ToHeaders UpdateCapacityProvider where
  toHeaders :: UpdateCapacityProvider -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateCapacityProvider -> 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.UpdateCapacityProvider" ::
                          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 UpdateCapacityProvider where
  toJSON :: UpdateCapacityProvider -> Value
toJSON UpdateCapacityProvider' {Text
AutoScalingGroupProviderUpdate
autoScalingGroupProvider :: AutoScalingGroupProviderUpdate
name :: Text
$sel:autoScalingGroupProvider:UpdateCapacityProvider' :: UpdateCapacityProvider -> AutoScalingGroupProviderUpdate
$sel:name:UpdateCapacityProvider' :: UpdateCapacityProvider -> 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
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"autoScalingGroupProvider"
                  Text -> AutoScalingGroupProviderUpdate -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AutoScalingGroupProviderUpdate
autoScalingGroupProvider
              )
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateCapacityProviderResponse' 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:
--
-- 'capacityProvider', 'updateCapacityProviderResponse_capacityProvider' - Details about the capacity provider.
--
-- 'httpStatus', 'updateCapacityProviderResponse_httpStatus' - The response's http status code.
newUpdateCapacityProviderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateCapacityProviderResponse
newUpdateCapacityProviderResponse :: Int -> UpdateCapacityProviderResponse
newUpdateCapacityProviderResponse Int
pHttpStatus_ =
  UpdateCapacityProviderResponse' :: Maybe CapacityProvider -> Int -> UpdateCapacityProviderResponse
UpdateCapacityProviderResponse'
    { $sel:capacityProvider:UpdateCapacityProviderResponse' :: Maybe CapacityProvider
capacityProvider =
        Maybe CapacityProvider
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateCapacityProviderResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the capacity provider.
updateCapacityProviderResponse_capacityProvider :: Lens.Lens' UpdateCapacityProviderResponse (Prelude.Maybe CapacityProvider)
updateCapacityProviderResponse_capacityProvider :: (Maybe CapacityProvider -> f (Maybe CapacityProvider))
-> UpdateCapacityProviderResponse
-> f UpdateCapacityProviderResponse
updateCapacityProviderResponse_capacityProvider = (UpdateCapacityProviderResponse -> Maybe CapacityProvider)
-> (UpdateCapacityProviderResponse
    -> Maybe CapacityProvider -> UpdateCapacityProviderResponse)
-> Lens
     UpdateCapacityProviderResponse
     UpdateCapacityProviderResponse
     (Maybe CapacityProvider)
     (Maybe CapacityProvider)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCapacityProviderResponse' {Maybe CapacityProvider
capacityProvider :: Maybe CapacityProvider
$sel:capacityProvider:UpdateCapacityProviderResponse' :: UpdateCapacityProviderResponse -> Maybe CapacityProvider
capacityProvider} -> Maybe CapacityProvider
capacityProvider) (\s :: UpdateCapacityProviderResponse
s@UpdateCapacityProviderResponse' {} Maybe CapacityProvider
a -> UpdateCapacityProviderResponse
s {$sel:capacityProvider:UpdateCapacityProviderResponse' :: Maybe CapacityProvider
capacityProvider = Maybe CapacityProvider
a} :: UpdateCapacityProviderResponse)

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

instance
  Prelude.NFData
    UpdateCapacityProviderResponse