{-# 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.CodeArtifact.Types.PackageVersionError
-- 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.CodeArtifact.Types.PackageVersionError where

import Amazonka.CodeArtifact.Types.PackageVersionErrorCode
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An error associated with package.
--
-- /See:/ 'newPackageVersionError' smart constructor.
data PackageVersionError = PackageVersionError'
  { -- | The error code associated with the error. Valid error codes are:
    --
    -- -   @ALREADY_EXISTS@
    --
    -- -   @MISMATCHED_REVISION@
    --
    -- -   @MISMATCHED_STATUS@
    --
    -- -   @NOT_ALLOWED@
    --
    -- -   @NOT_FOUND@
    --
    -- -   @SKIPPED@
    PackageVersionError -> Maybe PackageVersionErrorCode
errorCode :: Prelude.Maybe PackageVersionErrorCode,
    -- | The error message associated with the error.
    PackageVersionError -> Maybe Text
errorMessage :: Prelude.Maybe Prelude.Text
  }
  deriving (PackageVersionError -> PackageVersionError -> Bool
(PackageVersionError -> PackageVersionError -> Bool)
-> (PackageVersionError -> PackageVersionError -> Bool)
-> Eq PackageVersionError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PackageVersionError -> PackageVersionError -> Bool
$c/= :: PackageVersionError -> PackageVersionError -> Bool
== :: PackageVersionError -> PackageVersionError -> Bool
$c== :: PackageVersionError -> PackageVersionError -> Bool
Prelude.Eq, ReadPrec [PackageVersionError]
ReadPrec PackageVersionError
Int -> ReadS PackageVersionError
ReadS [PackageVersionError]
(Int -> ReadS PackageVersionError)
-> ReadS [PackageVersionError]
-> ReadPrec PackageVersionError
-> ReadPrec [PackageVersionError]
-> Read PackageVersionError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PackageVersionError]
$creadListPrec :: ReadPrec [PackageVersionError]
readPrec :: ReadPrec PackageVersionError
$creadPrec :: ReadPrec PackageVersionError
readList :: ReadS [PackageVersionError]
$creadList :: ReadS [PackageVersionError]
readsPrec :: Int -> ReadS PackageVersionError
$creadsPrec :: Int -> ReadS PackageVersionError
Prelude.Read, Int -> PackageVersionError -> ShowS
[PackageVersionError] -> ShowS
PackageVersionError -> String
(Int -> PackageVersionError -> ShowS)
-> (PackageVersionError -> String)
-> ([PackageVersionError] -> ShowS)
-> Show PackageVersionError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PackageVersionError] -> ShowS
$cshowList :: [PackageVersionError] -> ShowS
show :: PackageVersionError -> String
$cshow :: PackageVersionError -> String
showsPrec :: Int -> PackageVersionError -> ShowS
$cshowsPrec :: Int -> PackageVersionError -> ShowS
Prelude.Show, (forall x. PackageVersionError -> Rep PackageVersionError x)
-> (forall x. Rep PackageVersionError x -> PackageVersionError)
-> Generic PackageVersionError
forall x. Rep PackageVersionError x -> PackageVersionError
forall x. PackageVersionError -> Rep PackageVersionError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PackageVersionError x -> PackageVersionError
$cfrom :: forall x. PackageVersionError -> Rep PackageVersionError x
Prelude.Generic)

-- |
-- Create a value of 'PackageVersionError' 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:
--
-- 'errorCode', 'packageVersionError_errorCode' - The error code associated with the error. Valid error codes are:
--
-- -   @ALREADY_EXISTS@
--
-- -   @MISMATCHED_REVISION@
--
-- -   @MISMATCHED_STATUS@
--
-- -   @NOT_ALLOWED@
--
-- -   @NOT_FOUND@
--
-- -   @SKIPPED@
--
-- 'errorMessage', 'packageVersionError_errorMessage' - The error message associated with the error.
newPackageVersionError ::
  PackageVersionError
newPackageVersionError :: PackageVersionError
newPackageVersionError =
  PackageVersionError' :: Maybe PackageVersionErrorCode -> Maybe Text -> PackageVersionError
PackageVersionError'
    { $sel:errorCode:PackageVersionError' :: Maybe PackageVersionErrorCode
errorCode = Maybe PackageVersionErrorCode
forall a. Maybe a
Prelude.Nothing,
      $sel:errorMessage:PackageVersionError' :: Maybe Text
errorMessage = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The error code associated with the error. Valid error codes are:
--
-- -   @ALREADY_EXISTS@
--
-- -   @MISMATCHED_REVISION@
--
-- -   @MISMATCHED_STATUS@
--
-- -   @NOT_ALLOWED@
--
-- -   @NOT_FOUND@
--
-- -   @SKIPPED@
packageVersionError_errorCode :: Lens.Lens' PackageVersionError (Prelude.Maybe PackageVersionErrorCode)
packageVersionError_errorCode :: (Maybe PackageVersionErrorCode
 -> f (Maybe PackageVersionErrorCode))
-> PackageVersionError -> f PackageVersionError
packageVersionError_errorCode = (PackageVersionError -> Maybe PackageVersionErrorCode)
-> (PackageVersionError
    -> Maybe PackageVersionErrorCode -> PackageVersionError)
-> Lens
     PackageVersionError
     PackageVersionError
     (Maybe PackageVersionErrorCode)
     (Maybe PackageVersionErrorCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionError' {Maybe PackageVersionErrorCode
errorCode :: Maybe PackageVersionErrorCode
$sel:errorCode:PackageVersionError' :: PackageVersionError -> Maybe PackageVersionErrorCode
errorCode} -> Maybe PackageVersionErrorCode
errorCode) (\s :: PackageVersionError
s@PackageVersionError' {} Maybe PackageVersionErrorCode
a -> PackageVersionError
s {$sel:errorCode:PackageVersionError' :: Maybe PackageVersionErrorCode
errorCode = Maybe PackageVersionErrorCode
a} :: PackageVersionError)

-- | The error message associated with the error.
packageVersionError_errorMessage :: Lens.Lens' PackageVersionError (Prelude.Maybe Prelude.Text)
packageVersionError_errorMessage :: (Maybe Text -> f (Maybe Text))
-> PackageVersionError -> f PackageVersionError
packageVersionError_errorMessage = (PackageVersionError -> Maybe Text)
-> (PackageVersionError -> Maybe Text -> PackageVersionError)
-> Lens
     PackageVersionError PackageVersionError (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PackageVersionError' {Maybe Text
errorMessage :: Maybe Text
$sel:errorMessage:PackageVersionError' :: PackageVersionError -> Maybe Text
errorMessage} -> Maybe Text
errorMessage) (\s :: PackageVersionError
s@PackageVersionError' {} Maybe Text
a -> PackageVersionError
s {$sel:errorMessage:PackageVersionError' :: Maybe Text
errorMessage = Maybe Text
a} :: PackageVersionError)

instance Core.FromJSON PackageVersionError where
  parseJSON :: Value -> Parser PackageVersionError
parseJSON =
    String
-> (Object -> Parser PackageVersionError)
-> Value
-> Parser PackageVersionError
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"PackageVersionError"
      ( \Object
x ->
          Maybe PackageVersionErrorCode -> Maybe Text -> PackageVersionError
PackageVersionError'
            (Maybe PackageVersionErrorCode
 -> Maybe Text -> PackageVersionError)
-> Parser (Maybe PackageVersionErrorCode)
-> Parser (Maybe Text -> PackageVersionError)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PackageVersionErrorCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorCode")
            Parser (Maybe Text -> PackageVersionError)
-> Parser (Maybe Text) -> Parser PackageVersionError
forall (f :: * -> *) a b. Applicative f => 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
"errorMessage")
      )

instance Prelude.Hashable PackageVersionError

instance Prelude.NFData PackageVersionError