{-# 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.RobOMaker.RegisterRobot
-- 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)
--
-- Registers a robot with a fleet.
module Amazonka.RobOMaker.RegisterRobot
  ( -- * Creating a Request
    RegisterRobot (..),
    newRegisterRobot,

    -- * Request Lenses
    registerRobot_fleet,
    registerRobot_robot,

    -- * Destructuring the Response
    RegisterRobotResponse (..),
    newRegisterRobotResponse,

    -- * Response Lenses
    registerRobotResponse_robot,
    registerRobotResponse_fleet,
    registerRobotResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'RegisterRobot' 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:
--
-- 'fleet', 'registerRobot_fleet' - The Amazon Resource Name (ARN) of the fleet.
--
-- 'robot', 'registerRobot_robot' - The Amazon Resource Name (ARN) of the robot.
newRegisterRobot ::
  -- | 'fleet'
  Prelude.Text ->
  -- | 'robot'
  Prelude.Text ->
  RegisterRobot
newRegisterRobot :: Text -> Text -> RegisterRobot
newRegisterRobot Text
pFleet_ Text
pRobot_ =
  RegisterRobot' :: Text -> Text -> RegisterRobot
RegisterRobot' {$sel:fleet:RegisterRobot' :: Text
fleet = Text
pFleet_, $sel:robot:RegisterRobot' :: Text
robot = Text
pRobot_}

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

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

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

instance Prelude.NFData RegisterRobot

instance Core.ToHeaders RegisterRobot where
  toHeaders :: RegisterRobot -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RegisterRobot -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON RegisterRobot where
  toJSON :: RegisterRobot -> Value
toJSON RegisterRobot' {Text
robot :: Text
fleet :: Text
$sel:robot:RegisterRobot' :: RegisterRobot -> Text
$sel:fleet:RegisterRobot' :: RegisterRobot -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"fleet" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
fleet),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"robot" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
robot)
          ]
      )

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

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

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

-- |
-- Create a value of 'RegisterRobotResponse' 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:
--
-- 'robot', 'registerRobotResponse_robot' - Information about the robot registration.
--
-- 'fleet', 'registerRobotResponse_fleet' - The Amazon Resource Name (ARN) of the fleet that the robot will join.
--
-- 'httpStatus', 'registerRobotResponse_httpStatus' - The response's http status code.
newRegisterRobotResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterRobotResponse
newRegisterRobotResponse :: Int -> RegisterRobotResponse
newRegisterRobotResponse Int
pHttpStatus_ =
  RegisterRobotResponse' :: Maybe Text -> Maybe Text -> Int -> RegisterRobotResponse
RegisterRobotResponse'
    { $sel:robot:RegisterRobotResponse' :: Maybe Text
robot = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fleet:RegisterRobotResponse' :: Maybe Text
fleet = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RegisterRobotResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the robot registration.
registerRobotResponse_robot :: Lens.Lens' RegisterRobotResponse (Prelude.Maybe Prelude.Text)
registerRobotResponse_robot :: (Maybe Text -> f (Maybe Text))
-> RegisterRobotResponse -> f RegisterRobotResponse
registerRobotResponse_robot = (RegisterRobotResponse -> Maybe Text)
-> (RegisterRobotResponse -> Maybe Text -> RegisterRobotResponse)
-> Lens
     RegisterRobotResponse
     RegisterRobotResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterRobotResponse' {Maybe Text
robot :: Maybe Text
$sel:robot:RegisterRobotResponse' :: RegisterRobotResponse -> Maybe Text
robot} -> Maybe Text
robot) (\s :: RegisterRobotResponse
s@RegisterRobotResponse' {} Maybe Text
a -> RegisterRobotResponse
s {$sel:robot:RegisterRobotResponse' :: Maybe Text
robot = Maybe Text
a} :: RegisterRobotResponse)

-- | The Amazon Resource Name (ARN) of the fleet that the robot will join.
registerRobotResponse_fleet :: Lens.Lens' RegisterRobotResponse (Prelude.Maybe Prelude.Text)
registerRobotResponse_fleet :: (Maybe Text -> f (Maybe Text))
-> RegisterRobotResponse -> f RegisterRobotResponse
registerRobotResponse_fleet = (RegisterRobotResponse -> Maybe Text)
-> (RegisterRobotResponse -> Maybe Text -> RegisterRobotResponse)
-> Lens
     RegisterRobotResponse
     RegisterRobotResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterRobotResponse' {Maybe Text
fleet :: Maybe Text
$sel:fleet:RegisterRobotResponse' :: RegisterRobotResponse -> Maybe Text
fleet} -> Maybe Text
fleet) (\s :: RegisterRobotResponse
s@RegisterRobotResponse' {} Maybe Text
a -> RegisterRobotResponse
s {$sel:fleet:RegisterRobotResponse' :: Maybe Text
fleet = Maybe Text
a} :: RegisterRobotResponse)

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

instance Prelude.NFData RegisterRobotResponse