{-# 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.CodeBuild.Types.BuildStatusConfig
-- 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.CodeBuild.Types.BuildStatusConfig 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

-- | Contains information that defines how the CodeBuild build project
-- reports the build status to the source provider.
--
-- /See:/ 'newBuildStatusConfig' smart constructor.
data BuildStatusConfig = BuildStatusConfig'
  { -- | Specifies the context of the build status CodeBuild sends to the source
    -- provider. The usage of this parameter depends on the source provider.
    --
    -- [Bitbucket]
    --     This parameter is used for the @name@ parameter in the Bitbucket
    --     commit status. For more information, see
    --     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
    --     in the Bitbucket API documentation.
    --
    -- [GitHub\/GitHub Enterprise Server]
    --     This parameter is used for the @context@ parameter in the GitHub
    --     commit status. For more information, see
    --     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
    --     in the GitHub developer guide.
    BuildStatusConfig -> Maybe Text
context :: Prelude.Maybe Prelude.Text,
    -- | Specifies the target url of the build status CodeBuild sends to the
    -- source provider. The usage of this parameter depends on the source
    -- provider.
    --
    -- [Bitbucket]
    --     This parameter is used for the @url@ parameter in the Bitbucket
    --     commit status. For more information, see
    --     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
    --     in the Bitbucket API documentation.
    --
    -- [GitHub\/GitHub Enterprise Server]
    --     This parameter is used for the @target_url@ parameter in the GitHub
    --     commit status. For more information, see
    --     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
    --     in the GitHub developer guide.
    BuildStatusConfig -> Maybe Text
targetUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (BuildStatusConfig -> BuildStatusConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BuildStatusConfig -> BuildStatusConfig -> Bool
$c/= :: BuildStatusConfig -> BuildStatusConfig -> Bool
== :: BuildStatusConfig -> BuildStatusConfig -> Bool
$c== :: BuildStatusConfig -> BuildStatusConfig -> Bool
Prelude.Eq, ReadPrec [BuildStatusConfig]
ReadPrec BuildStatusConfig
Int -> ReadS BuildStatusConfig
ReadS [BuildStatusConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BuildStatusConfig]
$creadListPrec :: ReadPrec [BuildStatusConfig]
readPrec :: ReadPrec BuildStatusConfig
$creadPrec :: ReadPrec BuildStatusConfig
readList :: ReadS [BuildStatusConfig]
$creadList :: ReadS [BuildStatusConfig]
readsPrec :: Int -> ReadS BuildStatusConfig
$creadsPrec :: Int -> ReadS BuildStatusConfig
Prelude.Read, Int -> BuildStatusConfig -> ShowS
[BuildStatusConfig] -> ShowS
BuildStatusConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BuildStatusConfig] -> ShowS
$cshowList :: [BuildStatusConfig] -> ShowS
show :: BuildStatusConfig -> String
$cshow :: BuildStatusConfig -> String
showsPrec :: Int -> BuildStatusConfig -> ShowS
$cshowsPrec :: Int -> BuildStatusConfig -> ShowS
Prelude.Show, forall x. Rep BuildStatusConfig x -> BuildStatusConfig
forall x. BuildStatusConfig -> Rep BuildStatusConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BuildStatusConfig x -> BuildStatusConfig
$cfrom :: forall x. BuildStatusConfig -> Rep BuildStatusConfig x
Prelude.Generic)

-- |
-- Create a value of 'BuildStatusConfig' 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:
--
-- 'context', 'buildStatusConfig_context' - Specifies the context of the build status CodeBuild sends to the source
-- provider. The usage of this parameter depends on the source provider.
--
-- [Bitbucket]
--     This parameter is used for the @name@ parameter in the Bitbucket
--     commit status. For more information, see
--     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
--     in the Bitbucket API documentation.
--
-- [GitHub\/GitHub Enterprise Server]
--     This parameter is used for the @context@ parameter in the GitHub
--     commit status. For more information, see
--     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
--     in the GitHub developer guide.
--
-- 'targetUrl', 'buildStatusConfig_targetUrl' - Specifies the target url of the build status CodeBuild sends to the
-- source provider. The usage of this parameter depends on the source
-- provider.
--
-- [Bitbucket]
--     This parameter is used for the @url@ parameter in the Bitbucket
--     commit status. For more information, see
--     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
--     in the Bitbucket API documentation.
--
-- [GitHub\/GitHub Enterprise Server]
--     This parameter is used for the @target_url@ parameter in the GitHub
--     commit status. For more information, see
--     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
--     in the GitHub developer guide.
newBuildStatusConfig ::
  BuildStatusConfig
newBuildStatusConfig :: BuildStatusConfig
newBuildStatusConfig =
  BuildStatusConfig'
    { $sel:context:BuildStatusConfig' :: Maybe Text
context = forall a. Maybe a
Prelude.Nothing,
      $sel:targetUrl:BuildStatusConfig' :: Maybe Text
targetUrl = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the context of the build status CodeBuild sends to the source
-- provider. The usage of this parameter depends on the source provider.
--
-- [Bitbucket]
--     This parameter is used for the @name@ parameter in the Bitbucket
--     commit status. For more information, see
--     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
--     in the Bitbucket API documentation.
--
-- [GitHub\/GitHub Enterprise Server]
--     This parameter is used for the @context@ parameter in the GitHub
--     commit status. For more information, see
--     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
--     in the GitHub developer guide.
buildStatusConfig_context :: Lens.Lens' BuildStatusConfig (Prelude.Maybe Prelude.Text)
buildStatusConfig_context :: Lens' BuildStatusConfig (Maybe Text)
buildStatusConfig_context = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildStatusConfig' {Maybe Text
context :: Maybe Text
$sel:context:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
context} -> Maybe Text
context) (\s :: BuildStatusConfig
s@BuildStatusConfig' {} Maybe Text
a -> BuildStatusConfig
s {$sel:context:BuildStatusConfig' :: Maybe Text
context = Maybe Text
a} :: BuildStatusConfig)

-- | Specifies the target url of the build status CodeBuild sends to the
-- source provider. The usage of this parameter depends on the source
-- provider.
--
-- [Bitbucket]
--     This parameter is used for the @url@ parameter in the Bitbucket
--     commit status. For more information, see
--     <https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build build>
--     in the Bitbucket API documentation.
--
-- [GitHub\/GitHub Enterprise Server]
--     This parameter is used for the @target_url@ parameter in the GitHub
--     commit status. For more information, see
--     <https://developer.github.com/v3/repos/statuses/#create-a-commit-status Create a commit status>
--     in the GitHub developer guide.
buildStatusConfig_targetUrl :: Lens.Lens' BuildStatusConfig (Prelude.Maybe Prelude.Text)
buildStatusConfig_targetUrl :: Lens' BuildStatusConfig (Maybe Text)
buildStatusConfig_targetUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BuildStatusConfig' {Maybe Text
targetUrl :: Maybe Text
$sel:targetUrl:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
targetUrl} -> Maybe Text
targetUrl) (\s :: BuildStatusConfig
s@BuildStatusConfig' {} Maybe Text
a -> BuildStatusConfig
s {$sel:targetUrl:BuildStatusConfig' :: Maybe Text
targetUrl = Maybe Text
a} :: BuildStatusConfig)

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

instance Prelude.Hashable BuildStatusConfig where
  hashWithSalt :: Int -> BuildStatusConfig -> Int
hashWithSalt Int
_salt BuildStatusConfig' {Maybe Text
targetUrl :: Maybe Text
context :: Maybe Text
$sel:targetUrl:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
$sel:context:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
context
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
targetUrl

instance Prelude.NFData BuildStatusConfig where
  rnf :: BuildStatusConfig -> ()
rnf BuildStatusConfig' {Maybe Text
targetUrl :: Maybe Text
context :: Maybe Text
$sel:targetUrl:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
$sel:context:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
context
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
targetUrl

instance Data.ToJSON BuildStatusConfig where
  toJSON :: BuildStatusConfig -> Value
toJSON BuildStatusConfig' {Maybe Text
targetUrl :: Maybe Text
context :: Maybe Text
$sel:targetUrl:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
$sel:context:BuildStatusConfig' :: BuildStatusConfig -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"context" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
context,
            (Key
"targetUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetUrl
          ]
      )