{-# 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.IoTEvents.CreateInput
-- 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 input.
module Amazonka.IoTEvents.CreateInput
  ( -- * Creating a Request
    CreateInput (..),
    newCreateInput,

    -- * Request Lenses
    createInput_inputDescription,
    createInput_tags,
    createInput_inputName,
    createInput_inputDefinition,

    -- * Destructuring the Response
    CreateInputResponse (..),
    newCreateInputResponse,

    -- * Response Lenses
    createInputResponse_inputConfiguration,
    createInputResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTEvents.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:/ 'newCreateInput' smart constructor.
data CreateInput = CreateInput'
  { -- | A brief description of the input.
    CreateInput -> Maybe Text
inputDescription :: Prelude.Maybe Prelude.Text,
    -- | Metadata that can be used to manage the input.
    CreateInput -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name you want to give to the input.
    CreateInput -> Text
inputName :: Prelude.Text,
    -- | The definition of the input.
    CreateInput -> InputDefinition
inputDefinition :: InputDefinition
  }
  deriving (CreateInput -> CreateInput -> Bool
(CreateInput -> CreateInput -> Bool)
-> (CreateInput -> CreateInput -> Bool) -> Eq CreateInput
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInput -> CreateInput -> Bool
$c/= :: CreateInput -> CreateInput -> Bool
== :: CreateInput -> CreateInput -> Bool
$c== :: CreateInput -> CreateInput -> Bool
Prelude.Eq, ReadPrec [CreateInput]
ReadPrec CreateInput
Int -> ReadS CreateInput
ReadS [CreateInput]
(Int -> ReadS CreateInput)
-> ReadS [CreateInput]
-> ReadPrec CreateInput
-> ReadPrec [CreateInput]
-> Read CreateInput
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInput]
$creadListPrec :: ReadPrec [CreateInput]
readPrec :: ReadPrec CreateInput
$creadPrec :: ReadPrec CreateInput
readList :: ReadS [CreateInput]
$creadList :: ReadS [CreateInput]
readsPrec :: Int -> ReadS CreateInput
$creadsPrec :: Int -> ReadS CreateInput
Prelude.Read, Int -> CreateInput -> ShowS
[CreateInput] -> ShowS
CreateInput -> String
(Int -> CreateInput -> ShowS)
-> (CreateInput -> String)
-> ([CreateInput] -> ShowS)
-> Show CreateInput
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInput] -> ShowS
$cshowList :: [CreateInput] -> ShowS
show :: CreateInput -> String
$cshow :: CreateInput -> String
showsPrec :: Int -> CreateInput -> ShowS
$cshowsPrec :: Int -> CreateInput -> ShowS
Prelude.Show, (forall x. CreateInput -> Rep CreateInput x)
-> (forall x. Rep CreateInput x -> CreateInput)
-> Generic CreateInput
forall x. Rep CreateInput x -> CreateInput
forall x. CreateInput -> Rep CreateInput x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInput x -> CreateInput
$cfrom :: forall x. CreateInput -> Rep CreateInput x
Prelude.Generic)

-- |
-- Create a value of 'CreateInput' 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:
--
-- 'inputDescription', 'createInput_inputDescription' - A brief description of the input.
--
-- 'tags', 'createInput_tags' - Metadata that can be used to manage the input.
--
-- 'inputName', 'createInput_inputName' - The name you want to give to the input.
--
-- 'inputDefinition', 'createInput_inputDefinition' - The definition of the input.
newCreateInput ::
  -- | 'inputName'
  Prelude.Text ->
  -- | 'inputDefinition'
  InputDefinition ->
  CreateInput
newCreateInput :: Text -> InputDefinition -> CreateInput
newCreateInput Text
pInputName_ InputDefinition
pInputDefinition_ =
  CreateInput' :: Maybe Text -> Maybe [Tag] -> Text -> InputDefinition -> CreateInput
CreateInput'
    { $sel:inputDescription:CreateInput' :: Maybe Text
inputDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateInput' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:inputName:CreateInput' :: Text
inputName = Text
pInputName_,
      $sel:inputDefinition:CreateInput' :: InputDefinition
inputDefinition = InputDefinition
pInputDefinition_
    }

-- | A brief description of the input.
createInput_inputDescription :: Lens.Lens' CreateInput (Prelude.Maybe Prelude.Text)
createInput_inputDescription :: (Maybe Text -> f (Maybe Text)) -> CreateInput -> f CreateInput
createInput_inputDescription = (CreateInput -> Maybe Text)
-> (CreateInput -> Maybe Text -> CreateInput)
-> Lens CreateInput CreateInput (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInput' {Maybe Text
inputDescription :: Maybe Text
$sel:inputDescription:CreateInput' :: CreateInput -> Maybe Text
inputDescription} -> Maybe Text
inputDescription) (\s :: CreateInput
s@CreateInput' {} Maybe Text
a -> CreateInput
s {$sel:inputDescription:CreateInput' :: Maybe Text
inputDescription = Maybe Text
a} :: CreateInput)

-- | Metadata that can be used to manage the input.
createInput_tags :: Lens.Lens' CreateInput (Prelude.Maybe [Tag])
createInput_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateInput -> f CreateInput
createInput_tags = (CreateInput -> Maybe [Tag])
-> (CreateInput -> Maybe [Tag] -> CreateInput)
-> Lens CreateInput CreateInput (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInput' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateInput' :: CreateInput -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateInput
s@CreateInput' {} Maybe [Tag]
a -> CreateInput
s {$sel:tags:CreateInput' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateInput) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateInput -> f CreateInput)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateInput
-> f CreateInput
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

-- | The name you want to give to the input.
createInput_inputName :: Lens.Lens' CreateInput Prelude.Text
createInput_inputName :: (Text -> f Text) -> CreateInput -> f CreateInput
createInput_inputName = (CreateInput -> Text)
-> (CreateInput -> Text -> CreateInput)
-> Lens CreateInput CreateInput Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInput' {Text
inputName :: Text
$sel:inputName:CreateInput' :: CreateInput -> Text
inputName} -> Text
inputName) (\s :: CreateInput
s@CreateInput' {} Text
a -> CreateInput
s {$sel:inputName:CreateInput' :: Text
inputName = Text
a} :: CreateInput)

-- | The definition of the input.
createInput_inputDefinition :: Lens.Lens' CreateInput InputDefinition
createInput_inputDefinition :: (InputDefinition -> f InputDefinition)
-> CreateInput -> f CreateInput
createInput_inputDefinition = (CreateInput -> InputDefinition)
-> (CreateInput -> InputDefinition -> CreateInput)
-> Lens CreateInput CreateInput InputDefinition InputDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInput' {InputDefinition
inputDefinition :: InputDefinition
$sel:inputDefinition:CreateInput' :: CreateInput -> InputDefinition
inputDefinition} -> InputDefinition
inputDefinition) (\s :: CreateInput
s@CreateInput' {} InputDefinition
a -> CreateInput
s {$sel:inputDefinition:CreateInput' :: InputDefinition
inputDefinition = InputDefinition
a} :: CreateInput)

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

instance Prelude.NFData CreateInput

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

instance Core.ToJSON CreateInput where
  toJSON :: CreateInput -> Value
toJSON CreateInput' {Maybe [Tag]
Maybe Text
Text
InputDefinition
inputDefinition :: InputDefinition
inputName :: Text
tags :: Maybe [Tag]
inputDescription :: Maybe Text
$sel:inputDefinition:CreateInput' :: CreateInput -> InputDefinition
$sel:inputName:CreateInput' :: CreateInput -> Text
$sel:tags:CreateInput' :: CreateInput -> Maybe [Tag]
$sel:inputDescription:CreateInput' :: CreateInput -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"inputDescription" 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
inputDescription,
            (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
"inputName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
inputName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"inputDefinition" Text -> InputDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InputDefinition
inputDefinition)
          ]
      )

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

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

-- | /See:/ 'newCreateInputResponse' smart constructor.
data CreateInputResponse = CreateInputResponse'
  { -- | Information about the configuration of the input.
    CreateInputResponse -> Maybe InputConfiguration
inputConfiguration :: Prelude.Maybe InputConfiguration,
    -- | The response's http status code.
    CreateInputResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateInputResponse -> CreateInputResponse -> Bool
(CreateInputResponse -> CreateInputResponse -> Bool)
-> (CreateInputResponse -> CreateInputResponse -> Bool)
-> Eq CreateInputResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInputResponse -> CreateInputResponse -> Bool
$c/= :: CreateInputResponse -> CreateInputResponse -> Bool
== :: CreateInputResponse -> CreateInputResponse -> Bool
$c== :: CreateInputResponse -> CreateInputResponse -> Bool
Prelude.Eq, ReadPrec [CreateInputResponse]
ReadPrec CreateInputResponse
Int -> ReadS CreateInputResponse
ReadS [CreateInputResponse]
(Int -> ReadS CreateInputResponse)
-> ReadS [CreateInputResponse]
-> ReadPrec CreateInputResponse
-> ReadPrec [CreateInputResponse]
-> Read CreateInputResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInputResponse]
$creadListPrec :: ReadPrec [CreateInputResponse]
readPrec :: ReadPrec CreateInputResponse
$creadPrec :: ReadPrec CreateInputResponse
readList :: ReadS [CreateInputResponse]
$creadList :: ReadS [CreateInputResponse]
readsPrec :: Int -> ReadS CreateInputResponse
$creadsPrec :: Int -> ReadS CreateInputResponse
Prelude.Read, Int -> CreateInputResponse -> ShowS
[CreateInputResponse] -> ShowS
CreateInputResponse -> String
(Int -> CreateInputResponse -> ShowS)
-> (CreateInputResponse -> String)
-> ([CreateInputResponse] -> ShowS)
-> Show CreateInputResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInputResponse] -> ShowS
$cshowList :: [CreateInputResponse] -> ShowS
show :: CreateInputResponse -> String
$cshow :: CreateInputResponse -> String
showsPrec :: Int -> CreateInputResponse -> ShowS
$cshowsPrec :: Int -> CreateInputResponse -> ShowS
Prelude.Show, (forall x. CreateInputResponse -> Rep CreateInputResponse x)
-> (forall x. Rep CreateInputResponse x -> CreateInputResponse)
-> Generic CreateInputResponse
forall x. Rep CreateInputResponse x -> CreateInputResponse
forall x. CreateInputResponse -> Rep CreateInputResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInputResponse x -> CreateInputResponse
$cfrom :: forall x. CreateInputResponse -> Rep CreateInputResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateInputResponse' 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:
--
-- 'inputConfiguration', 'createInputResponse_inputConfiguration' - Information about the configuration of the input.
--
-- 'httpStatus', 'createInputResponse_httpStatus' - The response's http status code.
newCreateInputResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateInputResponse
newCreateInputResponse :: Int -> CreateInputResponse
newCreateInputResponse Int
pHttpStatus_ =
  CreateInputResponse' :: Maybe InputConfiguration -> Int -> CreateInputResponse
CreateInputResponse'
    { $sel:inputConfiguration:CreateInputResponse' :: Maybe InputConfiguration
inputConfiguration =
        Maybe InputConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateInputResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the configuration of the input.
createInputResponse_inputConfiguration :: Lens.Lens' CreateInputResponse (Prelude.Maybe InputConfiguration)
createInputResponse_inputConfiguration :: (Maybe InputConfiguration -> f (Maybe InputConfiguration))
-> CreateInputResponse -> f CreateInputResponse
createInputResponse_inputConfiguration = (CreateInputResponse -> Maybe InputConfiguration)
-> (CreateInputResponse
    -> Maybe InputConfiguration -> CreateInputResponse)
-> Lens
     CreateInputResponse
     CreateInputResponse
     (Maybe InputConfiguration)
     (Maybe InputConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInputResponse' {Maybe InputConfiguration
inputConfiguration :: Maybe InputConfiguration
$sel:inputConfiguration:CreateInputResponse' :: CreateInputResponse -> Maybe InputConfiguration
inputConfiguration} -> Maybe InputConfiguration
inputConfiguration) (\s :: CreateInputResponse
s@CreateInputResponse' {} Maybe InputConfiguration
a -> CreateInputResponse
s {$sel:inputConfiguration:CreateInputResponse' :: Maybe InputConfiguration
inputConfiguration = Maybe InputConfiguration
a} :: CreateInputResponse)

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

instance Prelude.NFData CreateInputResponse