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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECR.Types.ResourceDetails
import qualified Amazonka.Prelude as Prelude

-- | Details about the resource involved in a finding.
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | An object that contains details about the resource involved in a
    -- finding.
    Resource -> Maybe ResourceDetails
details :: Prelude.Maybe ResourceDetails,
    -- | The ID of the resource.
    Resource -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The tags attached to the resource.
    Resource -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The type of resource.
    Resource -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Resource -> Resource -> Bool
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]
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
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. 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:
--
-- 'details', 'resource_details' - An object that contains details about the resource involved in a
-- finding.
--
-- 'id', 'resource_id' - The ID of the resource.
--
-- 'tags', 'resource_tags' - The tags attached to the resource.
--
-- 'type'', 'resource_type' - The type of resource.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource'
    { $sel:details:Resource' :: Maybe ResourceDetails
details = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Resource' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:Resource' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Resource' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | An object that contains details about the resource involved in a
-- finding.
resource_details :: Lens.Lens' Resource (Prelude.Maybe ResourceDetails)
resource_details :: Lens' Resource (Maybe ResourceDetails)
resource_details = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe ResourceDetails
details :: Maybe ResourceDetails
$sel:details:Resource' :: Resource -> Maybe ResourceDetails
details} -> Maybe ResourceDetails
details) (\s :: Resource
s@Resource' {} Maybe ResourceDetails
a -> Resource
s {$sel:details:Resource' :: Maybe ResourceDetails
details = Maybe ResourceDetails
a} :: Resource)

-- | The ID of the resource.
resource_id :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_id :: Lens' Resource (Maybe Text)
resource_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
id :: Maybe Text
$sel:id:Resource' :: Resource -> Maybe Text
id} -> Maybe Text
id) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:id:Resource' :: Maybe Text
id = Maybe Text
a} :: Resource)

-- | The tags attached to the resource.
resource_tags :: Lens.Lens' Resource (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
resource_tags :: Lens' Resource (Maybe (HashMap Text Text))
resource_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:Resource' :: Resource -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: Resource
s@Resource' {} Maybe (HashMap Text Text)
a -> Resource
s {$sel:tags:Resource' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: Resource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of resource.
resource_type :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_type :: Lens' Resource (Maybe Text)
resource_type = 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 Data.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe ResourceDetails
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe Text
-> Resource
Resource'
            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
"details")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"id")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"tags" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"type")
      )

instance Prelude.Hashable Resource where
  hashWithSalt :: Int -> Resource -> Int
hashWithSalt Int
_salt Resource' {Maybe Text
Maybe (HashMap Text Text)
Maybe ResourceDetails
type' :: Maybe Text
tags :: Maybe (HashMap Text Text)
id :: Maybe Text
details :: Maybe ResourceDetails
$sel:type':Resource' :: Resource -> Maybe Text
$sel:tags:Resource' :: Resource -> Maybe (HashMap Text Text)
$sel:id:Resource' :: Resource -> Maybe Text
$sel:details:Resource' :: Resource -> Maybe ResourceDetails
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceDetails
details
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Resource where
  rnf :: Resource -> ()
rnf Resource' {Maybe Text
Maybe (HashMap Text Text)
Maybe ResourceDetails
type' :: Maybe Text
tags :: Maybe (HashMap Text Text)
id :: Maybe Text
details :: Maybe ResourceDetails
$sel:type':Resource' :: Resource -> Maybe Text
$sel:tags:Resource' :: Resource -> Maybe (HashMap Text Text)
$sel:id:Resource' :: Resource -> Maybe Text
$sel:details:Resource' :: Resource -> Maybe ResourceDetails
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceDetails
details
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'