{-# 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.IoTWireless.CreateWirelessGatewayTask
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a task for a wireless gateway.
module Amazonka.IoTWireless.CreateWirelessGatewayTask
  ( -- * Creating a Request
    CreateWirelessGatewayTask (..),
    newCreateWirelessGatewayTask,

    -- * Request Lenses
    createWirelessGatewayTask_id,
    createWirelessGatewayTask_wirelessGatewayTaskDefinitionId,

    -- * Destructuring the Response
    CreateWirelessGatewayTaskResponse (..),
    newCreateWirelessGatewayTaskResponse,

    -- * Response Lenses
    createWirelessGatewayTaskResponse_status,
    createWirelessGatewayTaskResponse_wirelessGatewayTaskDefinitionId,
    createWirelessGatewayTaskResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IoTWireless.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateWirelessGatewayTask' smart constructor.
data CreateWirelessGatewayTask = CreateWirelessGatewayTask'
  { -- | The ID of the resource to update.
    CreateWirelessGatewayTask -> Text
id :: Prelude.Text,
    -- | The ID of the WirelessGatewayTaskDefinition.
    CreateWirelessGatewayTask -> Text
wirelessGatewayTaskDefinitionId :: Prelude.Text
  }
  deriving (CreateWirelessGatewayTask -> CreateWirelessGatewayTask -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateWirelessGatewayTask -> CreateWirelessGatewayTask -> Bool
$c/= :: CreateWirelessGatewayTask -> CreateWirelessGatewayTask -> Bool
== :: CreateWirelessGatewayTask -> CreateWirelessGatewayTask -> Bool
$c== :: CreateWirelessGatewayTask -> CreateWirelessGatewayTask -> Bool
Prelude.Eq, ReadPrec [CreateWirelessGatewayTask]
ReadPrec CreateWirelessGatewayTask
Int -> ReadS CreateWirelessGatewayTask
ReadS [CreateWirelessGatewayTask]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateWirelessGatewayTask]
$creadListPrec :: ReadPrec [CreateWirelessGatewayTask]
readPrec :: ReadPrec CreateWirelessGatewayTask
$creadPrec :: ReadPrec CreateWirelessGatewayTask
readList :: ReadS [CreateWirelessGatewayTask]
$creadList :: ReadS [CreateWirelessGatewayTask]
readsPrec :: Int -> ReadS CreateWirelessGatewayTask
$creadsPrec :: Int -> ReadS CreateWirelessGatewayTask
Prelude.Read, Int -> CreateWirelessGatewayTask -> ShowS
[CreateWirelessGatewayTask] -> ShowS
CreateWirelessGatewayTask -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateWirelessGatewayTask] -> ShowS
$cshowList :: [CreateWirelessGatewayTask] -> ShowS
show :: CreateWirelessGatewayTask -> String
$cshow :: CreateWirelessGatewayTask -> String
showsPrec :: Int -> CreateWirelessGatewayTask -> ShowS
$cshowsPrec :: Int -> CreateWirelessGatewayTask -> ShowS
Prelude.Show, forall x.
Rep CreateWirelessGatewayTask x -> CreateWirelessGatewayTask
forall x.
CreateWirelessGatewayTask -> Rep CreateWirelessGatewayTask x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateWirelessGatewayTask x -> CreateWirelessGatewayTask
$cfrom :: forall x.
CreateWirelessGatewayTask -> Rep CreateWirelessGatewayTask x
Prelude.Generic)

-- |
-- Create a value of 'CreateWirelessGatewayTask' 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:
--
-- 'id', 'createWirelessGatewayTask_id' - The ID of the resource to update.
--
-- 'wirelessGatewayTaskDefinitionId', 'createWirelessGatewayTask_wirelessGatewayTaskDefinitionId' - The ID of the WirelessGatewayTaskDefinition.
newCreateWirelessGatewayTask ::
  -- | 'id'
  Prelude.Text ->
  -- | 'wirelessGatewayTaskDefinitionId'
  Prelude.Text ->
  CreateWirelessGatewayTask
newCreateWirelessGatewayTask :: Text -> Text -> CreateWirelessGatewayTask
newCreateWirelessGatewayTask
  Text
pId_
  Text
pWirelessGatewayTaskDefinitionId_ =
    CreateWirelessGatewayTask'
      { $sel:id:CreateWirelessGatewayTask' :: Text
id = Text
pId_,
        $sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: Text
wirelessGatewayTaskDefinitionId =
          Text
pWirelessGatewayTaskDefinitionId_
      }

-- | The ID of the resource to update.
createWirelessGatewayTask_id :: Lens.Lens' CreateWirelessGatewayTask Prelude.Text
createWirelessGatewayTask_id :: Lens' CreateWirelessGatewayTask Text
createWirelessGatewayTask_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWirelessGatewayTask' {Text
id :: Text
$sel:id:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
id} -> Text
id) (\s :: CreateWirelessGatewayTask
s@CreateWirelessGatewayTask' {} Text
a -> CreateWirelessGatewayTask
s {$sel:id:CreateWirelessGatewayTask' :: Text
id = Text
a} :: CreateWirelessGatewayTask)

-- | The ID of the WirelessGatewayTaskDefinition.
createWirelessGatewayTask_wirelessGatewayTaskDefinitionId :: Lens.Lens' CreateWirelessGatewayTask Prelude.Text
createWirelessGatewayTask_wirelessGatewayTaskDefinitionId :: Lens' CreateWirelessGatewayTask Text
createWirelessGatewayTask_wirelessGatewayTaskDefinitionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWirelessGatewayTask' {Text
wirelessGatewayTaskDefinitionId :: Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
wirelessGatewayTaskDefinitionId} -> Text
wirelessGatewayTaskDefinitionId) (\s :: CreateWirelessGatewayTask
s@CreateWirelessGatewayTask' {} Text
a -> CreateWirelessGatewayTask
s {$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: Text
wirelessGatewayTaskDefinitionId = Text
a} :: CreateWirelessGatewayTask)

instance Core.AWSRequest CreateWirelessGatewayTask where
  type
    AWSResponse CreateWirelessGatewayTask =
      CreateWirelessGatewayTaskResponse
  request :: (Service -> Service)
-> CreateWirelessGatewayTask -> Request CreateWirelessGatewayTask
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateWirelessGatewayTask
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateWirelessGatewayTask)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe WirelessGatewayTaskStatus
-> Maybe Text -> Int -> CreateWirelessGatewayTaskResponse
CreateWirelessGatewayTaskResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Status")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"WirelessGatewayTaskDefinitionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateWirelessGatewayTask where
  hashWithSalt :: Int -> CreateWirelessGatewayTask -> Int
hashWithSalt Int
_salt CreateWirelessGatewayTask' {Text
wirelessGatewayTaskDefinitionId :: Text
id :: Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
$sel:id:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
wirelessGatewayTaskDefinitionId

instance Prelude.NFData CreateWirelessGatewayTask where
  rnf :: CreateWirelessGatewayTask -> ()
rnf CreateWirelessGatewayTask' {Text
wirelessGatewayTaskDefinitionId :: Text
id :: Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
$sel:id:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
wirelessGatewayTaskDefinitionId

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

instance Data.ToJSON CreateWirelessGatewayTask where
  toJSON :: CreateWirelessGatewayTask -> Value
toJSON CreateWirelessGatewayTask' {Text
wirelessGatewayTaskDefinitionId :: Text
id :: Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
$sel:id:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"WirelessGatewayTaskDefinitionId"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
wirelessGatewayTaskDefinitionId
              )
          ]
      )

instance Data.ToPath CreateWirelessGatewayTask where
  toPath :: CreateWirelessGatewayTask -> ByteString
toPath CreateWirelessGatewayTask' {Text
wirelessGatewayTaskDefinitionId :: Text
id :: Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
$sel:id:CreateWirelessGatewayTask' :: CreateWirelessGatewayTask -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/wireless-gateways/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id, ByteString
"/tasks"]

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

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

-- |
-- Create a value of 'CreateWirelessGatewayTaskResponse' 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:
--
-- 'status', 'createWirelessGatewayTaskResponse_status' - The status of the request.
--
-- 'wirelessGatewayTaskDefinitionId', 'createWirelessGatewayTaskResponse_wirelessGatewayTaskDefinitionId' - The ID of the WirelessGatewayTaskDefinition.
--
-- 'httpStatus', 'createWirelessGatewayTaskResponse_httpStatus' - The response's http status code.
newCreateWirelessGatewayTaskResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateWirelessGatewayTaskResponse
newCreateWirelessGatewayTaskResponse :: Int -> CreateWirelessGatewayTaskResponse
newCreateWirelessGatewayTaskResponse Int
pHttpStatus_ =
  CreateWirelessGatewayTaskResponse'
    { $sel:status:CreateWirelessGatewayTaskResponse' :: Maybe WirelessGatewayTaskStatus
status =
        forall a. Maybe a
Prelude.Nothing,
      $sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTaskResponse' :: Maybe Text
wirelessGatewayTaskDefinitionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateWirelessGatewayTaskResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The status of the request.
createWirelessGatewayTaskResponse_status :: Lens.Lens' CreateWirelessGatewayTaskResponse (Prelude.Maybe WirelessGatewayTaskStatus)
createWirelessGatewayTaskResponse_status :: Lens'
  CreateWirelessGatewayTaskResponse (Maybe WirelessGatewayTaskStatus)
createWirelessGatewayTaskResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWirelessGatewayTaskResponse' {Maybe WirelessGatewayTaskStatus
status :: Maybe WirelessGatewayTaskStatus
$sel:status:CreateWirelessGatewayTaskResponse' :: CreateWirelessGatewayTaskResponse
-> Maybe WirelessGatewayTaskStatus
status} -> Maybe WirelessGatewayTaskStatus
status) (\s :: CreateWirelessGatewayTaskResponse
s@CreateWirelessGatewayTaskResponse' {} Maybe WirelessGatewayTaskStatus
a -> CreateWirelessGatewayTaskResponse
s {$sel:status:CreateWirelessGatewayTaskResponse' :: Maybe WirelessGatewayTaskStatus
status = Maybe WirelessGatewayTaskStatus
a} :: CreateWirelessGatewayTaskResponse)

-- | The ID of the WirelessGatewayTaskDefinition.
createWirelessGatewayTaskResponse_wirelessGatewayTaskDefinitionId :: Lens.Lens' CreateWirelessGatewayTaskResponse (Prelude.Maybe Prelude.Text)
createWirelessGatewayTaskResponse_wirelessGatewayTaskDefinitionId :: Lens' CreateWirelessGatewayTaskResponse (Maybe Text)
createWirelessGatewayTaskResponse_wirelessGatewayTaskDefinitionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateWirelessGatewayTaskResponse' {Maybe Text
wirelessGatewayTaskDefinitionId :: Maybe Text
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTaskResponse' :: CreateWirelessGatewayTaskResponse -> Maybe Text
wirelessGatewayTaskDefinitionId} -> Maybe Text
wirelessGatewayTaskDefinitionId) (\s :: CreateWirelessGatewayTaskResponse
s@CreateWirelessGatewayTaskResponse' {} Maybe Text
a -> CreateWirelessGatewayTaskResponse
s {$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTaskResponse' :: Maybe Text
wirelessGatewayTaskDefinitionId = Maybe Text
a} :: CreateWirelessGatewayTaskResponse)

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

instance
  Prelude.NFData
    CreateWirelessGatewayTaskResponse
  where
  rnf :: CreateWirelessGatewayTaskResponse -> ()
rnf CreateWirelessGatewayTaskResponse' {Int
Maybe Text
Maybe WirelessGatewayTaskStatus
httpStatus :: Int
wirelessGatewayTaskDefinitionId :: Maybe Text
status :: Maybe WirelessGatewayTaskStatus
$sel:httpStatus:CreateWirelessGatewayTaskResponse' :: CreateWirelessGatewayTaskResponse -> Int
$sel:wirelessGatewayTaskDefinitionId:CreateWirelessGatewayTaskResponse' :: CreateWirelessGatewayTaskResponse -> Maybe Text
$sel:status:CreateWirelessGatewayTaskResponse' :: CreateWirelessGatewayTaskResponse
-> Maybe WirelessGatewayTaskStatus
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe WirelessGatewayTaskStatus
status
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
wirelessGatewayTaskDefinitionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus