{-# 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.IoTSiteWise.Types.CustomerManagedS3Storage
-- 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.IoTSiteWise.Types.CustomerManagedS3Storage where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about a customer managed Amazon S3 bucket.
--
-- /See:/ 'newCustomerManagedS3Storage' smart constructor.
data CustomerManagedS3Storage = CustomerManagedS3Storage'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the Amazon S3 object. For more information about how to find the ARN
    -- for an Amazon S3 object, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-arn-format.html Amazon S3 resources>
    -- in the /Amazon Simple Storage Service User Guide/.
    CustomerManagedS3Storage -> Text
s3ResourceArn :: Prelude.Text,
    -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
    -- of the Identity and Access Management role that allows IoT SiteWise to
    -- send data to Amazon S3.
    CustomerManagedS3Storage -> Text
roleArn :: Prelude.Text
  }
  deriving (CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool
(CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool)
-> (CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool)
-> Eq CustomerManagedS3Storage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool
$c/= :: CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool
== :: CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool
$c== :: CustomerManagedS3Storage -> CustomerManagedS3Storage -> Bool
Prelude.Eq, ReadPrec [CustomerManagedS3Storage]
ReadPrec CustomerManagedS3Storage
Int -> ReadS CustomerManagedS3Storage
ReadS [CustomerManagedS3Storage]
(Int -> ReadS CustomerManagedS3Storage)
-> ReadS [CustomerManagedS3Storage]
-> ReadPrec CustomerManagedS3Storage
-> ReadPrec [CustomerManagedS3Storage]
-> Read CustomerManagedS3Storage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomerManagedS3Storage]
$creadListPrec :: ReadPrec [CustomerManagedS3Storage]
readPrec :: ReadPrec CustomerManagedS3Storage
$creadPrec :: ReadPrec CustomerManagedS3Storage
readList :: ReadS [CustomerManagedS3Storage]
$creadList :: ReadS [CustomerManagedS3Storage]
readsPrec :: Int -> ReadS CustomerManagedS3Storage
$creadsPrec :: Int -> ReadS CustomerManagedS3Storage
Prelude.Read, Int -> CustomerManagedS3Storage -> ShowS
[CustomerManagedS3Storage] -> ShowS
CustomerManagedS3Storage -> String
(Int -> CustomerManagedS3Storage -> ShowS)
-> (CustomerManagedS3Storage -> String)
-> ([CustomerManagedS3Storage] -> ShowS)
-> Show CustomerManagedS3Storage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomerManagedS3Storage] -> ShowS
$cshowList :: [CustomerManagedS3Storage] -> ShowS
show :: CustomerManagedS3Storage -> String
$cshow :: CustomerManagedS3Storage -> String
showsPrec :: Int -> CustomerManagedS3Storage -> ShowS
$cshowsPrec :: Int -> CustomerManagedS3Storage -> ShowS
Prelude.Show, (forall x.
 CustomerManagedS3Storage -> Rep CustomerManagedS3Storage x)
-> (forall x.
    Rep CustomerManagedS3Storage x -> CustomerManagedS3Storage)
-> Generic CustomerManagedS3Storage
forall x.
Rep CustomerManagedS3Storage x -> CustomerManagedS3Storage
forall x.
CustomerManagedS3Storage -> Rep CustomerManagedS3Storage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomerManagedS3Storage x -> CustomerManagedS3Storage
$cfrom :: forall x.
CustomerManagedS3Storage -> Rep CustomerManagedS3Storage x
Prelude.Generic)

-- |
-- Create a value of 'CustomerManagedS3Storage' 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:
--
-- 's3ResourceArn', 'customerManagedS3Storage_s3ResourceArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Amazon S3 object. For more information about how to find the ARN
-- for an Amazon S3 object, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-arn-format.html Amazon S3 resources>
-- in the /Amazon Simple Storage Service User Guide/.
--
-- 'roleArn', 'customerManagedS3Storage_roleArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Identity and Access Management role that allows IoT SiteWise to
-- send data to Amazon S3.
newCustomerManagedS3Storage ::
  -- | 's3ResourceArn'
  Prelude.Text ->
  -- | 'roleArn'
  Prelude.Text ->
  CustomerManagedS3Storage
newCustomerManagedS3Storage :: Text -> Text -> CustomerManagedS3Storage
newCustomerManagedS3Storage Text
pS3ResourceArn_ Text
pRoleArn_ =
  CustomerManagedS3Storage' :: Text -> Text -> CustomerManagedS3Storage
CustomerManagedS3Storage'
    { $sel:s3ResourceArn:CustomerManagedS3Storage' :: Text
s3ResourceArn =
        Text
pS3ResourceArn_,
      $sel:roleArn:CustomerManagedS3Storage' :: Text
roleArn = Text
pRoleArn_
    }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Amazon S3 object. For more information about how to find the ARN
-- for an Amazon S3 object, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-arn-format.html Amazon S3 resources>
-- in the /Amazon Simple Storage Service User Guide/.
customerManagedS3Storage_s3ResourceArn :: Lens.Lens' CustomerManagedS3Storage Prelude.Text
customerManagedS3Storage_s3ResourceArn :: (Text -> f Text)
-> CustomerManagedS3Storage -> f CustomerManagedS3Storage
customerManagedS3Storage_s3ResourceArn = (CustomerManagedS3Storage -> Text)
-> (CustomerManagedS3Storage -> Text -> CustomerManagedS3Storage)
-> Lens CustomerManagedS3Storage CustomerManagedS3Storage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedS3Storage' {Text
s3ResourceArn :: Text
$sel:s3ResourceArn:CustomerManagedS3Storage' :: CustomerManagedS3Storage -> Text
s3ResourceArn} -> Text
s3ResourceArn) (\s :: CustomerManagedS3Storage
s@CustomerManagedS3Storage' {} Text
a -> CustomerManagedS3Storage
s {$sel:s3ResourceArn:CustomerManagedS3Storage' :: Text
s3ResourceArn = Text
a} :: CustomerManagedS3Storage)

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html ARN>
-- of the Identity and Access Management role that allows IoT SiteWise to
-- send data to Amazon S3.
customerManagedS3Storage_roleArn :: Lens.Lens' CustomerManagedS3Storage Prelude.Text
customerManagedS3Storage_roleArn :: (Text -> f Text)
-> CustomerManagedS3Storage -> f CustomerManagedS3Storage
customerManagedS3Storage_roleArn = (CustomerManagedS3Storage -> Text)
-> (CustomerManagedS3Storage -> Text -> CustomerManagedS3Storage)
-> Lens CustomerManagedS3Storage CustomerManagedS3Storage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomerManagedS3Storage' {Text
roleArn :: Text
$sel:roleArn:CustomerManagedS3Storage' :: CustomerManagedS3Storage -> Text
roleArn} -> Text
roleArn) (\s :: CustomerManagedS3Storage
s@CustomerManagedS3Storage' {} Text
a -> CustomerManagedS3Storage
s {$sel:roleArn:CustomerManagedS3Storage' :: Text
roleArn = Text
a} :: CustomerManagedS3Storage)

instance Core.FromJSON CustomerManagedS3Storage where
  parseJSON :: Value -> Parser CustomerManagedS3Storage
parseJSON =
    String
-> (Object -> Parser CustomerManagedS3Storage)
-> Value
-> Parser CustomerManagedS3Storage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomerManagedS3Storage"
      ( \Object
x ->
          Text -> Text -> CustomerManagedS3Storage
CustomerManagedS3Storage'
            (Text -> Text -> CustomerManagedS3Storage)
-> Parser Text -> Parser (Text -> CustomerManagedS3Storage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"s3ResourceArn")
            Parser (Text -> CustomerManagedS3Storage)
-> Parser Text -> Parser CustomerManagedS3Storage
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
"roleArn")
      )

instance Prelude.Hashable CustomerManagedS3Storage

instance Prelude.NFData CustomerManagedS3Storage

instance Core.ToJSON CustomerManagedS3Storage where
  toJSON :: CustomerManagedS3Storage -> Value
toJSON CustomerManagedS3Storage' {Text
roleArn :: Text
s3ResourceArn :: Text
$sel:roleArn:CustomerManagedS3Storage' :: CustomerManagedS3Storage -> Text
$sel:s3ResourceArn:CustomerManagedS3Storage' :: CustomerManagedS3Storage -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"s3ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
s3ResourceArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"roleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
roleArn)
          ]
      )