{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticBeanstalk.Types.SourceBuildInformation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticBeanstalk.Types.SourceRepository
import Amazonka.ElasticBeanstalk.Types.SourceType
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
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]
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
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. 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'
      { $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 :: Lens' SourceBuildInformation SourceType
sourceBuildInformation_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 :: Lens' SourceBuildInformation SourceRepository
sourceBuildInformation_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 :: Lens' SourceBuildInformation Text
sourceBuildInformation_sourceLocation = 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 Data.FromXML SourceBuildInformation where
  parseXML :: [Node] -> Either String SourceBuildInformation
parseXML [Node]
x =
    SourceType -> SourceRepository -> Text -> SourceBuildInformation
SourceBuildInformation'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SourceType")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SourceRepository")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"SourceLocation")

instance Prelude.Hashable SourceBuildInformation where
  hashWithSalt :: Int -> SourceBuildInformation -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SourceType
sourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SourceRepository
sourceRepository
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceLocation

instance Prelude.NFData SourceBuildInformation where
  rnf :: SourceBuildInformation -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf SourceType
sourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SourceRepository
sourceRepository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceLocation

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SourceType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: SourceType
sourceType,
        ByteString
"SourceRepository" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: SourceRepository
sourceRepository,
        ByteString
"SourceLocation" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
sourceLocation
      ]