{-# 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.LookoutVision.Types.Anomaly
-- 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.LookoutVision.Types.Anomaly where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LookoutVision.Types.PixelAnomaly
import qualified Amazonka.Prelude as Prelude

-- | Information about an anomaly type found on an image by an image
-- segmentation model. For more information, see DetectAnomalies.
--
-- /See:/ 'newAnomaly' smart constructor.
data Anomaly = Anomaly'
  { -- | The name of an anomaly type found in an image. @Name@ maps to an anomaly
    -- type in the training dataset, apart from the anomaly type @background@.
    -- The service automatically inserts the @background@ anomaly type into the
    -- response from @DetectAnomalies@.
    Anomaly -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Information about the pixel mask that covers an anomaly type.
    Anomaly -> Maybe PixelAnomaly
pixelAnomaly :: Prelude.Maybe PixelAnomaly
  }
  deriving (Anomaly -> Anomaly -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Anomaly -> Anomaly -> Bool
$c/= :: Anomaly -> Anomaly -> Bool
== :: Anomaly -> Anomaly -> Bool
$c== :: Anomaly -> Anomaly -> Bool
Prelude.Eq, ReadPrec [Anomaly]
ReadPrec Anomaly
Int -> ReadS Anomaly
ReadS [Anomaly]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Anomaly]
$creadListPrec :: ReadPrec [Anomaly]
readPrec :: ReadPrec Anomaly
$creadPrec :: ReadPrec Anomaly
readList :: ReadS [Anomaly]
$creadList :: ReadS [Anomaly]
readsPrec :: Int -> ReadS Anomaly
$creadsPrec :: Int -> ReadS Anomaly
Prelude.Read, Int -> Anomaly -> ShowS
[Anomaly] -> ShowS
Anomaly -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Anomaly] -> ShowS
$cshowList :: [Anomaly] -> ShowS
show :: Anomaly -> String
$cshow :: Anomaly -> String
showsPrec :: Int -> Anomaly -> ShowS
$cshowsPrec :: Int -> Anomaly -> ShowS
Prelude.Show, forall x. Rep Anomaly x -> Anomaly
forall x. Anomaly -> Rep Anomaly x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Anomaly x -> Anomaly
$cfrom :: forall x. Anomaly -> Rep Anomaly x
Prelude.Generic)

-- |
-- Create a value of 'Anomaly' 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:
--
-- 'name', 'anomaly_name' - The name of an anomaly type found in an image. @Name@ maps to an anomaly
-- type in the training dataset, apart from the anomaly type @background@.
-- The service automatically inserts the @background@ anomaly type into the
-- response from @DetectAnomalies@.
--
-- 'pixelAnomaly', 'anomaly_pixelAnomaly' - Information about the pixel mask that covers an anomaly type.
newAnomaly ::
  Anomaly
newAnomaly :: Anomaly
newAnomaly =
  Anomaly'
    { $sel:name:Anomaly' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:pixelAnomaly:Anomaly' :: Maybe PixelAnomaly
pixelAnomaly = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of an anomaly type found in an image. @Name@ maps to an anomaly
-- type in the training dataset, apart from the anomaly type @background@.
-- The service automatically inserts the @background@ anomaly type into the
-- response from @DetectAnomalies@.
anomaly_name :: Lens.Lens' Anomaly (Prelude.Maybe Prelude.Text)
anomaly_name :: Lens' Anomaly (Maybe Text)
anomaly_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Anomaly' {Maybe Text
name :: Maybe Text
$sel:name:Anomaly' :: Anomaly -> Maybe Text
name} -> Maybe Text
name) (\s :: Anomaly
s@Anomaly' {} Maybe Text
a -> Anomaly
s {$sel:name:Anomaly' :: Maybe Text
name = Maybe Text
a} :: Anomaly)

-- | Information about the pixel mask that covers an anomaly type.
anomaly_pixelAnomaly :: Lens.Lens' Anomaly (Prelude.Maybe PixelAnomaly)
anomaly_pixelAnomaly :: Lens' Anomaly (Maybe PixelAnomaly)
anomaly_pixelAnomaly = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Anomaly' {Maybe PixelAnomaly
pixelAnomaly :: Maybe PixelAnomaly
$sel:pixelAnomaly:Anomaly' :: Anomaly -> Maybe PixelAnomaly
pixelAnomaly} -> Maybe PixelAnomaly
pixelAnomaly) (\s :: Anomaly
s@Anomaly' {} Maybe PixelAnomaly
a -> Anomaly
s {$sel:pixelAnomaly:Anomaly' :: Maybe PixelAnomaly
pixelAnomaly = Maybe PixelAnomaly
a} :: Anomaly)

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

instance Prelude.Hashable Anomaly where
  hashWithSalt :: Int -> Anomaly -> Int
hashWithSalt Int
_salt Anomaly' {Maybe Text
Maybe PixelAnomaly
pixelAnomaly :: Maybe PixelAnomaly
name :: Maybe Text
$sel:pixelAnomaly:Anomaly' :: Anomaly -> Maybe PixelAnomaly
$sel:name:Anomaly' :: Anomaly -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PixelAnomaly
pixelAnomaly

instance Prelude.NFData Anomaly where
  rnf :: Anomaly -> ()
rnf Anomaly' {Maybe Text
Maybe PixelAnomaly
pixelAnomaly :: Maybe PixelAnomaly
name :: Maybe Text
$sel:pixelAnomaly:Anomaly' :: Anomaly -> Maybe PixelAnomaly
$sel:name:Anomaly' :: Anomaly -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PixelAnomaly
pixelAnomaly