{-# 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.CreateTheme
-- 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 theme.
--
-- A /theme/ is set of configuration options for color and layout. Themes
-- apply to analyses and dashboards. For more information, see
-- <https://docs.aws.amazon.com/quicksight/latest/user/themes-in-quicksight.html Using Themes in Amazon QuickSight>
-- in the /Amazon QuickSight User Guide/.
module Amazonka.QuickSight.CreateTheme
  ( -- * Creating a Request
    CreateTheme (..),
    newCreateTheme,

    -- * Request Lenses
    createTheme_versionDescription,
    createTheme_permissions,
    createTheme_tags,
    createTheme_awsAccountId,
    createTheme_themeId,
    createTheme_name,
    createTheme_baseThemeId,
    createTheme_configuration,

    -- * Destructuring the Response
    CreateThemeResponse (..),
    newCreateThemeResponse,

    -- * Response Lenses
    createThemeResponse_requestId,
    createThemeResponse_themeId,
    createThemeResponse_arn,
    createThemeResponse_creationStatus,
    createThemeResponse_versionArn,
    createThemeResponse_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:/ 'newCreateTheme' smart constructor.
data CreateTheme = CreateTheme'
  { -- | A description of the first version of the theme that you\'re creating.
    -- Every time @UpdateTheme@ is called, a new version is created. Each
    -- version of the theme has a description of the version in the
    -- @VersionDescription@ field.
    CreateTheme -> Maybe Text
versionDescription :: Prelude.Maybe Prelude.Text,
    -- | A valid grouping of resource permissions to apply to the new theme.
    CreateTheme -> Maybe (NonEmpty ResourcePermission)
permissions :: Prelude.Maybe (Prelude.NonEmpty ResourcePermission),
    -- | A map of the key-value pairs for the resource tag or tags that you want
    -- to add to the resource.
    CreateTheme -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The ID of the Amazon Web Services account where you want to store the
    -- new theme.
    CreateTheme -> Text
awsAccountId :: Prelude.Text,
    -- | An ID for the theme that you want to create. The theme ID is unique per
    -- Amazon Web Services Region in each Amazon Web Services account.
    CreateTheme -> Text
themeId :: Prelude.Text,
    -- | A display name for the theme.
    CreateTheme -> Text
name :: Prelude.Text,
    -- | The ID of the theme that a custom theme will inherit from. All themes
    -- inherit from one of the starting themes defined by Amazon QuickSight.
    -- For a list of the starting themes, use @ListThemes@ or choose __Themes__
    -- from within a Amazon QuickSight analysis.
    CreateTheme -> Text
baseThemeId :: Prelude.Text,
    -- | The theme configuration, which contains the theme display properties.
    CreateTheme -> ThemeConfiguration
configuration :: ThemeConfiguration
  }
  deriving (CreateTheme -> CreateTheme -> Bool
(CreateTheme -> CreateTheme -> Bool)
-> (CreateTheme -> CreateTheme -> Bool) -> Eq CreateTheme
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateTheme -> CreateTheme -> Bool
$c/= :: CreateTheme -> CreateTheme -> Bool
== :: CreateTheme -> CreateTheme -> Bool
$c== :: CreateTheme -> CreateTheme -> Bool
Prelude.Eq, ReadPrec [CreateTheme]
ReadPrec CreateTheme
Int -> ReadS CreateTheme
ReadS [CreateTheme]
(Int -> ReadS CreateTheme)
-> ReadS [CreateTheme]
-> ReadPrec CreateTheme
-> ReadPrec [CreateTheme]
-> Read CreateTheme
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateTheme]
$creadListPrec :: ReadPrec [CreateTheme]
readPrec :: ReadPrec CreateTheme
$creadPrec :: ReadPrec CreateTheme
readList :: ReadS [CreateTheme]
$creadList :: ReadS [CreateTheme]
readsPrec :: Int -> ReadS CreateTheme
$creadsPrec :: Int -> ReadS CreateTheme
Prelude.Read, Int -> CreateTheme -> ShowS
[CreateTheme] -> ShowS
CreateTheme -> String
(Int -> CreateTheme -> ShowS)
-> (CreateTheme -> String)
-> ([CreateTheme] -> ShowS)
-> Show CreateTheme
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateTheme] -> ShowS
$cshowList :: [CreateTheme] -> ShowS
show :: CreateTheme -> String
$cshow :: CreateTheme -> String
showsPrec :: Int -> CreateTheme -> ShowS
$cshowsPrec :: Int -> CreateTheme -> ShowS
Prelude.Show, (forall x. CreateTheme -> Rep CreateTheme x)
-> (forall x. Rep CreateTheme x -> CreateTheme)
-> Generic CreateTheme
forall x. Rep CreateTheme x -> CreateTheme
forall x. CreateTheme -> Rep CreateTheme x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateTheme x -> CreateTheme
$cfrom :: forall x. CreateTheme -> Rep CreateTheme x
Prelude.Generic)

-- |
-- Create a value of 'CreateTheme' 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', 'createTheme_versionDescription' - A description of the first version of the theme that you\'re creating.
-- Every time @UpdateTheme@ is called, a new version is created. Each
-- version of the theme has a description of the version in the
-- @VersionDescription@ field.
--
-- 'permissions', 'createTheme_permissions' - A valid grouping of resource permissions to apply to the new theme.
--
-- 'tags', 'createTheme_tags' - A map of the key-value pairs for the resource tag or tags that you want
-- to add to the resource.
--
-- 'awsAccountId', 'createTheme_awsAccountId' - The ID of the Amazon Web Services account where you want to store the
-- new theme.
--
-- 'themeId', 'createTheme_themeId' - An ID for the theme that you want to create. The theme ID is unique per
-- Amazon Web Services Region in each Amazon Web Services account.
--
-- 'name', 'createTheme_name' - A display name for the theme.
--
-- 'baseThemeId', 'createTheme_baseThemeId' - The ID of the theme that a custom theme will inherit from. All themes
-- inherit from one of the starting themes defined by Amazon QuickSight.
-- For a list of the starting themes, use @ListThemes@ or choose __Themes__
-- from within a Amazon QuickSight analysis.
--
-- 'configuration', 'createTheme_configuration' - The theme configuration, which contains the theme display properties.
newCreateTheme ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'themeId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'baseThemeId'
  Prelude.Text ->
  -- | 'configuration'
  ThemeConfiguration ->
  CreateTheme
newCreateTheme :: Text -> Text -> Text -> Text -> ThemeConfiguration -> CreateTheme
newCreateTheme
  Text
pAwsAccountId_
  Text
pThemeId_
  Text
pName_
  Text
pBaseThemeId_
  ThemeConfiguration
pConfiguration_ =
    CreateTheme' :: Maybe Text
-> Maybe (NonEmpty ResourcePermission)
-> Maybe (NonEmpty Tag)
-> Text
-> Text
-> Text
-> Text
-> ThemeConfiguration
-> CreateTheme
CreateTheme'
      { $sel:versionDescription:CreateTheme' :: Maybe Text
versionDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:permissions:CreateTheme' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateTheme' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:awsAccountId:CreateTheme' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:themeId:CreateTheme' :: Text
themeId = Text
pThemeId_,
        $sel:name:CreateTheme' :: Text
name = Text
pName_,
        $sel:baseThemeId:CreateTheme' :: Text
baseThemeId = Text
pBaseThemeId_,
        $sel:configuration:CreateTheme' :: ThemeConfiguration
configuration = ThemeConfiguration
pConfiguration_
      }

-- | A description of the first version of the theme that you\'re creating.
-- Every time @UpdateTheme@ is called, a new version is created. Each
-- version of the theme has a description of the version in the
-- @VersionDescription@ field.
createTheme_versionDescription :: Lens.Lens' CreateTheme (Prelude.Maybe Prelude.Text)
createTheme_versionDescription :: (Maybe Text -> f (Maybe Text)) -> CreateTheme -> f CreateTheme
createTheme_versionDescription = (CreateTheme -> Maybe Text)
-> (CreateTheme -> Maybe Text -> CreateTheme)
-> Lens CreateTheme CreateTheme (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {Maybe Text
versionDescription :: Maybe Text
$sel:versionDescription:CreateTheme' :: CreateTheme -> Maybe Text
versionDescription} -> Maybe Text
versionDescription) (\s :: CreateTheme
s@CreateTheme' {} Maybe Text
a -> CreateTheme
s {$sel:versionDescription:CreateTheme' :: Maybe Text
versionDescription = Maybe Text
a} :: CreateTheme)

-- | A valid grouping of resource permissions to apply to the new theme.
createTheme_permissions :: Lens.Lens' CreateTheme (Prelude.Maybe (Prelude.NonEmpty ResourcePermission))
createTheme_permissions :: (Maybe (NonEmpty ResourcePermission)
 -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateTheme -> f CreateTheme
createTheme_permissions = (CreateTheme -> Maybe (NonEmpty ResourcePermission))
-> (CreateTheme
    -> Maybe (NonEmpty ResourcePermission) -> CreateTheme)
-> Lens
     CreateTheme
     CreateTheme
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {Maybe (NonEmpty ResourcePermission)
permissions :: Maybe (NonEmpty ResourcePermission)
$sel:permissions:CreateTheme' :: CreateTheme -> Maybe (NonEmpty ResourcePermission)
permissions} -> Maybe (NonEmpty ResourcePermission)
permissions) (\s :: CreateTheme
s@CreateTheme' {} Maybe (NonEmpty ResourcePermission)
a -> CreateTheme
s {$sel:permissions:CreateTheme' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
a} :: CreateTheme) ((Maybe (NonEmpty ResourcePermission)
  -> f (Maybe (NonEmpty ResourcePermission)))
 -> CreateTheme -> f CreateTheme)
-> ((Maybe (NonEmpty ResourcePermission)
     -> f (Maybe (NonEmpty ResourcePermission)))
    -> Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> (Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateTheme
-> f CreateTheme
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

-- | A map of the key-value pairs for the resource tag or tags that you want
-- to add to the resource.
createTheme_tags :: Lens.Lens' CreateTheme (Prelude.Maybe (Prelude.NonEmpty Tag))
createTheme_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateTheme -> f CreateTheme
createTheme_tags = (CreateTheme -> Maybe (NonEmpty Tag))
-> (CreateTheme -> Maybe (NonEmpty Tag) -> CreateTheme)
-> Lens
     CreateTheme
     CreateTheme
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateTheme' :: CreateTheme -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateTheme
s@CreateTheme' {} Maybe (NonEmpty Tag)
a -> CreateTheme
s {$sel:tags:CreateTheme' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateTheme) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateTheme -> f CreateTheme)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateTheme
-> f CreateTheme
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 of the Amazon Web Services account where you want to store the
-- new theme.
createTheme_awsAccountId :: Lens.Lens' CreateTheme Prelude.Text
createTheme_awsAccountId :: (Text -> f Text) -> CreateTheme -> f CreateTheme
createTheme_awsAccountId = (CreateTheme -> Text)
-> (CreateTheme -> Text -> CreateTheme)
-> Lens CreateTheme CreateTheme Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {Text
awsAccountId :: Text
$sel:awsAccountId:CreateTheme' :: CreateTheme -> Text
awsAccountId} -> Text
awsAccountId) (\s :: CreateTheme
s@CreateTheme' {} Text
a -> CreateTheme
s {$sel:awsAccountId:CreateTheme' :: Text
awsAccountId = Text
a} :: CreateTheme)

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

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

-- | The ID of the theme that a custom theme will inherit from. All themes
-- inherit from one of the starting themes defined by Amazon QuickSight.
-- For a list of the starting themes, use @ListThemes@ or choose __Themes__
-- from within a Amazon QuickSight analysis.
createTheme_baseThemeId :: Lens.Lens' CreateTheme Prelude.Text
createTheme_baseThemeId :: (Text -> f Text) -> CreateTheme -> f CreateTheme
createTheme_baseThemeId = (CreateTheme -> Text)
-> (CreateTheme -> Text -> CreateTheme)
-> Lens CreateTheme CreateTheme Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {Text
baseThemeId :: Text
$sel:baseThemeId:CreateTheme' :: CreateTheme -> Text
baseThemeId} -> Text
baseThemeId) (\s :: CreateTheme
s@CreateTheme' {} Text
a -> CreateTheme
s {$sel:baseThemeId:CreateTheme' :: Text
baseThemeId = Text
a} :: CreateTheme)

-- | The theme configuration, which contains the theme display properties.
createTheme_configuration :: Lens.Lens' CreateTheme ThemeConfiguration
createTheme_configuration :: (ThemeConfiguration -> f ThemeConfiguration)
-> CreateTheme -> f CreateTheme
createTheme_configuration = (CreateTheme -> ThemeConfiguration)
-> (CreateTheme -> ThemeConfiguration -> CreateTheme)
-> Lens
     CreateTheme CreateTheme ThemeConfiguration ThemeConfiguration
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateTheme' {ThemeConfiguration
configuration :: ThemeConfiguration
$sel:configuration:CreateTheme' :: CreateTheme -> ThemeConfiguration
configuration} -> ThemeConfiguration
configuration) (\s :: CreateTheme
s@CreateTheme' {} ThemeConfiguration
a -> CreateTheme
s {$sel:configuration:CreateTheme' :: ThemeConfiguration
configuration = ThemeConfiguration
a} :: CreateTheme)

instance Core.AWSRequest CreateTheme where
  type AWSResponse CreateTheme = CreateThemeResponse
  request :: CreateTheme -> Request CreateTheme
request = Service -> CreateTheme -> Request CreateTheme
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateTheme
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTheme)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateTheme))
-> Logger
-> Service
-> Proxy CreateTheme
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateTheme)))
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 Text
-> Maybe ResourceStatus
-> Maybe Text
-> Int
-> CreateThemeResponse
CreateThemeResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe ResourceStatus
 -> Maybe Text
 -> Int
 -> CreateThemeResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe ResourceStatus
      -> Maybe Text
      -> Int
      -> CreateThemeResponse)
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 Text
   -> Maybe ResourceStatus
   -> Maybe Text
   -> Int
   -> CreateThemeResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe ResourceStatus
      -> Maybe Text
      -> Int
      -> CreateThemeResponse)
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
"ThemeId")
            Either
  String
  (Maybe Text
   -> Maybe ResourceStatus
   -> Maybe Text
   -> Int
   -> CreateThemeResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe ResourceStatus -> Maybe Text -> Int -> CreateThemeResponse)
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 -> Int -> CreateThemeResponse)
-> Either String (Maybe ResourceStatus)
-> Either String (Maybe Text -> Int -> CreateThemeResponse)
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 -> Int -> CreateThemeResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateThemeResponse)
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 -> CreateThemeResponse)
-> Either String Int -> Either String CreateThemeResponse
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 CreateTheme

instance Prelude.NFData CreateTheme

instance Core.ToHeaders CreateTheme where
  toHeaders :: CreateTheme -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateTheme -> 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 CreateTheme where
  toJSON :: CreateTheme -> Value
toJSON CreateTheme' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Text
ThemeConfiguration
configuration :: ThemeConfiguration
baseThemeId :: Text
name :: Text
themeId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
versionDescription :: Maybe Text
$sel:configuration:CreateTheme' :: CreateTheme -> ThemeConfiguration
$sel:baseThemeId:CreateTheme' :: CreateTheme -> Text
$sel:name:CreateTheme' :: CreateTheme -> Text
$sel:themeId:CreateTheme' :: CreateTheme -> Text
$sel:awsAccountId:CreateTheme' :: CreateTheme -> Text
$sel:tags:CreateTheme' :: CreateTheme -> Maybe (NonEmpty Tag)
$sel:permissions:CreateTheme' :: CreateTheme -> Maybe (NonEmpty ResourcePermission)
$sel:versionDescription:CreateTheme' :: CreateTheme -> 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
"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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"BaseThemeId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
baseThemeId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"Configuration" Text -> ThemeConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ThemeConfiguration
configuration)
          ]
      )

instance Core.ToPath CreateTheme where
  toPath :: CreateTheme -> ByteString
toPath CreateTheme' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Text
ThemeConfiguration
configuration :: ThemeConfiguration
baseThemeId :: Text
name :: Text
themeId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
versionDescription :: Maybe Text
$sel:configuration:CreateTheme' :: CreateTheme -> ThemeConfiguration
$sel:baseThemeId:CreateTheme' :: CreateTheme -> Text
$sel:name:CreateTheme' :: CreateTheme -> Text
$sel:themeId:CreateTheme' :: CreateTheme -> Text
$sel:awsAccountId:CreateTheme' :: CreateTheme -> Text
$sel:tags:CreateTheme' :: CreateTheme -> Maybe (NonEmpty Tag)
$sel:permissions:CreateTheme' :: CreateTheme -> Maybe (NonEmpty ResourcePermission)
$sel:versionDescription:CreateTheme' :: CreateTheme -> 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
"/themes/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
themeId
      ]

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

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

-- |
-- Create a value of 'CreateThemeResponse' 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', 'createThemeResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'themeId', 'createThemeResponse_themeId' - The ID of the theme.
--
-- 'arn', 'createThemeResponse_arn' - The Amazon Resource Name (ARN) for the theme.
--
-- 'creationStatus', 'createThemeResponse_creationStatus' - The theme creation status.
--
-- 'versionArn', 'createThemeResponse_versionArn' - The Amazon Resource Name (ARN) for the new theme.
--
-- 'status', 'createThemeResponse_status' - The HTTP status of the request.
newCreateThemeResponse ::
  -- | 'status'
  Prelude.Int ->
  CreateThemeResponse
newCreateThemeResponse :: Int -> CreateThemeResponse
newCreateThemeResponse Int
pStatus_ =
  CreateThemeResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ResourceStatus
-> Maybe Text
-> Int
-> CreateThemeResponse
CreateThemeResponse'
    { $sel:requestId:CreateThemeResponse' :: Maybe Text
requestId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:themeId:CreateThemeResponse' :: Maybe Text
themeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CreateThemeResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationStatus:CreateThemeResponse' :: Maybe ResourceStatus
creationStatus = Maybe ResourceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:versionArn:CreateThemeResponse' :: Maybe Text
versionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:CreateThemeResponse' :: Int
status = Int
pStatus_
    }

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

-- | The ID of the theme.
createThemeResponse_themeId :: Lens.Lens' CreateThemeResponse (Prelude.Maybe Prelude.Text)
createThemeResponse_themeId :: (Maybe Text -> f (Maybe Text))
-> CreateThemeResponse -> f CreateThemeResponse
createThemeResponse_themeId = (CreateThemeResponse -> Maybe Text)
-> (CreateThemeResponse -> Maybe Text -> CreateThemeResponse)
-> Lens
     CreateThemeResponse CreateThemeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThemeResponse' {Maybe Text
themeId :: Maybe Text
$sel:themeId:CreateThemeResponse' :: CreateThemeResponse -> Maybe Text
themeId} -> Maybe Text
themeId) (\s :: CreateThemeResponse
s@CreateThemeResponse' {} Maybe Text
a -> CreateThemeResponse
s {$sel:themeId:CreateThemeResponse' :: Maybe Text
themeId = Maybe Text
a} :: CreateThemeResponse)

-- | The Amazon Resource Name (ARN) for the theme.
createThemeResponse_arn :: Lens.Lens' CreateThemeResponse (Prelude.Maybe Prelude.Text)
createThemeResponse_arn :: (Maybe Text -> f (Maybe Text))
-> CreateThemeResponse -> f CreateThemeResponse
createThemeResponse_arn = (CreateThemeResponse -> Maybe Text)
-> (CreateThemeResponse -> Maybe Text -> CreateThemeResponse)
-> Lens
     CreateThemeResponse CreateThemeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThemeResponse' {Maybe Text
arn :: Maybe Text
$sel:arn:CreateThemeResponse' :: CreateThemeResponse -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CreateThemeResponse
s@CreateThemeResponse' {} Maybe Text
a -> CreateThemeResponse
s {$sel:arn:CreateThemeResponse' :: Maybe Text
arn = Maybe Text
a} :: CreateThemeResponse)

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

-- | The Amazon Resource Name (ARN) for the new theme.
createThemeResponse_versionArn :: Lens.Lens' CreateThemeResponse (Prelude.Maybe Prelude.Text)
createThemeResponse_versionArn :: (Maybe Text -> f (Maybe Text))
-> CreateThemeResponse -> f CreateThemeResponse
createThemeResponse_versionArn = (CreateThemeResponse -> Maybe Text)
-> (CreateThemeResponse -> Maybe Text -> CreateThemeResponse)
-> Lens
     CreateThemeResponse CreateThemeResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateThemeResponse' {Maybe Text
versionArn :: Maybe Text
$sel:versionArn:CreateThemeResponse' :: CreateThemeResponse -> Maybe Text
versionArn} -> Maybe Text
versionArn) (\s :: CreateThemeResponse
s@CreateThemeResponse' {} Maybe Text
a -> CreateThemeResponse
s {$sel:versionArn:CreateThemeResponse' :: Maybe Text
versionArn = Maybe Text
a} :: CreateThemeResponse)

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

instance Prelude.NFData CreateThemeResponse