{-# 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.LookoutEquipment.Types.LabelsS3InputConfiguration
-- 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.LookoutEquipment.Types.LabelsS3InputConfiguration 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

-- | The location information (prefix and bucket name) for the s3 location
-- being used for label data.
--
-- /See:/ 'newLabelsS3InputConfiguration' smart constructor.
data LabelsS3InputConfiguration = LabelsS3InputConfiguration'
  { -- | The prefix for the S3 bucket used for the label data.
    LabelsS3InputConfiguration -> Maybe Text
prefix :: Prelude.Maybe Prelude.Text,
    -- | The name of the S3 bucket holding the label data.
    LabelsS3InputConfiguration -> Text
bucket :: Prelude.Text
  }
  deriving (LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool
$c/= :: LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool
== :: LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool
$c== :: LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool
Prelude.Eq, ReadPrec [LabelsS3InputConfiguration]
ReadPrec LabelsS3InputConfiguration
Int -> ReadS LabelsS3InputConfiguration
ReadS [LabelsS3InputConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LabelsS3InputConfiguration]
$creadListPrec :: ReadPrec [LabelsS3InputConfiguration]
readPrec :: ReadPrec LabelsS3InputConfiguration
$creadPrec :: ReadPrec LabelsS3InputConfiguration
readList :: ReadS [LabelsS3InputConfiguration]
$creadList :: ReadS [LabelsS3InputConfiguration]
readsPrec :: Int -> ReadS LabelsS3InputConfiguration
$creadsPrec :: Int -> ReadS LabelsS3InputConfiguration
Prelude.Read, Int -> LabelsS3InputConfiguration -> ShowS
[LabelsS3InputConfiguration] -> ShowS
LabelsS3InputConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LabelsS3InputConfiguration] -> ShowS
$cshowList :: [LabelsS3InputConfiguration] -> ShowS
show :: LabelsS3InputConfiguration -> String
$cshow :: LabelsS3InputConfiguration -> String
showsPrec :: Int -> LabelsS3InputConfiguration -> ShowS
$cshowsPrec :: Int -> LabelsS3InputConfiguration -> ShowS
Prelude.Show, forall x.
Rep LabelsS3InputConfiguration x -> LabelsS3InputConfiguration
forall x.
LabelsS3InputConfiguration -> Rep LabelsS3InputConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep LabelsS3InputConfiguration x -> LabelsS3InputConfiguration
$cfrom :: forall x.
LabelsS3InputConfiguration -> Rep LabelsS3InputConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'LabelsS3InputConfiguration' 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:
--
-- 'prefix', 'labelsS3InputConfiguration_prefix' - The prefix for the S3 bucket used for the label data.
--
-- 'bucket', 'labelsS3InputConfiguration_bucket' - The name of the S3 bucket holding the label data.
newLabelsS3InputConfiguration ::
  -- | 'bucket'
  Prelude.Text ->
  LabelsS3InputConfiguration
newLabelsS3InputConfiguration :: Text -> LabelsS3InputConfiguration
newLabelsS3InputConfiguration Text
pBucket_ =
  LabelsS3InputConfiguration'
    { $sel:prefix:LabelsS3InputConfiguration' :: Maybe Text
prefix =
        forall a. Maybe a
Prelude.Nothing,
      $sel:bucket:LabelsS3InputConfiguration' :: Text
bucket = Text
pBucket_
    }

-- | The prefix for the S3 bucket used for the label data.
labelsS3InputConfiguration_prefix :: Lens.Lens' LabelsS3InputConfiguration (Prelude.Maybe Prelude.Text)
labelsS3InputConfiguration_prefix :: Lens' LabelsS3InputConfiguration (Maybe Text)
labelsS3InputConfiguration_prefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelsS3InputConfiguration' {Maybe Text
prefix :: Maybe Text
$sel:prefix:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Maybe Text
prefix} -> Maybe Text
prefix) (\s :: LabelsS3InputConfiguration
s@LabelsS3InputConfiguration' {} Maybe Text
a -> LabelsS3InputConfiguration
s {$sel:prefix:LabelsS3InputConfiguration' :: Maybe Text
prefix = Maybe Text
a} :: LabelsS3InputConfiguration)

-- | The name of the S3 bucket holding the label data.
labelsS3InputConfiguration_bucket :: Lens.Lens' LabelsS3InputConfiguration Prelude.Text
labelsS3InputConfiguration_bucket :: Lens' LabelsS3InputConfiguration Text
labelsS3InputConfiguration_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LabelsS3InputConfiguration' {Text
bucket :: Text
$sel:bucket:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Text
bucket} -> Text
bucket) (\s :: LabelsS3InputConfiguration
s@LabelsS3InputConfiguration' {} Text
a -> LabelsS3InputConfiguration
s {$sel:bucket:LabelsS3InputConfiguration' :: Text
bucket = Text
a} :: LabelsS3InputConfiguration)

instance Data.FromJSON LabelsS3InputConfiguration where
  parseJSON :: Value -> Parser LabelsS3InputConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LabelsS3InputConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> LabelsS3InputConfiguration
LabelsS3InputConfiguration'
            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
"Prefix")
            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
"Bucket")
      )

instance Prelude.Hashable LabelsS3InputConfiguration where
  hashWithSalt :: Int -> LabelsS3InputConfiguration -> Int
hashWithSalt Int
_salt LabelsS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
$sel:bucket:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Text
$sel:prefix:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
prefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
bucket

instance Prelude.NFData LabelsS3InputConfiguration where
  rnf :: LabelsS3InputConfiguration -> ()
rnf LabelsS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
$sel:bucket:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Text
$sel:prefix:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
prefix seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
bucket

instance Data.ToJSON LabelsS3InputConfiguration where
  toJSON :: LabelsS3InputConfiguration -> Value
toJSON LabelsS3InputConfiguration' {Maybe Text
Text
bucket :: Text
prefix :: Maybe Text
$sel:bucket:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Text
$sel:prefix:LabelsS3InputConfiguration' :: LabelsS3InputConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Prefix" 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
prefix,
            forall a. a -> Maybe a
Prelude.Just (Key
"Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
bucket)
          ]
      )