{-# 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-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)
--
-- Schedules a service software update for an Amazon OpenSearch Service
-- domain.
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.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 @ StartServiceSoftwareUpdate @
-- operation. Specifies the name of the domain to schedule a service
-- software update for.
--
-- /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
(StartServiceSoftwareUpdate -> StartServiceSoftwareUpdate -> Bool)
-> (StartServiceSoftwareUpdate
    -> StartServiceSoftwareUpdate -> Bool)
-> Eq StartServiceSoftwareUpdate
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]
(Int -> ReadS StartServiceSoftwareUpdate)
-> ReadS [StartServiceSoftwareUpdate]
-> ReadPrec StartServiceSoftwareUpdate
-> ReadPrec [StartServiceSoftwareUpdate]
-> Read 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
(Int -> StartServiceSoftwareUpdate -> ShowS)
-> (StartServiceSoftwareUpdate -> String)
-> ([StartServiceSoftwareUpdate] -> ShowS)
-> Show StartServiceSoftwareUpdate
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.
 StartServiceSoftwareUpdate -> Rep StartServiceSoftwareUpdate x)
-> (forall x.
    Rep StartServiceSoftwareUpdate x -> StartServiceSoftwareUpdate)
-> Generic StartServiceSoftwareUpdate
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' :: Text -> StartServiceSoftwareUpdate
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 :: (Text -> f Text)
-> StartServiceSoftwareUpdate -> f StartServiceSoftwareUpdate
startServiceSoftwareUpdate_domainName = (StartServiceSoftwareUpdate -> Text)
-> (StartServiceSoftwareUpdate
    -> Text -> StartServiceSoftwareUpdate)
-> Lens
     StartServiceSoftwareUpdate StartServiceSoftwareUpdate Text Text
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 :: StartServiceSoftwareUpdate -> Request StartServiceSoftwareUpdate
request = Service
-> StartServiceSoftwareUpdate -> Request StartServiceSoftwareUpdate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartServiceSoftwareUpdate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartServiceSoftwareUpdate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse StartServiceSoftwareUpdate))
-> Logger
-> Service
-> Proxy StartServiceSoftwareUpdate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartServiceSoftwareUpdate)))
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 -> StartServiceSoftwareUpdateResponse
StartServiceSoftwareUpdateResponse'
            (Maybe ServiceSoftwareOptions
 -> Int -> StartServiceSoftwareUpdateResponse)
-> Either String (Maybe ServiceSoftwareOptions)
-> Either String (Int -> StartServiceSoftwareUpdateResponse)
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 -> StartServiceSoftwareUpdateResponse)
-> Either String Int
-> Either String StartServiceSoftwareUpdateResponse
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 StartServiceSoftwareUpdate

instance Prelude.NFData StartServiceSoftwareUpdate

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

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

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

-- | The result 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
(StartServiceSoftwareUpdateResponse
 -> StartServiceSoftwareUpdateResponse -> Bool)
-> (StartServiceSoftwareUpdateResponse
    -> StartServiceSoftwareUpdateResponse -> Bool)
-> Eq StartServiceSoftwareUpdateResponse
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]
(Int -> ReadS StartServiceSoftwareUpdateResponse)
-> ReadS [StartServiceSoftwareUpdateResponse]
-> ReadPrec StartServiceSoftwareUpdateResponse
-> ReadPrec [StartServiceSoftwareUpdateResponse]
-> Read 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
(Int -> StartServiceSoftwareUpdateResponse -> ShowS)
-> (StartServiceSoftwareUpdateResponse -> String)
-> ([StartServiceSoftwareUpdateResponse] -> ShowS)
-> Show StartServiceSoftwareUpdateResponse
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.
 StartServiceSoftwareUpdateResponse
 -> Rep StartServiceSoftwareUpdateResponse x)
-> (forall x.
    Rep StartServiceSoftwareUpdateResponse x
    -> StartServiceSoftwareUpdateResponse)
-> Generic StartServiceSoftwareUpdateResponse
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' :: Maybe ServiceSoftwareOptions
-> Int -> StartServiceSoftwareUpdateResponse
StartServiceSoftwareUpdateResponse'
    { $sel:serviceSoftwareOptions:StartServiceSoftwareUpdateResponse' :: Maybe ServiceSoftwareOptions
serviceSoftwareOptions =
        Maybe 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 :: (Maybe ServiceSoftwareOptions -> f (Maybe ServiceSoftwareOptions))
-> StartServiceSoftwareUpdateResponse
-> f StartServiceSoftwareUpdateResponse
startServiceSoftwareUpdateResponse_serviceSoftwareOptions = (StartServiceSoftwareUpdateResponse
 -> Maybe ServiceSoftwareOptions)
-> (StartServiceSoftwareUpdateResponse
    -> Maybe ServiceSoftwareOptions
    -> StartServiceSoftwareUpdateResponse)
-> Lens
     StartServiceSoftwareUpdateResponse
     StartServiceSoftwareUpdateResponse
     (Maybe ServiceSoftwareOptions)
     (Maybe 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 :: (Int -> f Int)
-> StartServiceSoftwareUpdateResponse
-> f StartServiceSoftwareUpdateResponse
startServiceSoftwareUpdateResponse_httpStatus = (StartServiceSoftwareUpdateResponse -> Int)
-> (StartServiceSoftwareUpdateResponse
    -> Int -> StartServiceSoftwareUpdateResponse)
-> Lens
     StartServiceSoftwareUpdateResponse
     StartServiceSoftwareUpdateResponse
     Int
     Int
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