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

import Amazonka.AuditManager.Types.AWSAccount
import Amazonka.AuditManager.Types.AWSService
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The wrapper that contains the Amazon Web Services accounts and services
-- in scope for the assessment.
--
-- /See:/ 'newScope' smart constructor.
data Scope = Scope'
  { -- | The Amazon Web Services accounts included in the scope of the
    -- assessment.
    Scope -> Maybe [AWSAccount]
awsAccounts :: Prelude.Maybe [AWSAccount],
    -- | The Amazon Web Services services included in the scope of the
    -- assessment.
    Scope -> Maybe [AWSService]
awsServices :: Prelude.Maybe [AWSService]
  }
  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:
--
-- 'awsAccounts', 'scope_awsAccounts' - The Amazon Web Services accounts included in the scope of the
-- assessment.
--
-- 'awsServices', 'scope_awsServices' - The Amazon Web Services services included in the scope of the
-- assessment.
newScope ::
  Scope
newScope :: Scope
newScope =
  Scope' :: Maybe [AWSAccount] -> Maybe [AWSService] -> Scope
Scope'
    { $sel:awsAccounts:Scope' :: Maybe [AWSAccount]
awsAccounts = Maybe [AWSAccount]
forall a. Maybe a
Prelude.Nothing,
      $sel:awsServices:Scope' :: Maybe [AWSService]
awsServices = Maybe [AWSService]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Web Services accounts included in the scope of the
-- assessment.
scope_awsAccounts :: Lens.Lens' Scope (Prelude.Maybe [AWSAccount])
scope_awsAccounts :: (Maybe [AWSAccount] -> f (Maybe [AWSAccount])) -> Scope -> f Scope
scope_awsAccounts = (Scope -> Maybe [AWSAccount])
-> (Scope -> Maybe [AWSAccount] -> Scope)
-> Lens Scope Scope (Maybe [AWSAccount]) (Maybe [AWSAccount])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scope' {Maybe [AWSAccount]
awsAccounts :: Maybe [AWSAccount]
$sel:awsAccounts:Scope' :: Scope -> Maybe [AWSAccount]
awsAccounts} -> Maybe [AWSAccount]
awsAccounts) (\s :: Scope
s@Scope' {} Maybe [AWSAccount]
a -> Scope
s {$sel:awsAccounts:Scope' :: Maybe [AWSAccount]
awsAccounts = Maybe [AWSAccount]
a} :: Scope) ((Maybe [AWSAccount] -> f (Maybe [AWSAccount]))
 -> Scope -> f Scope)
-> ((Maybe [AWSAccount] -> f (Maybe [AWSAccount]))
    -> Maybe [AWSAccount] -> f (Maybe [AWSAccount]))
-> (Maybe [AWSAccount] -> f (Maybe [AWSAccount]))
-> Scope
-> f Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AWSAccount] [AWSAccount] [AWSAccount] [AWSAccount]
-> Iso
     (Maybe [AWSAccount])
     (Maybe [AWSAccount])
     (Maybe [AWSAccount])
     (Maybe [AWSAccount])
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 [AWSAccount] [AWSAccount] [AWSAccount] [AWSAccount]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Web Services services included in the scope of the
-- assessment.
scope_awsServices :: Lens.Lens' Scope (Prelude.Maybe [AWSService])
scope_awsServices :: (Maybe [AWSService] -> f (Maybe [AWSService])) -> Scope -> f Scope
scope_awsServices = (Scope -> Maybe [AWSService])
-> (Scope -> Maybe [AWSService] -> Scope)
-> Lens Scope Scope (Maybe [AWSService]) (Maybe [AWSService])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scope' {Maybe [AWSService]
awsServices :: Maybe [AWSService]
$sel:awsServices:Scope' :: Scope -> Maybe [AWSService]
awsServices} -> Maybe [AWSService]
awsServices) (\s :: Scope
s@Scope' {} Maybe [AWSService]
a -> Scope
s {$sel:awsServices:Scope' :: Maybe [AWSService]
awsServices = Maybe [AWSService]
a} :: Scope) ((Maybe [AWSService] -> f (Maybe [AWSService]))
 -> Scope -> f Scope)
-> ((Maybe [AWSService] -> f (Maybe [AWSService]))
    -> Maybe [AWSService] -> f (Maybe [AWSService]))
-> (Maybe [AWSService] -> f (Maybe [AWSService]))
-> Scope
-> f Scope
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [AWSService] [AWSService] [AWSService] [AWSService]
-> Iso
     (Maybe [AWSService])
     (Maybe [AWSService])
     (Maybe [AWSService])
     (Maybe [AWSService])
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 [AWSService] [AWSService] [AWSService] [AWSService]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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 [AWSAccount] -> Maybe [AWSService] -> Scope
Scope'
            (Maybe [AWSAccount] -> Maybe [AWSService] -> Scope)
-> Parser (Maybe [AWSAccount])
-> Parser (Maybe [AWSService] -> Scope)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [AWSAccount]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsAccounts" Parser (Maybe (Maybe [AWSAccount]))
-> Maybe [AWSAccount] -> Parser (Maybe [AWSAccount])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AWSAccount]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [AWSService] -> Scope)
-> Parser (Maybe [AWSService]) -> Parser Scope
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [AWSService]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"awsServices" Parser (Maybe (Maybe [AWSService]))
-> Maybe [AWSService] -> Parser (Maybe [AWSService])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AWSService]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Scope

instance Prelude.NFData Scope

instance Core.ToJSON Scope where
  toJSON :: Scope -> Value
toJSON Scope' {Maybe [AWSAccount]
Maybe [AWSService]
awsServices :: Maybe [AWSService]
awsAccounts :: Maybe [AWSAccount]
$sel:awsServices:Scope' :: Scope -> Maybe [AWSService]
$sel:awsAccounts:Scope' :: Scope -> Maybe [AWSAccount]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"awsAccounts" Text -> [AWSAccount] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AWSAccount] -> Pair) -> Maybe [AWSAccount] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AWSAccount]
awsAccounts,
            (Text
"awsServices" Text -> [AWSService] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AWSService] -> Pair) -> Maybe [AWSService] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AWSService]
awsServices
          ]
      )