{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SMS.GenerateChangeSet
-- 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)
--
-- Generates a target change set for a currently launched stack and writes
-- it to an Amazon S3 object in the customer’s Amazon S3 bucket.
module Amazonka.SMS.GenerateChangeSet
  ( -- * Creating a Request
    GenerateChangeSet (..),
    newGenerateChangeSet,

    -- * Request Lenses
    generateChangeSet_appId,
    generateChangeSet_changesetFormat,

    -- * Destructuring the Response
    GenerateChangeSetResponse (..),
    newGenerateChangeSetResponse,

    -- * Response Lenses
    generateChangeSetResponse_s3Location,
    generateChangeSetResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SMS.Types

-- | /See:/ 'newGenerateChangeSet' smart constructor.
data GenerateChangeSet = GenerateChangeSet'
  { -- | The ID of the application associated with the change set.
    GenerateChangeSet -> Maybe Text
appId :: Prelude.Maybe Prelude.Text,
    -- | The format for the change set.
    GenerateChangeSet -> Maybe OutputFormat
changesetFormat :: Prelude.Maybe OutputFormat
  }
  deriving (GenerateChangeSet -> GenerateChangeSet -> Bool
(GenerateChangeSet -> GenerateChangeSet -> Bool)
-> (GenerateChangeSet -> GenerateChangeSet -> Bool)
-> Eq GenerateChangeSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateChangeSet -> GenerateChangeSet -> Bool
$c/= :: GenerateChangeSet -> GenerateChangeSet -> Bool
== :: GenerateChangeSet -> GenerateChangeSet -> Bool
$c== :: GenerateChangeSet -> GenerateChangeSet -> Bool
Prelude.Eq, ReadPrec [GenerateChangeSet]
ReadPrec GenerateChangeSet
Int -> ReadS GenerateChangeSet
ReadS [GenerateChangeSet]
(Int -> ReadS GenerateChangeSet)
-> ReadS [GenerateChangeSet]
-> ReadPrec GenerateChangeSet
-> ReadPrec [GenerateChangeSet]
-> Read GenerateChangeSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateChangeSet]
$creadListPrec :: ReadPrec [GenerateChangeSet]
readPrec :: ReadPrec GenerateChangeSet
$creadPrec :: ReadPrec GenerateChangeSet
readList :: ReadS [GenerateChangeSet]
$creadList :: ReadS [GenerateChangeSet]
readsPrec :: Int -> ReadS GenerateChangeSet
$creadsPrec :: Int -> ReadS GenerateChangeSet
Prelude.Read, Int -> GenerateChangeSet -> ShowS
[GenerateChangeSet] -> ShowS
GenerateChangeSet -> String
(Int -> GenerateChangeSet -> ShowS)
-> (GenerateChangeSet -> String)
-> ([GenerateChangeSet] -> ShowS)
-> Show GenerateChangeSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateChangeSet] -> ShowS
$cshowList :: [GenerateChangeSet] -> ShowS
show :: GenerateChangeSet -> String
$cshow :: GenerateChangeSet -> String
showsPrec :: Int -> GenerateChangeSet -> ShowS
$cshowsPrec :: Int -> GenerateChangeSet -> ShowS
Prelude.Show, (forall x. GenerateChangeSet -> Rep GenerateChangeSet x)
-> (forall x. Rep GenerateChangeSet x -> GenerateChangeSet)
-> Generic GenerateChangeSet
forall x. Rep GenerateChangeSet x -> GenerateChangeSet
forall x. GenerateChangeSet -> Rep GenerateChangeSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GenerateChangeSet x -> GenerateChangeSet
$cfrom :: forall x. GenerateChangeSet -> Rep GenerateChangeSet x
Prelude.Generic)

-- |
-- Create a value of 'GenerateChangeSet' 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:
--
-- 'appId', 'generateChangeSet_appId' - The ID of the application associated with the change set.
--
-- 'changesetFormat', 'generateChangeSet_changesetFormat' - The format for the change set.
newGenerateChangeSet ::
  GenerateChangeSet
newGenerateChangeSet :: GenerateChangeSet
newGenerateChangeSet =
  GenerateChangeSet' :: Maybe Text -> Maybe OutputFormat -> GenerateChangeSet
GenerateChangeSet'
    { $sel:appId:GenerateChangeSet' :: Maybe Text
appId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:changesetFormat:GenerateChangeSet' :: Maybe OutputFormat
changesetFormat = Maybe OutputFormat
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the application associated with the change set.
generateChangeSet_appId :: Lens.Lens' GenerateChangeSet (Prelude.Maybe Prelude.Text)
generateChangeSet_appId :: (Maybe Text -> f (Maybe Text))
-> GenerateChangeSet -> f GenerateChangeSet
generateChangeSet_appId = (GenerateChangeSet -> Maybe Text)
-> (GenerateChangeSet -> Maybe Text -> GenerateChangeSet)
-> Lens
     GenerateChangeSet GenerateChangeSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateChangeSet' {Maybe Text
appId :: Maybe Text
$sel:appId:GenerateChangeSet' :: GenerateChangeSet -> Maybe Text
appId} -> Maybe Text
appId) (\s :: GenerateChangeSet
s@GenerateChangeSet' {} Maybe Text
a -> GenerateChangeSet
s {$sel:appId:GenerateChangeSet' :: Maybe Text
appId = Maybe Text
a} :: GenerateChangeSet)

-- | The format for the change set.
generateChangeSet_changesetFormat :: Lens.Lens' GenerateChangeSet (Prelude.Maybe OutputFormat)
generateChangeSet_changesetFormat :: (Maybe OutputFormat -> f (Maybe OutputFormat))
-> GenerateChangeSet -> f GenerateChangeSet
generateChangeSet_changesetFormat = (GenerateChangeSet -> Maybe OutputFormat)
-> (GenerateChangeSet -> Maybe OutputFormat -> GenerateChangeSet)
-> Lens
     GenerateChangeSet
     GenerateChangeSet
     (Maybe OutputFormat)
     (Maybe OutputFormat)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateChangeSet' {Maybe OutputFormat
changesetFormat :: Maybe OutputFormat
$sel:changesetFormat:GenerateChangeSet' :: GenerateChangeSet -> Maybe OutputFormat
changesetFormat} -> Maybe OutputFormat
changesetFormat) (\s :: GenerateChangeSet
s@GenerateChangeSet' {} Maybe OutputFormat
a -> GenerateChangeSet
s {$sel:changesetFormat:GenerateChangeSet' :: Maybe OutputFormat
changesetFormat = Maybe OutputFormat
a} :: GenerateChangeSet)

instance Core.AWSRequest GenerateChangeSet where
  type
    AWSResponse GenerateChangeSet =
      GenerateChangeSetResponse
  request :: GenerateChangeSet -> Request GenerateChangeSet
request = Service -> GenerateChangeSet -> Request GenerateChangeSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GenerateChangeSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GenerateChangeSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GenerateChangeSet))
-> Logger
-> Service
-> Proxy GenerateChangeSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GenerateChangeSet)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe S3Location -> Int -> GenerateChangeSetResponse
GenerateChangeSetResponse'
            (Maybe S3Location -> Int -> GenerateChangeSetResponse)
-> Either String (Maybe S3Location)
-> Either String (Int -> GenerateChangeSetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe S3Location)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"s3Location")
            Either String (Int -> GenerateChangeSetResponse)
-> Either String Int -> Either String GenerateChangeSetResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GenerateChangeSet

instance Prelude.NFData GenerateChangeSet

instance Core.ToHeaders GenerateChangeSet where
  toHeaders :: GenerateChangeSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GenerateChangeSet -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSServerMigrationService_V2016_10_24.GenerateChangeSet" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON GenerateChangeSet where
  toJSON :: GenerateChangeSet -> Value
toJSON GenerateChangeSet' {Maybe Text
Maybe OutputFormat
changesetFormat :: Maybe OutputFormat
appId :: Maybe Text
$sel:changesetFormat:GenerateChangeSet' :: GenerateChangeSet -> Maybe OutputFormat
$sel:appId:GenerateChangeSet' :: GenerateChangeSet -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"appId" 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
appId,
            (Text
"changesetFormat" Text -> OutputFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (OutputFormat -> Pair) -> Maybe OutputFormat -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe OutputFormat
changesetFormat
          ]
      )

instance Core.ToPath GenerateChangeSet where
  toPath :: GenerateChangeSet -> ByteString
toPath = ByteString -> GenerateChangeSet -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery GenerateChangeSet where
  toQuery :: GenerateChangeSet -> QueryString
toQuery = QueryString -> GenerateChangeSet -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGenerateChangeSetResponse' smart constructor.
data GenerateChangeSetResponse = GenerateChangeSetResponse'
  { -- | The location of the Amazon S3 object.
    GenerateChangeSetResponse -> Maybe S3Location
s3Location :: Prelude.Maybe S3Location,
    -- | The response's http status code.
    GenerateChangeSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool
(GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool)
-> (GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool)
-> Eq GenerateChangeSetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool
$c/= :: GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool
== :: GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool
$c== :: GenerateChangeSetResponse -> GenerateChangeSetResponse -> Bool
Prelude.Eq, ReadPrec [GenerateChangeSetResponse]
ReadPrec GenerateChangeSetResponse
Int -> ReadS GenerateChangeSetResponse
ReadS [GenerateChangeSetResponse]
(Int -> ReadS GenerateChangeSetResponse)
-> ReadS [GenerateChangeSetResponse]
-> ReadPrec GenerateChangeSetResponse
-> ReadPrec [GenerateChangeSetResponse]
-> Read GenerateChangeSetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateChangeSetResponse]
$creadListPrec :: ReadPrec [GenerateChangeSetResponse]
readPrec :: ReadPrec GenerateChangeSetResponse
$creadPrec :: ReadPrec GenerateChangeSetResponse
readList :: ReadS [GenerateChangeSetResponse]
$creadList :: ReadS [GenerateChangeSetResponse]
readsPrec :: Int -> ReadS GenerateChangeSetResponse
$creadsPrec :: Int -> ReadS GenerateChangeSetResponse
Prelude.Read, Int -> GenerateChangeSetResponse -> ShowS
[GenerateChangeSetResponse] -> ShowS
GenerateChangeSetResponse -> String
(Int -> GenerateChangeSetResponse -> ShowS)
-> (GenerateChangeSetResponse -> String)
-> ([GenerateChangeSetResponse] -> ShowS)
-> Show GenerateChangeSetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateChangeSetResponse] -> ShowS
$cshowList :: [GenerateChangeSetResponse] -> ShowS
show :: GenerateChangeSetResponse -> String
$cshow :: GenerateChangeSetResponse -> String
showsPrec :: Int -> GenerateChangeSetResponse -> ShowS
$cshowsPrec :: Int -> GenerateChangeSetResponse -> ShowS
Prelude.Show, (forall x.
 GenerateChangeSetResponse -> Rep GenerateChangeSetResponse x)
-> (forall x.
    Rep GenerateChangeSetResponse x -> GenerateChangeSetResponse)
-> Generic GenerateChangeSetResponse
forall x.
Rep GenerateChangeSetResponse x -> GenerateChangeSetResponse
forall x.
GenerateChangeSetResponse -> Rep GenerateChangeSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GenerateChangeSetResponse x -> GenerateChangeSetResponse
$cfrom :: forall x.
GenerateChangeSetResponse -> Rep GenerateChangeSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'GenerateChangeSetResponse' 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:
--
-- 's3Location', 'generateChangeSetResponse_s3Location' - The location of the Amazon S3 object.
--
-- 'httpStatus', 'generateChangeSetResponse_httpStatus' - The response's http status code.
newGenerateChangeSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GenerateChangeSetResponse
newGenerateChangeSetResponse :: Int -> GenerateChangeSetResponse
newGenerateChangeSetResponse Int
pHttpStatus_ =
  GenerateChangeSetResponse' :: Maybe S3Location -> Int -> GenerateChangeSetResponse
GenerateChangeSetResponse'
    { $sel:s3Location:GenerateChangeSetResponse' :: Maybe S3Location
s3Location =
        Maybe S3Location
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GenerateChangeSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The location of the Amazon S3 object.
generateChangeSetResponse_s3Location :: Lens.Lens' GenerateChangeSetResponse (Prelude.Maybe S3Location)
generateChangeSetResponse_s3Location :: (Maybe S3Location -> f (Maybe S3Location))
-> GenerateChangeSetResponse -> f GenerateChangeSetResponse
generateChangeSetResponse_s3Location = (GenerateChangeSetResponse -> Maybe S3Location)
-> (GenerateChangeSetResponse
    -> Maybe S3Location -> GenerateChangeSetResponse)
-> Lens
     GenerateChangeSetResponse
     GenerateChangeSetResponse
     (Maybe S3Location)
     (Maybe S3Location)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateChangeSetResponse' {Maybe S3Location
s3Location :: Maybe S3Location
$sel:s3Location:GenerateChangeSetResponse' :: GenerateChangeSetResponse -> Maybe S3Location
s3Location} -> Maybe S3Location
s3Location) (\s :: GenerateChangeSetResponse
s@GenerateChangeSetResponse' {} Maybe S3Location
a -> GenerateChangeSetResponse
s {$sel:s3Location:GenerateChangeSetResponse' :: Maybe S3Location
s3Location = Maybe S3Location
a} :: GenerateChangeSetResponse)

-- | The response's http status code.
generateChangeSetResponse_httpStatus :: Lens.Lens' GenerateChangeSetResponse Prelude.Int
generateChangeSetResponse_httpStatus :: (Int -> f Int)
-> GenerateChangeSetResponse -> f GenerateChangeSetResponse
generateChangeSetResponse_httpStatus = (GenerateChangeSetResponse -> Int)
-> (GenerateChangeSetResponse -> Int -> GenerateChangeSetResponse)
-> Lens GenerateChangeSetResponse GenerateChangeSetResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateChangeSetResponse' {Int
httpStatus :: Int
$sel:httpStatus:GenerateChangeSetResponse' :: GenerateChangeSetResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GenerateChangeSetResponse
s@GenerateChangeSetResponse' {} Int
a -> GenerateChangeSetResponse
s {$sel:httpStatus:GenerateChangeSetResponse' :: Int
httpStatus = Int
a} :: GenerateChangeSetResponse)

instance Prelude.NFData GenerateChangeSetResponse