{-# 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.StorageGateway.StartAvailabilityMonitorTest
-- 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)
--
-- Start a test that verifies that the specified gateway is configured for
-- High Availability monitoring in your host environment. This request only
-- initiates the test and that a successful response only indicates that
-- the test was started. It doesn\'t indicate that the test passed. For the
-- status of the test, invoke the @DescribeAvailabilityMonitorTest@ API.
--
-- Starting this test will cause your gateway to go offline for a brief
-- period.
module Amazonka.StorageGateway.StartAvailabilityMonitorTest
  ( -- * Creating a Request
    StartAvailabilityMonitorTest (..),
    newStartAvailabilityMonitorTest,

    -- * Request Lenses
    startAvailabilityMonitorTest_gatewayARN,

    -- * Destructuring the Response
    StartAvailabilityMonitorTestResponse (..),
    newStartAvailabilityMonitorTestResponse,

    -- * Response Lenses
    startAvailabilityMonitorTestResponse_gatewayARN,
    startAvailabilityMonitorTestResponse_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.StorageGateway.Types

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

-- |
-- Create a value of 'StartAvailabilityMonitorTest' 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:
--
-- 'gatewayARN', 'startAvailabilityMonitorTest_gatewayARN' - Undocumented member.
newStartAvailabilityMonitorTest ::
  -- | 'gatewayARN'
  Prelude.Text ->
  StartAvailabilityMonitorTest
newStartAvailabilityMonitorTest :: Text -> StartAvailabilityMonitorTest
newStartAvailabilityMonitorTest Text
pGatewayARN_ =
  StartAvailabilityMonitorTest' :: Text -> StartAvailabilityMonitorTest
StartAvailabilityMonitorTest'
    { $sel:gatewayARN:StartAvailabilityMonitorTest' :: Text
gatewayARN =
        Text
pGatewayARN_
    }

-- | Undocumented member.
startAvailabilityMonitorTest_gatewayARN :: Lens.Lens' StartAvailabilityMonitorTest Prelude.Text
startAvailabilityMonitorTest_gatewayARN :: (Text -> f Text)
-> StartAvailabilityMonitorTest -> f StartAvailabilityMonitorTest
startAvailabilityMonitorTest_gatewayARN = (StartAvailabilityMonitorTest -> Text)
-> (StartAvailabilityMonitorTest
    -> Text -> StartAvailabilityMonitorTest)
-> Lens
     StartAvailabilityMonitorTest StartAvailabilityMonitorTest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartAvailabilityMonitorTest' {Text
gatewayARN :: Text
$sel:gatewayARN:StartAvailabilityMonitorTest' :: StartAvailabilityMonitorTest -> Text
gatewayARN} -> Text
gatewayARN) (\s :: StartAvailabilityMonitorTest
s@StartAvailabilityMonitorTest' {} Text
a -> StartAvailabilityMonitorTest
s {$sel:gatewayARN:StartAvailabilityMonitorTest' :: Text
gatewayARN = Text
a} :: StartAvailabilityMonitorTest)

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

instance Prelude.NFData StartAvailabilityMonitorTest

instance Core.ToHeaders StartAvailabilityMonitorTest where
  toHeaders :: StartAvailabilityMonitorTest -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StartAvailabilityMonitorTest -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"StorageGateway_20130630.StartAvailabilityMonitorTest" ::
                          Prelude.ByteString
                      ),
            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 StartAvailabilityMonitorTest where
  toJSON :: StartAvailabilityMonitorTest -> Value
toJSON StartAvailabilityMonitorTest' {Text
gatewayARN :: Text
$sel:gatewayARN:StartAvailabilityMonitorTest' :: StartAvailabilityMonitorTest -> 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
"GatewayARN" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayARN)]
      )

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

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

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

-- |
-- Create a value of 'StartAvailabilityMonitorTestResponse' 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:
--
-- 'gatewayARN', 'startAvailabilityMonitorTestResponse_gatewayARN' - Undocumented member.
--
-- 'httpStatus', 'startAvailabilityMonitorTestResponse_httpStatus' - The response's http status code.
newStartAvailabilityMonitorTestResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartAvailabilityMonitorTestResponse
newStartAvailabilityMonitorTestResponse :: Int -> StartAvailabilityMonitorTestResponse
newStartAvailabilityMonitorTestResponse Int
pHttpStatus_ =
  StartAvailabilityMonitorTestResponse' :: Maybe Text -> Int -> StartAvailabilityMonitorTestResponse
StartAvailabilityMonitorTestResponse'
    { $sel:gatewayARN:StartAvailabilityMonitorTestResponse' :: Maybe Text
gatewayARN =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartAvailabilityMonitorTestResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
startAvailabilityMonitorTestResponse_gatewayARN :: Lens.Lens' StartAvailabilityMonitorTestResponse (Prelude.Maybe Prelude.Text)
startAvailabilityMonitorTestResponse_gatewayARN :: (Maybe Text -> f (Maybe Text))
-> StartAvailabilityMonitorTestResponse
-> f StartAvailabilityMonitorTestResponse
startAvailabilityMonitorTestResponse_gatewayARN = (StartAvailabilityMonitorTestResponse -> Maybe Text)
-> (StartAvailabilityMonitorTestResponse
    -> Maybe Text -> StartAvailabilityMonitorTestResponse)
-> Lens
     StartAvailabilityMonitorTestResponse
     StartAvailabilityMonitorTestResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartAvailabilityMonitorTestResponse' {Maybe Text
gatewayARN :: Maybe Text
$sel:gatewayARN:StartAvailabilityMonitorTestResponse' :: StartAvailabilityMonitorTestResponse -> Maybe Text
gatewayARN} -> Maybe Text
gatewayARN) (\s :: StartAvailabilityMonitorTestResponse
s@StartAvailabilityMonitorTestResponse' {} Maybe Text
a -> StartAvailabilityMonitorTestResponse
s {$sel:gatewayARN:StartAvailabilityMonitorTestResponse' :: Maybe Text
gatewayARN = Maybe Text
a} :: StartAvailabilityMonitorTestResponse)

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

instance
  Prelude.NFData
    StartAvailabilityMonitorTestResponse