{-# 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.StartServiceSoftwareUpdate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Schedules a service software update for an Amazon OpenSearch Service
-- domain. For more information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/service-software.html Service software updates in Amazon OpenSearch Service>.
module Amazonka.OpenSearch.StartServiceSoftwareUpdate
  ( -- * Creating a Request
    StartServiceSoftwareUpdate (..),
    newStartServiceSoftwareUpdate,

    -- * Request Lenses
    startServiceSoftwareUpdate_domainName,

    -- * Destructuring the Response
    StartServiceSoftwareUpdateResponse (..),
    newStartServiceSoftwareUpdateResponse,

    -- * Response Lenses
    startServiceSoftwareUpdateResponse_serviceSoftwareOptions,
    startServiceSoftwareUpdateResponse_httpStatus,
  )
where

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

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

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

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

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

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

instance Data.ToJSON StartServiceSoftwareUpdate where
  toJSON :: StartServiceSoftwareUpdate -> Value
toJSON StartServiceSoftwareUpdate' {Text
domainName :: Text
$sel:domainName:StartServiceSoftwareUpdate' :: StartServiceSoftwareUpdate -> 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 StartServiceSoftwareUpdate where
  toPath :: StartServiceSoftwareUpdate -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/2021-01-01/opensearch/serviceSoftwareUpdate/start"

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

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

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

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

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

instance
  Prelude.NFData
    StartServiceSoftwareUpdateResponse
  where
  rnf :: StartServiceSoftwareUpdateResponse -> ()
rnf StartServiceSoftwareUpdateResponse' {Int
Maybe ServiceSoftwareOptions
httpStatus :: Int
serviceSoftwareOptions :: Maybe ServiceSoftwareOptions
$sel:httpStatus:StartServiceSoftwareUpdateResponse' :: StartServiceSoftwareUpdateResponse -> Int
$sel:serviceSoftwareOptions:StartServiceSoftwareUpdateResponse' :: StartServiceSoftwareUpdateResponse -> 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