{-# 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.Batch.UpdateSchedulingPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates a scheduling policy.
module Amazonka.Batch.UpdateSchedulingPolicy
  ( -- * Creating a Request
    UpdateSchedulingPolicy (..),
    newUpdateSchedulingPolicy,

    -- * Request Lenses
    updateSchedulingPolicy_fairsharePolicy,
    updateSchedulingPolicy_arn,

    -- * Destructuring the Response
    UpdateSchedulingPolicyResponse (..),
    newUpdateSchedulingPolicyResponse,

    -- * Response Lenses
    updateSchedulingPolicyResponse_httpStatus,
  )
where

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

-- | Contains the parameters for @UpdateSchedulingPolicy@.
--
-- /See:/ 'newUpdateSchedulingPolicy' smart constructor.
data UpdateSchedulingPolicy = UpdateSchedulingPolicy'
  { -- | The fair share policy.
    UpdateSchedulingPolicy -> Maybe FairsharePolicy
fairsharePolicy :: Prelude.Maybe FairsharePolicy,
    -- | The Amazon Resource Name (ARN) of the scheduling policy to update.
    UpdateSchedulingPolicy -> Text
arn :: Prelude.Text
  }
  deriving (UpdateSchedulingPolicy -> UpdateSchedulingPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSchedulingPolicy -> UpdateSchedulingPolicy -> Bool
$c/= :: UpdateSchedulingPolicy -> UpdateSchedulingPolicy -> Bool
== :: UpdateSchedulingPolicy -> UpdateSchedulingPolicy -> Bool
$c== :: UpdateSchedulingPolicy -> UpdateSchedulingPolicy -> Bool
Prelude.Eq, ReadPrec [UpdateSchedulingPolicy]
ReadPrec UpdateSchedulingPolicy
Int -> ReadS UpdateSchedulingPolicy
ReadS [UpdateSchedulingPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSchedulingPolicy]
$creadListPrec :: ReadPrec [UpdateSchedulingPolicy]
readPrec :: ReadPrec UpdateSchedulingPolicy
$creadPrec :: ReadPrec UpdateSchedulingPolicy
readList :: ReadS [UpdateSchedulingPolicy]
$creadList :: ReadS [UpdateSchedulingPolicy]
readsPrec :: Int -> ReadS UpdateSchedulingPolicy
$creadsPrec :: Int -> ReadS UpdateSchedulingPolicy
Prelude.Read, Int -> UpdateSchedulingPolicy -> ShowS
[UpdateSchedulingPolicy] -> ShowS
UpdateSchedulingPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSchedulingPolicy] -> ShowS
$cshowList :: [UpdateSchedulingPolicy] -> ShowS
show :: UpdateSchedulingPolicy -> String
$cshow :: UpdateSchedulingPolicy -> String
showsPrec :: Int -> UpdateSchedulingPolicy -> ShowS
$cshowsPrec :: Int -> UpdateSchedulingPolicy -> ShowS
Prelude.Show, forall x. Rep UpdateSchedulingPolicy x -> UpdateSchedulingPolicy
forall x. UpdateSchedulingPolicy -> Rep UpdateSchedulingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateSchedulingPolicy x -> UpdateSchedulingPolicy
$cfrom :: forall x. UpdateSchedulingPolicy -> Rep UpdateSchedulingPolicy x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSchedulingPolicy' 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:
--
-- 'fairsharePolicy', 'updateSchedulingPolicy_fairsharePolicy' - The fair share policy.
--
-- 'arn', 'updateSchedulingPolicy_arn' - The Amazon Resource Name (ARN) of the scheduling policy to update.
newUpdateSchedulingPolicy ::
  -- | 'arn'
  Prelude.Text ->
  UpdateSchedulingPolicy
newUpdateSchedulingPolicy :: Text -> UpdateSchedulingPolicy
newUpdateSchedulingPolicy Text
pArn_ =
  UpdateSchedulingPolicy'
    { $sel:fairsharePolicy:UpdateSchedulingPolicy' :: Maybe FairsharePolicy
fairsharePolicy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:arn:UpdateSchedulingPolicy' :: Text
arn = Text
pArn_
    }

-- | The fair share policy.
updateSchedulingPolicy_fairsharePolicy :: Lens.Lens' UpdateSchedulingPolicy (Prelude.Maybe FairsharePolicy)
updateSchedulingPolicy_fairsharePolicy :: Lens' UpdateSchedulingPolicy (Maybe FairsharePolicy)
updateSchedulingPolicy_fairsharePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSchedulingPolicy' {Maybe FairsharePolicy
fairsharePolicy :: Maybe FairsharePolicy
$sel:fairsharePolicy:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Maybe FairsharePolicy
fairsharePolicy} -> Maybe FairsharePolicy
fairsharePolicy) (\s :: UpdateSchedulingPolicy
s@UpdateSchedulingPolicy' {} Maybe FairsharePolicy
a -> UpdateSchedulingPolicy
s {$sel:fairsharePolicy:UpdateSchedulingPolicy' :: Maybe FairsharePolicy
fairsharePolicy = Maybe FairsharePolicy
a} :: UpdateSchedulingPolicy)

-- | The Amazon Resource Name (ARN) of the scheduling policy to update.
updateSchedulingPolicy_arn :: Lens.Lens' UpdateSchedulingPolicy Prelude.Text
updateSchedulingPolicy_arn :: Lens' UpdateSchedulingPolicy Text
updateSchedulingPolicy_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSchedulingPolicy' {Text
arn :: Text
$sel:arn:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Text
arn} -> Text
arn) (\s :: UpdateSchedulingPolicy
s@UpdateSchedulingPolicy' {} Text
a -> UpdateSchedulingPolicy
s {$sel:arn:UpdateSchedulingPolicy' :: Text
arn = Text
a} :: UpdateSchedulingPolicy)

instance Core.AWSRequest UpdateSchedulingPolicy where
  type
    AWSResponse UpdateSchedulingPolicy =
      UpdateSchedulingPolicyResponse
  request :: (Service -> Service)
-> UpdateSchedulingPolicy -> Request UpdateSchedulingPolicy
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateSchedulingPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSchedulingPolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateSchedulingPolicyResponse
UpdateSchedulingPolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateSchedulingPolicy where
  hashWithSalt :: Int -> UpdateSchedulingPolicy -> Int
hashWithSalt Int
_salt UpdateSchedulingPolicy' {Maybe FairsharePolicy
Text
arn :: Text
fairsharePolicy :: Maybe FairsharePolicy
$sel:arn:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Text
$sel:fairsharePolicy:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Maybe FairsharePolicy
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FairsharePolicy
fairsharePolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData UpdateSchedulingPolicy where
  rnf :: UpdateSchedulingPolicy -> ()
rnf UpdateSchedulingPolicy' {Maybe FairsharePolicy
Text
arn :: Text
fairsharePolicy :: Maybe FairsharePolicy
$sel:arn:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Text
$sel:fairsharePolicy:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Maybe FairsharePolicy
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FairsharePolicy
fairsharePolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn

instance Data.ToHeaders UpdateSchedulingPolicy where
  toHeaders :: UpdateSchedulingPolicy -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateSchedulingPolicy where
  toJSON :: UpdateSchedulingPolicy -> Value
toJSON UpdateSchedulingPolicy' {Maybe FairsharePolicy
Text
arn :: Text
fairsharePolicy :: Maybe FairsharePolicy
$sel:arn:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Text
$sel:fairsharePolicy:UpdateSchedulingPolicy' :: UpdateSchedulingPolicy -> Maybe FairsharePolicy
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"fairsharePolicy" 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 FairsharePolicy
fairsharePolicy,
            forall a. a -> Maybe a
Prelude.Just (Key
"arn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
arn)
          ]
      )

instance Data.ToPath UpdateSchedulingPolicy where
  toPath :: UpdateSchedulingPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/updateschedulingpolicy"

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

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

-- |
-- Create a value of 'UpdateSchedulingPolicyResponse' 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:
--
-- 'httpStatus', 'updateSchedulingPolicyResponse_httpStatus' - The response's http status code.
newUpdateSchedulingPolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateSchedulingPolicyResponse
newUpdateSchedulingPolicyResponse :: Int -> UpdateSchedulingPolicyResponse
newUpdateSchedulingPolicyResponse Int
pHttpStatus_ =
  UpdateSchedulingPolicyResponse'
    { $sel:httpStatus:UpdateSchedulingPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    UpdateSchedulingPolicyResponse
  where
  rnf :: UpdateSchedulingPolicyResponse -> ()
rnf UpdateSchedulingPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateSchedulingPolicyResponse' :: UpdateSchedulingPolicyResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus