{-# 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.CodeDeploy.Types.RevisionLocation
-- 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.CodeDeploy.Types.RevisionLocation where

import Amazonka.CodeDeploy.Types.AppSpecContent
import Amazonka.CodeDeploy.Types.GitHubLocation
import Amazonka.CodeDeploy.Types.RawString
import Amazonka.CodeDeploy.Types.RevisionLocationType
import Amazonka.CodeDeploy.Types.S3Location
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the location of an application revision.
--
-- /See:/ 'newRevisionLocation' smart constructor.
data RevisionLocation = RevisionLocation'
  { -- | Information about the location of an AWS Lambda deployment revision
    -- stored as a RawString.
    RevisionLocation -> Maybe RawString
string :: Prelude.Maybe RawString,
    -- | The type of application revision:
    --
    -- -   S3: An application revision stored in Amazon S3.
    --
    -- -   GitHub: An application revision stored in GitHub (EC2\/On-premises
    --     deployments only).
    --
    -- -   String: A YAML-formatted or JSON-formatted string (AWS Lambda
    --     deployments only).
    --
    -- -   AppSpecContent: An @AppSpecContent@ object that contains the
    --     contents of an AppSpec file for an AWS Lambda or Amazon ECS
    --     deployment. The content is formatted as JSON or YAML stored as a
    --     RawString.
    RevisionLocation -> Maybe RevisionLocationType
revisionType :: Prelude.Maybe RevisionLocationType,
    -- | Information about the location of a revision stored in Amazon S3.
    RevisionLocation -> Maybe S3Location
s3Location :: Prelude.Maybe S3Location,
    -- | The content of an AppSpec file for an AWS Lambda or Amazon ECS
    -- deployment. The content is formatted as JSON or YAML and stored as a
    -- RawString.
    RevisionLocation -> Maybe AppSpecContent
appSpecContent :: Prelude.Maybe AppSpecContent,
    -- | Information about the location of application artifacts stored in
    -- GitHub.
    RevisionLocation -> Maybe GitHubLocation
gitHubLocation :: Prelude.Maybe GitHubLocation
  }
  deriving (RevisionLocation -> RevisionLocation -> Bool
(RevisionLocation -> RevisionLocation -> Bool)
-> (RevisionLocation -> RevisionLocation -> Bool)
-> Eq RevisionLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RevisionLocation -> RevisionLocation -> Bool
$c/= :: RevisionLocation -> RevisionLocation -> Bool
== :: RevisionLocation -> RevisionLocation -> Bool
$c== :: RevisionLocation -> RevisionLocation -> Bool
Prelude.Eq, ReadPrec [RevisionLocation]
ReadPrec RevisionLocation
Int -> ReadS RevisionLocation
ReadS [RevisionLocation]
(Int -> ReadS RevisionLocation)
-> ReadS [RevisionLocation]
-> ReadPrec RevisionLocation
-> ReadPrec [RevisionLocation]
-> Read RevisionLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RevisionLocation]
$creadListPrec :: ReadPrec [RevisionLocation]
readPrec :: ReadPrec RevisionLocation
$creadPrec :: ReadPrec RevisionLocation
readList :: ReadS [RevisionLocation]
$creadList :: ReadS [RevisionLocation]
readsPrec :: Int -> ReadS RevisionLocation
$creadsPrec :: Int -> ReadS RevisionLocation
Prelude.Read, Int -> RevisionLocation -> ShowS
[RevisionLocation] -> ShowS
RevisionLocation -> String
(Int -> RevisionLocation -> ShowS)
-> (RevisionLocation -> String)
-> ([RevisionLocation] -> ShowS)
-> Show RevisionLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RevisionLocation] -> ShowS
$cshowList :: [RevisionLocation] -> ShowS
show :: RevisionLocation -> String
$cshow :: RevisionLocation -> String
showsPrec :: Int -> RevisionLocation -> ShowS
$cshowsPrec :: Int -> RevisionLocation -> ShowS
Prelude.Show, (forall x. RevisionLocation -> Rep RevisionLocation x)
-> (forall x. Rep RevisionLocation x -> RevisionLocation)
-> Generic RevisionLocation
forall x. Rep RevisionLocation x -> RevisionLocation
forall x. RevisionLocation -> Rep RevisionLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RevisionLocation x -> RevisionLocation
$cfrom :: forall x. RevisionLocation -> Rep RevisionLocation x
Prelude.Generic)

-- |
-- Create a value of 'RevisionLocation' 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:
--
-- 'string', 'revisionLocation_string' - Information about the location of an AWS Lambda deployment revision
-- stored as a RawString.
--
-- 'revisionType', 'revisionLocation_revisionType' - The type of application revision:
--
-- -   S3: An application revision stored in Amazon S3.
--
-- -   GitHub: An application revision stored in GitHub (EC2\/On-premises
--     deployments only).
--
-- -   String: A YAML-formatted or JSON-formatted string (AWS Lambda
--     deployments only).
--
-- -   AppSpecContent: An @AppSpecContent@ object that contains the
--     contents of an AppSpec file for an AWS Lambda or Amazon ECS
--     deployment. The content is formatted as JSON or YAML stored as a
--     RawString.
--
-- 's3Location', 'revisionLocation_s3Location' - Information about the location of a revision stored in Amazon S3.
--
-- 'appSpecContent', 'revisionLocation_appSpecContent' - The content of an AppSpec file for an AWS Lambda or Amazon ECS
-- deployment. The content is formatted as JSON or YAML and stored as a
-- RawString.
--
-- 'gitHubLocation', 'revisionLocation_gitHubLocation' - Information about the location of application artifacts stored in
-- GitHub.
newRevisionLocation ::
  RevisionLocation
newRevisionLocation :: RevisionLocation
newRevisionLocation =
  RevisionLocation' :: Maybe RawString
-> Maybe RevisionLocationType
-> Maybe S3Location
-> Maybe AppSpecContent
-> Maybe GitHubLocation
-> RevisionLocation
RevisionLocation'
    { $sel:string:RevisionLocation' :: Maybe RawString
string = Maybe RawString
forall a. Maybe a
Prelude.Nothing,
      $sel:revisionType:RevisionLocation' :: Maybe RevisionLocationType
revisionType = Maybe RevisionLocationType
forall a. Maybe a
Prelude.Nothing,
      $sel:s3Location:RevisionLocation' :: Maybe S3Location
s3Location = Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
      $sel:appSpecContent:RevisionLocation' :: Maybe AppSpecContent
appSpecContent = Maybe AppSpecContent
forall a. Maybe a
Prelude.Nothing,
      $sel:gitHubLocation:RevisionLocation' :: Maybe GitHubLocation
gitHubLocation = Maybe GitHubLocation
forall a. Maybe a
Prelude.Nothing
    }

-- | Information about the location of an AWS Lambda deployment revision
-- stored as a RawString.
revisionLocation_string :: Lens.Lens' RevisionLocation (Prelude.Maybe RawString)
revisionLocation_string :: (Maybe RawString -> f (Maybe RawString))
-> RevisionLocation -> f RevisionLocation
revisionLocation_string = (RevisionLocation -> Maybe RawString)
-> (RevisionLocation -> Maybe RawString -> RevisionLocation)
-> Lens
     RevisionLocation
     RevisionLocation
     (Maybe RawString)
     (Maybe RawString)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionLocation' {Maybe RawString
string :: Maybe RawString
$sel:string:RevisionLocation' :: RevisionLocation -> Maybe RawString
string} -> Maybe RawString
string) (\s :: RevisionLocation
s@RevisionLocation' {} Maybe RawString
a -> RevisionLocation
s {$sel:string:RevisionLocation' :: Maybe RawString
string = Maybe RawString
a} :: RevisionLocation)

-- | The type of application revision:
--
-- -   S3: An application revision stored in Amazon S3.
--
-- -   GitHub: An application revision stored in GitHub (EC2\/On-premises
--     deployments only).
--
-- -   String: A YAML-formatted or JSON-formatted string (AWS Lambda
--     deployments only).
--
-- -   AppSpecContent: An @AppSpecContent@ object that contains the
--     contents of an AppSpec file for an AWS Lambda or Amazon ECS
--     deployment. The content is formatted as JSON or YAML stored as a
--     RawString.
revisionLocation_revisionType :: Lens.Lens' RevisionLocation (Prelude.Maybe RevisionLocationType)
revisionLocation_revisionType :: (Maybe RevisionLocationType -> f (Maybe RevisionLocationType))
-> RevisionLocation -> f RevisionLocation
revisionLocation_revisionType = (RevisionLocation -> Maybe RevisionLocationType)
-> (RevisionLocation
    -> Maybe RevisionLocationType -> RevisionLocation)
-> Lens
     RevisionLocation
     RevisionLocation
     (Maybe RevisionLocationType)
     (Maybe RevisionLocationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionLocation' {Maybe RevisionLocationType
revisionType :: Maybe RevisionLocationType
$sel:revisionType:RevisionLocation' :: RevisionLocation -> Maybe RevisionLocationType
revisionType} -> Maybe RevisionLocationType
revisionType) (\s :: RevisionLocation
s@RevisionLocation' {} Maybe RevisionLocationType
a -> RevisionLocation
s {$sel:revisionType:RevisionLocation' :: Maybe RevisionLocationType
revisionType = Maybe RevisionLocationType
a} :: RevisionLocation)

-- | Information about the location of a revision stored in Amazon S3.
revisionLocation_s3Location :: Lens.Lens' RevisionLocation (Prelude.Maybe S3Location)
revisionLocation_s3Location :: (Maybe S3Location -> f (Maybe S3Location))
-> RevisionLocation -> f RevisionLocation
revisionLocation_s3Location = (RevisionLocation -> Maybe S3Location)
-> (RevisionLocation -> Maybe S3Location -> RevisionLocation)
-> Lens
     RevisionLocation
     RevisionLocation
     (Maybe S3Location)
     (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionLocation' {Maybe S3Location
s3Location :: Maybe S3Location
$sel:s3Location:RevisionLocation' :: RevisionLocation -> Maybe S3Location
s3Location} -> Maybe S3Location
s3Location) (\s :: RevisionLocation
s@RevisionLocation' {} Maybe S3Location
a -> RevisionLocation
s {$sel:s3Location:RevisionLocation' :: Maybe S3Location
s3Location = Maybe S3Location
a} :: RevisionLocation)

-- | The content of an AppSpec file for an AWS Lambda or Amazon ECS
-- deployment. The content is formatted as JSON or YAML and stored as a
-- RawString.
revisionLocation_appSpecContent :: Lens.Lens' RevisionLocation (Prelude.Maybe AppSpecContent)
revisionLocation_appSpecContent :: (Maybe AppSpecContent -> f (Maybe AppSpecContent))
-> RevisionLocation -> f RevisionLocation
revisionLocation_appSpecContent = (RevisionLocation -> Maybe AppSpecContent)
-> (RevisionLocation -> Maybe AppSpecContent -> RevisionLocation)
-> Lens
     RevisionLocation
     RevisionLocation
     (Maybe AppSpecContent)
     (Maybe AppSpecContent)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionLocation' {Maybe AppSpecContent
appSpecContent :: Maybe AppSpecContent
$sel:appSpecContent:RevisionLocation' :: RevisionLocation -> Maybe AppSpecContent
appSpecContent} -> Maybe AppSpecContent
appSpecContent) (\s :: RevisionLocation
s@RevisionLocation' {} Maybe AppSpecContent
a -> RevisionLocation
s {$sel:appSpecContent:RevisionLocation' :: Maybe AppSpecContent
appSpecContent = Maybe AppSpecContent
a} :: RevisionLocation)

-- | Information about the location of application artifacts stored in
-- GitHub.
revisionLocation_gitHubLocation :: Lens.Lens' RevisionLocation (Prelude.Maybe GitHubLocation)
revisionLocation_gitHubLocation :: (Maybe GitHubLocation -> f (Maybe GitHubLocation))
-> RevisionLocation -> f RevisionLocation
revisionLocation_gitHubLocation = (RevisionLocation -> Maybe GitHubLocation)
-> (RevisionLocation -> Maybe GitHubLocation -> RevisionLocation)
-> Lens
     RevisionLocation
     RevisionLocation
     (Maybe GitHubLocation)
     (Maybe GitHubLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RevisionLocation' {Maybe GitHubLocation
gitHubLocation :: Maybe GitHubLocation
$sel:gitHubLocation:RevisionLocation' :: RevisionLocation -> Maybe GitHubLocation
gitHubLocation} -> Maybe GitHubLocation
gitHubLocation) (\s :: RevisionLocation
s@RevisionLocation' {} Maybe GitHubLocation
a -> RevisionLocation
s {$sel:gitHubLocation:RevisionLocation' :: Maybe GitHubLocation
gitHubLocation = Maybe GitHubLocation
a} :: RevisionLocation)

instance Core.FromJSON RevisionLocation where
  parseJSON :: Value -> Parser RevisionLocation
parseJSON =
    String
-> (Object -> Parser RevisionLocation)
-> Value
-> Parser RevisionLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"RevisionLocation"
      ( \Object
x ->
          Maybe RawString
-> Maybe RevisionLocationType
-> Maybe S3Location
-> Maybe AppSpecContent
-> Maybe GitHubLocation
-> RevisionLocation
RevisionLocation'
            (Maybe RawString
 -> Maybe RevisionLocationType
 -> Maybe S3Location
 -> Maybe AppSpecContent
 -> Maybe GitHubLocation
 -> RevisionLocation)
-> Parser (Maybe RawString)
-> Parser
     (Maybe RevisionLocationType
      -> Maybe S3Location
      -> Maybe AppSpecContent
      -> Maybe GitHubLocation
      -> RevisionLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RawString)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"string")
            Parser
  (Maybe RevisionLocationType
   -> Maybe S3Location
   -> Maybe AppSpecContent
   -> Maybe GitHubLocation
   -> RevisionLocation)
-> Parser (Maybe RevisionLocationType)
-> Parser
     (Maybe S3Location
      -> Maybe AppSpecContent
      -> Maybe GitHubLocation
      -> RevisionLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RevisionLocationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"revisionType")
            Parser
  (Maybe S3Location
   -> Maybe AppSpecContent
   -> Maybe GitHubLocation
   -> RevisionLocation)
-> Parser (Maybe S3Location)
-> Parser
     (Maybe AppSpecContent -> Maybe GitHubLocation -> RevisionLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"s3Location")
            Parser
  (Maybe AppSpecContent -> Maybe GitHubLocation -> RevisionLocation)
-> Parser (Maybe AppSpecContent)
-> Parser (Maybe GitHubLocation -> RevisionLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AppSpecContent)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"appSpecContent")
            Parser (Maybe GitHubLocation -> RevisionLocation)
-> Parser (Maybe GitHubLocation) -> Parser RevisionLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe GitHubLocation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"gitHubLocation")
      )

instance Prelude.Hashable RevisionLocation

instance Prelude.NFData RevisionLocation

instance Core.ToJSON RevisionLocation where
  toJSON :: RevisionLocation -> Value
toJSON RevisionLocation' {Maybe AppSpecContent
Maybe GitHubLocation
Maybe RawString
Maybe RevisionLocationType
Maybe S3Location
gitHubLocation :: Maybe GitHubLocation
appSpecContent :: Maybe AppSpecContent
s3Location :: Maybe S3Location
revisionType :: Maybe RevisionLocationType
string :: Maybe RawString
$sel:gitHubLocation:RevisionLocation' :: RevisionLocation -> Maybe GitHubLocation
$sel:appSpecContent:RevisionLocation' :: RevisionLocation -> Maybe AppSpecContent
$sel:s3Location:RevisionLocation' :: RevisionLocation -> Maybe S3Location
$sel:revisionType:RevisionLocation' :: RevisionLocation -> Maybe RevisionLocationType
$sel:string:RevisionLocation' :: RevisionLocation -> Maybe RawString
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"string" Text -> RawString -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RawString -> Pair) -> Maybe RawString -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RawString
string,
            (Text
"revisionType" Text -> RevisionLocationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RevisionLocationType -> Pair)
-> Maybe RevisionLocationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RevisionLocationType
revisionType,
            (Text
"s3Location" Text -> S3Location -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (S3Location -> Pair) -> Maybe S3Location -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3Location
s3Location,
            (Text
"appSpecContent" Text -> AppSpecContent -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AppSpecContent -> Pair) -> Maybe AppSpecContent -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AppSpecContent
appSpecContent,
            (Text
"gitHubLocation" Text -> GitHubLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (GitHubLocation -> Pair) -> Maybe GitHubLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GitHubLocation
gitHubLocation
          ]
      )