{-# 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.CloudFront.Types.OriginSslProtocols
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFront.Types.OriginSslProtocols where

import Amazonka.CloudFront.Types.SslProtocol
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

-- | A complex type that contains information about the SSL\/TLS protocols
-- that CloudFront can use when establishing an HTTPS connection with your
-- origin.
--
-- /See:/ 'newOriginSslProtocols' smart constructor.
data OriginSslProtocols = OriginSslProtocols'
  { -- | The number of SSL\/TLS protocols that you want to allow CloudFront to
    -- use when establishing an HTTPS connection with this origin.
    OriginSslProtocols -> Int
quantity :: Prelude.Int,
    -- | A list that contains allowed SSL\/TLS protocols for this distribution.
    OriginSslProtocols -> [SslProtocol]
items :: [SslProtocol]
  }
  deriving (OriginSslProtocols -> OriginSslProtocols -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OriginSslProtocols -> OriginSslProtocols -> Bool
$c/= :: OriginSslProtocols -> OriginSslProtocols -> Bool
== :: OriginSslProtocols -> OriginSslProtocols -> Bool
$c== :: OriginSslProtocols -> OriginSslProtocols -> Bool
Prelude.Eq, ReadPrec [OriginSslProtocols]
ReadPrec OriginSslProtocols
Int -> ReadS OriginSslProtocols
ReadS [OriginSslProtocols]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OriginSslProtocols]
$creadListPrec :: ReadPrec [OriginSslProtocols]
readPrec :: ReadPrec OriginSslProtocols
$creadPrec :: ReadPrec OriginSslProtocols
readList :: ReadS [OriginSslProtocols]
$creadList :: ReadS [OriginSslProtocols]
readsPrec :: Int -> ReadS OriginSslProtocols
$creadsPrec :: Int -> ReadS OriginSslProtocols
Prelude.Read, Int -> OriginSslProtocols -> ShowS
[OriginSslProtocols] -> ShowS
OriginSslProtocols -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OriginSslProtocols] -> ShowS
$cshowList :: [OriginSslProtocols] -> ShowS
show :: OriginSslProtocols -> String
$cshow :: OriginSslProtocols -> String
showsPrec :: Int -> OriginSslProtocols -> ShowS
$cshowsPrec :: Int -> OriginSslProtocols -> ShowS
Prelude.Show, forall x. Rep OriginSslProtocols x -> OriginSslProtocols
forall x. OriginSslProtocols -> Rep OriginSslProtocols x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OriginSslProtocols x -> OriginSslProtocols
$cfrom :: forall x. OriginSslProtocols -> Rep OriginSslProtocols x
Prelude.Generic)

-- |
-- Create a value of 'OriginSslProtocols' 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:
--
-- 'quantity', 'originSslProtocols_quantity' - The number of SSL\/TLS protocols that you want to allow CloudFront to
-- use when establishing an HTTPS connection with this origin.
--
-- 'items', 'originSslProtocols_items' - A list that contains allowed SSL\/TLS protocols for this distribution.
newOriginSslProtocols ::
  -- | 'quantity'
  Prelude.Int ->
  OriginSslProtocols
newOriginSslProtocols :: Int -> OriginSslProtocols
newOriginSslProtocols Int
pQuantity_ =
  OriginSslProtocols'
    { $sel:quantity:OriginSslProtocols' :: Int
quantity = Int
pQuantity_,
      $sel:items:OriginSslProtocols' :: [SslProtocol]
items = forall a. Monoid a => a
Prelude.mempty
    }

-- | The number of SSL\/TLS protocols that you want to allow CloudFront to
-- use when establishing an HTTPS connection with this origin.
originSslProtocols_quantity :: Lens.Lens' OriginSslProtocols Prelude.Int
originSslProtocols_quantity :: Lens' OriginSslProtocols Int
originSslProtocols_quantity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginSslProtocols' {Int
quantity :: Int
$sel:quantity:OriginSslProtocols' :: OriginSslProtocols -> Int
quantity} -> Int
quantity) (\s :: OriginSslProtocols
s@OriginSslProtocols' {} Int
a -> OriginSslProtocols
s {$sel:quantity:OriginSslProtocols' :: Int
quantity = Int
a} :: OriginSslProtocols)

-- | A list that contains allowed SSL\/TLS protocols for this distribution.
originSslProtocols_items :: Lens.Lens' OriginSslProtocols [SslProtocol]
originSslProtocols_items :: Lens' OriginSslProtocols [SslProtocol]
originSslProtocols_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OriginSslProtocols' {[SslProtocol]
items :: [SslProtocol]
$sel:items:OriginSslProtocols' :: OriginSslProtocols -> [SslProtocol]
items} -> [SslProtocol]
items) (\s :: OriginSslProtocols
s@OriginSslProtocols' {} [SslProtocol]
a -> OriginSslProtocols
s {$sel:items:OriginSslProtocols' :: [SslProtocol]
items = [SslProtocol]
a} :: OriginSslProtocols) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML OriginSslProtocols where
  parseXML :: [Node] -> Either String OriginSslProtocols
parseXML [Node]
x =
    Int -> [SslProtocol] -> OriginSslProtocols
OriginSslProtocols'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"Quantity")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Items"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"SslProtocol"
                  )

instance Prelude.Hashable OriginSslProtocols where
  hashWithSalt :: Int -> OriginSslProtocols -> Int
hashWithSalt Int
_salt OriginSslProtocols' {Int
[SslProtocol]
items :: [SslProtocol]
quantity :: Int
$sel:items:OriginSslProtocols' :: OriginSslProtocols -> [SslProtocol]
$sel:quantity:OriginSslProtocols' :: OriginSslProtocols -> Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
quantity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [SslProtocol]
items

instance Prelude.NFData OriginSslProtocols where
  rnf :: OriginSslProtocols -> ()
rnf OriginSslProtocols' {Int
[SslProtocol]
items :: [SslProtocol]
quantity :: Int
$sel:items:OriginSslProtocols' :: OriginSslProtocols -> [SslProtocol]
$sel:quantity:OriginSslProtocols' :: OriginSslProtocols -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
quantity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [SslProtocol]
items

instance Data.ToXML OriginSslProtocols where
  toXML :: OriginSslProtocols -> XML
toXML OriginSslProtocols' {Int
[SslProtocol]
items :: [SslProtocol]
quantity :: Int
$sel:items:OriginSslProtocols' :: OriginSslProtocols -> [SslProtocol]
$sel:quantity:OriginSslProtocols' :: OriginSslProtocols -> Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"Quantity" forall a. ToXML a => Name -> a -> XML
Data.@= Int
quantity,
        Name
"Items" forall a. ToXML a => Name -> a -> XML
Data.@= forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"SslProtocol" [SslProtocol]
items
      ]