{-# 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.Mobile.Types.Resource
-- 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.Mobile.Types.Resource where

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

-- | Information about an instance of an AWS resource associated with a
-- project.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { Resource -> Maybe Text
feature :: Prelude.Maybe Prelude.Text,
    Resource -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    Resource -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    Resource -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    Resource -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Resource -> Resource -> Bool
(Resource -> Resource -> Bool)
-> (Resource -> Resource -> Bool) -> Eq Resource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resource -> Resource -> Bool
$c/= :: Resource -> Resource -> Bool
== :: Resource -> Resource -> Bool
$c== :: Resource -> Resource -> Bool
Prelude.Eq, ReadPrec [Resource]
ReadPrec Resource
Int -> ReadS Resource
ReadS [Resource]
(Int -> ReadS Resource)
-> ReadS [Resource]
-> ReadPrec Resource
-> ReadPrec [Resource]
-> Read Resource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resource]
$creadListPrec :: ReadPrec [Resource]
readPrec :: ReadPrec Resource
$creadPrec :: ReadPrec Resource
readList :: ReadS [Resource]
$creadList :: ReadS [Resource]
readsPrec :: Int -> ReadS Resource
$creadsPrec :: Int -> ReadS Resource
Prelude.Read, Int -> Resource -> ShowS
[Resource] -> ShowS
Resource -> String
(Int -> Resource -> ShowS)
-> (Resource -> String) -> ([Resource] -> ShowS) -> Show Resource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resource] -> ShowS
$cshowList :: [Resource] -> ShowS
show :: Resource -> String
$cshow :: Resource -> String
showsPrec :: Int -> Resource -> ShowS
$cshowsPrec :: Int -> Resource -> ShowS
Prelude.Show, (forall x. Resource -> Rep Resource x)
-> (forall x. Rep Resource x -> Resource) -> Generic Resource
forall x. Rep Resource x -> Resource
forall x. Resource -> Rep Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resource x -> Resource
$cfrom :: forall x. Resource -> Rep Resource x
Prelude.Generic)

-- |
-- Create a value of 'Resource' 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:
--
-- 'feature', 'resource_feature' - Undocumented member.
--
-- 'arn', 'resource_arn' - Undocumented member.
--
-- 'name', 'resource_name' - Undocumented member.
--
-- 'attributes', 'resource_attributes' - Undocumented member.
--
-- 'type'', 'resource_type' - Undocumented member.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Resource
Resource'
    { $sel:feature:Resource' :: Maybe Text
feature = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:Resource' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Resource' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:Resource' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:type':Resource' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
resource_feature :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_feature :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_feature = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
feature :: Maybe Text
$sel:feature:Resource' :: Resource -> Maybe Text
feature} -> Maybe Text
feature) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:feature:Resource' :: Maybe Text
feature = Maybe Text
a} :: Resource)

-- | Undocumented member.
resource_arn :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_arn :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_arn = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
arn :: Maybe Text
$sel:arn:Resource' :: Resource -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:arn:Resource' :: Maybe Text
arn = Maybe Text
a} :: Resource)

-- | Undocumented member.
resource_name :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_name :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_name = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
name :: Maybe Text
$sel:name:Resource' :: Resource -> Maybe Text
name} -> Maybe Text
name) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:name:Resource' :: Maybe Text
name = Maybe Text
a} :: Resource)

-- | Undocumented member.
resource_attributes :: Lens.Lens' Resource (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
resource_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Resource -> f Resource
resource_attributes = (Resource -> Maybe (HashMap Text Text))
-> (Resource -> Maybe (HashMap Text Text) -> Resource)
-> Lens
     Resource
     Resource
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:Resource' :: Resource -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: Resource
s@Resource' {} Maybe (HashMap Text Text)
a -> Resource
s {$sel:attributes:Resource' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: Resource) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> Resource -> f Resource)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
resource_type :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_type :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_type = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
type' :: Maybe Text
$sel:type':Resource' :: Resource -> Maybe Text
type'} -> Maybe Text
type') (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:type':Resource' :: Maybe Text
type' = Maybe Text
a} :: Resource)

instance Core.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    String -> (Object -> Parser Resource) -> Value -> Parser Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Resource
Resource'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe Text
 -> Resource)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe Text
      -> Resource)
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
"feature")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe Text
   -> Resource)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe (HashMap Text Text) -> Maybe Text -> Resource)
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
"arn")
            Parser
  (Maybe Text -> Maybe (HashMap Text Text) -> Maybe Text -> Resource)
-> Parser (Maybe Text)
-> Parser (Maybe (HashMap Text Text) -> Maybe Text -> Resource)
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
"name")
            Parser (Maybe (HashMap Text Text) -> Maybe Text -> Resource)
-> Parser (Maybe (HashMap Text Text))
-> Parser (Maybe Text -> Resource)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"attributes" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Resource)
-> Parser (Maybe Text) -> Parser Resource
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
"type")
      )

instance Prelude.Hashable Resource

instance Prelude.NFData Resource