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

import Amazonka.CloudFront.Types.CustomHeaders
import Amazonka.CloudFront.Types.CustomOriginConfig
import Amazonka.CloudFront.Types.OriginShield
import Amazonka.CloudFront.Types.S3OriginConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An origin.
--
-- An origin is the location where content is stored, and from which
-- CloudFront gets content to serve to viewers. To specify an origin:
--
-- -   Use @S3OriginConfig@ to specify an Amazon S3 bucket that is not
--     configured with static website hosting.
--
-- -   Use @CustomOriginConfig@ to specify all other kinds of origins,
--     including:
--
--     -   An Amazon S3 bucket that is configured with static website
--         hosting
--
--     -   An Elastic Load Balancing load balancer
--
--     -   An AWS Elemental MediaPackage endpoint
--
--     -   An AWS Elemental MediaStore container
--
--     -   Any other HTTP server, running on an Amazon EC2 instance or any
--         other kind of host
--
-- For the current maximum number of origins that you can specify per
-- distribution, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html#limits-web-distributions General Quotas on Web Distributions>
-- in the /Amazon CloudFront Developer Guide/ (quotas were formerly
-- referred to as limits).
--
-- /See:/ 'newOrigin' smart constructor.
data Origin = Origin'
  { -- | A list of HTTP header names and values that CloudFront adds to the
    -- requests that it sends to the origin.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html Adding Custom Headers to Origin Requests>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Maybe CustomHeaders
customHeaders :: Prelude.Maybe CustomHeaders,
    -- | Use this type to specify an origin that is not an Amazon S3 bucket, with
    -- one exception. If the Amazon S3 bucket is configured with static website
    -- hosting, use this type. If the Amazon S3 bucket is not configured with
    -- static website hosting, use the @S3OriginConfig@ type instead.
    Origin -> Maybe CustomOriginConfig
customOriginConfig :: Prelude.Maybe CustomOriginConfig,
    -- | The number of seconds that CloudFront waits when trying to establish a
    -- connection to the origin. The minimum timeout is 1 second, the maximum
    -- is 10 seconds, and the default (if you don’t specify otherwise) is 10
    -- seconds.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-timeout Origin Connection Timeout>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Maybe Int
connectionTimeout :: Prelude.Maybe Prelude.Int,
    -- | The number of times that CloudFront attempts to connect to the origin.
    -- The minimum number is 1, the maximum is 3, and the default (if you don’t
    -- specify otherwise) is 3.
    --
    -- For a custom origin (including an Amazon S3 bucket that’s configured
    -- with static website hosting), this value also specifies the number of
    -- times that CloudFront attempts to get a response from the origin, in the
    -- case of an
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginResponseTimeout Origin Response Timeout>.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-attempts Origin Connection Attempts>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Maybe Int
connectionAttempts :: Prelude.Maybe Prelude.Int,
    -- | Use this type to specify an origin that is an Amazon S3 bucket that is
    -- not configured with static website hosting. To specify any other type of
    -- origin, including an Amazon S3 bucket that is configured with static
    -- website hosting, use the @CustomOriginConfig@ type instead.
    Origin -> Maybe S3OriginConfig
s3OriginConfig :: Prelude.Maybe S3OriginConfig,
    -- | An optional path that CloudFront appends to the origin domain name when
    -- CloudFront requests content from the origin.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath Origin Path>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Maybe Text
originPath :: Prelude.Maybe Prelude.Text,
    -- | CloudFront Origin Shield. Using Origin Shield can help reduce the load
    -- on your origin.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html Using Origin Shield>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Maybe OriginShield
originShield :: Prelude.Maybe OriginShield,
    -- | A unique identifier for the origin. This value must be unique within the
    -- distribution.
    --
    -- Use this value to specify the @TargetOriginId@ in a @CacheBehavior@ or
    -- @DefaultCacheBehavior@.
    Origin -> Text
id :: Prelude.Text,
    -- | The domain name for the origin.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDomainName Origin Domain Name>
    -- in the /Amazon CloudFront Developer Guide/.
    Origin -> Text
domainName :: Prelude.Text
  }
  deriving (Origin -> Origin -> Bool
(Origin -> Origin -> Bool)
-> (Origin -> Origin -> Bool) -> Eq Origin
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Origin -> Origin -> Bool
$c/= :: Origin -> Origin -> Bool
== :: Origin -> Origin -> Bool
$c== :: Origin -> Origin -> Bool
Prelude.Eq, ReadPrec [Origin]
ReadPrec Origin
Int -> ReadS Origin
ReadS [Origin]
(Int -> ReadS Origin)
-> ReadS [Origin]
-> ReadPrec Origin
-> ReadPrec [Origin]
-> Read Origin
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Origin]
$creadListPrec :: ReadPrec [Origin]
readPrec :: ReadPrec Origin
$creadPrec :: ReadPrec Origin
readList :: ReadS [Origin]
$creadList :: ReadS [Origin]
readsPrec :: Int -> ReadS Origin
$creadsPrec :: Int -> ReadS Origin
Prelude.Read, Int -> Origin -> ShowS
[Origin] -> ShowS
Origin -> String
(Int -> Origin -> ShowS)
-> (Origin -> String) -> ([Origin] -> ShowS) -> Show Origin
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Origin] -> ShowS
$cshowList :: [Origin] -> ShowS
show :: Origin -> String
$cshow :: Origin -> String
showsPrec :: Int -> Origin -> ShowS
$cshowsPrec :: Int -> Origin -> ShowS
Prelude.Show, (forall x. Origin -> Rep Origin x)
-> (forall x. Rep Origin x -> Origin) -> Generic Origin
forall x. Rep Origin x -> Origin
forall x. Origin -> Rep Origin x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Origin x -> Origin
$cfrom :: forall x. Origin -> Rep Origin x
Prelude.Generic)

-- |
-- Create a value of 'Origin' 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:
--
-- 'customHeaders', 'origin_customHeaders' - A list of HTTP header names and values that CloudFront adds to the
-- requests that it sends to the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html Adding Custom Headers to Origin Requests>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 'customOriginConfig', 'origin_customOriginConfig' - Use this type to specify an origin that is not an Amazon S3 bucket, with
-- one exception. If the Amazon S3 bucket is configured with static website
-- hosting, use this type. If the Amazon S3 bucket is not configured with
-- static website hosting, use the @S3OriginConfig@ type instead.
--
-- 'connectionTimeout', 'origin_connectionTimeout' - The number of seconds that CloudFront waits when trying to establish a
-- connection to the origin. The minimum timeout is 1 second, the maximum
-- is 10 seconds, and the default (if you don’t specify otherwise) is 10
-- seconds.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-timeout Origin Connection Timeout>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 'connectionAttempts', 'origin_connectionAttempts' - The number of times that CloudFront attempts to connect to the origin.
-- The minimum number is 1, the maximum is 3, and the default (if you don’t
-- specify otherwise) is 3.
--
-- For a custom origin (including an Amazon S3 bucket that’s configured
-- with static website hosting), this value also specifies the number of
-- times that CloudFront attempts to get a response from the origin, in the
-- case of an
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginResponseTimeout Origin Response Timeout>.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-attempts Origin Connection Attempts>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 's3OriginConfig', 'origin_s3OriginConfig' - Use this type to specify an origin that is an Amazon S3 bucket that is
-- not configured with static website hosting. To specify any other type of
-- origin, including an Amazon S3 bucket that is configured with static
-- website hosting, use the @CustomOriginConfig@ type instead.
--
-- 'originPath', 'origin_originPath' - An optional path that CloudFront appends to the origin domain name when
-- CloudFront requests content from the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath Origin Path>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 'originShield', 'origin_originShield' - CloudFront Origin Shield. Using Origin Shield can help reduce the load
-- on your origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html Using Origin Shield>
-- in the /Amazon CloudFront Developer Guide/.
--
-- 'id', 'origin_id' - A unique identifier for the origin. This value must be unique within the
-- distribution.
--
-- Use this value to specify the @TargetOriginId@ in a @CacheBehavior@ or
-- @DefaultCacheBehavior@.
--
-- 'domainName', 'origin_domainName' - The domain name for the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDomainName Origin Domain Name>
-- in the /Amazon CloudFront Developer Guide/.
newOrigin ::
  -- | 'id'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  Origin
newOrigin :: Text -> Text -> Origin
newOrigin Text
pId_ Text
pDomainName_ =
  Origin' :: Maybe CustomHeaders
-> Maybe CustomOriginConfig
-> Maybe Int
-> Maybe Int
-> Maybe S3OriginConfig
-> Maybe Text
-> Maybe OriginShield
-> Text
-> Text
-> Origin
Origin'
    { $sel:customHeaders:Origin' :: Maybe CustomHeaders
customHeaders = Maybe CustomHeaders
forall a. Maybe a
Prelude.Nothing,
      $sel:customOriginConfig:Origin' :: Maybe CustomOriginConfig
customOriginConfig = Maybe CustomOriginConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionTimeout:Origin' :: Maybe Int
connectionTimeout = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionAttempts:Origin' :: Maybe Int
connectionAttempts = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:s3OriginConfig:Origin' :: Maybe S3OriginConfig
s3OriginConfig = Maybe S3OriginConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:originPath:Origin' :: Maybe Text
originPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:originShield:Origin' :: Maybe OriginShield
originShield = Maybe OriginShield
forall a. Maybe a
Prelude.Nothing,
      $sel:id:Origin' :: Text
id = Text
pId_,
      $sel:domainName:Origin' :: Text
domainName = Text
pDomainName_
    }

-- | A list of HTTP header names and values that CloudFront adds to the
-- requests that it sends to the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html Adding Custom Headers to Origin Requests>
-- in the /Amazon CloudFront Developer Guide/.
origin_customHeaders :: Lens.Lens' Origin (Prelude.Maybe CustomHeaders)
origin_customHeaders :: (Maybe CustomHeaders -> f (Maybe CustomHeaders))
-> Origin -> f Origin
origin_customHeaders = (Origin -> Maybe CustomHeaders)
-> (Origin -> Maybe CustomHeaders -> Origin)
-> Lens Origin Origin (Maybe CustomHeaders) (Maybe CustomHeaders)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe CustomHeaders
customHeaders :: Maybe CustomHeaders
$sel:customHeaders:Origin' :: Origin -> Maybe CustomHeaders
customHeaders} -> Maybe CustomHeaders
customHeaders) (\s :: Origin
s@Origin' {} Maybe CustomHeaders
a -> Origin
s {$sel:customHeaders:Origin' :: Maybe CustomHeaders
customHeaders = Maybe CustomHeaders
a} :: Origin)

-- | Use this type to specify an origin that is not an Amazon S3 bucket, with
-- one exception. If the Amazon S3 bucket is configured with static website
-- hosting, use this type. If the Amazon S3 bucket is not configured with
-- static website hosting, use the @S3OriginConfig@ type instead.
origin_customOriginConfig :: Lens.Lens' Origin (Prelude.Maybe CustomOriginConfig)
origin_customOriginConfig :: (Maybe CustomOriginConfig -> f (Maybe CustomOriginConfig))
-> Origin -> f Origin
origin_customOriginConfig = (Origin -> Maybe CustomOriginConfig)
-> (Origin -> Maybe CustomOriginConfig -> Origin)
-> Lens
     Origin Origin (Maybe CustomOriginConfig) (Maybe CustomOriginConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe CustomOriginConfig
customOriginConfig :: Maybe CustomOriginConfig
$sel:customOriginConfig:Origin' :: Origin -> Maybe CustomOriginConfig
customOriginConfig} -> Maybe CustomOriginConfig
customOriginConfig) (\s :: Origin
s@Origin' {} Maybe CustomOriginConfig
a -> Origin
s {$sel:customOriginConfig:Origin' :: Maybe CustomOriginConfig
customOriginConfig = Maybe CustomOriginConfig
a} :: Origin)

-- | The number of seconds that CloudFront waits when trying to establish a
-- connection to the origin. The minimum timeout is 1 second, the maximum
-- is 10 seconds, and the default (if you don’t specify otherwise) is 10
-- seconds.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-timeout Origin Connection Timeout>
-- in the /Amazon CloudFront Developer Guide/.
origin_connectionTimeout :: Lens.Lens' Origin (Prelude.Maybe Prelude.Int)
origin_connectionTimeout :: (Maybe Int -> f (Maybe Int)) -> Origin -> f Origin
origin_connectionTimeout = (Origin -> Maybe Int)
-> (Origin -> Maybe Int -> Origin)
-> Lens Origin Origin (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe Int
connectionTimeout :: Maybe Int
$sel:connectionTimeout:Origin' :: Origin -> Maybe Int
connectionTimeout} -> Maybe Int
connectionTimeout) (\s :: Origin
s@Origin' {} Maybe Int
a -> Origin
s {$sel:connectionTimeout:Origin' :: Maybe Int
connectionTimeout = Maybe Int
a} :: Origin)

-- | The number of times that CloudFront attempts to connect to the origin.
-- The minimum number is 1, the maximum is 3, and the default (if you don’t
-- specify otherwise) is 3.
--
-- For a custom origin (including an Amazon S3 bucket that’s configured
-- with static website hosting), this value also specifies the number of
-- times that CloudFront attempts to get a response from the origin, in the
-- case of an
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginResponseTimeout Origin Response Timeout>.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#origin-connection-attempts Origin Connection Attempts>
-- in the /Amazon CloudFront Developer Guide/.
origin_connectionAttempts :: Lens.Lens' Origin (Prelude.Maybe Prelude.Int)
origin_connectionAttempts :: (Maybe Int -> f (Maybe Int)) -> Origin -> f Origin
origin_connectionAttempts = (Origin -> Maybe Int)
-> (Origin -> Maybe Int -> Origin)
-> Lens Origin Origin (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe Int
connectionAttempts :: Maybe Int
$sel:connectionAttempts:Origin' :: Origin -> Maybe Int
connectionAttempts} -> Maybe Int
connectionAttempts) (\s :: Origin
s@Origin' {} Maybe Int
a -> Origin
s {$sel:connectionAttempts:Origin' :: Maybe Int
connectionAttempts = Maybe Int
a} :: Origin)

-- | Use this type to specify an origin that is an Amazon S3 bucket that is
-- not configured with static website hosting. To specify any other type of
-- origin, including an Amazon S3 bucket that is configured with static
-- website hosting, use the @CustomOriginConfig@ type instead.
origin_s3OriginConfig :: Lens.Lens' Origin (Prelude.Maybe S3OriginConfig)
origin_s3OriginConfig :: (Maybe S3OriginConfig -> f (Maybe S3OriginConfig))
-> Origin -> f Origin
origin_s3OriginConfig = (Origin -> Maybe S3OriginConfig)
-> (Origin -> Maybe S3OriginConfig -> Origin)
-> Lens Origin Origin (Maybe S3OriginConfig) (Maybe S3OriginConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe S3OriginConfig
s3OriginConfig :: Maybe S3OriginConfig
$sel:s3OriginConfig:Origin' :: Origin -> Maybe S3OriginConfig
s3OriginConfig} -> Maybe S3OriginConfig
s3OriginConfig) (\s :: Origin
s@Origin' {} Maybe S3OriginConfig
a -> Origin
s {$sel:s3OriginConfig:Origin' :: Maybe S3OriginConfig
s3OriginConfig = Maybe S3OriginConfig
a} :: Origin)

-- | An optional path that CloudFront appends to the origin domain name when
-- CloudFront requests content from the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesOriginPath Origin Path>
-- in the /Amazon CloudFront Developer Guide/.
origin_originPath :: Lens.Lens' Origin (Prelude.Maybe Prelude.Text)
origin_originPath :: (Maybe Text -> f (Maybe Text)) -> Origin -> f Origin
origin_originPath = (Origin -> Maybe Text)
-> (Origin -> Maybe Text -> Origin)
-> Lens Origin Origin (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe Text
originPath :: Maybe Text
$sel:originPath:Origin' :: Origin -> Maybe Text
originPath} -> Maybe Text
originPath) (\s :: Origin
s@Origin' {} Maybe Text
a -> Origin
s {$sel:originPath:Origin' :: Maybe Text
originPath = Maybe Text
a} :: Origin)

-- | CloudFront Origin Shield. Using Origin Shield can help reduce the load
-- on your origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html Using Origin Shield>
-- in the /Amazon CloudFront Developer Guide/.
origin_originShield :: Lens.Lens' Origin (Prelude.Maybe OriginShield)
origin_originShield :: (Maybe OriginShield -> f (Maybe OriginShield))
-> Origin -> f Origin
origin_originShield = (Origin -> Maybe OriginShield)
-> (Origin -> Maybe OriginShield -> Origin)
-> Lens Origin Origin (Maybe OriginShield) (Maybe OriginShield)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Maybe OriginShield
originShield :: Maybe OriginShield
$sel:originShield:Origin' :: Origin -> Maybe OriginShield
originShield} -> Maybe OriginShield
originShield) (\s :: Origin
s@Origin' {} Maybe OriginShield
a -> Origin
s {$sel:originShield:Origin' :: Maybe OriginShield
originShield = Maybe OriginShield
a} :: Origin)

-- | A unique identifier for the origin. This value must be unique within the
-- distribution.
--
-- Use this value to specify the @TargetOriginId@ in a @CacheBehavior@ or
-- @DefaultCacheBehavior@.
origin_id :: Lens.Lens' Origin Prelude.Text
origin_id :: (Text -> f Text) -> Origin -> f Origin
origin_id = (Origin -> Text)
-> (Origin -> Text -> Origin) -> Lens Origin Origin Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Text
id :: Text
$sel:id:Origin' :: Origin -> Text
id} -> Text
id) (\s :: Origin
s@Origin' {} Text
a -> Origin
s {$sel:id:Origin' :: Text
id = Text
a} :: Origin)

-- | The domain name for the origin.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDomainName Origin Domain Name>
-- in the /Amazon CloudFront Developer Guide/.
origin_domainName :: Lens.Lens' Origin Prelude.Text
origin_domainName :: (Text -> f Text) -> Origin -> f Origin
origin_domainName = (Origin -> Text)
-> (Origin -> Text -> Origin) -> Lens Origin Origin Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Origin' {Text
domainName :: Text
$sel:domainName:Origin' :: Origin -> Text
domainName} -> Text
domainName) (\s :: Origin
s@Origin' {} Text
a -> Origin
s {$sel:domainName:Origin' :: Text
domainName = Text
a} :: Origin)

instance Core.FromXML Origin where
  parseXML :: [Node] -> Either String Origin
parseXML [Node]
x =
    Maybe CustomHeaders
-> Maybe CustomOriginConfig
-> Maybe Int
-> Maybe Int
-> Maybe S3OriginConfig
-> Maybe Text
-> Maybe OriginShield
-> Text
-> Text
-> Origin
Origin'
      (Maybe CustomHeaders
 -> Maybe CustomOriginConfig
 -> Maybe Int
 -> Maybe Int
 -> Maybe S3OriginConfig
 -> Maybe Text
 -> Maybe OriginShield
 -> Text
 -> Text
 -> Origin)
-> Either String (Maybe CustomHeaders)
-> Either
     String
     (Maybe CustomOriginConfig
      -> Maybe Int
      -> Maybe Int
      -> Maybe S3OriginConfig
      -> Maybe Text
      -> Maybe OriginShield
      -> Text
      -> Text
      -> Origin)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe CustomHeaders)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CustomHeaders")
      Either
  String
  (Maybe CustomOriginConfig
   -> Maybe Int
   -> Maybe Int
   -> Maybe S3OriginConfig
   -> Maybe Text
   -> Maybe OriginShield
   -> Text
   -> Text
   -> Origin)
-> Either String (Maybe CustomOriginConfig)
-> Either
     String
     (Maybe Int
      -> Maybe Int
      -> Maybe S3OriginConfig
      -> Maybe Text
      -> Maybe OriginShield
      -> Text
      -> Text
      -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe CustomOriginConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"CustomOriginConfig")
      Either
  String
  (Maybe Int
   -> Maybe Int
   -> Maybe S3OriginConfig
   -> Maybe Text
   -> Maybe OriginShield
   -> Text
   -> Text
   -> Origin)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe Int
      -> Maybe S3OriginConfig
      -> Maybe Text
      -> Maybe OriginShield
      -> Text
      -> Text
      -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ConnectionTimeout")
      Either
  String
  (Maybe Int
   -> Maybe S3OriginConfig
   -> Maybe Text
   -> Maybe OriginShield
   -> Text
   -> Text
   -> Origin)
-> Either String (Maybe Int)
-> Either
     String
     (Maybe S3OriginConfig
      -> Maybe Text -> Maybe OriginShield -> Text -> Text -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ConnectionAttempts")
      Either
  String
  (Maybe S3OriginConfig
   -> Maybe Text -> Maybe OriginShield -> Text -> Text -> Origin)
-> Either String (Maybe S3OriginConfig)
-> Either
     String (Maybe Text -> Maybe OriginShield -> Text -> Text -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe S3OriginConfig)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"S3OriginConfig")
      Either
  String (Maybe Text -> Maybe OriginShield -> Text -> Text -> Origin)
-> Either String (Maybe Text)
-> Either String (Maybe OriginShield -> Text -> Text -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OriginPath")
      Either String (Maybe OriginShield -> Text -> Text -> Origin)
-> Either String (Maybe OriginShield)
-> Either String (Text -> Text -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe OriginShield)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OriginShield")
      Either String (Text -> Text -> Origin)
-> Either String Text -> Either String (Text -> Origin)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either String (Text -> Origin)
-> Either String Text -> Either String Origin
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DomainName")

instance Prelude.Hashable Origin

instance Prelude.NFData Origin

instance Core.ToXML Origin where
  toXML :: Origin -> XML
toXML Origin' {Maybe Int
Maybe Text
Maybe CustomHeaders
Maybe OriginShield
Maybe S3OriginConfig
Maybe CustomOriginConfig
Text
domainName :: Text
id :: Text
originShield :: Maybe OriginShield
originPath :: Maybe Text
s3OriginConfig :: Maybe S3OriginConfig
connectionAttempts :: Maybe Int
connectionTimeout :: Maybe Int
customOriginConfig :: Maybe CustomOriginConfig
customHeaders :: Maybe CustomHeaders
$sel:domainName:Origin' :: Origin -> Text
$sel:id:Origin' :: Origin -> Text
$sel:originShield:Origin' :: Origin -> Maybe OriginShield
$sel:originPath:Origin' :: Origin -> Maybe Text
$sel:s3OriginConfig:Origin' :: Origin -> Maybe S3OriginConfig
$sel:connectionAttempts:Origin' :: Origin -> Maybe Int
$sel:connectionTimeout:Origin' :: Origin -> Maybe Int
$sel:customOriginConfig:Origin' :: Origin -> Maybe CustomOriginConfig
$sel:customHeaders:Origin' :: Origin -> Maybe CustomHeaders
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"CustomHeaders" Name -> Maybe CustomHeaders -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe CustomHeaders
customHeaders,
        Name
"CustomOriginConfig" Name -> Maybe CustomOriginConfig -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe CustomOriginConfig
customOriginConfig,
        Name
"ConnectionTimeout" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
connectionTimeout,
        Name
"ConnectionAttempts" Name -> Maybe Int -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Int
connectionAttempts,
        Name
"S3OriginConfig" Name -> Maybe S3OriginConfig -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe S3OriginConfig
s3OriginConfig,
        Name
"OriginPath" Name -> Maybe Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe Text
originPath,
        Name
"OriginShield" Name -> Maybe OriginShield -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe OriginShield
originShield,
        Name
"Id" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
id,
        Name
"DomainName" Name -> Text -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Text
domainName
      ]