{-# 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.S3.Types.CORSConfiguration
-- 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.S3.Types.CORSConfiguration where

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
import Amazonka.S3.Internal
import Amazonka.S3.Types.CORSRule

-- | Describes the cross-origin access configuration for objects in an Amazon
-- S3 bucket. For more information, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html Enabling Cross-Origin Resource Sharing>
-- in the /Amazon S3 User Guide/.
--
-- /See:/ 'newCORSConfiguration' smart constructor.
data CORSConfiguration = CORSConfiguration'
  { -- | A set of origins and methods (cross-origin access that you want to
    -- allow). You can add up to 100 rules to the configuration.
    CORSConfiguration -> [CORSRule]
cORSRules :: [CORSRule]
  }
  deriving (CORSConfiguration -> CORSConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CORSConfiguration -> CORSConfiguration -> Bool
$c/= :: CORSConfiguration -> CORSConfiguration -> Bool
== :: CORSConfiguration -> CORSConfiguration -> Bool
$c== :: CORSConfiguration -> CORSConfiguration -> Bool
Prelude.Eq, ReadPrec [CORSConfiguration]
ReadPrec CORSConfiguration
Int -> ReadS CORSConfiguration
ReadS [CORSConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CORSConfiguration]
$creadListPrec :: ReadPrec [CORSConfiguration]
readPrec :: ReadPrec CORSConfiguration
$creadPrec :: ReadPrec CORSConfiguration
readList :: ReadS [CORSConfiguration]
$creadList :: ReadS [CORSConfiguration]
readsPrec :: Int -> ReadS CORSConfiguration
$creadsPrec :: Int -> ReadS CORSConfiguration
Prelude.Read, Int -> CORSConfiguration -> ShowS
[CORSConfiguration] -> ShowS
CORSConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CORSConfiguration] -> ShowS
$cshowList :: [CORSConfiguration] -> ShowS
show :: CORSConfiguration -> String
$cshow :: CORSConfiguration -> String
showsPrec :: Int -> CORSConfiguration -> ShowS
$cshowsPrec :: Int -> CORSConfiguration -> ShowS
Prelude.Show, forall x. Rep CORSConfiguration x -> CORSConfiguration
forall x. CORSConfiguration -> Rep CORSConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CORSConfiguration x -> CORSConfiguration
$cfrom :: forall x. CORSConfiguration -> Rep CORSConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'CORSConfiguration' 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:
--
-- 'cORSRules', 'cORSConfiguration_cORSRules' - A set of origins and methods (cross-origin access that you want to
-- allow). You can add up to 100 rules to the configuration.
newCORSConfiguration ::
  CORSConfiguration
newCORSConfiguration :: CORSConfiguration
newCORSConfiguration =
  CORSConfiguration' {$sel:cORSRules:CORSConfiguration' :: [CORSRule]
cORSRules = forall a. Monoid a => a
Prelude.mempty}

-- | A set of origins and methods (cross-origin access that you want to
-- allow). You can add up to 100 rules to the configuration.
cORSConfiguration_cORSRules :: Lens.Lens' CORSConfiguration [CORSRule]
cORSConfiguration_cORSRules :: Lens' CORSConfiguration [CORSRule]
cORSConfiguration_cORSRules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CORSConfiguration' {[CORSRule]
cORSRules :: [CORSRule]
$sel:cORSRules:CORSConfiguration' :: CORSConfiguration -> [CORSRule]
cORSRules} -> [CORSRule]
cORSRules) (\s :: CORSConfiguration
s@CORSConfiguration' {} [CORSRule]
a -> CORSConfiguration
s {$sel:cORSRules:CORSConfiguration' :: [CORSRule]
cORSRules = [CORSRule]
a} :: CORSConfiguration) 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 Prelude.Hashable CORSConfiguration where
  hashWithSalt :: Int -> CORSConfiguration -> Int
hashWithSalt Int
_salt CORSConfiguration' {[CORSRule]
cORSRules :: [CORSRule]
$sel:cORSRules:CORSConfiguration' :: CORSConfiguration -> [CORSRule]
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [CORSRule]
cORSRules

instance Prelude.NFData CORSConfiguration where
  rnf :: CORSConfiguration -> ()
rnf CORSConfiguration' {[CORSRule]
cORSRules :: [CORSRule]
$sel:cORSRules:CORSConfiguration' :: CORSConfiguration -> [CORSRule]
..} = forall a. NFData a => a -> ()
Prelude.rnf [CORSRule]
cORSRules

instance Data.ToXML CORSConfiguration where
  toXML :: CORSConfiguration -> XML
toXML CORSConfiguration' {[CORSRule]
cORSRules :: [CORSRule]
$sel:cORSRules:CORSConfiguration' :: CORSConfiguration -> [CORSRule]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Data.toXMLList Name
"CORSRule" [CORSRule]
cORSRules]