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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(BuildStatusConfig -> BuildStatusConfig -> Bool)
-> (BuildStatusConfig -> BuildStatusConfig -> Bool)
-> Eq BuildStatusConfig
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]
(Int -> ReadS BuildStatusConfig)
-> ReadS [BuildStatusConfig]
-> ReadPrec BuildStatusConfig
-> ReadPrec [BuildStatusConfig]
-> Read 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
(Int -> BuildStatusConfig -> ShowS)
-> (BuildStatusConfig -> String)
-> ([BuildStatusConfig] -> ShowS)
-> Show BuildStatusConfig
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. BuildStatusConfig -> Rep BuildStatusConfig x)
-> (forall x. Rep BuildStatusConfig x -> BuildStatusConfig)
-> Generic BuildStatusConfig
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' :: Maybe Text -> Maybe Text -> BuildStatusConfig
BuildStatusConfig'
    { $sel:context:BuildStatusConfig' :: Maybe Text
context = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetUrl:BuildStatusConfig' :: Maybe Text
targetUrl = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> BuildStatusConfig -> f BuildStatusConfig
buildStatusConfig_context = (BuildStatusConfig -> Maybe Text)
-> (BuildStatusConfig -> Maybe Text -> BuildStatusConfig)
-> Lens
     BuildStatusConfig BuildStatusConfig (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text))
-> BuildStatusConfig -> f BuildStatusConfig
buildStatusConfig_targetUrl = (BuildStatusConfig -> Maybe Text)
-> (BuildStatusConfig -> Maybe Text -> BuildStatusConfig)
-> Lens
     BuildStatusConfig BuildStatusConfig (Maybe Text) (Maybe Text)
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 Core.FromJSON BuildStatusConfig where
  parseJSON :: Value -> Parser BuildStatusConfig
parseJSON =
    String
-> (Object -> Parser BuildStatusConfig)
-> Value
-> Parser BuildStatusConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BuildStatusConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> BuildStatusConfig
BuildStatusConfig'
            (Maybe Text -> Maybe Text -> BuildStatusConfig)
-> Parser (Maybe Text) -> Parser (Maybe Text -> BuildStatusConfig)
forall (f :: * -> *) a b. Functor 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
"context")
            Parser (Maybe Text -> BuildStatusConfig)
-> Parser (Maybe Text) -> Parser BuildStatusConfig
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
"targetUrl")
      )

instance Prelude.Hashable BuildStatusConfig

instance Prelude.NFData BuildStatusConfig

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"context" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
context,
            (Text
"targetUrl" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
targetUrl
          ]
      )