{-# 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.ApplicationCostProfiler.Types.SourceS3Location
-- 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.ApplicationCostProfiler.Types.SourceS3Location where

import Amazonka.ApplicationCostProfiler.Types.S3BucketRegion
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Represents the Amazon Simple Storage Service (Amazon S3) location where
-- usage data is read from.
--
-- /See:/ 'newSourceS3Location' smart constructor.
data SourceS3Location = SourceS3Location'
  { -- | Region of the bucket. Only required for Regions that are disabled by
    -- default. For more infomration about Regions that are disabled by
    -- default, see
    -- <https://docs.aws.amazon.com/general/latest/gr/rande-manage.html#rande-manage-enable Enabling a Region>
    -- in the /AWS General Reference guide/.
    SourceS3Location -> Maybe S3BucketRegion
region :: Prelude.Maybe S3BucketRegion,
    -- | Name of the bucket.
    SourceS3Location -> Text
bucket :: Prelude.Text,
    -- | Key of the object.
    SourceS3Location -> Text
key :: Prelude.Text
  }
  deriving (SourceS3Location -> SourceS3Location -> Bool
(SourceS3Location -> SourceS3Location -> Bool)
-> (SourceS3Location -> SourceS3Location -> Bool)
-> Eq SourceS3Location
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceS3Location -> SourceS3Location -> Bool
$c/= :: SourceS3Location -> SourceS3Location -> Bool
== :: SourceS3Location -> SourceS3Location -> Bool
$c== :: SourceS3Location -> SourceS3Location -> Bool
Prelude.Eq, ReadPrec [SourceS3Location]
ReadPrec SourceS3Location
Int -> ReadS SourceS3Location
ReadS [SourceS3Location]
(Int -> ReadS SourceS3Location)
-> ReadS [SourceS3Location]
-> ReadPrec SourceS3Location
-> ReadPrec [SourceS3Location]
-> Read SourceS3Location
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceS3Location]
$creadListPrec :: ReadPrec [SourceS3Location]
readPrec :: ReadPrec SourceS3Location
$creadPrec :: ReadPrec SourceS3Location
readList :: ReadS [SourceS3Location]
$creadList :: ReadS [SourceS3Location]
readsPrec :: Int -> ReadS SourceS3Location
$creadsPrec :: Int -> ReadS SourceS3Location
Prelude.Read, Int -> SourceS3Location -> ShowS
[SourceS3Location] -> ShowS
SourceS3Location -> String
(Int -> SourceS3Location -> ShowS)
-> (SourceS3Location -> String)
-> ([SourceS3Location] -> ShowS)
-> Show SourceS3Location
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceS3Location] -> ShowS
$cshowList :: [SourceS3Location] -> ShowS
show :: SourceS3Location -> String
$cshow :: SourceS3Location -> String
showsPrec :: Int -> SourceS3Location -> ShowS
$cshowsPrec :: Int -> SourceS3Location -> ShowS
Prelude.Show, (forall x. SourceS3Location -> Rep SourceS3Location x)
-> (forall x. Rep SourceS3Location x -> SourceS3Location)
-> Generic SourceS3Location
forall x. Rep SourceS3Location x -> SourceS3Location
forall x. SourceS3Location -> Rep SourceS3Location x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceS3Location x -> SourceS3Location
$cfrom :: forall x. SourceS3Location -> Rep SourceS3Location x
Prelude.Generic)

-- |
-- Create a value of 'SourceS3Location' 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:
--
-- 'region', 'sourceS3Location_region' - Region of the bucket. Only required for Regions that are disabled by
-- default. For more infomration about Regions that are disabled by
-- default, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande-manage.html#rande-manage-enable Enabling a Region>
-- in the /AWS General Reference guide/.
--
-- 'bucket', 'sourceS3Location_bucket' - Name of the bucket.
--
-- 'key', 'sourceS3Location_key' - Key of the object.
newSourceS3Location ::
  -- | 'bucket'
  Prelude.Text ->
  -- | 'key'
  Prelude.Text ->
  SourceS3Location
newSourceS3Location :: Text -> Text -> SourceS3Location
newSourceS3Location Text
pBucket_ Text
pKey_ =
  SourceS3Location' :: Maybe S3BucketRegion -> Text -> Text -> SourceS3Location
SourceS3Location'
    { $sel:region:SourceS3Location' :: Maybe S3BucketRegion
region = Maybe S3BucketRegion
forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:SourceS3Location' :: Text
bucket = Text
pBucket_,
      $sel:key:SourceS3Location' :: Text
key = Text
pKey_
    }

-- | Region of the bucket. Only required for Regions that are disabled by
-- default. For more infomration about Regions that are disabled by
-- default, see
-- <https://docs.aws.amazon.com/general/latest/gr/rande-manage.html#rande-manage-enable Enabling a Region>
-- in the /AWS General Reference guide/.
sourceS3Location_region :: Lens.Lens' SourceS3Location (Prelude.Maybe S3BucketRegion)
sourceS3Location_region :: (Maybe S3BucketRegion -> f (Maybe S3BucketRegion))
-> SourceS3Location -> f SourceS3Location
sourceS3Location_region = (SourceS3Location -> Maybe S3BucketRegion)
-> (SourceS3Location -> Maybe S3BucketRegion -> SourceS3Location)
-> Lens
     SourceS3Location
     SourceS3Location
     (Maybe S3BucketRegion)
     (Maybe S3BucketRegion)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceS3Location' {Maybe S3BucketRegion
region :: Maybe S3BucketRegion
$sel:region:SourceS3Location' :: SourceS3Location -> Maybe S3BucketRegion
region} -> Maybe S3BucketRegion
region) (\s :: SourceS3Location
s@SourceS3Location' {} Maybe S3BucketRegion
a -> SourceS3Location
s {$sel:region:SourceS3Location' :: Maybe S3BucketRegion
region = Maybe S3BucketRegion
a} :: SourceS3Location)

-- | Name of the bucket.
sourceS3Location_bucket :: Lens.Lens' SourceS3Location Prelude.Text
sourceS3Location_bucket :: (Text -> f Text) -> SourceS3Location -> f SourceS3Location
sourceS3Location_bucket = (SourceS3Location -> Text)
-> (SourceS3Location -> Text -> SourceS3Location)
-> Lens SourceS3Location SourceS3Location Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceS3Location' {Text
bucket :: Text
$sel:bucket:SourceS3Location' :: SourceS3Location -> Text
bucket} -> Text
bucket) (\s :: SourceS3Location
s@SourceS3Location' {} Text
a -> SourceS3Location
s {$sel:bucket:SourceS3Location' :: Text
bucket = Text
a} :: SourceS3Location)

-- | Key of the object.
sourceS3Location_key :: Lens.Lens' SourceS3Location Prelude.Text
sourceS3Location_key :: (Text -> f Text) -> SourceS3Location -> f SourceS3Location
sourceS3Location_key = (SourceS3Location -> Text)
-> (SourceS3Location -> Text -> SourceS3Location)
-> Lens SourceS3Location SourceS3Location Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceS3Location' {Text
key :: Text
$sel:key:SourceS3Location' :: SourceS3Location -> Text
key} -> Text
key) (\s :: SourceS3Location
s@SourceS3Location' {} Text
a -> SourceS3Location
s {$sel:key:SourceS3Location' :: Text
key = Text
a} :: SourceS3Location)

instance Prelude.Hashable SourceS3Location

instance Prelude.NFData SourceS3Location

instance Core.ToJSON SourceS3Location where
  toJSON :: SourceS3Location -> Value
toJSON SourceS3Location' {Maybe S3BucketRegion
Text
key :: Text
bucket :: Text
region :: Maybe S3BucketRegion
$sel:key:SourceS3Location' :: SourceS3Location -> Text
$sel:bucket:SourceS3Location' :: SourceS3Location -> Text
$sel:region:SourceS3Location' :: SourceS3Location -> Maybe S3BucketRegion
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"region" Text -> S3BucketRegion -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3BucketRegion -> Pair) -> Maybe S3BucketRegion -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3BucketRegion
region,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"bucket" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
bucket),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"key" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
key)
          ]
      )