{-# 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.CreateAnalysis
-- 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 an analysis in Amazon QuickSight.
module Amazonka.QuickSight.CreateAnalysis
  ( -- * Creating a Request
    CreateAnalysis (..),
    newCreateAnalysis,

    -- * Request Lenses
    createAnalysis_themeArn,
    createAnalysis_parameters,
    createAnalysis_permissions,
    createAnalysis_tags,
    createAnalysis_awsAccountId,
    createAnalysis_analysisId,
    createAnalysis_name,
    createAnalysis_sourceEntity,

    -- * Destructuring the Response
    CreateAnalysisResponse (..),
    newCreateAnalysisResponse,

    -- * Response Lenses
    createAnalysisResponse_requestId,
    createAnalysisResponse_analysisId,
    createAnalysisResponse_arn,
    createAnalysisResponse_creationStatus,
    createAnalysisResponse_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:/ 'newCreateAnalysis' smart constructor.
data CreateAnalysis = CreateAnalysis'
  { -- | The ARN for the theme to apply to the analysis that you\'re creating. To
    -- see the theme in the Amazon QuickSight console, make sure that you have
    -- access to it.
    CreateAnalysis -> Maybe Text
themeArn :: Prelude.Maybe Prelude.Text,
    -- | The parameter names and override values that you want to use. An
    -- analysis can have any parameter type, and some parameters might accept
    -- multiple values.
    CreateAnalysis -> Maybe Parameters
parameters :: Prelude.Maybe Parameters,
    -- | A structure that describes the principals and the resource-level
    -- permissions on an analysis. You can use the @Permissions@ structure to
    -- grant permissions by providing a list of Identity and Access Management
    -- (IAM) action information for each principal listed by Amazon Resource
    -- Name (ARN).
    --
    -- To specify no permissions, omit @Permissions@.
    CreateAnalysis -> 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 analysis.
    CreateAnalysis -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The ID of the Amazon Web Services account where you are creating an
    -- analysis.
    CreateAnalysis -> Text
awsAccountId :: Prelude.Text,
    -- | The ID for the analysis that you\'re creating. This ID displays in the
    -- URL of the analysis.
    CreateAnalysis -> Text
analysisId :: Prelude.Text,
    -- | A descriptive name for the analysis that you\'re creating. This name
    -- displays for the analysis in the Amazon QuickSight console.
    CreateAnalysis -> Text
name :: Prelude.Text,
    -- | A source entity to use for the analysis that you\'re creating. This
    -- metadata structure contains details that describe a source template and
    -- one or more datasets.
    CreateAnalysis -> AnalysisSourceEntity
sourceEntity :: AnalysisSourceEntity
  }
  deriving (CreateAnalysis -> CreateAnalysis -> Bool
(CreateAnalysis -> CreateAnalysis -> Bool)
-> (CreateAnalysis -> CreateAnalysis -> Bool) -> Eq CreateAnalysis
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAnalysis -> CreateAnalysis -> Bool
$c/= :: CreateAnalysis -> CreateAnalysis -> Bool
== :: CreateAnalysis -> CreateAnalysis -> Bool
$c== :: CreateAnalysis -> CreateAnalysis -> Bool
Prelude.Eq, ReadPrec [CreateAnalysis]
ReadPrec CreateAnalysis
Int -> ReadS CreateAnalysis
ReadS [CreateAnalysis]
(Int -> ReadS CreateAnalysis)
-> ReadS [CreateAnalysis]
-> ReadPrec CreateAnalysis
-> ReadPrec [CreateAnalysis]
-> Read CreateAnalysis
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAnalysis]
$creadListPrec :: ReadPrec [CreateAnalysis]
readPrec :: ReadPrec CreateAnalysis
$creadPrec :: ReadPrec CreateAnalysis
readList :: ReadS [CreateAnalysis]
$creadList :: ReadS [CreateAnalysis]
readsPrec :: Int -> ReadS CreateAnalysis
$creadsPrec :: Int -> ReadS CreateAnalysis
Prelude.Read, Int -> CreateAnalysis -> ShowS
[CreateAnalysis] -> ShowS
CreateAnalysis -> String
(Int -> CreateAnalysis -> ShowS)
-> (CreateAnalysis -> String)
-> ([CreateAnalysis] -> ShowS)
-> Show CreateAnalysis
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAnalysis] -> ShowS
$cshowList :: [CreateAnalysis] -> ShowS
show :: CreateAnalysis -> String
$cshow :: CreateAnalysis -> String
showsPrec :: Int -> CreateAnalysis -> ShowS
$cshowsPrec :: Int -> CreateAnalysis -> ShowS
Prelude.Show, (forall x. CreateAnalysis -> Rep CreateAnalysis x)
-> (forall x. Rep CreateAnalysis x -> CreateAnalysis)
-> Generic CreateAnalysis
forall x. Rep CreateAnalysis x -> CreateAnalysis
forall x. CreateAnalysis -> Rep CreateAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAnalysis x -> CreateAnalysis
$cfrom :: forall x. CreateAnalysis -> Rep CreateAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'CreateAnalysis' 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:
--
-- 'themeArn', 'createAnalysis_themeArn' - The ARN for the theme to apply to the analysis that you\'re creating. To
-- see the theme in the Amazon QuickSight console, make sure that you have
-- access to it.
--
-- 'parameters', 'createAnalysis_parameters' - The parameter names and override values that you want to use. An
-- analysis can have any parameter type, and some parameters might accept
-- multiple values.
--
-- 'permissions', 'createAnalysis_permissions' - A structure that describes the principals and the resource-level
-- permissions on an analysis. You can use the @Permissions@ structure to
-- grant permissions by providing a list of Identity and Access Management
-- (IAM) action information for each principal listed by Amazon Resource
-- Name (ARN).
--
-- To specify no permissions, omit @Permissions@.
--
-- 'tags', 'createAnalysis_tags' - Contains a map of the key-value pairs for the resource tag or tags
-- assigned to the analysis.
--
-- 'awsAccountId', 'createAnalysis_awsAccountId' - The ID of the Amazon Web Services account where you are creating an
-- analysis.
--
-- 'analysisId', 'createAnalysis_analysisId' - The ID for the analysis that you\'re creating. This ID displays in the
-- URL of the analysis.
--
-- 'name', 'createAnalysis_name' - A descriptive name for the analysis that you\'re creating. This name
-- displays for the analysis in the Amazon QuickSight console.
--
-- 'sourceEntity', 'createAnalysis_sourceEntity' - A source entity to use for the analysis that you\'re creating. This
-- metadata structure contains details that describe a source template and
-- one or more datasets.
newCreateAnalysis ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'analysisId'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  -- | 'sourceEntity'
  AnalysisSourceEntity ->
  CreateAnalysis
newCreateAnalysis :: Text -> Text -> Text -> AnalysisSourceEntity -> CreateAnalysis
newCreateAnalysis
  Text
pAwsAccountId_
  Text
pAnalysisId_
  Text
pName_
  AnalysisSourceEntity
pSourceEntity_ =
    CreateAnalysis' :: Maybe Text
-> Maybe Parameters
-> Maybe (NonEmpty ResourcePermission)
-> Maybe (NonEmpty Tag)
-> Text
-> Text
-> Text
-> AnalysisSourceEntity
-> CreateAnalysis
CreateAnalysis'
      { $sel:themeArn:CreateAnalysis' :: Maybe Text
themeArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:parameters:CreateAnalysis' :: Maybe Parameters
parameters = Maybe Parameters
forall a. Maybe a
Prelude.Nothing,
        $sel:permissions:CreateAnalysis' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateAnalysis' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
        $sel:awsAccountId:CreateAnalysis' :: Text
awsAccountId = Text
pAwsAccountId_,
        $sel:analysisId:CreateAnalysis' :: Text
analysisId = Text
pAnalysisId_,
        $sel:name:CreateAnalysis' :: Text
name = Text
pName_,
        $sel:sourceEntity:CreateAnalysis' :: AnalysisSourceEntity
sourceEntity = AnalysisSourceEntity
pSourceEntity_
      }

-- | The ARN for the theme to apply to the analysis that you\'re creating. To
-- see the theme in the Amazon QuickSight console, make sure that you have
-- access to it.
createAnalysis_themeArn :: Lens.Lens' CreateAnalysis (Prelude.Maybe Prelude.Text)
createAnalysis_themeArn :: (Maybe Text -> f (Maybe Text))
-> CreateAnalysis -> f CreateAnalysis
createAnalysis_themeArn = (CreateAnalysis -> Maybe Text)
-> (CreateAnalysis -> Maybe Text -> CreateAnalysis)
-> Lens CreateAnalysis CreateAnalysis (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Maybe Text
themeArn :: Maybe Text
$sel:themeArn:CreateAnalysis' :: CreateAnalysis -> Maybe Text
themeArn} -> Maybe Text
themeArn) (\s :: CreateAnalysis
s@CreateAnalysis' {} Maybe Text
a -> CreateAnalysis
s {$sel:themeArn:CreateAnalysis' :: Maybe Text
themeArn = Maybe Text
a} :: CreateAnalysis)

-- | The parameter names and override values that you want to use. An
-- analysis can have any parameter type, and some parameters might accept
-- multiple values.
createAnalysis_parameters :: Lens.Lens' CreateAnalysis (Prelude.Maybe Parameters)
createAnalysis_parameters :: (Maybe Parameters -> f (Maybe Parameters))
-> CreateAnalysis -> f CreateAnalysis
createAnalysis_parameters = (CreateAnalysis -> Maybe Parameters)
-> (CreateAnalysis -> Maybe Parameters -> CreateAnalysis)
-> Lens
     CreateAnalysis CreateAnalysis (Maybe Parameters) (Maybe Parameters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Maybe Parameters
parameters :: Maybe Parameters
$sel:parameters:CreateAnalysis' :: CreateAnalysis -> Maybe Parameters
parameters} -> Maybe Parameters
parameters) (\s :: CreateAnalysis
s@CreateAnalysis' {} Maybe Parameters
a -> CreateAnalysis
s {$sel:parameters:CreateAnalysis' :: Maybe Parameters
parameters = Maybe Parameters
a} :: CreateAnalysis)

-- | A structure that describes the principals and the resource-level
-- permissions on an analysis. You can use the @Permissions@ structure to
-- grant permissions by providing a list of Identity and Access Management
-- (IAM) action information for each principal listed by Amazon Resource
-- Name (ARN).
--
-- To specify no permissions, omit @Permissions@.
createAnalysis_permissions :: Lens.Lens' CreateAnalysis (Prelude.Maybe (Prelude.NonEmpty ResourcePermission))
createAnalysis_permissions :: (Maybe (NonEmpty ResourcePermission)
 -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateAnalysis -> f CreateAnalysis
createAnalysis_permissions = (CreateAnalysis -> Maybe (NonEmpty ResourcePermission))
-> (CreateAnalysis
    -> Maybe (NonEmpty ResourcePermission) -> CreateAnalysis)
-> Lens
     CreateAnalysis
     CreateAnalysis
     (Maybe (NonEmpty ResourcePermission))
     (Maybe (NonEmpty ResourcePermission))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Maybe (NonEmpty ResourcePermission)
permissions :: Maybe (NonEmpty ResourcePermission)
$sel:permissions:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty ResourcePermission)
permissions} -> Maybe (NonEmpty ResourcePermission)
permissions) (\s :: CreateAnalysis
s@CreateAnalysis' {} Maybe (NonEmpty ResourcePermission)
a -> CreateAnalysis
s {$sel:permissions:CreateAnalysis' :: Maybe (NonEmpty ResourcePermission)
permissions = Maybe (NonEmpty ResourcePermission)
a} :: CreateAnalysis) ((Maybe (NonEmpty ResourcePermission)
  -> f (Maybe (NonEmpty ResourcePermission)))
 -> CreateAnalysis -> f CreateAnalysis)
-> ((Maybe (NonEmpty ResourcePermission)
     -> f (Maybe (NonEmpty ResourcePermission)))
    -> Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> (Maybe (NonEmpty ResourcePermission)
    -> f (Maybe (NonEmpty ResourcePermission)))
-> CreateAnalysis
-> f CreateAnalysis
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 analysis.
createAnalysis_tags :: Lens.Lens' CreateAnalysis (Prelude.Maybe (Prelude.NonEmpty Tag))
createAnalysis_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateAnalysis -> f CreateAnalysis
createAnalysis_tags = (CreateAnalysis -> Maybe (NonEmpty Tag))
-> (CreateAnalysis -> Maybe (NonEmpty Tag) -> CreateAnalysis)
-> Lens
     CreateAnalysis
     CreateAnalysis
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateAnalysis
s@CreateAnalysis' {} Maybe (NonEmpty Tag)
a -> CreateAnalysis
s {$sel:tags:CreateAnalysis' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateAnalysis) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateAnalysis -> f CreateAnalysis)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateAnalysis
-> f CreateAnalysis
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 are creating an
-- analysis.
createAnalysis_awsAccountId :: Lens.Lens' CreateAnalysis Prelude.Text
createAnalysis_awsAccountId :: (Text -> f Text) -> CreateAnalysis -> f CreateAnalysis
createAnalysis_awsAccountId = (CreateAnalysis -> Text)
-> (CreateAnalysis -> Text -> CreateAnalysis)
-> Lens CreateAnalysis CreateAnalysis Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Text
awsAccountId :: Text
$sel:awsAccountId:CreateAnalysis' :: CreateAnalysis -> Text
awsAccountId} -> Text
awsAccountId) (\s :: CreateAnalysis
s@CreateAnalysis' {} Text
a -> CreateAnalysis
s {$sel:awsAccountId:CreateAnalysis' :: Text
awsAccountId = Text
a} :: CreateAnalysis)

-- | The ID for the analysis that you\'re creating. This ID displays in the
-- URL of the analysis.
createAnalysis_analysisId :: Lens.Lens' CreateAnalysis Prelude.Text
createAnalysis_analysisId :: (Text -> f Text) -> CreateAnalysis -> f CreateAnalysis
createAnalysis_analysisId = (CreateAnalysis -> Text)
-> (CreateAnalysis -> Text -> CreateAnalysis)
-> Lens CreateAnalysis CreateAnalysis Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Text
analysisId :: Text
$sel:analysisId:CreateAnalysis' :: CreateAnalysis -> Text
analysisId} -> Text
analysisId) (\s :: CreateAnalysis
s@CreateAnalysis' {} Text
a -> CreateAnalysis
s {$sel:analysisId:CreateAnalysis' :: Text
analysisId = Text
a} :: CreateAnalysis)

-- | A descriptive name for the analysis that you\'re creating. This name
-- displays for the analysis in the Amazon QuickSight console.
createAnalysis_name :: Lens.Lens' CreateAnalysis Prelude.Text
createAnalysis_name :: (Text -> f Text) -> CreateAnalysis -> f CreateAnalysis
createAnalysis_name = (CreateAnalysis -> Text)
-> (CreateAnalysis -> Text -> CreateAnalysis)
-> Lens CreateAnalysis CreateAnalysis Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {Text
name :: Text
$sel:name:CreateAnalysis' :: CreateAnalysis -> Text
name} -> Text
name) (\s :: CreateAnalysis
s@CreateAnalysis' {} Text
a -> CreateAnalysis
s {$sel:name:CreateAnalysis' :: Text
name = Text
a} :: CreateAnalysis)

-- | A source entity to use for the analysis that you\'re creating. This
-- metadata structure contains details that describe a source template and
-- one or more datasets.
createAnalysis_sourceEntity :: Lens.Lens' CreateAnalysis AnalysisSourceEntity
createAnalysis_sourceEntity :: (AnalysisSourceEntity -> f AnalysisSourceEntity)
-> CreateAnalysis -> f CreateAnalysis
createAnalysis_sourceEntity = (CreateAnalysis -> AnalysisSourceEntity)
-> (CreateAnalysis -> AnalysisSourceEntity -> CreateAnalysis)
-> Lens
     CreateAnalysis
     CreateAnalysis
     AnalysisSourceEntity
     AnalysisSourceEntity
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysis' {AnalysisSourceEntity
sourceEntity :: AnalysisSourceEntity
$sel:sourceEntity:CreateAnalysis' :: CreateAnalysis -> AnalysisSourceEntity
sourceEntity} -> AnalysisSourceEntity
sourceEntity) (\s :: CreateAnalysis
s@CreateAnalysis' {} AnalysisSourceEntity
a -> CreateAnalysis
s {$sel:sourceEntity:CreateAnalysis' :: AnalysisSourceEntity
sourceEntity = AnalysisSourceEntity
a} :: CreateAnalysis)

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

instance Prelude.NFData CreateAnalysis

instance Core.ToHeaders CreateAnalysis where
  toHeaders :: CreateAnalysis -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateAnalysis -> 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 CreateAnalysis where
  toJSON :: CreateAnalysis -> Value
toJSON CreateAnalysis' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Maybe Parameters
Text
AnalysisSourceEntity
sourceEntity :: AnalysisSourceEntity
name :: Text
analysisId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
parameters :: Maybe Parameters
themeArn :: Maybe Text
$sel:sourceEntity:CreateAnalysis' :: CreateAnalysis -> AnalysisSourceEntity
$sel:name:CreateAnalysis' :: CreateAnalysis -> Text
$sel:analysisId:CreateAnalysis' :: CreateAnalysis -> Text
$sel:awsAccountId:CreateAnalysis' :: CreateAnalysis -> Text
$sel:tags:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty Tag)
$sel:permissions:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty ResourcePermission)
$sel:parameters:CreateAnalysis' :: CreateAnalysis -> Maybe Parameters
$sel:themeArn:CreateAnalysis' :: CreateAnalysis -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ThemeArn" 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
themeArn,
            (Text
"Parameters" Text -> Parameters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Parameters -> Pair) -> Maybe Parameters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Parameters
parameters,
            (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
"SourceEntity" Text -> AnalysisSourceEntity -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AnalysisSourceEntity
sourceEntity)
          ]
      )

instance Core.ToPath CreateAnalysis where
  toPath :: CreateAnalysis -> ByteString
toPath CreateAnalysis' {Maybe (NonEmpty ResourcePermission)
Maybe (NonEmpty Tag)
Maybe Text
Maybe Parameters
Text
AnalysisSourceEntity
sourceEntity :: AnalysisSourceEntity
name :: Text
analysisId :: Text
awsAccountId :: Text
tags :: Maybe (NonEmpty Tag)
permissions :: Maybe (NonEmpty ResourcePermission)
parameters :: Maybe Parameters
themeArn :: Maybe Text
$sel:sourceEntity:CreateAnalysis' :: CreateAnalysis -> AnalysisSourceEntity
$sel:name:CreateAnalysis' :: CreateAnalysis -> Text
$sel:analysisId:CreateAnalysis' :: CreateAnalysis -> Text
$sel:awsAccountId:CreateAnalysis' :: CreateAnalysis -> Text
$sel:tags:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty Tag)
$sel:permissions:CreateAnalysis' :: CreateAnalysis -> Maybe (NonEmpty ResourcePermission)
$sel:parameters:CreateAnalysis' :: CreateAnalysis -> Maybe Parameters
$sel:themeArn:CreateAnalysis' :: CreateAnalysis -> 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
"/analyses/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
analysisId
      ]

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

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

-- |
-- Create a value of 'CreateAnalysisResponse' 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', 'createAnalysisResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'analysisId', 'createAnalysisResponse_analysisId' - The ID of the analysis.
--
-- 'arn', 'createAnalysisResponse_arn' - The ARN for the analysis.
--
-- 'creationStatus', 'createAnalysisResponse_creationStatus' - The status of the creation of the analysis.
--
-- 'status', 'createAnalysisResponse_status' - The HTTP status of the request.
newCreateAnalysisResponse ::
  -- | 'status'
  Prelude.Int ->
  CreateAnalysisResponse
newCreateAnalysisResponse :: Int -> CreateAnalysisResponse
newCreateAnalysisResponse Int
pStatus_ =
  CreateAnalysisResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe ResourceStatus
-> Int
-> CreateAnalysisResponse
CreateAnalysisResponse'
    { $sel:requestId:CreateAnalysisResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisId:CreateAnalysisResponse' :: Maybe Text
analysisId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CreateAnalysisResponse' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationStatus:CreateAnalysisResponse' :: Maybe ResourceStatus
creationStatus = Maybe ResourceStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:status:CreateAnalysisResponse' :: Int
status = Int
pStatus_
    }

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

-- | The ID of the analysis.
createAnalysisResponse_analysisId :: Lens.Lens' CreateAnalysisResponse (Prelude.Maybe Prelude.Text)
createAnalysisResponse_analysisId :: (Maybe Text -> f (Maybe Text))
-> CreateAnalysisResponse -> f CreateAnalysisResponse
createAnalysisResponse_analysisId = (CreateAnalysisResponse -> Maybe Text)
-> (CreateAnalysisResponse -> Maybe Text -> CreateAnalysisResponse)
-> Lens
     CreateAnalysisResponse
     CreateAnalysisResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysisResponse' {Maybe Text
analysisId :: Maybe Text
$sel:analysisId:CreateAnalysisResponse' :: CreateAnalysisResponse -> Maybe Text
analysisId} -> Maybe Text
analysisId) (\s :: CreateAnalysisResponse
s@CreateAnalysisResponse' {} Maybe Text
a -> CreateAnalysisResponse
s {$sel:analysisId:CreateAnalysisResponse' :: Maybe Text
analysisId = Maybe Text
a} :: CreateAnalysisResponse)

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

-- | The status of the creation of the analysis.
createAnalysisResponse_creationStatus :: Lens.Lens' CreateAnalysisResponse (Prelude.Maybe ResourceStatus)
createAnalysisResponse_creationStatus :: (Maybe ResourceStatus -> f (Maybe ResourceStatus))
-> CreateAnalysisResponse -> f CreateAnalysisResponse
createAnalysisResponse_creationStatus = (CreateAnalysisResponse -> Maybe ResourceStatus)
-> (CreateAnalysisResponse
    -> Maybe ResourceStatus -> CreateAnalysisResponse)
-> Lens
     CreateAnalysisResponse
     CreateAnalysisResponse
     (Maybe ResourceStatus)
     (Maybe ResourceStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAnalysisResponse' {Maybe ResourceStatus
creationStatus :: Maybe ResourceStatus
$sel:creationStatus:CreateAnalysisResponse' :: CreateAnalysisResponse -> Maybe ResourceStatus
creationStatus} -> Maybe ResourceStatus
creationStatus) (\s :: CreateAnalysisResponse
s@CreateAnalysisResponse' {} Maybe ResourceStatus
a -> CreateAnalysisResponse
s {$sel:creationStatus:CreateAnalysisResponse' :: Maybe ResourceStatus
creationStatus = Maybe ResourceStatus
a} :: CreateAnalysisResponse)

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

instance Prelude.NFData CreateAnalysisResponse