{-# 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.Inspector.Types.Scope
-- 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.Inspector.Types.Scope where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types.ScopeType
import qualified Amazonka.Prelude as Prelude

-- | This data type contains key-value pairs that identify various Amazon
-- resources.
--
-- /See:/ 'newScope' smart constructor.
data Scope = Scope'
  { -- | The type of the scope.
    Scope -> Maybe ScopeType
key :: Prelude.Maybe ScopeType,
    -- | The resource identifier for the specified scope type.
    Scope -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (Scope -> Scope -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Scope -> Scope -> Bool
$c/= :: Scope -> Scope -> Bool
== :: Scope -> Scope -> Bool
$c== :: Scope -> Scope -> Bool
Prelude.Eq, ReadPrec [Scope]
ReadPrec Scope
Int -> ReadS Scope
ReadS [Scope]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Scope]
$creadListPrec :: ReadPrec [Scope]
readPrec :: ReadPrec Scope
$creadPrec :: ReadPrec Scope
readList :: ReadS [Scope]
$creadList :: ReadS [Scope]
readsPrec :: Int -> ReadS Scope
$creadsPrec :: Int -> ReadS Scope
Prelude.Read, Int -> Scope -> ShowS
[Scope] -> ShowS
Scope -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Scope] -> ShowS
$cshowList :: [Scope] -> ShowS
show :: Scope -> String
$cshow :: Scope -> String
showsPrec :: Int -> Scope -> ShowS
$cshowsPrec :: Int -> Scope -> ShowS
Prelude.Show, forall x. Rep Scope x -> Scope
forall x. Scope -> Rep Scope x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Scope x -> Scope
$cfrom :: forall x. Scope -> Rep Scope x
Prelude.Generic)

-- |
-- Create a value of 'Scope' 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:
--
-- 'key', 'scope_key' - The type of the scope.
--
-- 'value', 'scope_value' - The resource identifier for the specified scope type.
newScope ::
  Scope
newScope :: Scope
newScope =
  Scope'
    { $sel:key:Scope' :: Maybe ScopeType
key = forall a. Maybe a
Prelude.Nothing,
      $sel:value:Scope' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the scope.
scope_key :: Lens.Lens' Scope (Prelude.Maybe ScopeType)
scope_key :: Lens' Scope (Maybe ScopeType)
scope_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scope' {Maybe ScopeType
key :: Maybe ScopeType
$sel:key:Scope' :: Scope -> Maybe ScopeType
key} -> Maybe ScopeType
key) (\s :: Scope
s@Scope' {} Maybe ScopeType
a -> Scope
s {$sel:key:Scope' :: Maybe ScopeType
key = Maybe ScopeType
a} :: Scope)

-- | The resource identifier for the specified scope type.
scope_value :: Lens.Lens' Scope (Prelude.Maybe Prelude.Text)
scope_value :: Lens' Scope (Maybe Text)
scope_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scope' {Maybe Text
value :: Maybe Text
$sel:value:Scope' :: Scope -> Maybe Text
value} -> Maybe Text
value) (\s :: Scope
s@Scope' {} Maybe Text
a -> Scope
s {$sel:value:Scope' :: Maybe Text
value = Maybe Text
a} :: Scope)

instance Data.FromJSON Scope where
  parseJSON :: Value -> Parser Scope
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Scope"
      ( \Object
x ->
          Maybe ScopeType -> Maybe Text -> Scope
Scope'
            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
"key")
            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
"value")
      )

instance Prelude.Hashable Scope where
  hashWithSalt :: Int -> Scope -> Int
hashWithSalt Int
_salt Scope' {Maybe Text
Maybe ScopeType
value :: Maybe Text
key :: Maybe ScopeType
$sel:value:Scope' :: Scope -> Maybe Text
$sel:key:Scope' :: Scope -> Maybe ScopeType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ScopeType
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData Scope where
  rnf :: Scope -> ()
rnf Scope' {Maybe Text
Maybe ScopeType
value :: Maybe Text
key :: Maybe ScopeType
$sel:value:Scope' :: Scope -> Maybe Text
$sel:key:Scope' :: Scope -> Maybe ScopeType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ScopeType
key seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value