{-# 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.Restrictions
-- 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.Restrictions where

import Amazonka.CloudFront.Types.GeoRestriction
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex type that identifies ways in which you want to restrict
-- distribution of your content.
--
-- /See:/ 'newRestrictions' smart constructor.
data Restrictions = Restrictions'
  { -- | A complex type that controls the countries in which your content is
    -- distributed. CloudFront determines the location of your users using
    -- @MaxMind@ GeoIP databases.
    Restrictions -> GeoRestriction
geoRestriction :: GeoRestriction
  }
  deriving (Restrictions -> Restrictions -> Bool
(Restrictions -> Restrictions -> Bool)
-> (Restrictions -> Restrictions -> Bool) -> Eq Restrictions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Restrictions -> Restrictions -> Bool
$c/= :: Restrictions -> Restrictions -> Bool
== :: Restrictions -> Restrictions -> Bool
$c== :: Restrictions -> Restrictions -> Bool
Prelude.Eq, ReadPrec [Restrictions]
ReadPrec Restrictions
Int -> ReadS Restrictions
ReadS [Restrictions]
(Int -> ReadS Restrictions)
-> ReadS [Restrictions]
-> ReadPrec Restrictions
-> ReadPrec [Restrictions]
-> Read Restrictions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Restrictions]
$creadListPrec :: ReadPrec [Restrictions]
readPrec :: ReadPrec Restrictions
$creadPrec :: ReadPrec Restrictions
readList :: ReadS [Restrictions]
$creadList :: ReadS [Restrictions]
readsPrec :: Int -> ReadS Restrictions
$creadsPrec :: Int -> ReadS Restrictions
Prelude.Read, Int -> Restrictions -> ShowS
[Restrictions] -> ShowS
Restrictions -> String
(Int -> Restrictions -> ShowS)
-> (Restrictions -> String)
-> ([Restrictions] -> ShowS)
-> Show Restrictions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Restrictions] -> ShowS
$cshowList :: [Restrictions] -> ShowS
show :: Restrictions -> String
$cshow :: Restrictions -> String
showsPrec :: Int -> Restrictions -> ShowS
$cshowsPrec :: Int -> Restrictions -> ShowS
Prelude.Show, (forall x. Restrictions -> Rep Restrictions x)
-> (forall x. Rep Restrictions x -> Restrictions)
-> Generic Restrictions
forall x. Rep Restrictions x -> Restrictions
forall x. Restrictions -> Rep Restrictions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Restrictions x -> Restrictions
$cfrom :: forall x. Restrictions -> Rep Restrictions x
Prelude.Generic)

-- |
-- Create a value of 'Restrictions' 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:
--
-- 'geoRestriction', 'restrictions_geoRestriction' - A complex type that controls the countries in which your content is
-- distributed. CloudFront determines the location of your users using
-- @MaxMind@ GeoIP databases.
newRestrictions ::
  -- | 'geoRestriction'
  GeoRestriction ->
  Restrictions
newRestrictions :: GeoRestriction -> Restrictions
newRestrictions GeoRestriction
pGeoRestriction_ =
  Restrictions' :: GeoRestriction -> Restrictions
Restrictions' {$sel:geoRestriction:Restrictions' :: GeoRestriction
geoRestriction = GeoRestriction
pGeoRestriction_}

-- | A complex type that controls the countries in which your content is
-- distributed. CloudFront determines the location of your users using
-- @MaxMind@ GeoIP databases.
restrictions_geoRestriction :: Lens.Lens' Restrictions GeoRestriction
restrictions_geoRestriction :: (GeoRestriction -> f GeoRestriction)
-> Restrictions -> f Restrictions
restrictions_geoRestriction = (Restrictions -> GeoRestriction)
-> (Restrictions -> GeoRestriction -> Restrictions)
-> Lens Restrictions Restrictions GeoRestriction GeoRestriction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Restrictions' {GeoRestriction
geoRestriction :: GeoRestriction
$sel:geoRestriction:Restrictions' :: Restrictions -> GeoRestriction
geoRestriction} -> GeoRestriction
geoRestriction) (\s :: Restrictions
s@Restrictions' {} GeoRestriction
a -> Restrictions
s {$sel:geoRestriction:Restrictions' :: GeoRestriction
geoRestriction = GeoRestriction
a} :: Restrictions)

instance Core.FromXML Restrictions where
  parseXML :: [Node] -> Either String Restrictions
parseXML [Node]
x =
    GeoRestriction -> Restrictions
Restrictions'
      (GeoRestriction -> Restrictions)
-> Either String GeoRestriction -> Either String Restrictions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String GeoRestriction
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"GeoRestriction")

instance Prelude.Hashable Restrictions

instance Prelude.NFData Restrictions

instance Core.ToXML Restrictions where
  toXML :: Restrictions -> XML
toXML Restrictions' {GeoRestriction
geoRestriction :: GeoRestriction
$sel:geoRestriction:Restrictions' :: Restrictions -> GeoRestriction
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"GeoRestriction" Name -> GeoRestriction -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= GeoRestriction
geoRestriction]