{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LicenseManager.Types.BorrowConfiguration
-- 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)
module Amazonka.LicenseManager.Types.BorrowConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Details about a borrow configuration.
--
-- /See:/ 'newBorrowConfiguration' smart constructor.
data BorrowConfiguration = BorrowConfiguration'
  { -- | Indicates whether early check-ins are allowed.
    BorrowConfiguration -> Bool
allowEarlyCheckIn :: Prelude.Bool,
    -- | Maximum time for the borrow configuration, in minutes.
    BorrowConfiguration -> Int
maxTimeToLiveInMinutes :: Prelude.Int
  }
  deriving (BorrowConfiguration -> BorrowConfiguration -> Bool
(BorrowConfiguration -> BorrowConfiguration -> Bool)
-> (BorrowConfiguration -> BorrowConfiguration -> Bool)
-> Eq BorrowConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BorrowConfiguration -> BorrowConfiguration -> Bool
$c/= :: BorrowConfiguration -> BorrowConfiguration -> Bool
== :: BorrowConfiguration -> BorrowConfiguration -> Bool
$c== :: BorrowConfiguration -> BorrowConfiguration -> Bool
Prelude.Eq, ReadPrec [BorrowConfiguration]
ReadPrec BorrowConfiguration
Int -> ReadS BorrowConfiguration
ReadS [BorrowConfiguration]
(Int -> ReadS BorrowConfiguration)
-> ReadS [BorrowConfiguration]
-> ReadPrec BorrowConfiguration
-> ReadPrec [BorrowConfiguration]
-> Read BorrowConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BorrowConfiguration]
$creadListPrec :: ReadPrec [BorrowConfiguration]
readPrec :: ReadPrec BorrowConfiguration
$creadPrec :: ReadPrec BorrowConfiguration
readList :: ReadS [BorrowConfiguration]
$creadList :: ReadS [BorrowConfiguration]
readsPrec :: Int -> ReadS BorrowConfiguration
$creadsPrec :: Int -> ReadS BorrowConfiguration
Prelude.Read, Int -> BorrowConfiguration -> ShowS
[BorrowConfiguration] -> ShowS
BorrowConfiguration -> String
(Int -> BorrowConfiguration -> ShowS)
-> (BorrowConfiguration -> String)
-> ([BorrowConfiguration] -> ShowS)
-> Show BorrowConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BorrowConfiguration] -> ShowS
$cshowList :: [BorrowConfiguration] -> ShowS
show :: BorrowConfiguration -> String
$cshow :: BorrowConfiguration -> String
showsPrec :: Int -> BorrowConfiguration -> ShowS
$cshowsPrec :: Int -> BorrowConfiguration -> ShowS
Prelude.Show, (forall x. BorrowConfiguration -> Rep BorrowConfiguration x)
-> (forall x. Rep BorrowConfiguration x -> BorrowConfiguration)
-> Generic BorrowConfiguration
forall x. Rep BorrowConfiguration x -> BorrowConfiguration
forall x. BorrowConfiguration -> Rep BorrowConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BorrowConfiguration x -> BorrowConfiguration
$cfrom :: forall x. BorrowConfiguration -> Rep BorrowConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'BorrowConfiguration' 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:
--
-- 'allowEarlyCheckIn', 'borrowConfiguration_allowEarlyCheckIn' - Indicates whether early check-ins are allowed.
--
-- 'maxTimeToLiveInMinutes', 'borrowConfiguration_maxTimeToLiveInMinutes' - Maximum time for the borrow configuration, in minutes.
newBorrowConfiguration ::
  -- | 'allowEarlyCheckIn'
  Prelude.Bool ->
  -- | 'maxTimeToLiveInMinutes'
  Prelude.Int ->
  BorrowConfiguration
newBorrowConfiguration :: Bool -> Int -> BorrowConfiguration
newBorrowConfiguration
  Bool
pAllowEarlyCheckIn_
  Int
pMaxTimeToLiveInMinutes_ =
    BorrowConfiguration' :: Bool -> Int -> BorrowConfiguration
BorrowConfiguration'
      { $sel:allowEarlyCheckIn:BorrowConfiguration' :: Bool
allowEarlyCheckIn =
          Bool
pAllowEarlyCheckIn_,
        $sel:maxTimeToLiveInMinutes:BorrowConfiguration' :: Int
maxTimeToLiveInMinutes = Int
pMaxTimeToLiveInMinutes_
      }

-- | Indicates whether early check-ins are allowed.
borrowConfiguration_allowEarlyCheckIn :: Lens.Lens' BorrowConfiguration Prelude.Bool
borrowConfiguration_allowEarlyCheckIn :: (Bool -> f Bool) -> BorrowConfiguration -> f BorrowConfiguration
borrowConfiguration_allowEarlyCheckIn = (BorrowConfiguration -> Bool)
-> (BorrowConfiguration -> Bool -> BorrowConfiguration)
-> Lens BorrowConfiguration BorrowConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BorrowConfiguration' {Bool
allowEarlyCheckIn :: Bool
$sel:allowEarlyCheckIn:BorrowConfiguration' :: BorrowConfiguration -> Bool
allowEarlyCheckIn} -> Bool
allowEarlyCheckIn) (\s :: BorrowConfiguration
s@BorrowConfiguration' {} Bool
a -> BorrowConfiguration
s {$sel:allowEarlyCheckIn:BorrowConfiguration' :: Bool
allowEarlyCheckIn = Bool
a} :: BorrowConfiguration)

-- | Maximum time for the borrow configuration, in minutes.
borrowConfiguration_maxTimeToLiveInMinutes :: Lens.Lens' BorrowConfiguration Prelude.Int
borrowConfiguration_maxTimeToLiveInMinutes :: (Int -> f Int) -> BorrowConfiguration -> f BorrowConfiguration
borrowConfiguration_maxTimeToLiveInMinutes = (BorrowConfiguration -> Int)
-> (BorrowConfiguration -> Int -> BorrowConfiguration)
-> Lens BorrowConfiguration BorrowConfiguration Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BorrowConfiguration' {Int
maxTimeToLiveInMinutes :: Int
$sel:maxTimeToLiveInMinutes:BorrowConfiguration' :: BorrowConfiguration -> Int
maxTimeToLiveInMinutes} -> Int
maxTimeToLiveInMinutes) (\s :: BorrowConfiguration
s@BorrowConfiguration' {} Int
a -> BorrowConfiguration
s {$sel:maxTimeToLiveInMinutes:BorrowConfiguration' :: Int
maxTimeToLiveInMinutes = Int
a} :: BorrowConfiguration)

instance Core.FromJSON BorrowConfiguration where
  parseJSON :: Value -> Parser BorrowConfiguration
parseJSON =
    String
-> (Object -> Parser BorrowConfiguration)
-> Value
-> Parser BorrowConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BorrowConfiguration"
      ( \Object
x ->
          Bool -> Int -> BorrowConfiguration
BorrowConfiguration'
            (Bool -> Int -> BorrowConfiguration)
-> Parser Bool -> Parser (Int -> BorrowConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AllowEarlyCheckIn")
            Parser (Int -> BorrowConfiguration)
-> Parser Int -> Parser BorrowConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxTimeToLiveInMinutes")
      )

instance Prelude.Hashable BorrowConfiguration

instance Prelude.NFData BorrowConfiguration

instance Core.ToJSON BorrowConfiguration where
  toJSON :: BorrowConfiguration -> Value
toJSON BorrowConfiguration' {Bool
Int
maxTimeToLiveInMinutes :: Int
allowEarlyCheckIn :: Bool
$sel:maxTimeToLiveInMinutes:BorrowConfiguration' :: BorrowConfiguration -> Int
$sel:allowEarlyCheckIn:BorrowConfiguration' :: BorrowConfiguration -> Bool
..} =
    [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
"AllowEarlyCheckIn" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
allowEarlyCheckIn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"MaxTimeToLiveInMinutes"
                  Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
maxTimeToLiveInMinutes
              )
          ]
      )