{-# 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.ElasticSearch.CancelElasticsearchServiceSoftwareUpdate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Cancels a scheduled service software update for an Amazon ES domain. You
-- can only perform this operation before the @AutomatedUpdateDate@ and
-- when the @UpdateStatus@ is in the @PENDING_UPDATE@ state.
module Amazonka.ElasticSearch.CancelElasticsearchServiceSoftwareUpdate
  ( -- * Creating a Request
    CancelElasticsearchServiceSoftwareUpdate (..),
    newCancelElasticsearchServiceSoftwareUpdate,

    -- * Request Lenses
    cancelElasticsearchServiceSoftwareUpdate_domainName,

    -- * Destructuring the Response
    CancelElasticsearchServiceSoftwareUpdateResponse (..),
    newCancelElasticsearchServiceSoftwareUpdateResponse,

    -- * Response Lenses
    cancelElasticsearchServiceSoftwareUpdateResponse_serviceSoftwareOptions,
    cancelElasticsearchServiceSoftwareUpdateResponse_httpStatus,
  )
where

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

-- | Container for the parameters to the
-- @CancelElasticsearchServiceSoftwareUpdate@ operation. Specifies the name
-- of the Elasticsearch domain that you wish to cancel a service software
-- update on.
--
-- /See:/ 'newCancelElasticsearchServiceSoftwareUpdate' smart constructor.
data CancelElasticsearchServiceSoftwareUpdate = CancelElasticsearchServiceSoftwareUpdate'
  { -- | The name of the domain that you want to stop the latest service software
    -- update on.
    CancelElasticsearchServiceSoftwareUpdate -> Text
domainName :: Prelude.Text
  }
  deriving (CancelElasticsearchServiceSoftwareUpdate
-> CancelElasticsearchServiceSoftwareUpdate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelElasticsearchServiceSoftwareUpdate
-> CancelElasticsearchServiceSoftwareUpdate -> Bool
$c/= :: CancelElasticsearchServiceSoftwareUpdate
-> CancelElasticsearchServiceSoftwareUpdate -> Bool
== :: CancelElasticsearchServiceSoftwareUpdate
-> CancelElasticsearchServiceSoftwareUpdate -> Bool
$c== :: CancelElasticsearchServiceSoftwareUpdate
-> CancelElasticsearchServiceSoftwareUpdate -> Bool
Prelude.Eq, ReadPrec [CancelElasticsearchServiceSoftwareUpdate]
ReadPrec CancelElasticsearchServiceSoftwareUpdate
Int -> ReadS CancelElasticsearchServiceSoftwareUpdate
ReadS [CancelElasticsearchServiceSoftwareUpdate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelElasticsearchServiceSoftwareUpdate]
$creadListPrec :: ReadPrec [CancelElasticsearchServiceSoftwareUpdate]
readPrec :: ReadPrec CancelElasticsearchServiceSoftwareUpdate
$creadPrec :: ReadPrec CancelElasticsearchServiceSoftwareUpdate
readList :: ReadS [CancelElasticsearchServiceSoftwareUpdate]
$creadList :: ReadS [CancelElasticsearchServiceSoftwareUpdate]
readsPrec :: Int -> ReadS CancelElasticsearchServiceSoftwareUpdate
$creadsPrec :: Int -> ReadS CancelElasticsearchServiceSoftwareUpdate
Prelude.Read, Int -> CancelElasticsearchServiceSoftwareUpdate -> ShowS
[CancelElasticsearchServiceSoftwareUpdate] -> ShowS
CancelElasticsearchServiceSoftwareUpdate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelElasticsearchServiceSoftwareUpdate] -> ShowS
$cshowList :: [CancelElasticsearchServiceSoftwareUpdate] -> ShowS
show :: CancelElasticsearchServiceSoftwareUpdate -> String
$cshow :: CancelElasticsearchServiceSoftwareUpdate -> String
showsPrec :: Int -> CancelElasticsearchServiceSoftwareUpdate -> ShowS
$cshowsPrec :: Int -> CancelElasticsearchServiceSoftwareUpdate -> ShowS
Prelude.Show, forall x.
Rep CancelElasticsearchServiceSoftwareUpdate x
-> CancelElasticsearchServiceSoftwareUpdate
forall x.
CancelElasticsearchServiceSoftwareUpdate
-> Rep CancelElasticsearchServiceSoftwareUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelElasticsearchServiceSoftwareUpdate x
-> CancelElasticsearchServiceSoftwareUpdate
$cfrom :: forall x.
CancelElasticsearchServiceSoftwareUpdate
-> Rep CancelElasticsearchServiceSoftwareUpdate x
Prelude.Generic)

-- |
-- Create a value of 'CancelElasticsearchServiceSoftwareUpdate' 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:
--
-- 'domainName', 'cancelElasticsearchServiceSoftwareUpdate_domainName' - The name of the domain that you want to stop the latest service software
-- update on.
newCancelElasticsearchServiceSoftwareUpdate ::
  -- | 'domainName'
  Prelude.Text ->
  CancelElasticsearchServiceSoftwareUpdate
newCancelElasticsearchServiceSoftwareUpdate :: Text -> CancelElasticsearchServiceSoftwareUpdate
newCancelElasticsearchServiceSoftwareUpdate
  Text
pDomainName_ =
    CancelElasticsearchServiceSoftwareUpdate'
      { $sel:domainName:CancelElasticsearchServiceSoftwareUpdate' :: Text
domainName =
          Text
pDomainName_
      }

-- | The name of the domain that you want to stop the latest service software
-- update on.
cancelElasticsearchServiceSoftwareUpdate_domainName :: Lens.Lens' CancelElasticsearchServiceSoftwareUpdate Prelude.Text
cancelElasticsearchServiceSoftwareUpdate_domainName :: Lens' CancelElasticsearchServiceSoftwareUpdate Text
cancelElasticsearchServiceSoftwareUpdate_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelElasticsearchServiceSoftwareUpdate' {Text
domainName :: Text
$sel:domainName:CancelElasticsearchServiceSoftwareUpdate' :: CancelElasticsearchServiceSoftwareUpdate -> Text
domainName} -> Text
domainName) (\s :: CancelElasticsearchServiceSoftwareUpdate
s@CancelElasticsearchServiceSoftwareUpdate' {} Text
a -> CancelElasticsearchServiceSoftwareUpdate
s {$sel:domainName:CancelElasticsearchServiceSoftwareUpdate' :: Text
domainName = Text
a} :: CancelElasticsearchServiceSoftwareUpdate)

instance
  Core.AWSRequest
    CancelElasticsearchServiceSoftwareUpdate
  where
  type
    AWSResponse
      CancelElasticsearchServiceSoftwareUpdate =
      CancelElasticsearchServiceSoftwareUpdateResponse
  request :: (Service -> Service)
-> CancelElasticsearchServiceSoftwareUpdate
-> Request CancelElasticsearchServiceSoftwareUpdate
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 CancelElasticsearchServiceSoftwareUpdate
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse
           (AWSResponse CancelElasticsearchServiceSoftwareUpdate)))
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 ServiceSoftwareOptions
-> Int -> CancelElasticsearchServiceSoftwareUpdateResponse
CancelElasticsearchServiceSoftwareUpdateResponse'
            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
"ServiceSoftwareOptions")
            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
    CancelElasticsearchServiceSoftwareUpdate
  where
  hashWithSalt :: Int -> CancelElasticsearchServiceSoftwareUpdate -> Int
hashWithSalt
    Int
_salt
    CancelElasticsearchServiceSoftwareUpdate' {Text
domainName :: Text
$sel:domainName:CancelElasticsearchServiceSoftwareUpdate' :: CancelElasticsearchServiceSoftwareUpdate -> Text
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

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

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

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

instance
  Data.ToPath
    CancelElasticsearchServiceSoftwareUpdate
  where
  toPath :: CancelElasticsearchServiceSoftwareUpdate -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/2015-01-01/es/serviceSoftwareUpdate/cancel"

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

-- | The result of a @CancelElasticsearchServiceSoftwareUpdate@ operation.
-- Contains the status of the update.
--
-- /See:/ 'newCancelElasticsearchServiceSoftwareUpdateResponse' smart constructor.
data CancelElasticsearchServiceSoftwareUpdateResponse = CancelElasticsearchServiceSoftwareUpdateResponse'
  { -- | The current status of the Elasticsearch service software update.
    CancelElasticsearchServiceSoftwareUpdateResponse
-> Maybe ServiceSoftwareOptions
serviceSoftwareOptions :: Prelude.Maybe ServiceSoftwareOptions,
    -- | The response's http status code.
    CancelElasticsearchServiceSoftwareUpdateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CancelElasticsearchServiceSoftwareUpdateResponse
-> CancelElasticsearchServiceSoftwareUpdateResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelElasticsearchServiceSoftwareUpdateResponse
-> CancelElasticsearchServiceSoftwareUpdateResponse -> Bool
$c/= :: CancelElasticsearchServiceSoftwareUpdateResponse
-> CancelElasticsearchServiceSoftwareUpdateResponse -> Bool
== :: CancelElasticsearchServiceSoftwareUpdateResponse
-> CancelElasticsearchServiceSoftwareUpdateResponse -> Bool
$c== :: CancelElasticsearchServiceSoftwareUpdateResponse
-> CancelElasticsearchServiceSoftwareUpdateResponse -> Bool
Prelude.Eq, ReadPrec [CancelElasticsearchServiceSoftwareUpdateResponse]
ReadPrec CancelElasticsearchServiceSoftwareUpdateResponse
Int -> ReadS CancelElasticsearchServiceSoftwareUpdateResponse
ReadS [CancelElasticsearchServiceSoftwareUpdateResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelElasticsearchServiceSoftwareUpdateResponse]
$creadListPrec :: ReadPrec [CancelElasticsearchServiceSoftwareUpdateResponse]
readPrec :: ReadPrec CancelElasticsearchServiceSoftwareUpdateResponse
$creadPrec :: ReadPrec CancelElasticsearchServiceSoftwareUpdateResponse
readList :: ReadS [CancelElasticsearchServiceSoftwareUpdateResponse]
$creadList :: ReadS [CancelElasticsearchServiceSoftwareUpdateResponse]
readsPrec :: Int -> ReadS CancelElasticsearchServiceSoftwareUpdateResponse
$creadsPrec :: Int -> ReadS CancelElasticsearchServiceSoftwareUpdateResponse
Prelude.Read, Int -> CancelElasticsearchServiceSoftwareUpdateResponse -> ShowS
[CancelElasticsearchServiceSoftwareUpdateResponse] -> ShowS
CancelElasticsearchServiceSoftwareUpdateResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelElasticsearchServiceSoftwareUpdateResponse] -> ShowS
$cshowList :: [CancelElasticsearchServiceSoftwareUpdateResponse] -> ShowS
show :: CancelElasticsearchServiceSoftwareUpdateResponse -> String
$cshow :: CancelElasticsearchServiceSoftwareUpdateResponse -> String
showsPrec :: Int -> CancelElasticsearchServiceSoftwareUpdateResponse -> ShowS
$cshowsPrec :: Int -> CancelElasticsearchServiceSoftwareUpdateResponse -> ShowS
Prelude.Show, forall x.
Rep CancelElasticsearchServiceSoftwareUpdateResponse x
-> CancelElasticsearchServiceSoftwareUpdateResponse
forall x.
CancelElasticsearchServiceSoftwareUpdateResponse
-> Rep CancelElasticsearchServiceSoftwareUpdateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelElasticsearchServiceSoftwareUpdateResponse x
-> CancelElasticsearchServiceSoftwareUpdateResponse
$cfrom :: forall x.
CancelElasticsearchServiceSoftwareUpdateResponse
-> Rep CancelElasticsearchServiceSoftwareUpdateResponse x
Prelude.Generic)

-- |
-- Create a value of 'CancelElasticsearchServiceSoftwareUpdateResponse' 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:
--
-- 'serviceSoftwareOptions', 'cancelElasticsearchServiceSoftwareUpdateResponse_serviceSoftwareOptions' - The current status of the Elasticsearch service software update.
--
-- 'httpStatus', 'cancelElasticsearchServiceSoftwareUpdateResponse_httpStatus' - The response's http status code.
newCancelElasticsearchServiceSoftwareUpdateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CancelElasticsearchServiceSoftwareUpdateResponse
newCancelElasticsearchServiceSoftwareUpdateResponse :: Int -> CancelElasticsearchServiceSoftwareUpdateResponse
newCancelElasticsearchServiceSoftwareUpdateResponse
  Int
pHttpStatus_ =
    CancelElasticsearchServiceSoftwareUpdateResponse'
      { $sel:serviceSoftwareOptions:CancelElasticsearchServiceSoftwareUpdateResponse' :: Maybe ServiceSoftwareOptions
serviceSoftwareOptions =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:CancelElasticsearchServiceSoftwareUpdateResponse' :: Int
httpStatus = Int
pHttpStatus_
      }

-- | The current status of the Elasticsearch service software update.
cancelElasticsearchServiceSoftwareUpdateResponse_serviceSoftwareOptions :: Lens.Lens' CancelElasticsearchServiceSoftwareUpdateResponse (Prelude.Maybe ServiceSoftwareOptions)
cancelElasticsearchServiceSoftwareUpdateResponse_serviceSoftwareOptions :: Lens'
  CancelElasticsearchServiceSoftwareUpdateResponse
  (Maybe ServiceSoftwareOptions)
cancelElasticsearchServiceSoftwareUpdateResponse_serviceSoftwareOptions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CancelElasticsearchServiceSoftwareUpdateResponse' {Maybe ServiceSoftwareOptions
serviceSoftwareOptions :: Maybe ServiceSoftwareOptions
$sel:serviceSoftwareOptions:CancelElasticsearchServiceSoftwareUpdateResponse' :: CancelElasticsearchServiceSoftwareUpdateResponse
-> Maybe ServiceSoftwareOptions
serviceSoftwareOptions} -> Maybe ServiceSoftwareOptions
serviceSoftwareOptions) (\s :: CancelElasticsearchServiceSoftwareUpdateResponse
s@CancelElasticsearchServiceSoftwareUpdateResponse' {} Maybe ServiceSoftwareOptions
a -> CancelElasticsearchServiceSoftwareUpdateResponse
s {$sel:serviceSoftwareOptions:CancelElasticsearchServiceSoftwareUpdateResponse' :: Maybe ServiceSoftwareOptions
serviceSoftwareOptions = Maybe ServiceSoftwareOptions
a} :: CancelElasticsearchServiceSoftwareUpdateResponse)

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

instance
  Prelude.NFData
    CancelElasticsearchServiceSoftwareUpdateResponse
  where
  rnf :: CancelElasticsearchServiceSoftwareUpdateResponse -> ()
rnf
    CancelElasticsearchServiceSoftwareUpdateResponse' {Int
Maybe ServiceSoftwareOptions
httpStatus :: Int
serviceSoftwareOptions :: Maybe ServiceSoftwareOptions
$sel:httpStatus:CancelElasticsearchServiceSoftwareUpdateResponse' :: CancelElasticsearchServiceSoftwareUpdateResponse -> Int
$sel:serviceSoftwareOptions:CancelElasticsearchServiceSoftwareUpdateResponse' :: CancelElasticsearchServiceSoftwareUpdateResponse
-> Maybe ServiceSoftwareOptions
..} =
      forall a. NFData a => a -> ()
Prelude.rnf Maybe ServiceSoftwareOptions
serviceSoftwareOptions
        seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus