{-# 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.QuickSight.CreateTemplate
-- 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)
--
-- Creates a template from an existing Amazon QuickSight analysis or
-- template. You can use the resulting template to create a dashboard.
--
-- A /template/ is an entity in Amazon QuickSight that encapsulates the
-- metadata required to create an analysis and that you can use to create s
-- dashboard. A template adds a layer of abstraction by using placeholders
-- to replace the dataset associated with the analysis. You can use
-- templates to create dashboards by replacing dataset placeholders with
-- datasets that follow the same schema that was used to create the source
-- analysis and template.
module Amazonka.QuickSight.CreateTemplate
  ( -- * Creating a Request
    CreateTemplate (..),
    newCreateTemplate,

    -- * Request Lenses
    createTemplate_versionDescription,
    createTemplate_name,
    createTemplate_permissions,
    createTemplate_tags,
    createTemplate_awsAccountId,
    createTemplate_templateId,
    createTemplate_sourceEntity,

    -- * Destructuring the Response
    CreateTemplateResponse (..),
    newCreateTemplateResponse,

    -- * Response Lenses
    createTemplateResponse_requestId,
    createTemplateResponse_arn,
    createTemplateResponse_creationStatus,
    createTemplateResponse_templateId,
    createTemplateResponse_versionArn,
    createTemplateResponse_status,
  )
where

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

-- | /See:/ 'newCreateTemplate' smart constructor.
data CreateTemplate = CreateTemplate'
  { -- | A description of the current template version being created. This API
    -- operation creates the first version of the template. Every time
    -- @UpdateTemplate@ is called, a new version is created. Each version of
    -- the template maintains a description of the version in the
    -- @VersionDescription@ field.
    CreateTemplate -> Maybe Text
versionDescription :: Prelude.Maybe Prelude.Text,
    -- | A display name for the template.
    CreateTemplate -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A list of resource permissions to be set on the template.
    CreateTemplate -> Maybe (NonEmpty ResourcePermission)
permissions :: Prelude.Maybe (Prelude.NonEmpty ResourcePermission),
    -- | Contains a map of the key-value pairs for the resource tag or tags
    -- assigned to the resource.
    CreateTemplate -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The ID for the Amazon Web Services account that the group is in. You use
    -- the ID for the Amazon Web Services account that contains your Amazon
    -- QuickSight account.
    CreateTemplate -> Text
awsAccountId :: Prelude.Text,
    -- | An ID for the template that you want to create. This template is unique
    -- per Amazon Web Services Region; in each Amazon Web Services account.
    CreateTemplate -> Text
templateId :: Prelude.Text,
    -- | The entity that you are using as a source when you create the template.
    -- In @SourceEntity@, you specify the type of object you\'re using as
    -- source: @SourceTemplate@ for a template or @SourceAnalysis@ for an
    -- analysis. Both of these require an Amazon Resource Name (ARN). For
    -- @SourceTemplate@, specify the ARN of the source template. For
    -- @SourceAnalysis@, specify the ARN of the source analysis. The
    -- @SourceTemplate@ ARN can contain any Amazon Web Services account and any
    -- Amazon QuickSight-supported Amazon Web Services Region.
    --
    -- Use the @DataSetReferences@ entity within @SourceTemplate@ or
    -- @SourceAnalysis@ to list the replacement datasets for the placeholders
    -- listed in the original. The schema in each dataset must match its
    -- placeholder.
    CreateTemplate -> TemplateSourceEntity
sourceEntity :: TemplateSourceEntity
  }
  deriving (CreateTemplate -> CreateTemplate -> Bool
(CreateTemplate -> CreateTemplate -> Bool)
-> (CreateTemplate -> CreateTemplate -> Bool) -> Eq CreateTemplate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTemplate -> CreateTemplate -> Bool
$c/= :: CreateTemplate -> CreateTemplate -> Bool
== :: CreateTemplate -> CreateTemplate -> Bool
$c== :: CreateTemplate -> CreateTemplate -> Bool
Prelude.Eq, ReadPrec [CreateTemplate]
ReadPrec CreateTemplate
Int -> ReadS CreateTemplate
ReadS [CreateTemplate]
(Int -> ReadS CreateTemplate)
-> ReadS [CreateTemplate]
-> ReadPrec CreateTemplate
-> ReadPrec [CreateTemplate]
-> Read CreateTemplate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTemplate]
$creadListPrec :: ReadPrec [CreateTemplate]
readPrec :: ReadPrec CreateTemplate
$creadPrec :: ReadPrec CreateTemplate
readList :: ReadS [CreateTemplate]
$creadList :: ReadS [CreateTemplate]
readsPrec :: Int -> ReadS CreateTemplate
$creadsPrec :: Int -> ReadS CreateTemplate
Prelude.Read, Int -> CreateTemplate -> ShowS
[CreateTemplate] -> ShowS
CreateTemplate -> String
(Int -> CreateTemplate -> ShowS)
-> (CreateTemplate -> String)
-> ([CreateTemplate] -> ShowS)
-> Show CreateTemplate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTemplate] -> ShowS
$cshowList :: [CreateTemplate] -> ShowS
show :: CreateTemplate -> String
$cshow :: CreateTemplate -> String
showsPrec :: Int -> CreateTemplate -> ShowS
$cshowsPrec :: Int -> CreateTemplate -> ShowS
Prelude.Show, (forall x. CreateTemplate -> Rep CreateTemplate x)
-> (forall x. Rep CreateTemplate x -> CreateTemplate)
-> Generic CreateTemplate
forall x. Rep CreateTemplate x -> CreateTemplate
forall x. CreateTemplate -> Rep CreateTemplate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTemplate x -> CreateTemplate
$cfrom :: forall x. CreateTemplate -> Rep CreateTemplate x
Prelude.Generic)

-- |
-- Create a value of 'CreateTemplate' 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:
--
-- 'versionDescription', 'createTemplate_versionDescription' - A description of the current template version being created. This API
-- operation creates the first version of the template. Every time
-- @UpdateTemplate@ is called, a new version is created. Each version of
-- the template maintains a description of the version in the
-- @VersionDescription@ field.
--
-- 'name', 'createTemplate_name' - A display name for the template.
--
-- 'permissions', 'createTemplate_permissions' - A list of resource permissions to be set on the template.
--
-- 'tags', 'createTemplate_tags' - Contains a map of the key-value pairs for the resource tag or tags
-- assigned to the resource.
--
-- 'awsAccountId', 'createTemplate_awsAccountId' - The ID for the Amazon Web Services account that the group is in. You use
-- the ID for the Amazon Web Services account that contains your Amazon
-- QuickSight account.
--
-- 'templateId', 'createTemplate_templateId' - An ID for the template that you want to create. This template is unique
-- per Amazon Web Services Region; in each Amazon Web Services account.
--
-- 'sourceEntity', 'createTemplate_sourceEntity' - The entity that you are using as a source when you create the template.
-- In @SourceEntity@, you specify the type of object you\'re using as
-- source: @SourceTemplate@ for a template or @SourceAnalysis@ for an
-- analysis. Both of these require an Amazon Resource Name (ARN). For
-- @SourceTemplate@, specify the ARN of the source template. For
-- @SourceAnalysis@, specify the ARN of the source analysis. The
-- @SourceTemplate@ ARN can contain any Amazon Web Services account and any
-- Amazon QuickSight-supported Amazon Web Services Region.
--
-- Use the @DataSetReferences@ entity within @SourceTemplate@ or
-- @SourceAnalysis@ to list the replacement datasets for the placeholders
-- listed in the original. The schema in each dataset must match its
-- placeholder.
newCreateTemplate ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'templateId'
  Prelude.Text ->
  -- | 'sourceEntity'
  TemplateSourceEntity ->
  CreateTemplate
newCreateTemplate :: Text -> Text -> TemplateSourceEntity -> CreateTemplate
newCreateTemplate
  Text
pAwsAccountId_
  Text
pTemplateId_
  TemplateSourceEntity
pSourceEntity_ =
    CreateTemplate' :: Maybe Text
-> Maybe Text
-> Maybe (NonEmpty ResourcePermission)
-> Maybe (NonEmpty Tag)
-> Text
-> Text
-> TemplateSourceEntity
-> CreateTemplate
CreateTemplate'
      { $sel:versionDescription:CreateTemplate' :: Maybe Text
versionDescription =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateTemplate' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:permissions:CreateTemplate' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateTemplate' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:awsAccountId:CreateTemplate' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:templateId:CreateTemplate' :: Text
templateId = Text
pTemplateId_,
        $sel:sourceEntity:CreateTemplate' :: TemplateSourceEntity
sourceEntity = TemplateSourceEntity
pSourceEntity_
      }

-- | A description of the current template version being created. This API
-- operation creates the first version of the template. Every time
-- @UpdateTemplate@ is called, a new version is created. Each version of
-- the template maintains a description of the version in the
-- @VersionDescription@ field.
createTemplate_versionDescription :: Lens.Lens' CreateTemplate (Prelude.Maybe Prelude.Text)
createTemplate_versionDescription :: (Maybe Text -> f (Maybe Text))
-> CreateTemplate -> f CreateTemplate
createTemplate_versionDescription = (CreateTemplate -> Maybe Text)
-> (CreateTemplate -> Maybe Text -> CreateTemplate)
-> Lens CreateTemplate CreateTemplate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Maybe Text
versionDescription :: Maybe Text
$sel:versionDescription:CreateTemplate' :: CreateTemplate -> Maybe Text
versionDescription} -> Maybe Text
versionDescription) (\s :: CreateTemplate
s@CreateTemplate' {} Maybe Text
a -> CreateTemplate
s {$sel:versionDescription:CreateTemplate' :: Maybe Text
versionDescription = Maybe Text
a} :: CreateTemplate)

-- | A display name for the template.
createTemplate_name :: Lens.Lens' CreateTemplate (Prelude.Maybe Prelude.Text)
createTemplate_name :: (Maybe Text -> f (Maybe Text))
-> CreateTemplate -> f CreateTemplate
createTemplate_name = (CreateTemplate -> Maybe Text)
-> (CreateTemplate -> Maybe Text -> CreateTemplate)
-> Lens CreateTemplate CreateTemplate (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Maybe Text
name :: Maybe Text
$sel:name:CreateTemplate' :: CreateTemplate -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateTemplate
s@CreateTemplate' {} Maybe Text
a -> CreateTemplate
s {$sel:name:CreateTemplate' :: Maybe Text
name = Maybe Text
a} :: CreateTemplate)

-- | A list of resource permissions to be set on the template.
createTemplate_permissions :: Lens.Lens' CreateTemplate (Prelude.Maybe (Prelude.NonEmpty ResourcePermission))
createTemplate_permissions :: (Maybe (NonEmpty ResourcePermission)
 -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateTemplate -> f CreateTemplate
createTemplate_permissions = (CreateTemplate -> Maybe (NonEmpty ResourcePermission))
-> (CreateTemplate
    -> Maybe (NonEmpty ResourcePermission) -> CreateTemplate)
-> Lens
     CreateTemplate
     CreateTemplate
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Maybe (NonEmpty ResourcePermission)
permissions :: Maybe (NonEmpty ResourcePermission)
$sel:permissions:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty ResourcePermission)
permissions} -> Maybe (NonEmpty ResourcePermission)
permissions) (\s :: CreateTemplate
s@CreateTemplate' {} Maybe (NonEmpty ResourcePermission)
a -> CreateTemplate
s {$sel:permissions:CreateTemplate' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
a} :: CreateTemplate) ((Maybe (NonEmpty ResourcePermission)
  -> f (Maybe (NonEmpty ResourcePermission)))
 -> CreateTemplate -> f CreateTemplate)
-> ((Maybe (NonEmpty ResourcePermission)
     -> f (Maybe (NonEmpty ResourcePermission)))
    -> Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> (Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateTemplate
-> f CreateTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
-> Iso
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
  (NonEmpty ResourcePermission)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Contains a map of the key-value pairs for the resource tag or tags
-- assigned to the resource.
createTemplate_tags :: Lens.Lens' CreateTemplate (Prelude.Maybe (Prelude.NonEmpty Tag))
createTemplate_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateTemplate -> f CreateTemplate
createTemplate_tags = (CreateTemplate -> Maybe (NonEmpty Tag))
-> (CreateTemplate -> Maybe (NonEmpty Tag) -> CreateTemplate)
-> Lens
     CreateTemplate
     CreateTemplate
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateTemplate
s@CreateTemplate' {} Maybe (NonEmpty Tag)
a -> CreateTemplate
s {$sel:tags:CreateTemplate' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateTemplate) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateTemplate -> f CreateTemplate)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateTemplate
-> f CreateTemplate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ID for the Amazon Web Services account that the group is in. You use
-- the ID for the Amazon Web Services account that contains your Amazon
-- QuickSight account.
createTemplate_awsAccountId :: Lens.Lens' CreateTemplate Prelude.Text
createTemplate_awsAccountId :: (Text -> f Text) -> CreateTemplate -> f CreateTemplate
createTemplate_awsAccountId = (CreateTemplate -> Text)
-> (CreateTemplate -> Text -> CreateTemplate)
-> Lens CreateTemplate CreateTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Text
awsAccountId :: Text
$sel:awsAccountId:CreateTemplate' :: CreateTemplate -> Text
awsAccountId} -> Text
awsAccountId) (\s :: CreateTemplate
s@CreateTemplate' {} Text
a -> CreateTemplate
s {$sel:awsAccountId:CreateTemplate' :: Text
awsAccountId = Text
a} :: CreateTemplate)

-- | An ID for the template that you want to create. This template is unique
-- per Amazon Web Services Region; in each Amazon Web Services account.
createTemplate_templateId :: Lens.Lens' CreateTemplate Prelude.Text
createTemplate_templateId :: (Text -> f Text) -> CreateTemplate -> f CreateTemplate
createTemplate_templateId = (CreateTemplate -> Text)
-> (CreateTemplate -> Text -> CreateTemplate)
-> Lens CreateTemplate CreateTemplate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {Text
templateId :: Text
$sel:templateId:CreateTemplate' :: CreateTemplate -> Text
templateId} -> Text
templateId) (\s :: CreateTemplate
s@CreateTemplate' {} Text
a -> CreateTemplate
s {$sel:templateId:CreateTemplate' :: Text
templateId = Text
a} :: CreateTemplate)

-- | The entity that you are using as a source when you create the template.
-- In @SourceEntity@, you specify the type of object you\'re using as
-- source: @SourceTemplate@ for a template or @SourceAnalysis@ for an
-- analysis. Both of these require an Amazon Resource Name (ARN). For
-- @SourceTemplate@, specify the ARN of the source template. For
-- @SourceAnalysis@, specify the ARN of the source analysis. The
-- @SourceTemplate@ ARN can contain any Amazon Web Services account and any
-- Amazon QuickSight-supported Amazon Web Services Region.
--
-- Use the @DataSetReferences@ entity within @SourceTemplate@ or
-- @SourceAnalysis@ to list the replacement datasets for the placeholders
-- listed in the original. The schema in each dataset must match its
-- placeholder.
createTemplate_sourceEntity :: Lens.Lens' CreateTemplate TemplateSourceEntity
createTemplate_sourceEntity :: (TemplateSourceEntity -> f TemplateSourceEntity)
-> CreateTemplate -> f CreateTemplate
createTemplate_sourceEntity = (CreateTemplate -> TemplateSourceEntity)
-> (CreateTemplate -> TemplateSourceEntity -> CreateTemplate)
-> Lens
     CreateTemplate
     CreateTemplate
     TemplateSourceEntity
     TemplateSourceEntity
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplate' {TemplateSourceEntity
sourceEntity :: TemplateSourceEntity
$sel:sourceEntity:CreateTemplate' :: CreateTemplate -> TemplateSourceEntity
sourceEntity} -> TemplateSourceEntity
sourceEntity) (\s :: CreateTemplate
s@CreateTemplate' {} TemplateSourceEntity
a -> CreateTemplate
s {$sel:sourceEntity:CreateTemplate' :: TemplateSourceEntity
sourceEntity = TemplateSourceEntity
a} :: CreateTemplate)

instance Core.AWSRequest CreateTemplate where
  type
    AWSResponse CreateTemplate =
      CreateTemplateResponse
  request :: CreateTemplate -> Request CreateTemplate
request = Service -> CreateTemplate -> Request CreateTemplate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTemplate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTemplate))
-> Logger
-> Service
-> Proxy CreateTemplate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTemplate)))
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 Text
-> Maybe Text
-> Maybe ResourceStatus
-> Maybe Text
-> Maybe Text
-> Int
-> CreateTemplateResponse
CreateTemplateResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe ResourceStatus
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> CreateTemplateResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe ResourceStatus
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> CreateTemplateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RequestId")
            Either
  String
  (Maybe Text
   -> Maybe ResourceStatus
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> CreateTemplateResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe ResourceStatus
      -> Maybe Text -> Maybe Text -> Int -> CreateTemplateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Arn")
            Either
  String
  (Maybe ResourceStatus
   -> Maybe Text -> Maybe Text -> Int -> CreateTemplateResponse)
-> Either String (Maybe ResourceStatus)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> CreateTemplateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ResourceStatus)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CreationStatus")
            Either
  String (Maybe Text -> Maybe Text -> Int -> CreateTemplateResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> CreateTemplateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TemplateId")
            Either String (Maybe Text -> Int -> CreateTemplateResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateTemplateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"VersionArn")
            Either String (Int -> CreateTemplateResponse)
-> Either String Int -> Either String CreateTemplateResponse
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 CreateTemplate

instance Prelude.NFData CreateTemplate

instance Core.ToHeaders CreateTemplate where
  toHeaders :: CreateTemplate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTemplate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateTemplate where
  toJSON :: CreateTemplate -> Value
toJSON CreateTemplate' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Text
TemplateSourceEntity
sourceEntity :: TemplateSourceEntity
templateId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
name :: Maybe Text
versionDescription :: Maybe Text
$sel:sourceEntity:CreateTemplate' :: CreateTemplate -> TemplateSourceEntity
$sel:templateId:CreateTemplate' :: CreateTemplate -> Text
$sel:awsAccountId:CreateTemplate' :: CreateTemplate -> Text
$sel:tags:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty Tag)
$sel:permissions:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty ResourcePermission)
$sel:name:CreateTemplate' :: CreateTemplate -> Maybe Text
$sel:versionDescription:CreateTemplate' :: CreateTemplate -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VersionDescription" 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
versionDescription,
            (Text
"Name" 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
name,
            (Text
"Permissions" Text -> NonEmpty ResourcePermission -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty ResourcePermission -> Pair)
-> Maybe (NonEmpty ResourcePermission) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ResourcePermission)
permissions,
            (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SourceEntity" Text -> TemplateSourceEntity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TemplateSourceEntity
sourceEntity)
          ]
      )

instance Core.ToPath CreateTemplate where
  toPath :: CreateTemplate -> ByteString
toPath CreateTemplate' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Text
TemplateSourceEntity
sourceEntity :: TemplateSourceEntity
templateId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
name :: Maybe Text
versionDescription :: Maybe Text
$sel:sourceEntity:CreateTemplate' :: CreateTemplate -> TemplateSourceEntity
$sel:templateId:CreateTemplate' :: CreateTemplate -> Text
$sel:awsAccountId:CreateTemplate' :: CreateTemplate -> Text
$sel:tags:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty Tag)
$sel:permissions:CreateTemplate' :: CreateTemplate -> Maybe (NonEmpty ResourcePermission)
$sel:name:CreateTemplate' :: CreateTemplate -> Maybe Text
$sel:versionDescription:CreateTemplate' :: CreateTemplate -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/templates/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
templateId
      ]

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

-- | /See:/ 'newCreateTemplateResponse' smart constructor.
data CreateTemplateResponse = CreateTemplateResponse'
  { -- | The Amazon Web Services request ID for this operation.
    CreateTemplateResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The ARN for the template.
    CreateTemplateResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The template creation status.
    CreateTemplateResponse -> Maybe ResourceStatus
creationStatus :: Prelude.Maybe ResourceStatus,
    -- | The ID of the template.
    CreateTemplateResponse -> Maybe Text
templateId :: Prelude.Maybe Prelude.Text,
    -- | The ARN for the template, including the version information of the first
    -- version.
    CreateTemplateResponse -> Maybe Text
versionArn :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    CreateTemplateResponse -> Int
status :: Prelude.Int
  }
  deriving (CreateTemplateResponse -> CreateTemplateResponse -> Bool
(CreateTemplateResponse -> CreateTemplateResponse -> Bool)
-> (CreateTemplateResponse -> CreateTemplateResponse -> Bool)
-> Eq CreateTemplateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTemplateResponse -> CreateTemplateResponse -> Bool
$c/= :: CreateTemplateResponse -> CreateTemplateResponse -> Bool
== :: CreateTemplateResponse -> CreateTemplateResponse -> Bool
$c== :: CreateTemplateResponse -> CreateTemplateResponse -> Bool
Prelude.Eq, ReadPrec [CreateTemplateResponse]
ReadPrec CreateTemplateResponse
Int -> ReadS CreateTemplateResponse
ReadS [CreateTemplateResponse]
(Int -> ReadS CreateTemplateResponse)
-> ReadS [CreateTemplateResponse]
-> ReadPrec CreateTemplateResponse
-> ReadPrec [CreateTemplateResponse]
-> Read CreateTemplateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTemplateResponse]
$creadListPrec :: ReadPrec [CreateTemplateResponse]
readPrec :: ReadPrec CreateTemplateResponse
$creadPrec :: ReadPrec CreateTemplateResponse
readList :: ReadS [CreateTemplateResponse]
$creadList :: ReadS [CreateTemplateResponse]
readsPrec :: Int -> ReadS CreateTemplateResponse
$creadsPrec :: Int -> ReadS CreateTemplateResponse
Prelude.Read, Int -> CreateTemplateResponse -> ShowS
[CreateTemplateResponse] -> ShowS
CreateTemplateResponse -> String
(Int -> CreateTemplateResponse -> ShowS)
-> (CreateTemplateResponse -> String)
-> ([CreateTemplateResponse] -> ShowS)
-> Show CreateTemplateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTemplateResponse] -> ShowS
$cshowList :: [CreateTemplateResponse] -> ShowS
show :: CreateTemplateResponse -> String
$cshow :: CreateTemplateResponse -> String
showsPrec :: Int -> CreateTemplateResponse -> ShowS
$cshowsPrec :: Int -> CreateTemplateResponse -> ShowS
Prelude.Show, (forall x. CreateTemplateResponse -> Rep CreateTemplateResponse x)
-> (forall x.
    Rep CreateTemplateResponse x -> CreateTemplateResponse)
-> Generic CreateTemplateResponse
forall x. Rep CreateTemplateResponse x -> CreateTemplateResponse
forall x. CreateTemplateResponse -> Rep CreateTemplateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTemplateResponse x -> CreateTemplateResponse
$cfrom :: forall x. CreateTemplateResponse -> Rep CreateTemplateResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateTemplateResponse' 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:
--
-- 'requestId', 'createTemplateResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'arn', 'createTemplateResponse_arn' - The ARN for the template.
--
-- 'creationStatus', 'createTemplateResponse_creationStatus' - The template creation status.
--
-- 'templateId', 'createTemplateResponse_templateId' - The ID of the template.
--
-- 'versionArn', 'createTemplateResponse_versionArn' - The ARN for the template, including the version information of the first
-- version.
--
-- 'status', 'createTemplateResponse_status' - The HTTP status of the request.
newCreateTemplateResponse ::
  -- | 'status'
  Prelude.Int ->
  CreateTemplateResponse
newCreateTemplateResponse :: Int -> CreateTemplateResponse
newCreateTemplateResponse Int
pStatus_ =
  CreateTemplateResponse' :: Maybe Text
-> Maybe Text
-> Maybe ResourceStatus
-> Maybe Text
-> Maybe Text
-> Int
-> CreateTemplateResponse
CreateTemplateResponse'
    { $sel:requestId:CreateTemplateResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CreateTemplateResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationStatus:CreateTemplateResponse' :: Maybe ResourceStatus
creationStatus = Maybe ResourceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:templateId:CreateTemplateResponse' :: Maybe Text
templateId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:versionArn:CreateTemplateResponse' :: Maybe Text
versionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:CreateTemplateResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
createTemplateResponse_requestId :: Lens.Lens' CreateTemplateResponse (Prelude.Maybe Prelude.Text)
createTemplateResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_requestId = (CreateTemplateResponse -> Maybe Text)
-> (CreateTemplateResponse -> Maybe Text -> CreateTemplateResponse)
-> Lens
     CreateTemplateResponse
     CreateTemplateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:CreateTemplateResponse' :: CreateTemplateResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Maybe Text
a -> CreateTemplateResponse
s {$sel:requestId:CreateTemplateResponse' :: Maybe Text
requestId = Maybe Text
a} :: CreateTemplateResponse)

-- | The ARN for the template.
createTemplateResponse_arn :: Lens.Lens' CreateTemplateResponse (Prelude.Maybe Prelude.Text)
createTemplateResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_arn = (CreateTemplateResponse -> Maybe Text)
-> (CreateTemplateResponse -> Maybe Text -> CreateTemplateResponse)
-> Lens
     CreateTemplateResponse
     CreateTemplateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CreateTemplateResponse' :: CreateTemplateResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Maybe Text
a -> CreateTemplateResponse
s {$sel:arn:CreateTemplateResponse' :: Maybe Text
arn = Maybe Text
a} :: CreateTemplateResponse)

-- | The template creation status.
createTemplateResponse_creationStatus :: Lens.Lens' CreateTemplateResponse (Prelude.Maybe ResourceStatus)
createTemplateResponse_creationStatus :: (Maybe ResourceStatus -> f (Maybe ResourceStatus))
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_creationStatus = (CreateTemplateResponse -> Maybe ResourceStatus)
-> (CreateTemplateResponse
    -> Maybe ResourceStatus -> CreateTemplateResponse)
-> Lens
     CreateTemplateResponse
     CreateTemplateResponse
     (Maybe ResourceStatus)
     (Maybe ResourceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Maybe ResourceStatus
creationStatus :: Maybe ResourceStatus
$sel:creationStatus:CreateTemplateResponse' :: CreateTemplateResponse -> Maybe ResourceStatus
creationStatus} -> Maybe ResourceStatus
creationStatus) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Maybe ResourceStatus
a -> CreateTemplateResponse
s {$sel:creationStatus:CreateTemplateResponse' :: Maybe ResourceStatus
creationStatus = Maybe ResourceStatus
a} :: CreateTemplateResponse)

-- | The ID of the template.
createTemplateResponse_templateId :: Lens.Lens' CreateTemplateResponse (Prelude.Maybe Prelude.Text)
createTemplateResponse_templateId :: (Maybe Text -> f (Maybe Text))
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_templateId = (CreateTemplateResponse -> Maybe Text)
-> (CreateTemplateResponse -> Maybe Text -> CreateTemplateResponse)
-> Lens
     CreateTemplateResponse
     CreateTemplateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Maybe Text
templateId :: Maybe Text
$sel:templateId:CreateTemplateResponse' :: CreateTemplateResponse -> Maybe Text
templateId} -> Maybe Text
templateId) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Maybe Text
a -> CreateTemplateResponse
s {$sel:templateId:CreateTemplateResponse' :: Maybe Text
templateId = Maybe Text
a} :: CreateTemplateResponse)

-- | The ARN for the template, including the version information of the first
-- version.
createTemplateResponse_versionArn :: Lens.Lens' CreateTemplateResponse (Prelude.Maybe Prelude.Text)
createTemplateResponse_versionArn :: (Maybe Text -> f (Maybe Text))
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_versionArn = (CreateTemplateResponse -> Maybe Text)
-> (CreateTemplateResponse -> Maybe Text -> CreateTemplateResponse)
-> Lens
     CreateTemplateResponse
     CreateTemplateResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Maybe Text
versionArn :: Maybe Text
$sel:versionArn:CreateTemplateResponse' :: CreateTemplateResponse -> Maybe Text
versionArn} -> Maybe Text
versionArn) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Maybe Text
a -> CreateTemplateResponse
s {$sel:versionArn:CreateTemplateResponse' :: Maybe Text
versionArn = Maybe Text
a} :: CreateTemplateResponse)

-- | The HTTP status of the request.
createTemplateResponse_status :: Lens.Lens' CreateTemplateResponse Prelude.Int
createTemplateResponse_status :: (Int -> f Int)
-> CreateTemplateResponse -> f CreateTemplateResponse
createTemplateResponse_status = (CreateTemplateResponse -> Int)
-> (CreateTemplateResponse -> Int -> CreateTemplateResponse)
-> Lens CreateTemplateResponse CreateTemplateResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTemplateResponse' {Int
status :: Int
$sel:status:CreateTemplateResponse' :: CreateTemplateResponse -> Int
status} -> Int
status) (\s :: CreateTemplateResponse
s@CreateTemplateResponse' {} Int
a -> CreateTemplateResponse
s {$sel:status:CreateTemplateResponse' :: Int
status = Int
a} :: CreateTemplateResponse)

instance Prelude.NFData CreateTemplateResponse