{-# 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.ElasticBeanstalk.Types.SourceBuildInformation
-- 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.ElasticBeanstalk.Types.SourceBuildInformation where

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.Types.SourceRepository
import Amazonka.ElasticBeanstalk.Types.SourceType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Location of the source code for an application version.
--
-- /See:/ 'newSourceBuildInformation' smart constructor.
data SourceBuildInformation = SourceBuildInformation'
  { -- | The type of repository.
    --
    -- -   @Git@
    --
    -- -   @Zip@
    SourceBuildInformation -> SourceType
sourceType :: SourceType,
    -- | Location where the repository is stored.
    --
    -- -   @CodeCommit@
    --
    -- -   @S3@
    SourceBuildInformation -> SourceRepository
sourceRepository :: SourceRepository,
    -- | The location of the source code, as a formatted string, depending on the
    -- value of @SourceRepository@
    --
    -- -   For @CodeCommit@, the format is the repository name and commit ID,
    --     separated by a forward slash. For example,
    --     @my-git-repo\/265cfa0cf6af46153527f55d6503ec030551f57a@.
    --
    -- -   For @S3@, the format is the S3 bucket name and object key, separated
    --     by a forward slash. For example,
    --     @my-s3-bucket\/Folders\/my-source-file@.
    SourceBuildInformation -> Text
sourceLocation :: Prelude.Text
  }
  deriving (SourceBuildInformation -> SourceBuildInformation -> Bool
(SourceBuildInformation -> SourceBuildInformation -> Bool)
-> (SourceBuildInformation -> SourceBuildInformation -> Bool)
-> Eq SourceBuildInformation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceBuildInformation -> SourceBuildInformation -> Bool
$c/= :: SourceBuildInformation -> SourceBuildInformation -> Bool
== :: SourceBuildInformation -> SourceBuildInformation -> Bool
$c== :: SourceBuildInformation -> SourceBuildInformation -> Bool
Prelude.Eq, ReadPrec [SourceBuildInformation]
ReadPrec SourceBuildInformation
Int -> ReadS SourceBuildInformation
ReadS [SourceBuildInformation]
(Int -> ReadS SourceBuildInformation)
-> ReadS [SourceBuildInformation]
-> ReadPrec SourceBuildInformation
-> ReadPrec [SourceBuildInformation]
-> Read SourceBuildInformation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceBuildInformation]
$creadListPrec :: ReadPrec [SourceBuildInformation]
readPrec :: ReadPrec SourceBuildInformation
$creadPrec :: ReadPrec SourceBuildInformation
readList :: ReadS [SourceBuildInformation]
$creadList :: ReadS [SourceBuildInformation]
readsPrec :: Int -> ReadS SourceBuildInformation
$creadsPrec :: Int -> ReadS SourceBuildInformation
Prelude.Read, Int -> SourceBuildInformation -> ShowS
[SourceBuildInformation] -> ShowS
SourceBuildInformation -> String
(Int -> SourceBuildInformation -> ShowS)
-> (SourceBuildInformation -> String)
-> ([SourceBuildInformation] -> ShowS)
-> Show SourceBuildInformation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceBuildInformation] -> ShowS
$cshowList :: [SourceBuildInformation] -> ShowS
show :: SourceBuildInformation -> String
$cshow :: SourceBuildInformation -> String
showsPrec :: Int -> SourceBuildInformation -> ShowS
$cshowsPrec :: Int -> SourceBuildInformation -> ShowS
Prelude.Show, (forall x. SourceBuildInformation -> Rep SourceBuildInformation x)
-> (forall x.
    Rep SourceBuildInformation x -> SourceBuildInformation)
-> Generic SourceBuildInformation
forall x. Rep SourceBuildInformation x -> SourceBuildInformation
forall x. SourceBuildInformation -> Rep SourceBuildInformation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceBuildInformation x -> SourceBuildInformation
$cfrom :: forall x. SourceBuildInformation -> Rep SourceBuildInformation x
Prelude.Generic)

-- |
-- Create a value of 'SourceBuildInformation' 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:
--
-- 'sourceType', 'sourceBuildInformation_sourceType' - The type of repository.
--
-- -   @Git@
--
-- -   @Zip@
--
-- 'sourceRepository', 'sourceBuildInformation_sourceRepository' - Location where the repository is stored.
--
-- -   @CodeCommit@
--
-- -   @S3@
--
-- 'sourceLocation', 'sourceBuildInformation_sourceLocation' - The location of the source code, as a formatted string, depending on the
-- value of @SourceRepository@
--
-- -   For @CodeCommit@, the format is the repository name and commit ID,
--     separated by a forward slash. For example,
--     @my-git-repo\/265cfa0cf6af46153527f55d6503ec030551f57a@.
--
-- -   For @S3@, the format is the S3 bucket name and object key, separated
--     by a forward slash. For example,
--     @my-s3-bucket\/Folders\/my-source-file@.
newSourceBuildInformation ::
  -- | 'sourceType'
  SourceType ->
  -- | 'sourceRepository'
  SourceRepository ->
  -- | 'sourceLocation'
  Prelude.Text ->
  SourceBuildInformation
newSourceBuildInformation :: SourceType -> SourceRepository -> Text -> SourceBuildInformation
newSourceBuildInformation
  SourceType
pSourceType_
  SourceRepository
pSourceRepository_
  Text
pSourceLocation_ =
    SourceBuildInformation' :: SourceType -> SourceRepository -> Text -> SourceBuildInformation
SourceBuildInformation'
      { $sel:sourceType:SourceBuildInformation' :: SourceType
sourceType = SourceType
pSourceType_,
        $sel:sourceRepository:SourceBuildInformation' :: SourceRepository
sourceRepository = SourceRepository
pSourceRepository_,
        $sel:sourceLocation:SourceBuildInformation' :: Text
sourceLocation = Text
pSourceLocation_
      }

-- | The type of repository.
--
-- -   @Git@
--
-- -   @Zip@
sourceBuildInformation_sourceType :: Lens.Lens' SourceBuildInformation SourceType
sourceBuildInformation_sourceType :: (SourceType -> f SourceType)
-> SourceBuildInformation -> f SourceBuildInformation
sourceBuildInformation_sourceType = (SourceBuildInformation -> SourceType)
-> (SourceBuildInformation -> SourceType -> SourceBuildInformation)
-> Lens
     SourceBuildInformation SourceBuildInformation SourceType SourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceBuildInformation' {SourceType
sourceType :: SourceType
$sel:sourceType:SourceBuildInformation' :: SourceBuildInformation -> SourceType
sourceType} -> SourceType
sourceType) (\s :: SourceBuildInformation
s@SourceBuildInformation' {} SourceType
a -> SourceBuildInformation
s {$sel:sourceType:SourceBuildInformation' :: SourceType
sourceType = SourceType
a} :: SourceBuildInformation)

-- | Location where the repository is stored.
--
-- -   @CodeCommit@
--
-- -   @S3@
sourceBuildInformation_sourceRepository :: Lens.Lens' SourceBuildInformation SourceRepository
sourceBuildInformation_sourceRepository :: (SourceRepository -> f SourceRepository)
-> SourceBuildInformation -> f SourceBuildInformation
sourceBuildInformation_sourceRepository = (SourceBuildInformation -> SourceRepository)
-> (SourceBuildInformation
    -> SourceRepository -> SourceBuildInformation)
-> Lens
     SourceBuildInformation
     SourceBuildInformation
     SourceRepository
     SourceRepository
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceBuildInformation' {SourceRepository
sourceRepository :: SourceRepository
$sel:sourceRepository:SourceBuildInformation' :: SourceBuildInformation -> SourceRepository
sourceRepository} -> SourceRepository
sourceRepository) (\s :: SourceBuildInformation
s@SourceBuildInformation' {} SourceRepository
a -> SourceBuildInformation
s {$sel:sourceRepository:SourceBuildInformation' :: SourceRepository
sourceRepository = SourceRepository
a} :: SourceBuildInformation)

-- | The location of the source code, as a formatted string, depending on the
-- value of @SourceRepository@
--
-- -   For @CodeCommit@, the format is the repository name and commit ID,
--     separated by a forward slash. For example,
--     @my-git-repo\/265cfa0cf6af46153527f55d6503ec030551f57a@.
--
-- -   For @S3@, the format is the S3 bucket name and object key, separated
--     by a forward slash. For example,
--     @my-s3-bucket\/Folders\/my-source-file@.
sourceBuildInformation_sourceLocation :: Lens.Lens' SourceBuildInformation Prelude.Text
sourceBuildInformation_sourceLocation :: (Text -> f Text)
-> SourceBuildInformation -> f SourceBuildInformation
sourceBuildInformation_sourceLocation = (SourceBuildInformation -> Text)
-> (SourceBuildInformation -> Text -> SourceBuildInformation)
-> Lens SourceBuildInformation SourceBuildInformation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceBuildInformation' {Text
sourceLocation :: Text
$sel:sourceLocation:SourceBuildInformation' :: SourceBuildInformation -> Text
sourceLocation} -> Text
sourceLocation) (\s :: SourceBuildInformation
s@SourceBuildInformation' {} Text
a -> SourceBuildInformation
s {$sel:sourceLocation:SourceBuildInformation' :: Text
sourceLocation = Text
a} :: SourceBuildInformation)

instance Core.FromXML SourceBuildInformation where
  parseXML :: [Node] -> Either String SourceBuildInformation
parseXML [Node]
x =
    SourceType -> SourceRepository -> Text -> SourceBuildInformation
SourceBuildInformation'
      (SourceType -> SourceRepository -> Text -> SourceBuildInformation)
-> Either String SourceType
-> Either
     String (SourceRepository -> Text -> SourceBuildInformation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String SourceType
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"SourceType")
      Either String (SourceRepository -> Text -> SourceBuildInformation)
-> Either String SourceRepository
-> Either String (Text -> SourceBuildInformation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String SourceRepository
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"SourceRepository")
      Either String (Text -> SourceBuildInformation)
-> Either String Text -> Either String SourceBuildInformation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"SourceLocation")

instance Prelude.Hashable SourceBuildInformation

instance Prelude.NFData SourceBuildInformation

instance Core.ToQuery SourceBuildInformation where
  toQuery :: SourceBuildInformation -> QueryString
toQuery SourceBuildInformation' {Text
SourceRepository
SourceType
sourceLocation :: Text
sourceRepository :: SourceRepository
sourceType :: SourceType
$sel:sourceLocation:SourceBuildInformation' :: SourceBuildInformation -> Text
$sel:sourceRepository:SourceBuildInformation' :: SourceBuildInformation -> SourceRepository
$sel:sourceType:SourceBuildInformation' :: SourceBuildInformation -> SourceType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SourceType" ByteString -> SourceType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: SourceType
sourceType,
        ByteString
"SourceRepository" ByteString -> SourceRepository -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: SourceRepository
sourceRepository,
        ByteString
"SourceLocation" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
sourceLocation
      ]