{-# 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.AppStream.Types.StorageConnector
-- 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.AppStream.Types.StorageConnector where

import Amazonka.AppStream.Types.StorageConnectorType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a connector that enables persistent storage for users.
--
-- /See:/ 'newStorageConnector' smart constructor.
data StorageConnector = StorageConnector'
  { -- | The names of the domains for the account.
    StorageConnector -> Maybe [Text]
domains :: Prelude.Maybe [Prelude.Text],
    -- | The ARN of the storage connector.
    StorageConnector -> Maybe Text
resourceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | The type of storage connector.
    StorageConnector -> StorageConnectorType
connectorType :: StorageConnectorType
  }
  deriving (StorageConnector -> StorageConnector -> Bool
(StorageConnector -> StorageConnector -> Bool)
-> (StorageConnector -> StorageConnector -> Bool)
-> Eq StorageConnector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StorageConnector -> StorageConnector -> Bool
$c/= :: StorageConnector -> StorageConnector -> Bool
== :: StorageConnector -> StorageConnector -> Bool
$c== :: StorageConnector -> StorageConnector -> Bool
Prelude.Eq, ReadPrec [StorageConnector]
ReadPrec StorageConnector
Int -> ReadS StorageConnector
ReadS [StorageConnector]
(Int -> ReadS StorageConnector)
-> ReadS [StorageConnector]
-> ReadPrec StorageConnector
-> ReadPrec [StorageConnector]
-> Read StorageConnector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StorageConnector]
$creadListPrec :: ReadPrec [StorageConnector]
readPrec :: ReadPrec StorageConnector
$creadPrec :: ReadPrec StorageConnector
readList :: ReadS [StorageConnector]
$creadList :: ReadS [StorageConnector]
readsPrec :: Int -> ReadS StorageConnector
$creadsPrec :: Int -> ReadS StorageConnector
Prelude.Read, Int -> StorageConnector -> ShowS
[StorageConnector] -> ShowS
StorageConnector -> String
(Int -> StorageConnector -> ShowS)
-> (StorageConnector -> String)
-> ([StorageConnector] -> ShowS)
-> Show StorageConnector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StorageConnector] -> ShowS
$cshowList :: [StorageConnector] -> ShowS
show :: StorageConnector -> String
$cshow :: StorageConnector -> String
showsPrec :: Int -> StorageConnector -> ShowS
$cshowsPrec :: Int -> StorageConnector -> ShowS
Prelude.Show, (forall x. StorageConnector -> Rep StorageConnector x)
-> (forall x. Rep StorageConnector x -> StorageConnector)
-> Generic StorageConnector
forall x. Rep StorageConnector x -> StorageConnector
forall x. StorageConnector -> Rep StorageConnector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StorageConnector x -> StorageConnector
$cfrom :: forall x. StorageConnector -> Rep StorageConnector x
Prelude.Generic)

-- |
-- Create a value of 'StorageConnector' 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:
--
-- 'domains', 'storageConnector_domains' - The names of the domains for the account.
--
-- 'resourceIdentifier', 'storageConnector_resourceIdentifier' - The ARN of the storage connector.
--
-- 'connectorType', 'storageConnector_connectorType' - The type of storage connector.
newStorageConnector ::
  -- | 'connectorType'
  StorageConnectorType ->
  StorageConnector
newStorageConnector :: StorageConnectorType -> StorageConnector
newStorageConnector StorageConnectorType
pConnectorType_ =
  StorageConnector' :: Maybe [Text]
-> Maybe Text -> StorageConnectorType -> StorageConnector
StorageConnector'
    { $sel:domains:StorageConnector' :: Maybe [Text]
domains = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifier:StorageConnector' :: Maybe Text
resourceIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:connectorType:StorageConnector' :: StorageConnectorType
connectorType = StorageConnectorType
pConnectorType_
    }

-- | The names of the domains for the account.
storageConnector_domains :: Lens.Lens' StorageConnector (Prelude.Maybe [Prelude.Text])
storageConnector_domains :: (Maybe [Text] -> f (Maybe [Text]))
-> StorageConnector -> f StorageConnector
storageConnector_domains = (StorageConnector -> Maybe [Text])
-> (StorageConnector -> Maybe [Text] -> StorageConnector)
-> Lens
     StorageConnector StorageConnector (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageConnector' {Maybe [Text]
domains :: Maybe [Text]
$sel:domains:StorageConnector' :: StorageConnector -> Maybe [Text]
domains} -> Maybe [Text]
domains) (\s :: StorageConnector
s@StorageConnector' {} Maybe [Text]
a -> StorageConnector
s {$sel:domains:StorageConnector' :: Maybe [Text]
domains = Maybe [Text]
a} :: StorageConnector) ((Maybe [Text] -> f (Maybe [Text]))
 -> StorageConnector -> f StorageConnector)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> StorageConnector
-> f StorageConnector
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the storage connector.
storageConnector_resourceIdentifier :: Lens.Lens' StorageConnector (Prelude.Maybe Prelude.Text)
storageConnector_resourceIdentifier :: (Maybe Text -> f (Maybe Text))
-> StorageConnector -> f StorageConnector
storageConnector_resourceIdentifier = (StorageConnector -> Maybe Text)
-> (StorageConnector -> Maybe Text -> StorageConnector)
-> Lens StorageConnector StorageConnector (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageConnector' {Maybe Text
resourceIdentifier :: Maybe Text
$sel:resourceIdentifier:StorageConnector' :: StorageConnector -> Maybe Text
resourceIdentifier} -> Maybe Text
resourceIdentifier) (\s :: StorageConnector
s@StorageConnector' {} Maybe Text
a -> StorageConnector
s {$sel:resourceIdentifier:StorageConnector' :: Maybe Text
resourceIdentifier = Maybe Text
a} :: StorageConnector)

-- | The type of storage connector.
storageConnector_connectorType :: Lens.Lens' StorageConnector StorageConnectorType
storageConnector_connectorType :: (StorageConnectorType -> f StorageConnectorType)
-> StorageConnector -> f StorageConnector
storageConnector_connectorType = (StorageConnector -> StorageConnectorType)
-> (StorageConnector -> StorageConnectorType -> StorageConnector)
-> Lens
     StorageConnector
     StorageConnector
     StorageConnectorType
     StorageConnectorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageConnector' {StorageConnectorType
connectorType :: StorageConnectorType
$sel:connectorType:StorageConnector' :: StorageConnector -> StorageConnectorType
connectorType} -> StorageConnectorType
connectorType) (\s :: StorageConnector
s@StorageConnector' {} StorageConnectorType
a -> StorageConnector
s {$sel:connectorType:StorageConnector' :: StorageConnectorType
connectorType = StorageConnectorType
a} :: StorageConnector)

instance Core.FromJSON StorageConnector where
  parseJSON :: Value -> Parser StorageConnector
parseJSON =
    String
-> (Object -> Parser StorageConnector)
-> Value
-> Parser StorageConnector
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StorageConnector"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text -> StorageConnectorType -> StorageConnector
StorageConnector'
            (Maybe [Text]
 -> Maybe Text -> StorageConnectorType -> StorageConnector)
-> Parser (Maybe [Text])
-> Parser (Maybe Text -> StorageConnectorType -> StorageConnector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Domains" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> StorageConnectorType -> StorageConnector)
-> Parser (Maybe Text)
-> Parser (StorageConnectorType -> StorageConnector)
forall (f :: * -> *) a b. Applicative f => 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
"ResourceIdentifier")
            Parser (StorageConnectorType -> StorageConnector)
-> Parser StorageConnectorType -> Parser StorageConnector
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser StorageConnectorType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ConnectorType")
      )

instance Prelude.Hashable StorageConnector

instance Prelude.NFData StorageConnector

instance Core.ToJSON StorageConnector where
  toJSON :: StorageConnector -> Value
toJSON StorageConnector' {Maybe [Text]
Maybe Text
StorageConnectorType
connectorType :: StorageConnectorType
resourceIdentifier :: Maybe Text
domains :: Maybe [Text]
$sel:connectorType:StorageConnector' :: StorageConnector -> StorageConnectorType
$sel:resourceIdentifier:StorageConnector' :: StorageConnector -> Maybe Text
$sel:domains:StorageConnector' :: StorageConnector -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Domains" 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]
domains,
            (Text
"ResourceIdentifier" 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
resourceIdentifier,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ConnectorType" Text -> StorageConnectorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StorageConnectorType
connectorType)
          ]
      )