{-# 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.Panorama.Types.S3Location
-- 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.Panorama.Types.S3Location 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

-- | A location in Amazon S3.
--
-- /See:/ 'newS3Location' smart constructor.
data S3Location = S3Location'
  { -- | The bucket\'s Region.
    S3Location -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | A bucket name.
    S3Location -> Text
bucketName :: Prelude.Text,
    -- | An object key.
    S3Location -> Text
objectKey :: Prelude.Text
  }
  deriving (S3Location -> S3Location -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Location -> S3Location -> Bool
$c/= :: S3Location -> S3Location -> Bool
== :: S3Location -> S3Location -> Bool
$c== :: S3Location -> S3Location -> Bool
Prelude.Eq, ReadPrec [S3Location]
ReadPrec S3Location
Int -> ReadS S3Location
ReadS [S3Location]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Location]
$creadListPrec :: ReadPrec [S3Location]
readPrec :: ReadPrec S3Location
$creadPrec :: ReadPrec S3Location
readList :: ReadS [S3Location]
$creadList :: ReadS [S3Location]
readsPrec :: Int -> ReadS S3Location
$creadsPrec :: Int -> ReadS S3Location
Prelude.Read, Int -> S3Location -> ShowS
[S3Location] -> ShowS
S3Location -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Location] -> ShowS
$cshowList :: [S3Location] -> ShowS
show :: S3Location -> String
$cshow :: S3Location -> String
showsPrec :: Int -> S3Location -> ShowS
$cshowsPrec :: Int -> S3Location -> ShowS
Prelude.Show, forall x. Rep S3Location x -> S3Location
forall x. S3Location -> Rep S3Location x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Location x -> S3Location
$cfrom :: forall x. S3Location -> Rep S3Location x
Prelude.Generic)

-- |
-- Create a value of 'S3Location' 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', 's3Location_region' - The bucket\'s Region.
--
-- 'bucketName', 's3Location_bucketName' - A bucket name.
--
-- 'objectKey', 's3Location_objectKey' - An object key.
newS3Location ::
  -- | 'bucketName'
  Prelude.Text ->
  -- | 'objectKey'
  Prelude.Text ->
  S3Location
newS3Location :: Text -> Text -> S3Location
newS3Location Text
pBucketName_ Text
pObjectKey_ =
  S3Location'
    { $sel:region:S3Location' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:bucketName:S3Location' :: Text
bucketName = Text
pBucketName_,
      $sel:objectKey:S3Location' :: Text
objectKey = Text
pObjectKey_
    }

-- | The bucket\'s Region.
s3Location_region :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_region :: Lens' S3Location (Maybe Text)
s3Location_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
region :: Maybe Text
$sel:region:S3Location' :: S3Location -> Maybe Text
region} -> Maybe Text
region) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:region:S3Location' :: Maybe Text
region = Maybe Text
a} :: S3Location)

-- | A bucket name.
s3Location_bucketName :: Lens.Lens' S3Location Prelude.Text
s3Location_bucketName :: Lens' S3Location Text
s3Location_bucketName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Text
bucketName :: Text
$sel:bucketName:S3Location' :: S3Location -> Text
bucketName} -> Text
bucketName) (\s :: S3Location
s@S3Location' {} Text
a -> S3Location
s {$sel:bucketName:S3Location' :: Text
bucketName = Text
a} :: S3Location)

-- | An object key.
s3Location_objectKey :: Lens.Lens' S3Location Prelude.Text
s3Location_objectKey :: Lens' S3Location Text
s3Location_objectKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Text
objectKey :: Text
$sel:objectKey:S3Location' :: S3Location -> Text
objectKey} -> Text
objectKey) (\s :: S3Location
s@S3Location' {} Text
a -> S3Location
s {$sel:objectKey:S3Location' :: Text
objectKey = Text
a} :: S3Location)

instance Data.FromJSON S3Location where
  parseJSON :: Value -> Parser S3Location
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Location"
      ( \Object
x ->
          Maybe Text -> Text -> Text -> S3Location
S3Location'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Region")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"BucketName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ObjectKey")
      )

instance Prelude.Hashable S3Location where
  hashWithSalt :: Int -> S3Location -> Int
hashWithSalt Int
_salt S3Location' {Maybe Text
Text
objectKey :: Text
bucketName :: Text
region :: Maybe Text
$sel:objectKey:S3Location' :: S3Location -> Text
$sel:bucketName:S3Location' :: S3Location -> Text
$sel:region:S3Location' :: S3Location -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucketName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
objectKey

instance Prelude.NFData S3Location where
  rnf :: S3Location -> ()
rnf S3Location' {Maybe Text
Text
objectKey :: Text
bucketName :: Text
region :: Maybe Text
$sel:objectKey:S3Location' :: S3Location -> Text
$sel:bucketName:S3Location' :: S3Location -> Text
$sel:region:S3Location' :: S3Location -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucketName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
objectKey

instance Data.ToJSON S3Location where
  toJSON :: S3Location -> Value
toJSON S3Location' {Maybe Text
Text
objectKey :: Text
bucketName :: Text
region :: Maybe Text
$sel:objectKey:S3Location' :: S3Location -> Text
$sel:bucketName:S3Location' :: S3Location -> Text
$sel:region:S3Location' :: S3Location -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
region,
            forall a. a -> Maybe a
Prelude.Just (Key
"BucketName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucketName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ObjectKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
objectKey)
          ]
      )