{-# 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.IoTAnalytics.CreateDatasetContent
-- 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 the content of a dataset by applying a @queryAction@ (a SQL
-- query) or a @containerAction@ (executing a containerized application).
module Amazonka.IoTAnalytics.CreateDatasetContent
  ( -- * Creating a Request
    CreateDatasetContent (..),
    newCreateDatasetContent,

    -- * Request Lenses
    createDatasetContent_versionId,
    createDatasetContent_datasetName,

    -- * Destructuring the Response
    CreateDatasetContentResponse (..),
    newCreateDatasetContentResponse,

    -- * Response Lenses
    createDatasetContentResponse_versionId,
    createDatasetContentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.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:/ 'newCreateDatasetContent' smart constructor.
data CreateDatasetContent = CreateDatasetContent'
  { -- | The version ID of the dataset content. To specify @versionId@ for a
    -- dataset content, the dataset must use a
    -- <https://docs.aws.amazon.com/iotanalytics/latest/APIReference/API_DeltaTime.html DeltaTimer>
    -- filter.
    CreateDatasetContent -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | The name of the dataset.
    CreateDatasetContent -> Text
datasetName :: Prelude.Text
  }
  deriving (CreateDatasetContent -> CreateDatasetContent -> Bool
(CreateDatasetContent -> CreateDatasetContent -> Bool)
-> (CreateDatasetContent -> CreateDatasetContent -> Bool)
-> Eq CreateDatasetContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDatasetContent -> CreateDatasetContent -> Bool
$c/= :: CreateDatasetContent -> CreateDatasetContent -> Bool
== :: CreateDatasetContent -> CreateDatasetContent -> Bool
$c== :: CreateDatasetContent -> CreateDatasetContent -> Bool
Prelude.Eq, ReadPrec [CreateDatasetContent]
ReadPrec CreateDatasetContent
Int -> ReadS CreateDatasetContent
ReadS [CreateDatasetContent]
(Int -> ReadS CreateDatasetContent)
-> ReadS [CreateDatasetContent]
-> ReadPrec CreateDatasetContent
-> ReadPrec [CreateDatasetContent]
-> Read CreateDatasetContent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDatasetContent]
$creadListPrec :: ReadPrec [CreateDatasetContent]
readPrec :: ReadPrec CreateDatasetContent
$creadPrec :: ReadPrec CreateDatasetContent
readList :: ReadS [CreateDatasetContent]
$creadList :: ReadS [CreateDatasetContent]
readsPrec :: Int -> ReadS CreateDatasetContent
$creadsPrec :: Int -> ReadS CreateDatasetContent
Prelude.Read, Int -> CreateDatasetContent -> ShowS
[CreateDatasetContent] -> ShowS
CreateDatasetContent -> String
(Int -> CreateDatasetContent -> ShowS)
-> (CreateDatasetContent -> String)
-> ([CreateDatasetContent] -> ShowS)
-> Show CreateDatasetContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDatasetContent] -> ShowS
$cshowList :: [CreateDatasetContent] -> ShowS
show :: CreateDatasetContent -> String
$cshow :: CreateDatasetContent -> String
showsPrec :: Int -> CreateDatasetContent -> ShowS
$cshowsPrec :: Int -> CreateDatasetContent -> ShowS
Prelude.Show, (forall x. CreateDatasetContent -> Rep CreateDatasetContent x)
-> (forall x. Rep CreateDatasetContent x -> CreateDatasetContent)
-> Generic CreateDatasetContent
forall x. Rep CreateDatasetContent x -> CreateDatasetContent
forall x. CreateDatasetContent -> Rep CreateDatasetContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDatasetContent x -> CreateDatasetContent
$cfrom :: forall x. CreateDatasetContent -> Rep CreateDatasetContent x
Prelude.Generic)

-- |
-- Create a value of 'CreateDatasetContent' 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:
--
-- 'versionId', 'createDatasetContent_versionId' - The version ID of the dataset content. To specify @versionId@ for a
-- dataset content, the dataset must use a
-- <https://docs.aws.amazon.com/iotanalytics/latest/APIReference/API_DeltaTime.html DeltaTimer>
-- filter.
--
-- 'datasetName', 'createDatasetContent_datasetName' - The name of the dataset.
newCreateDatasetContent ::
  -- | 'datasetName'
  Prelude.Text ->
  CreateDatasetContent
newCreateDatasetContent :: Text -> CreateDatasetContent
newCreateDatasetContent Text
pDatasetName_ =
  CreateDatasetContent' :: Maybe Text -> Text -> CreateDatasetContent
CreateDatasetContent'
    { $sel:versionId:CreateDatasetContent' :: Maybe Text
versionId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:datasetName:CreateDatasetContent' :: Text
datasetName = Text
pDatasetName_
    }

-- | The version ID of the dataset content. To specify @versionId@ for a
-- dataset content, the dataset must use a
-- <https://docs.aws.amazon.com/iotanalytics/latest/APIReference/API_DeltaTime.html DeltaTimer>
-- filter.
createDatasetContent_versionId :: Lens.Lens' CreateDatasetContent (Prelude.Maybe Prelude.Text)
createDatasetContent_versionId :: (Maybe Text -> f (Maybe Text))
-> CreateDatasetContent -> f CreateDatasetContent
createDatasetContent_versionId = (CreateDatasetContent -> Maybe Text)
-> (CreateDatasetContent -> Maybe Text -> CreateDatasetContent)
-> Lens
     CreateDatasetContent CreateDatasetContent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatasetContent' {Maybe Text
versionId :: Maybe Text
$sel:versionId:CreateDatasetContent' :: CreateDatasetContent -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: CreateDatasetContent
s@CreateDatasetContent' {} Maybe Text
a -> CreateDatasetContent
s {$sel:versionId:CreateDatasetContent' :: Maybe Text
versionId = Maybe Text
a} :: CreateDatasetContent)

-- | The name of the dataset.
createDatasetContent_datasetName :: Lens.Lens' CreateDatasetContent Prelude.Text
createDatasetContent_datasetName :: (Text -> f Text) -> CreateDatasetContent -> f CreateDatasetContent
createDatasetContent_datasetName = (CreateDatasetContent -> Text)
-> (CreateDatasetContent -> Text -> CreateDatasetContent)
-> Lens CreateDatasetContent CreateDatasetContent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatasetContent' {Text
datasetName :: Text
$sel:datasetName:CreateDatasetContent' :: CreateDatasetContent -> Text
datasetName} -> Text
datasetName) (\s :: CreateDatasetContent
s@CreateDatasetContent' {} Text
a -> CreateDatasetContent
s {$sel:datasetName:CreateDatasetContent' :: Text
datasetName = Text
a} :: CreateDatasetContent)

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

instance Prelude.NFData CreateDatasetContent

instance Core.ToHeaders CreateDatasetContent where
  toHeaders :: CreateDatasetContent -> ResponseHeaders
toHeaders = ResponseHeaders -> CreateDatasetContent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON CreateDatasetContent where
  toJSON :: CreateDatasetContent -> Value
toJSON CreateDatasetContent' {Maybe Text
Text
datasetName :: Text
versionId :: Maybe Text
$sel:datasetName:CreateDatasetContent' :: CreateDatasetContent -> Text
$sel:versionId:CreateDatasetContent' :: CreateDatasetContent -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"versionId" 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
versionId]
      )

instance Core.ToPath CreateDatasetContent where
  toPath :: CreateDatasetContent -> ByteString
toPath CreateDatasetContent' {Maybe Text
Text
datasetName :: Text
versionId :: Maybe Text
$sel:datasetName:CreateDatasetContent' :: CreateDatasetContent -> Text
$sel:versionId:CreateDatasetContent' :: CreateDatasetContent -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/datasets/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
datasetName, ByteString
"/content"]

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

-- | /See:/ 'newCreateDatasetContentResponse' smart constructor.
data CreateDatasetContentResponse = CreateDatasetContentResponse'
  { -- | The version ID of the dataset contents that are being created.
    CreateDatasetContentResponse -> Maybe Text
versionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDatasetContentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDatasetContentResponse
-> CreateDatasetContentResponse -> Bool
(CreateDatasetContentResponse
 -> CreateDatasetContentResponse -> Bool)
-> (CreateDatasetContentResponse
    -> CreateDatasetContentResponse -> Bool)
-> Eq CreateDatasetContentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDatasetContentResponse
-> CreateDatasetContentResponse -> Bool
$c/= :: CreateDatasetContentResponse
-> CreateDatasetContentResponse -> Bool
== :: CreateDatasetContentResponse
-> CreateDatasetContentResponse -> Bool
$c== :: CreateDatasetContentResponse
-> CreateDatasetContentResponse -> Bool
Prelude.Eq, ReadPrec [CreateDatasetContentResponse]
ReadPrec CreateDatasetContentResponse
Int -> ReadS CreateDatasetContentResponse
ReadS [CreateDatasetContentResponse]
(Int -> ReadS CreateDatasetContentResponse)
-> ReadS [CreateDatasetContentResponse]
-> ReadPrec CreateDatasetContentResponse
-> ReadPrec [CreateDatasetContentResponse]
-> Read CreateDatasetContentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDatasetContentResponse]
$creadListPrec :: ReadPrec [CreateDatasetContentResponse]
readPrec :: ReadPrec CreateDatasetContentResponse
$creadPrec :: ReadPrec CreateDatasetContentResponse
readList :: ReadS [CreateDatasetContentResponse]
$creadList :: ReadS [CreateDatasetContentResponse]
readsPrec :: Int -> ReadS CreateDatasetContentResponse
$creadsPrec :: Int -> ReadS CreateDatasetContentResponse
Prelude.Read, Int -> CreateDatasetContentResponse -> ShowS
[CreateDatasetContentResponse] -> ShowS
CreateDatasetContentResponse -> String
(Int -> CreateDatasetContentResponse -> ShowS)
-> (CreateDatasetContentResponse -> String)
-> ([CreateDatasetContentResponse] -> ShowS)
-> Show CreateDatasetContentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDatasetContentResponse] -> ShowS
$cshowList :: [CreateDatasetContentResponse] -> ShowS
show :: CreateDatasetContentResponse -> String
$cshow :: CreateDatasetContentResponse -> String
showsPrec :: Int -> CreateDatasetContentResponse -> ShowS
$cshowsPrec :: Int -> CreateDatasetContentResponse -> ShowS
Prelude.Show, (forall x.
 CreateDatasetContentResponse -> Rep CreateDatasetContentResponse x)
-> (forall x.
    Rep CreateDatasetContentResponse x -> CreateDatasetContentResponse)
-> Generic CreateDatasetContentResponse
forall x.
Rep CreateDatasetContentResponse x -> CreateDatasetContentResponse
forall x.
CreateDatasetContentResponse -> Rep CreateDatasetContentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDatasetContentResponse x -> CreateDatasetContentResponse
$cfrom :: forall x.
CreateDatasetContentResponse -> Rep CreateDatasetContentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDatasetContentResponse' 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:
--
-- 'versionId', 'createDatasetContentResponse_versionId' - The version ID of the dataset contents that are being created.
--
-- 'httpStatus', 'createDatasetContentResponse_httpStatus' - The response's http status code.
newCreateDatasetContentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDatasetContentResponse
newCreateDatasetContentResponse :: Int -> CreateDatasetContentResponse
newCreateDatasetContentResponse Int
pHttpStatus_ =
  CreateDatasetContentResponse' :: Maybe Text -> Int -> CreateDatasetContentResponse
CreateDatasetContentResponse'
    { $sel:versionId:CreateDatasetContentResponse' :: Maybe Text
versionId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDatasetContentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The version ID of the dataset contents that are being created.
createDatasetContentResponse_versionId :: Lens.Lens' CreateDatasetContentResponse (Prelude.Maybe Prelude.Text)
createDatasetContentResponse_versionId :: (Maybe Text -> f (Maybe Text))
-> CreateDatasetContentResponse -> f CreateDatasetContentResponse
createDatasetContentResponse_versionId = (CreateDatasetContentResponse -> Maybe Text)
-> (CreateDatasetContentResponse
    -> Maybe Text -> CreateDatasetContentResponse)
-> Lens
     CreateDatasetContentResponse
     CreateDatasetContentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDatasetContentResponse' {Maybe Text
versionId :: Maybe Text
$sel:versionId:CreateDatasetContentResponse' :: CreateDatasetContentResponse -> Maybe Text
versionId} -> Maybe Text
versionId) (\s :: CreateDatasetContentResponse
s@CreateDatasetContentResponse' {} Maybe Text
a -> CreateDatasetContentResponse
s {$sel:versionId:CreateDatasetContentResponse' :: Maybe Text
versionId = Maybe Text
a} :: CreateDatasetContentResponse)

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

instance Prelude.NFData CreateDatasetContentResponse