{-# 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.OpenSearch.CancelServiceSoftwareUpdate
-- 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)
--
-- Cancels a scheduled service software update for an Amazon OpenSearch
-- Service domain. You can only perform this operation before the
-- @AutomatedUpdateDate@ and when the @UpdateStatus@ is in the
-- @PENDING_UPDATE@ state.
module Amazonka.OpenSearch.CancelServiceSoftwareUpdate
  ( -- * Creating a Request
    CancelServiceSoftwareUpdate (..),
    newCancelServiceSoftwareUpdate,

    -- * Request Lenses
    cancelServiceSoftwareUpdate_domainName,

    -- * Destructuring the Response
    CancelServiceSoftwareUpdateResponse (..),
    newCancelServiceSoftwareUpdateResponse,

    -- * Response Lenses
    cancelServiceSoftwareUpdateResponse_serviceSoftwareOptions,
    cancelServiceSoftwareUpdateResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.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 @ CancelServiceSoftwareUpdate @
-- operation. Specifies the name of the domain that you wish to cancel a
-- service software update on.
--
-- /See:/ 'newCancelServiceSoftwareUpdate' smart constructor.
data CancelServiceSoftwareUpdate = CancelServiceSoftwareUpdate'
  { -- | The name of the domain that you want to stop the latest service software
    -- update on.
    CancelServiceSoftwareUpdate -> Text
domainName :: Prelude.Text
  }
  deriving (CancelServiceSoftwareUpdate -> CancelServiceSoftwareUpdate -> Bool
(CancelServiceSoftwareUpdate
 -> CancelServiceSoftwareUpdate -> Bool)
-> (CancelServiceSoftwareUpdate
    -> CancelServiceSoftwareUpdate -> Bool)
-> Eq CancelServiceSoftwareUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CancelServiceSoftwareUpdate -> CancelServiceSoftwareUpdate -> Bool
$c/= :: CancelServiceSoftwareUpdate -> CancelServiceSoftwareUpdate -> Bool
== :: CancelServiceSoftwareUpdate -> CancelServiceSoftwareUpdate -> Bool
$c== :: CancelServiceSoftwareUpdate -> CancelServiceSoftwareUpdate -> Bool
Prelude.Eq, ReadPrec [CancelServiceSoftwareUpdate]
ReadPrec CancelServiceSoftwareUpdate
Int -> ReadS CancelServiceSoftwareUpdate
ReadS [CancelServiceSoftwareUpdate]
(Int -> ReadS CancelServiceSoftwareUpdate)
-> ReadS [CancelServiceSoftwareUpdate]
-> ReadPrec CancelServiceSoftwareUpdate
-> ReadPrec [CancelServiceSoftwareUpdate]
-> Read CancelServiceSoftwareUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CancelServiceSoftwareUpdate]
$creadListPrec :: ReadPrec [CancelServiceSoftwareUpdate]
readPrec :: ReadPrec CancelServiceSoftwareUpdate
$creadPrec :: ReadPrec CancelServiceSoftwareUpdate
readList :: ReadS [CancelServiceSoftwareUpdate]
$creadList :: ReadS [CancelServiceSoftwareUpdate]
readsPrec :: Int -> ReadS CancelServiceSoftwareUpdate
$creadsPrec :: Int -> ReadS CancelServiceSoftwareUpdate
Prelude.Read, Int -> CancelServiceSoftwareUpdate -> ShowS
[CancelServiceSoftwareUpdate] -> ShowS
CancelServiceSoftwareUpdate -> String
(Int -> CancelServiceSoftwareUpdate -> ShowS)
-> (CancelServiceSoftwareUpdate -> String)
-> ([CancelServiceSoftwareUpdate] -> ShowS)
-> Show CancelServiceSoftwareUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CancelServiceSoftwareUpdate] -> ShowS
$cshowList :: [CancelServiceSoftwareUpdate] -> ShowS
show :: CancelServiceSoftwareUpdate -> String
$cshow :: CancelServiceSoftwareUpdate -> String
showsPrec :: Int -> CancelServiceSoftwareUpdate -> ShowS
$cshowsPrec :: Int -> CancelServiceSoftwareUpdate -> ShowS
Prelude.Show, (forall x.
 CancelServiceSoftwareUpdate -> Rep CancelServiceSoftwareUpdate x)
-> (forall x.
    Rep CancelServiceSoftwareUpdate x -> CancelServiceSoftwareUpdate)
-> Generic CancelServiceSoftwareUpdate
forall x.
Rep CancelServiceSoftwareUpdate x -> CancelServiceSoftwareUpdate
forall x.
CancelServiceSoftwareUpdate -> Rep CancelServiceSoftwareUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CancelServiceSoftwareUpdate x -> CancelServiceSoftwareUpdate
$cfrom :: forall x.
CancelServiceSoftwareUpdate -> Rep CancelServiceSoftwareUpdate x
Prelude.Generic)

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

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

instance Core.AWSRequest CancelServiceSoftwareUpdate where
  type
    AWSResponse CancelServiceSoftwareUpdate =
      CancelServiceSoftwareUpdateResponse
  request :: CancelServiceSoftwareUpdate -> Request CancelServiceSoftwareUpdate
request = Service
-> CancelServiceSoftwareUpdate
-> Request CancelServiceSoftwareUpdate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CancelServiceSoftwareUpdate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelServiceSoftwareUpdate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CancelServiceSoftwareUpdate))
-> Logger
-> Service
-> Proxy CancelServiceSoftwareUpdate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CancelServiceSoftwareUpdate)))
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 ServiceSoftwareOptions
-> Int -> CancelServiceSoftwareUpdateResponse
CancelServiceSoftwareUpdateResponse'
            (Maybe ServiceSoftwareOptions
 -> Int -> CancelServiceSoftwareUpdateResponse)
-> Either String (Maybe ServiceSoftwareOptions)
-> Either String (Int -> CancelServiceSoftwareUpdateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ServiceSoftwareOptions)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ServiceSoftwareOptions")
            Either String (Int -> CancelServiceSoftwareUpdateResponse)
-> Either String Int
-> Either String CancelServiceSoftwareUpdateResponse
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 CancelServiceSoftwareUpdate

instance Prelude.NFData CancelServiceSoftwareUpdate

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

instance Core.ToJSON CancelServiceSoftwareUpdate where
  toJSON :: CancelServiceSoftwareUpdate -> Value
toJSON CancelServiceSoftwareUpdate' {Text
domainName :: Text
$sel:domainName:CancelServiceSoftwareUpdate' :: CancelServiceSoftwareUpdate -> 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
"DomainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainName)]
      )

instance Core.ToPath CancelServiceSoftwareUpdate where
  toPath :: CancelServiceSoftwareUpdate -> ByteString
toPath =
    ByteString -> CancelServiceSoftwareUpdate -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/2021-01-01/opensearch/serviceSoftwareUpdate/cancel"

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

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

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

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

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

instance
  Prelude.NFData
    CancelServiceSoftwareUpdateResponse