{-# 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.CodeStar.Types.CodeDestination
-- 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.CodeStar.Types.CodeDestination where

import Amazonka.CodeStar.Types.CodeCommitCodeDestination
import Amazonka.CodeStar.Types.GitHubCodeDestination
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The repository to be created in AWS CodeStar. Valid values are AWS
-- CodeCommit or GitHub. After AWS CodeStar provisions the new repository,
-- the source code files provided with the project request are placed in
-- the repository.
--
-- /See:/ 'newCodeDestination' smart constructor.
data CodeDestination = CodeDestination'
  { -- | Information about the AWS CodeCommit repository to be created in AWS
    -- CodeStar. This is where the source code files provided with the project
    -- request will be uploaded after project creation.
    CodeDestination -> Maybe CodeCommitCodeDestination
codeCommit :: Prelude.Maybe CodeCommitCodeDestination,
    -- | Information about the GitHub repository to be created in AWS CodeStar.
    -- This is where the source code files provided with the project request
    -- will be uploaded after project creation.
    CodeDestination -> Maybe GitHubCodeDestination
gitHub :: Prelude.Maybe GitHubCodeDestination
  }
  deriving (CodeDestination -> CodeDestination -> Bool
(CodeDestination -> CodeDestination -> Bool)
-> (CodeDestination -> CodeDestination -> Bool)
-> Eq CodeDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeDestination -> CodeDestination -> Bool
$c/= :: CodeDestination -> CodeDestination -> Bool
== :: CodeDestination -> CodeDestination -> Bool
$c== :: CodeDestination -> CodeDestination -> Bool
Prelude.Eq, Int -> CodeDestination -> ShowS
[CodeDestination] -> ShowS
CodeDestination -> String
(Int -> CodeDestination -> ShowS)
-> (CodeDestination -> String)
-> ([CodeDestination] -> ShowS)
-> Show CodeDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeDestination] -> ShowS
$cshowList :: [CodeDestination] -> ShowS
show :: CodeDestination -> String
$cshow :: CodeDestination -> String
showsPrec :: Int -> CodeDestination -> ShowS
$cshowsPrec :: Int -> CodeDestination -> ShowS
Prelude.Show, (forall x. CodeDestination -> Rep CodeDestination x)
-> (forall x. Rep CodeDestination x -> CodeDestination)
-> Generic CodeDestination
forall x. Rep CodeDestination x -> CodeDestination
forall x. CodeDestination -> Rep CodeDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CodeDestination x -> CodeDestination
$cfrom :: forall x. CodeDestination -> Rep CodeDestination x
Prelude.Generic)

-- |
-- Create a value of 'CodeDestination' 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:
--
-- 'codeCommit', 'codeDestination_codeCommit' - Information about the AWS CodeCommit repository to be created in AWS
-- CodeStar. This is where the source code files provided with the project
-- request will be uploaded after project creation.
--
-- 'gitHub', 'codeDestination_gitHub' - Information about the GitHub repository to be created in AWS CodeStar.
-- This is where the source code files provided with the project request
-- will be uploaded after project creation.
newCodeDestination ::
  CodeDestination
newCodeDestination :: CodeDestination
newCodeDestination =
  CodeDestination' :: Maybe CodeCommitCodeDestination
-> Maybe GitHubCodeDestination -> CodeDestination
CodeDestination'
    { $sel:codeCommit:CodeDestination' :: Maybe CodeCommitCodeDestination
codeCommit = Maybe CodeCommitCodeDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:gitHub:CodeDestination' :: Maybe GitHubCodeDestination
gitHub = Maybe GitHubCodeDestination
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the AWS CodeCommit repository to be created in AWS
-- CodeStar. This is where the source code files provided with the project
-- request will be uploaded after project creation.
codeDestination_codeCommit :: Lens.Lens' CodeDestination (Prelude.Maybe CodeCommitCodeDestination)
codeDestination_codeCommit :: (Maybe CodeCommitCodeDestination
 -> f (Maybe CodeCommitCodeDestination))
-> CodeDestination -> f CodeDestination
codeDestination_codeCommit = (CodeDestination -> Maybe CodeCommitCodeDestination)
-> (CodeDestination
    -> Maybe CodeCommitCodeDestination -> CodeDestination)
-> Lens
     CodeDestination
     CodeDestination
     (Maybe CodeCommitCodeDestination)
     (Maybe CodeCommitCodeDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeDestination' {Maybe CodeCommitCodeDestination
codeCommit :: Maybe CodeCommitCodeDestination
$sel:codeCommit:CodeDestination' :: CodeDestination -> Maybe CodeCommitCodeDestination
codeCommit} -> Maybe CodeCommitCodeDestination
codeCommit) (\s :: CodeDestination
s@CodeDestination' {} Maybe CodeCommitCodeDestination
a -> CodeDestination
s {$sel:codeCommit:CodeDestination' :: Maybe CodeCommitCodeDestination
codeCommit = Maybe CodeCommitCodeDestination
a} :: CodeDestination)

-- | Information about the GitHub repository to be created in AWS CodeStar.
-- This is where the source code files provided with the project request
-- will be uploaded after project creation.
codeDestination_gitHub :: Lens.Lens' CodeDestination (Prelude.Maybe GitHubCodeDestination)
codeDestination_gitHub :: (Maybe GitHubCodeDestination -> f (Maybe GitHubCodeDestination))
-> CodeDestination -> f CodeDestination
codeDestination_gitHub = (CodeDestination -> Maybe GitHubCodeDestination)
-> (CodeDestination
    -> Maybe GitHubCodeDestination -> CodeDestination)
-> Lens
     CodeDestination
     CodeDestination
     (Maybe GitHubCodeDestination)
     (Maybe GitHubCodeDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CodeDestination' {Maybe GitHubCodeDestination
gitHub :: Maybe GitHubCodeDestination
$sel:gitHub:CodeDestination' :: CodeDestination -> Maybe GitHubCodeDestination
gitHub} -> Maybe GitHubCodeDestination
gitHub) (\s :: CodeDestination
s@CodeDestination' {} Maybe GitHubCodeDestination
a -> CodeDestination
s {$sel:gitHub:CodeDestination' :: Maybe GitHubCodeDestination
gitHub = Maybe GitHubCodeDestination
a} :: CodeDestination)

instance Prelude.Hashable CodeDestination

instance Prelude.NFData CodeDestination

instance Core.ToJSON CodeDestination where
  toJSON :: CodeDestination -> Value
toJSON CodeDestination' {Maybe CodeCommitCodeDestination
Maybe GitHubCodeDestination
gitHub :: Maybe GitHubCodeDestination
codeCommit :: Maybe CodeCommitCodeDestination
$sel:gitHub:CodeDestination' :: CodeDestination -> Maybe GitHubCodeDestination
$sel:codeCommit:CodeDestination' :: CodeDestination -> Maybe CodeCommitCodeDestination
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"codeCommit" Text -> CodeCommitCodeDestination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CodeCommitCodeDestination -> Pair)
-> Maybe CodeCommitCodeDestination -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CodeCommitCodeDestination
codeCommit,
            (Text
"gitHub" Text -> GitHubCodeDestination -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (GitHubCodeDestination -> Pair)
-> Maybe GitHubCodeDestination -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GitHubCodeDestination
gitHub
          ]
      )