{-# 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.Forecast.CreateDataset
-- 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 Amazon Forecast dataset. The information about the dataset
-- that you provide helps Forecast understand how to consume the data for
-- model training. This includes the following:
--
-- -   /@DataFrequency@/ - How frequently your historical time-series data
--     is collected.
--
-- -   /@Domain@/ and /@DatasetType@/ - Each dataset has an associated
--     dataset domain and a type within the domain. Amazon Forecast
--     provides a list of predefined domains and types within each domain.
--     For each unique dataset domain and type within the domain, Amazon
--     Forecast requires your data to include a minimum set of predefined
--     fields.
--
-- -   /@Schema@/ - A schema specifies the fields in the dataset, including
--     the field name and data type.
--
-- After creating a dataset, you import your training data into it and add
-- the dataset to a dataset group. You use the dataset group to create a
-- predictor. For more information, see howitworks-datasets-groups.
--
-- To get a list of all your datasets, use the ListDatasets operation.
--
-- For example Forecast datasets, see the
-- <https://github.com/aws-samples/amazon-forecast-samples Amazon Forecast Sample GitHub repository>.
--
-- The @Status@ of a dataset must be @ACTIVE@ before you can import
-- training data. Use the DescribeDataset operation to get the status.
module Amazonka.Forecast.CreateDataset
  ( -- * Creating a Request
    CreateDataset (..),
    newCreateDataset,

    -- * Request Lenses
    createDataset_dataFrequency,
    createDataset_encryptionConfig,
    createDataset_tags,
    createDataset_datasetName,
    createDataset_domain,
    createDataset_datasetType,
    createDataset_schema,

    -- * Destructuring the Response
    CreateDatasetResponse (..),
    newCreateDatasetResponse,

    -- * Response Lenses
    createDatasetResponse_datasetArn,
    createDatasetResponse_httpStatus,
  )
where

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

-- | /See:/ 'newCreateDataset' smart constructor.
data CreateDataset = CreateDataset'
  { -- | The frequency of data collection. This parameter is required for
    -- RELATED_TIME_SERIES datasets.
    --
    -- Valid intervals are Y (Year), M (Month), W (Week), D (Day), H (Hour),
    -- 30min (30 minutes), 15min (15 minutes), 10min (10 minutes), 5min (5
    -- minutes), and 1min (1 minute). For example, \"D\" indicates every day
    -- and \"15min\" indicates every 15 minutes.
    CreateDataset -> Maybe Text
dataFrequency :: Prelude.Maybe Prelude.Text,
    -- | An AWS Key Management Service (KMS) key and the AWS Identity and Access
    -- Management (IAM) role that Amazon Forecast can assume to access the key.
    CreateDataset -> Maybe EncryptionConfig
encryptionConfig :: Prelude.Maybe EncryptionConfig,
    -- | The optional metadata that you apply to the dataset to help you
    -- categorize and organize them. Each tag consists of a key and an optional
    -- value, both of which you define.
    --
    -- The following basic restrictions apply to tags:
    --
    -- -   Maximum number of tags per resource - 50.
    --
    -- -   For each resource, each tag key must be unique, and each tag key can
    --     have only one value.
    --
    -- -   Maximum key length - 128 Unicode characters in UTF-8.
    --
    -- -   Maximum value length - 256 Unicode characters in UTF-8.
    --
    -- -   If your tagging schema is used across multiple services and
    --     resources, remember that other services may have restrictions on
    --     allowed characters. Generally allowed characters are: letters,
    --     numbers, and spaces representable in UTF-8, and the following
    --     characters: + - = . _ : \/ \@.
    --
    -- -   Tag keys and values are case sensitive.
    --
    -- -   Do not use @aws:@, @AWS:@, or any upper or lowercase combination of
    --     such as a prefix for keys as it is reserved for AWS use. You cannot
    --     edit or delete tag keys with this prefix. Values can have this
    --     prefix. If a tag value has @aws@ as its prefix but the key does not,
    --     then Forecast considers it to be a user tag and will count against
    --     the limit of 50 tags. Tags with only the key prefix of @aws@ do not
    --     count against your tags per resource limit.
    CreateDataset -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | A name for the dataset.
    CreateDataset -> Text
datasetName :: Prelude.Text,
    -- | The domain associated with the dataset. When you add a dataset to a
    -- dataset group, this value and the value specified for the @Domain@
    -- parameter of the CreateDatasetGroup operation must match.
    --
    -- The @Domain@ and @DatasetType@ that you choose determine the fields that
    -- must be present in the training data that you import to the dataset. For
    -- example, if you choose the @RETAIL@ domain and @TARGET_TIME_SERIES@ as
    -- the @DatasetType@, Amazon Forecast requires @item_id@, @timestamp@, and
    -- @demand@ fields to be present in your data. For more information, see
    -- howitworks-datasets-groups.
    CreateDataset -> Domain
domain :: Domain,
    -- | The dataset type. Valid values depend on the chosen @Domain@.
    CreateDataset -> DatasetType
datasetType :: DatasetType,
    -- | The schema for the dataset. The schema attributes and their order must
    -- match the fields in your data. The dataset @Domain@ and @DatasetType@
    -- that you choose determine the minimum required fields in your training
    -- data. For information about the required fields for a specific dataset
    -- domain and type, see howitworks-domains-ds-types.
    CreateDataset -> Schema
schema :: Schema
  }
  deriving (CreateDataset -> CreateDataset -> Bool
(CreateDataset -> CreateDataset -> Bool)
-> (CreateDataset -> CreateDataset -> Bool) -> Eq CreateDataset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDataset -> CreateDataset -> Bool
$c/= :: CreateDataset -> CreateDataset -> Bool
== :: CreateDataset -> CreateDataset -> Bool
$c== :: CreateDataset -> CreateDataset -> Bool
Prelude.Eq, Int -> CreateDataset -> ShowS
[CreateDataset] -> ShowS
CreateDataset -> String
(Int -> CreateDataset -> ShowS)
-> (CreateDataset -> String)
-> ([CreateDataset] -> ShowS)
-> Show CreateDataset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDataset] -> ShowS
$cshowList :: [CreateDataset] -> ShowS
show :: CreateDataset -> String
$cshow :: CreateDataset -> String
showsPrec :: Int -> CreateDataset -> ShowS
$cshowsPrec :: Int -> CreateDataset -> ShowS
Prelude.Show, (forall x. CreateDataset -> Rep CreateDataset x)
-> (forall x. Rep CreateDataset x -> CreateDataset)
-> Generic CreateDataset
forall x. Rep CreateDataset x -> CreateDataset
forall x. CreateDataset -> Rep CreateDataset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDataset x -> CreateDataset
$cfrom :: forall x. CreateDataset -> Rep CreateDataset x
Prelude.Generic)

-- |
-- Create a value of 'CreateDataset' 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:
--
-- 'dataFrequency', 'createDataset_dataFrequency' - The frequency of data collection. This parameter is required for
-- RELATED_TIME_SERIES datasets.
--
-- Valid intervals are Y (Year), M (Month), W (Week), D (Day), H (Hour),
-- 30min (30 minutes), 15min (15 minutes), 10min (10 minutes), 5min (5
-- minutes), and 1min (1 minute). For example, \"D\" indicates every day
-- and \"15min\" indicates every 15 minutes.
--
-- 'encryptionConfig', 'createDataset_encryptionConfig' - An AWS Key Management Service (KMS) key and the AWS Identity and Access
-- Management (IAM) role that Amazon Forecast can assume to access the key.
--
-- 'tags', 'createDataset_tags' - The optional metadata that you apply to the dataset to help you
-- categorize and organize them. Each tag consists of a key and an optional
-- value, both of which you define.
--
-- The following basic restrictions apply to tags:
--
-- -   Maximum number of tags per resource - 50.
--
-- -   For each resource, each tag key must be unique, and each tag key can
--     have only one value.
--
-- -   Maximum key length - 128 Unicode characters in UTF-8.
--
-- -   Maximum value length - 256 Unicode characters in UTF-8.
--
-- -   If your tagging schema is used across multiple services and
--     resources, remember that other services may have restrictions on
--     allowed characters. Generally allowed characters are: letters,
--     numbers, and spaces representable in UTF-8, and the following
--     characters: + - = . _ : \/ \@.
--
-- -   Tag keys and values are case sensitive.
--
-- -   Do not use @aws:@, @AWS:@, or any upper or lowercase combination of
--     such as a prefix for keys as it is reserved for AWS use. You cannot
--     edit or delete tag keys with this prefix. Values can have this
--     prefix. If a tag value has @aws@ as its prefix but the key does not,
--     then Forecast considers it to be a user tag and will count against
--     the limit of 50 tags. Tags with only the key prefix of @aws@ do not
--     count against your tags per resource limit.
--
-- 'datasetName', 'createDataset_datasetName' - A name for the dataset.
--
-- 'domain', 'createDataset_domain' - The domain associated with the dataset. When you add a dataset to a
-- dataset group, this value and the value specified for the @Domain@
-- parameter of the CreateDatasetGroup operation must match.
--
-- The @Domain@ and @DatasetType@ that you choose determine the fields that
-- must be present in the training data that you import to the dataset. For
-- example, if you choose the @RETAIL@ domain and @TARGET_TIME_SERIES@ as
-- the @DatasetType@, Amazon Forecast requires @item_id@, @timestamp@, and
-- @demand@ fields to be present in your data. For more information, see
-- howitworks-datasets-groups.
--
-- 'datasetType', 'createDataset_datasetType' - The dataset type. Valid values depend on the chosen @Domain@.
--
-- 'schema', 'createDataset_schema' - The schema for the dataset. The schema attributes and their order must
-- match the fields in your data. The dataset @Domain@ and @DatasetType@
-- that you choose determine the minimum required fields in your training
-- data. For information about the required fields for a specific dataset
-- domain and type, see howitworks-domains-ds-types.
newCreateDataset ::
  -- | 'datasetName'
  Prelude.Text ->
  -- | 'domain'
  Domain ->
  -- | 'datasetType'
  DatasetType ->
  -- | 'schema'
  Schema ->
  CreateDataset
newCreateDataset :: Text -> Domain -> DatasetType -> Schema -> CreateDataset
newCreateDataset
  Text
pDatasetName_
  Domain
pDomain_
  DatasetType
pDatasetType_
  Schema
pSchema_ =
    CreateDataset' :: Maybe Text
-> Maybe EncryptionConfig
-> Maybe [Tag]
-> Text
-> Domain
-> DatasetType
-> Schema
-> CreateDataset
CreateDataset'
      { $sel:dataFrequency:CreateDataset' :: Maybe Text
dataFrequency = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:encryptionConfig:CreateDataset' :: Maybe EncryptionConfig
encryptionConfig = Maybe EncryptionConfig
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateDataset' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:datasetName:CreateDataset' :: Text
datasetName = Text
pDatasetName_,
        $sel:domain:CreateDataset' :: Domain
domain = Domain
pDomain_,
        $sel:datasetType:CreateDataset' :: DatasetType
datasetType = DatasetType
pDatasetType_,
        $sel:schema:CreateDataset' :: Schema
schema = Schema
pSchema_
      }

-- | The frequency of data collection. This parameter is required for
-- RELATED_TIME_SERIES datasets.
--
-- Valid intervals are Y (Year), M (Month), W (Week), D (Day), H (Hour),
-- 30min (30 minutes), 15min (15 minutes), 10min (10 minutes), 5min (5
-- minutes), and 1min (1 minute). For example, \"D\" indicates every day
-- and \"15min\" indicates every 15 minutes.
createDataset_dataFrequency :: Lens.Lens' CreateDataset (Prelude.Maybe Prelude.Text)
createDataset_dataFrequency :: (Maybe Text -> f (Maybe Text)) -> CreateDataset -> f CreateDataset
createDataset_dataFrequency = (CreateDataset -> Maybe Text)
-> (CreateDataset -> Maybe Text -> CreateDataset)
-> Lens CreateDataset CreateDataset (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Maybe Text
dataFrequency :: Maybe Text
$sel:dataFrequency:CreateDataset' :: CreateDataset -> Maybe Text
dataFrequency} -> Maybe Text
dataFrequency) (\s :: CreateDataset
s@CreateDataset' {} Maybe Text
a -> CreateDataset
s {$sel:dataFrequency:CreateDataset' :: Maybe Text
dataFrequency = Maybe Text
a} :: CreateDataset)

-- | An AWS Key Management Service (KMS) key and the AWS Identity and Access
-- Management (IAM) role that Amazon Forecast can assume to access the key.
createDataset_encryptionConfig :: Lens.Lens' CreateDataset (Prelude.Maybe EncryptionConfig)
createDataset_encryptionConfig :: (Maybe EncryptionConfig -> f (Maybe EncryptionConfig))
-> CreateDataset -> f CreateDataset
createDataset_encryptionConfig = (CreateDataset -> Maybe EncryptionConfig)
-> (CreateDataset -> Maybe EncryptionConfig -> CreateDataset)
-> Lens
     CreateDataset
     CreateDataset
     (Maybe EncryptionConfig)
     (Maybe EncryptionConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Maybe EncryptionConfig
encryptionConfig :: Maybe EncryptionConfig
$sel:encryptionConfig:CreateDataset' :: CreateDataset -> Maybe EncryptionConfig
encryptionConfig} -> Maybe EncryptionConfig
encryptionConfig) (\s :: CreateDataset
s@CreateDataset' {} Maybe EncryptionConfig
a -> CreateDataset
s {$sel:encryptionConfig:CreateDataset' :: Maybe EncryptionConfig
encryptionConfig = Maybe EncryptionConfig
a} :: CreateDataset)

-- | The optional metadata that you apply to the dataset to help you
-- categorize and organize them. Each tag consists of a key and an optional
-- value, both of which you define.
--
-- The following basic restrictions apply to tags:
--
-- -   Maximum number of tags per resource - 50.
--
-- -   For each resource, each tag key must be unique, and each tag key can
--     have only one value.
--
-- -   Maximum key length - 128 Unicode characters in UTF-8.
--
-- -   Maximum value length - 256 Unicode characters in UTF-8.
--
-- -   If your tagging schema is used across multiple services and
--     resources, remember that other services may have restrictions on
--     allowed characters. Generally allowed characters are: letters,
--     numbers, and spaces representable in UTF-8, and the following
--     characters: + - = . _ : \/ \@.
--
-- -   Tag keys and values are case sensitive.
--
-- -   Do not use @aws:@, @AWS:@, or any upper or lowercase combination of
--     such as a prefix for keys as it is reserved for AWS use. You cannot
--     edit or delete tag keys with this prefix. Values can have this
--     prefix. If a tag value has @aws@ as its prefix but the key does not,
--     then Forecast considers it to be a user tag and will count against
--     the limit of 50 tags. Tags with only the key prefix of @aws@ do not
--     count against your tags per resource limit.
createDataset_tags :: Lens.Lens' CreateDataset (Prelude.Maybe [Tag])
createDataset_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDataset -> f CreateDataset
createDataset_tags = (CreateDataset -> Maybe [Tag])
-> (CreateDataset -> Maybe [Tag] -> CreateDataset)
-> Lens CreateDataset CreateDataset (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateDataset' :: CreateDataset -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateDataset
s@CreateDataset' {} Maybe [Tag]
a -> CreateDataset
s {$sel:tags:CreateDataset' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateDataset) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> CreateDataset -> f CreateDataset)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateDataset
-> f CreateDataset
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A name for the dataset.
createDataset_datasetName :: Lens.Lens' CreateDataset Prelude.Text
createDataset_datasetName :: (Text -> f Text) -> CreateDataset -> f CreateDataset
createDataset_datasetName = (CreateDataset -> Text)
-> (CreateDataset -> Text -> CreateDataset)
-> Lens CreateDataset CreateDataset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Text
datasetName :: Text
$sel:datasetName:CreateDataset' :: CreateDataset -> Text
datasetName} -> Text
datasetName) (\s :: CreateDataset
s@CreateDataset' {} Text
a -> CreateDataset
s {$sel:datasetName:CreateDataset' :: Text
datasetName = Text
a} :: CreateDataset)

-- | The domain associated with the dataset. When you add a dataset to a
-- dataset group, this value and the value specified for the @Domain@
-- parameter of the CreateDatasetGroup operation must match.
--
-- The @Domain@ and @DatasetType@ that you choose determine the fields that
-- must be present in the training data that you import to the dataset. For
-- example, if you choose the @RETAIL@ domain and @TARGET_TIME_SERIES@ as
-- the @DatasetType@, Amazon Forecast requires @item_id@, @timestamp@, and
-- @demand@ fields to be present in your data. For more information, see
-- howitworks-datasets-groups.
createDataset_domain :: Lens.Lens' CreateDataset Domain
createDataset_domain :: (Domain -> f Domain) -> CreateDataset -> f CreateDataset
createDataset_domain = (CreateDataset -> Domain)
-> (CreateDataset -> Domain -> CreateDataset)
-> Lens CreateDataset CreateDataset Domain Domain
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Domain
domain :: Domain
$sel:domain:CreateDataset' :: CreateDataset -> Domain
domain} -> Domain
domain) (\s :: CreateDataset
s@CreateDataset' {} Domain
a -> CreateDataset
s {$sel:domain:CreateDataset' :: Domain
domain = Domain
a} :: CreateDataset)

-- | The dataset type. Valid values depend on the chosen @Domain@.
createDataset_datasetType :: Lens.Lens' CreateDataset DatasetType
createDataset_datasetType :: (DatasetType -> f DatasetType) -> CreateDataset -> f CreateDataset
createDataset_datasetType = (CreateDataset -> DatasetType)
-> (CreateDataset -> DatasetType -> CreateDataset)
-> Lens CreateDataset CreateDataset DatasetType DatasetType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {DatasetType
datasetType :: DatasetType
$sel:datasetType:CreateDataset' :: CreateDataset -> DatasetType
datasetType} -> DatasetType
datasetType) (\s :: CreateDataset
s@CreateDataset' {} DatasetType
a -> CreateDataset
s {$sel:datasetType:CreateDataset' :: DatasetType
datasetType = DatasetType
a} :: CreateDataset)

-- | The schema for the dataset. The schema attributes and their order must
-- match the fields in your data. The dataset @Domain@ and @DatasetType@
-- that you choose determine the minimum required fields in your training
-- data. For information about the required fields for a specific dataset
-- domain and type, see howitworks-domains-ds-types.
createDataset_schema :: Lens.Lens' CreateDataset Schema
createDataset_schema :: (Schema -> f Schema) -> CreateDataset -> f CreateDataset
createDataset_schema = (CreateDataset -> Schema)
-> (CreateDataset -> Schema -> CreateDataset)
-> Lens CreateDataset CreateDataset Schema Schema
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDataset' {Schema
schema :: Schema
$sel:schema:CreateDataset' :: CreateDataset -> Schema
schema} -> Schema
schema) (\s :: CreateDataset
s@CreateDataset' {} Schema
a -> CreateDataset
s {$sel:schema:CreateDataset' :: Schema
schema = Schema
a} :: CreateDataset)

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

instance Prelude.NFData CreateDataset

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

instance Core.ToJSON CreateDataset where
  toJSON :: CreateDataset -> Value
toJSON CreateDataset' {Maybe [Tag]
Maybe Text
Maybe EncryptionConfig
Text
DatasetType
Domain
Schema
schema :: Schema
datasetType :: DatasetType
domain :: Domain
datasetName :: Text
tags :: Maybe [Tag]
encryptionConfig :: Maybe EncryptionConfig
dataFrequency :: Maybe Text
$sel:schema:CreateDataset' :: CreateDataset -> Schema
$sel:datasetType:CreateDataset' :: CreateDataset -> DatasetType
$sel:domain:CreateDataset' :: CreateDataset -> Domain
$sel:datasetName:CreateDataset' :: CreateDataset -> Text
$sel:tags:CreateDataset' :: CreateDataset -> Maybe [Tag]
$sel:encryptionConfig:CreateDataset' :: CreateDataset -> Maybe EncryptionConfig
$sel:dataFrequency:CreateDataset' :: CreateDataset -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DataFrequency" 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
dataFrequency,
            (Text
"EncryptionConfig" Text -> EncryptionConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EncryptionConfig -> Pair) -> Maybe EncryptionConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionConfig
encryptionConfig,
            (Text
"Tags" Text -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatasetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
datasetName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Domain" Text -> Domain -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Domain
domain),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"DatasetType" Text -> DatasetType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DatasetType
datasetType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Schema" Text -> Schema -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Schema
schema)
          ]
      )

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

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

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

-- |
-- Create a value of 'CreateDatasetResponse' 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:
--
-- 'datasetArn', 'createDatasetResponse_datasetArn' - The Amazon Resource Name (ARN) of the dataset.
--
-- 'httpStatus', 'createDatasetResponse_httpStatus' - The response's http status code.
newCreateDatasetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDatasetResponse
newCreateDatasetResponse :: Int -> CreateDatasetResponse
newCreateDatasetResponse Int
pHttpStatus_ =
  CreateDatasetResponse' :: Maybe Text -> Int -> CreateDatasetResponse
CreateDatasetResponse'
    { $sel:datasetArn:CreateDatasetResponse' :: Maybe Text
datasetArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDatasetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the dataset.
createDatasetResponse_datasetArn :: Lens.Lens' CreateDatasetResponse (Prelude.Maybe Prelude.Text)
createDatasetResponse_datasetArn :: (Maybe Text -> f (Maybe Text))
-> CreateDatasetResponse -> f CreateDatasetResponse
createDatasetResponse_datasetArn = (CreateDatasetResponse -> Maybe Text)
-> (CreateDatasetResponse -> Maybe Text -> CreateDatasetResponse)
-> Lens
     CreateDatasetResponse
     CreateDatasetResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatasetResponse' {Maybe Text
datasetArn :: Maybe Text
$sel:datasetArn:CreateDatasetResponse' :: CreateDatasetResponse -> Maybe Text
datasetArn} -> Maybe Text
datasetArn) (\s :: CreateDatasetResponse
s@CreateDatasetResponse' {} Maybe Text
a -> CreateDatasetResponse
s {$sel:datasetArn:CreateDatasetResponse' :: Maybe Text
datasetArn = Maybe Text
a} :: CreateDatasetResponse)

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

instance Prelude.NFData CreateDatasetResponse