{-# 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-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.CloudFront.Types.OriginSslProtocols where

import Amazonka.CloudFront.Types.SslProtocol
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(OriginSslProtocols -> OriginSslProtocols -> Bool)
-> (OriginSslProtocols -> OriginSslProtocols -> Bool)
-> Eq OriginSslProtocols
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]
(Int -> ReadS OriginSslProtocols)
-> ReadS [OriginSslProtocols]
-> ReadPrec OriginSslProtocols
-> ReadPrec [OriginSslProtocols]
-> Read 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
(Int -> OriginSslProtocols -> ShowS)
-> (OriginSslProtocols -> String)
-> ([OriginSslProtocols] -> ShowS)
-> Show OriginSslProtocols
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. OriginSslProtocols -> Rep OriginSslProtocols x)
-> (forall x. Rep OriginSslProtocols x -> OriginSslProtocols)
-> Generic OriginSslProtocols
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' :: Int -> [SslProtocol] -> OriginSslProtocols
OriginSslProtocols'
    { $sel:quantity:OriginSslProtocols' :: Int
quantity = Int
pQuantity_,
      $sel:items:OriginSslProtocols' :: [SslProtocol]
items = [SslProtocol]
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 :: (Int -> f Int) -> OriginSslProtocols -> f OriginSslProtocols
originSslProtocols_quantity = (OriginSslProtocols -> Int)
-> (OriginSslProtocols -> Int -> OriginSslProtocols)
-> Lens OriginSslProtocols OriginSslProtocols Int Int
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 :: ([SslProtocol] -> f [SslProtocol])
-> OriginSslProtocols -> f OriginSslProtocols
originSslProtocols_items = (OriginSslProtocols -> [SslProtocol])
-> (OriginSslProtocols -> [SslProtocol] -> OriginSslProtocols)
-> Lens
     OriginSslProtocols OriginSslProtocols [SslProtocol] [SslProtocol]
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) (([SslProtocol] -> f [SslProtocol])
 -> OriginSslProtocols -> f OriginSslProtocols)
-> (([SslProtocol] -> f [SslProtocol])
    -> [SslProtocol] -> f [SslProtocol])
-> ([SslProtocol] -> f [SslProtocol])
-> OriginSslProtocols
-> f OriginSslProtocols
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([SslProtocol] -> f [SslProtocol])
-> [SslProtocol] -> f [SslProtocol]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable OriginSslProtocols

instance Prelude.NFData OriginSslProtocols

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