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

import qualified Amazonka.Core as Core
import Amazonka.Inspector.Types.ScopeType
import qualified Amazonka.Lens as Lens
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 resource identifier for the specified scope type.
    Scope -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The type of the scope.
    Scope -> Maybe ScopeType
key :: Prelude.Maybe ScopeType
  }
  deriving (Scope -> Scope -> Bool
(Scope -> Scope -> Bool) -> (Scope -> Scope -> Bool) -> Eq Scope
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]
(Int -> ReadS Scope)
-> ReadS [Scope]
-> ReadPrec Scope
-> ReadPrec [Scope]
-> Read 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
(Int -> Scope -> ShowS)
-> (Scope -> String) -> ([Scope] -> ShowS) -> Show Scope
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. Scope -> Rep Scope x)
-> (forall x. Rep Scope x -> Scope) -> Generic Scope
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:
--
-- 'value', 'scope_value' - The resource identifier for the specified scope type.
--
-- 'key', 'scope_key' - The type of the scope.
newScope ::
  Scope
newScope :: Scope
newScope =
  Scope' :: Maybe Text -> Maybe ScopeType -> Scope
Scope'
    { $sel:value:Scope' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:Scope' :: Maybe ScopeType
key = Maybe ScopeType
forall a. Maybe a
Prelude.Nothing
    }

-- | The resource identifier for the specified scope type.
scope_value :: Lens.Lens' Scope (Prelude.Maybe Prelude.Text)
scope_value :: (Maybe Text -> f (Maybe Text)) -> Scope -> f Scope
scope_value = (Scope -> Maybe Text)
-> (Scope -> Maybe Text -> Scope)
-> Lens Scope Scope (Maybe Text) (Maybe Text)
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)

-- | The type of the scope.
scope_key :: Lens.Lens' Scope (Prelude.Maybe ScopeType)
scope_key :: (Maybe ScopeType -> f (Maybe ScopeType)) -> Scope -> f Scope
scope_key = (Scope -> Maybe ScopeType)
-> (Scope -> Maybe ScopeType -> Scope)
-> Lens Scope Scope (Maybe ScopeType) (Maybe ScopeType)
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)

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

instance Prelude.Hashable Scope

instance Prelude.NFData Scope