{-# 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.Schemas.StartDiscoverer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts the discoverer
module Amazonka.Schemas.StartDiscoverer
  ( -- * Creating a Request
    StartDiscoverer (..),
    newStartDiscoverer,

    -- * Request Lenses
    startDiscoverer_discovererId,

    -- * Destructuring the Response
    StartDiscovererResponse (..),
    newStartDiscovererResponse,

    -- * Response Lenses
    startDiscovererResponse_discovererId,
    startDiscovererResponse_state,
    startDiscovererResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'StartDiscoverer' 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:
--
-- 'discovererId', 'startDiscoverer_discovererId' - The ID of the discoverer.
newStartDiscoverer ::
  -- | 'discovererId'
  Prelude.Text ->
  StartDiscoverer
newStartDiscoverer :: Text -> StartDiscoverer
newStartDiscoverer Text
pDiscovererId_ =
  StartDiscoverer' {$sel:discovererId:StartDiscoverer' :: Text
discovererId = Text
pDiscovererId_}

-- | The ID of the discoverer.
startDiscoverer_discovererId :: Lens.Lens' StartDiscoverer Prelude.Text
startDiscoverer_discovererId :: Lens' StartDiscoverer Text
startDiscoverer_discovererId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDiscoverer' {Text
discovererId :: Text
$sel:discovererId:StartDiscoverer' :: StartDiscoverer -> Text
discovererId} -> Text
discovererId) (\s :: StartDiscoverer
s@StartDiscoverer' {} Text
a -> StartDiscoverer
s {$sel:discovererId:StartDiscoverer' :: Text
discovererId = Text
a} :: StartDiscoverer)

instance Core.AWSRequest StartDiscoverer where
  type
    AWSResponse StartDiscoverer =
      StartDiscovererResponse
  request :: (Service -> Service) -> StartDiscoverer -> Request StartDiscoverer
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 StartDiscoverer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartDiscoverer)))
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 Text
-> Maybe DiscovererState -> Int -> StartDiscovererResponse
StartDiscovererResponse'
            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
"DiscovererId")
            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
"State")
            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 StartDiscoverer where
  hashWithSalt :: Int -> StartDiscoverer -> Int
hashWithSalt Int
_salt StartDiscoverer' {Text
discovererId :: Text
$sel:discovererId:StartDiscoverer' :: StartDiscoverer -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
discovererId

instance Prelude.NFData StartDiscoverer where
  rnf :: StartDiscoverer -> ()
rnf StartDiscoverer' {Text
discovererId :: Text
$sel:discovererId:StartDiscoverer' :: StartDiscoverer -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
discovererId

instance Data.ToHeaders StartDiscoverer where
  toHeaders :: StartDiscoverer -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartDiscoverer where
  toJSON :: StartDiscoverer -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath StartDiscoverer where
  toPath :: StartDiscoverer -> ByteString
toPath StartDiscoverer' {Text
discovererId :: Text
$sel:discovererId:StartDiscoverer' :: StartDiscoverer -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/discoverers/id/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
discovererId,
        ByteString
"/start"
      ]

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

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

-- |
-- Create a value of 'StartDiscovererResponse' 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:
--
-- 'discovererId', 'startDiscovererResponse_discovererId' - The ID of the discoverer.
--
-- 'state', 'startDiscovererResponse_state' - The state of the discoverer.
--
-- 'httpStatus', 'startDiscovererResponse_httpStatus' - The response's http status code.
newStartDiscovererResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartDiscovererResponse
newStartDiscovererResponse :: Int -> StartDiscovererResponse
newStartDiscovererResponse Int
pHttpStatus_ =
  StartDiscovererResponse'
    { $sel:discovererId:StartDiscovererResponse' :: Maybe Text
discovererId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:state:StartDiscovererResponse' :: Maybe DiscovererState
state = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartDiscovererResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the discoverer.
startDiscovererResponse_discovererId :: Lens.Lens' StartDiscovererResponse (Prelude.Maybe Prelude.Text)
startDiscovererResponse_discovererId :: Lens' StartDiscovererResponse (Maybe Text)
startDiscovererResponse_discovererId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDiscovererResponse' {Maybe Text
discovererId :: Maybe Text
$sel:discovererId:StartDiscovererResponse' :: StartDiscovererResponse -> Maybe Text
discovererId} -> Maybe Text
discovererId) (\s :: StartDiscovererResponse
s@StartDiscovererResponse' {} Maybe Text
a -> StartDiscovererResponse
s {$sel:discovererId:StartDiscovererResponse' :: Maybe Text
discovererId = Maybe Text
a} :: StartDiscovererResponse)

-- | The state of the discoverer.
startDiscovererResponse_state :: Lens.Lens' StartDiscovererResponse (Prelude.Maybe DiscovererState)
startDiscovererResponse_state :: Lens' StartDiscovererResponse (Maybe DiscovererState)
startDiscovererResponse_state = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartDiscovererResponse' {Maybe DiscovererState
state :: Maybe DiscovererState
$sel:state:StartDiscovererResponse' :: StartDiscovererResponse -> Maybe DiscovererState
state} -> Maybe DiscovererState
state) (\s :: StartDiscovererResponse
s@StartDiscovererResponse' {} Maybe DiscovererState
a -> StartDiscovererResponse
s {$sel:state:StartDiscovererResponse' :: Maybe DiscovererState
state = Maybe DiscovererState
a} :: StartDiscovererResponse)

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

instance Prelude.NFData StartDiscovererResponse where
  rnf :: StartDiscovererResponse -> ()
rnf StartDiscovererResponse' {Int
Maybe Text
Maybe DiscovererState
httpStatus :: Int
state :: Maybe DiscovererState
discovererId :: Maybe Text
$sel:httpStatus:StartDiscovererResponse' :: StartDiscovererResponse -> Int
$sel:state:StartDiscovererResponse' :: StartDiscovererResponse -> Maybe DiscovererState
$sel:discovererId:StartDiscovererResponse' :: StartDiscovererResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
discovererId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DiscovererState
state
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus