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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LabelsS3InputConfiguration -> LabelsS3InputConfiguration -> Bool)
-> (LabelsS3InputConfiguration
    -> LabelsS3InputConfiguration -> Bool)
-> Eq LabelsS3InputConfiguration
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]
(Int -> ReadS LabelsS3InputConfiguration)
-> ReadS [LabelsS3InputConfiguration]
-> ReadPrec LabelsS3InputConfiguration
-> ReadPrec [LabelsS3InputConfiguration]
-> Read 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
(Int -> LabelsS3InputConfiguration -> ShowS)
-> (LabelsS3InputConfiguration -> String)
-> ([LabelsS3InputConfiguration] -> ShowS)
-> Show LabelsS3InputConfiguration
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.
 LabelsS3InputConfiguration -> Rep LabelsS3InputConfiguration x)
-> (forall x.
    Rep LabelsS3InputConfiguration x -> LabelsS3InputConfiguration)
-> Generic LabelsS3InputConfiguration
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' :: Maybe Text -> Text -> LabelsS3InputConfiguration
LabelsS3InputConfiguration'
    { $sel:prefix:LabelsS3InputConfiguration' :: Maybe Text
prefix =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> LabelsS3InputConfiguration -> f LabelsS3InputConfiguration
labelsS3InputConfiguration_prefix = (LabelsS3InputConfiguration -> Maybe Text)
-> (LabelsS3InputConfiguration
    -> Maybe Text -> LabelsS3InputConfiguration)
-> Lens
     LabelsS3InputConfiguration
     LabelsS3InputConfiguration
     (Maybe Text)
     (Maybe Text)
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 :: (Text -> f Text)
-> LabelsS3InputConfiguration -> f LabelsS3InputConfiguration
labelsS3InputConfiguration_bucket = (LabelsS3InputConfiguration -> Text)
-> (LabelsS3InputConfiguration
    -> Text -> LabelsS3InputConfiguration)
-> Lens
     LabelsS3InputConfiguration LabelsS3InputConfiguration Text Text
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 Core.FromJSON LabelsS3InputConfiguration where
  parseJSON :: Value -> Parser LabelsS3InputConfiguration
parseJSON =
    String
-> (Object -> Parser LabelsS3InputConfiguration)
-> Value
-> Parser LabelsS3InputConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LabelsS3InputConfiguration"
      ( \Object
x ->
          Maybe Text -> Text -> LabelsS3InputConfiguration
LabelsS3InputConfiguration'
            (Maybe Text -> Text -> LabelsS3InputConfiguration)
-> Parser (Maybe Text)
-> Parser (Text -> LabelsS3InputConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Prefix")
            Parser (Text -> LabelsS3InputConfiguration)
-> Parser Text -> Parser LabelsS3InputConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Bucket")
      )

instance Prelude.Hashable LabelsS3InputConfiguration

instance Prelude.NFData LabelsS3InputConfiguration

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Prefix" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
prefix,
            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)
          ]
      )