{-# 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.ResourceExplorer2.Types.Index
-- 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.ResourceExplorer2.Types.Index where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.ResourceExplorer2.Types.IndexType

-- | An index is the data store used by Amazon Web Services Resource Explorer
-- to hold information about your Amazon Web Services resources that the
-- service discovers. Creating an index in an Amazon Web Services Region
-- turns on Resource Explorer and lets it discover your resources.
--
-- By default, an index is /local/, meaning that it contains information
-- about resources in only the same Region as the index. However, you can
-- promote the index of one Region in the account by calling
-- UpdateIndexType to convert it into an aggregator index. The aggregator
-- index receives a replicated copy of the index information from all other
-- Regions where Resource Explorer is turned on. This allows search
-- operations in that Region to return results from all Regions in the
-- account.
--
-- /See:/ 'newIndex' smart constructor.
data Index = Index'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
    -- of the index.
    Index -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services Region in which the index exists.
    Index -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The type of index. It can be one of the following values:
    --
    -- -   __LOCAL__ – The index contains information about resources from only
    --     the same Amazon Web Services Region.
    --
    -- -   __AGGREGATOR__ – Resource Explorer replicates copies of the indexed
    --     information about resources in all other Amazon Web Services Regions
    --     to the aggregator index. This lets search results in the Region with
    --     the aggregator index to include resources from all Regions in the
    --     account where Resource Explorer is turned on.
    Index -> Maybe IndexType
type' :: Prelude.Maybe IndexType
  }
  deriving (Index -> Index -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Index -> Index -> Bool
$c/= :: Index -> Index -> Bool
== :: Index -> Index -> Bool
$c== :: Index -> Index -> Bool
Prelude.Eq, ReadPrec [Index]
ReadPrec Index
Int -> ReadS Index
ReadS [Index]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Index]
$creadListPrec :: ReadPrec [Index]
readPrec :: ReadPrec Index
$creadPrec :: ReadPrec Index
readList :: ReadS [Index]
$creadList :: ReadS [Index]
readsPrec :: Int -> ReadS Index
$creadsPrec :: Int -> ReadS Index
Prelude.Read, Int -> Index -> ShowS
[Index] -> ShowS
Index -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Index] -> ShowS
$cshowList :: [Index] -> ShowS
show :: Index -> String
$cshow :: Index -> String
showsPrec :: Int -> Index -> ShowS
$cshowsPrec :: Int -> Index -> ShowS
Prelude.Show, forall x. Rep Index x -> Index
forall x. Index -> Rep Index x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Index x -> Index
$cfrom :: forall x. Index -> Rep Index x
Prelude.Generic)

-- |
-- Create a value of 'Index' 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:
--
-- 'arn', 'index_arn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the index.
--
-- 'region', 'index_region' - The Amazon Web Services Region in which the index exists.
--
-- 'type'', 'index_type' - The type of index. It can be one of the following values:
--
-- -   __LOCAL__ – The index contains information about resources from only
--     the same Amazon Web Services Region.
--
-- -   __AGGREGATOR__ – Resource Explorer replicates copies of the indexed
--     information about resources in all other Amazon Web Services Regions
--     to the aggregator index. This lets search results in the Region with
--     the aggregator index to include resources from all Regions in the
--     account where Resource Explorer is turned on.
newIndex ::
  Index
newIndex :: Index
newIndex =
  Index'
    { $sel:arn:Index' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:region:Index' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Index' :: Maybe IndexType
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the index.
index_arn :: Lens.Lens' Index (Prelude.Maybe Prelude.Text)
index_arn :: Lens' Index (Maybe Text)
index_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Index' {Maybe Text
arn :: Maybe Text
$sel:arn:Index' :: Index -> Maybe Text
arn} -> Maybe Text
arn) (\s :: Index
s@Index' {} Maybe Text
a -> Index
s {$sel:arn:Index' :: Maybe Text
arn = Maybe Text
a} :: Index)

-- | The Amazon Web Services Region in which the index exists.
index_region :: Lens.Lens' Index (Prelude.Maybe Prelude.Text)
index_region :: Lens' Index (Maybe Text)
index_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Index' {Maybe Text
region :: Maybe Text
$sel:region:Index' :: Index -> Maybe Text
region} -> Maybe Text
region) (\s :: Index
s@Index' {} Maybe Text
a -> Index
s {$sel:region:Index' :: Maybe Text
region = Maybe Text
a} :: Index)

-- | The type of index. It can be one of the following values:
--
-- -   __LOCAL__ – The index contains information about resources from only
--     the same Amazon Web Services Region.
--
-- -   __AGGREGATOR__ – Resource Explorer replicates copies of the indexed
--     information about resources in all other Amazon Web Services Regions
--     to the aggregator index. This lets search results in the Region with
--     the aggregator index to include resources from all Regions in the
--     account where Resource Explorer is turned on.
index_type :: Lens.Lens' Index (Prelude.Maybe IndexType)
index_type :: Lens' Index (Maybe IndexType)
index_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Index' {Maybe IndexType
type' :: Maybe IndexType
$sel:type':Index' :: Index -> Maybe IndexType
type'} -> Maybe IndexType
type') (\s :: Index
s@Index' {} Maybe IndexType
a -> Index
s {$sel:type':Index' :: Maybe IndexType
type' = Maybe IndexType
a} :: Index)

instance Data.FromJSON Index where
  parseJSON :: Value -> Parser Index
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Index"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe IndexType -> Index
Index'
            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
"Arn")
            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
"Region")
            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 Index where
  hashWithSalt :: Int -> Index -> Int
hashWithSalt Int
_salt Index' {Maybe Text
Maybe IndexType
type' :: Maybe IndexType
region :: Maybe Text
arn :: Maybe Text
$sel:type':Index' :: Index -> Maybe IndexType
$sel:region:Index' :: Index -> Maybe Text
$sel:arn:Index' :: Index -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
arn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IndexType
type'

instance Prelude.NFData Index where
  rnf :: Index -> ()
rnf Index' {Maybe Text
Maybe IndexType
type' :: Maybe IndexType
region :: Maybe Text
arn :: Maybe Text
$sel:type':Index' :: Index -> Maybe IndexType
$sel:region:Index' :: Index -> Maybe Text
$sel:arn:Index' :: Index -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe IndexType
type'