{-# 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.SSM.RegisterDefaultPatchBaseline
-- 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)
--
-- Defines the default patch baseline for the relevant operating system.
--
-- To reset the Amazon Web Services-predefined patch baseline as the
-- default, specify the full patch baseline Amazon Resource Name (ARN) as
-- the baseline ID value. For example, for CentOS, specify
-- @arn:aws:ssm:us-east-2:733109147000:patchbaseline\/pb-0574b43a65ea646ed@
-- instead of @pb-0574b43a65ea646ed@.
module Amazonka.SSM.RegisterDefaultPatchBaseline
  ( -- * Creating a Request
    RegisterDefaultPatchBaseline (..),
    newRegisterDefaultPatchBaseline,

    -- * Request Lenses
    registerDefaultPatchBaseline_baselineId,

    -- * Destructuring the Response
    RegisterDefaultPatchBaselineResponse (..),
    newRegisterDefaultPatchBaselineResponse,

    -- * Response Lenses
    registerDefaultPatchBaselineResponse_baselineId,
    registerDefaultPatchBaselineResponse_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.SSM.Types

-- | /See:/ 'newRegisterDefaultPatchBaseline' smart constructor.
data RegisterDefaultPatchBaseline = RegisterDefaultPatchBaseline'
  { -- | The ID of the patch baseline that should be the default patch baseline.
    RegisterDefaultPatchBaseline -> Text
baselineId :: Prelude.Text
  }
  deriving (RegisterDefaultPatchBaseline
-> RegisterDefaultPatchBaseline -> Bool
(RegisterDefaultPatchBaseline
 -> RegisterDefaultPatchBaseline -> Bool)
-> (RegisterDefaultPatchBaseline
    -> RegisterDefaultPatchBaseline -> Bool)
-> Eq RegisterDefaultPatchBaseline
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RegisterDefaultPatchBaseline
-> RegisterDefaultPatchBaseline -> Bool
$c/= :: RegisterDefaultPatchBaseline
-> RegisterDefaultPatchBaseline -> Bool
== :: RegisterDefaultPatchBaseline
-> RegisterDefaultPatchBaseline -> Bool
$c== :: RegisterDefaultPatchBaseline
-> RegisterDefaultPatchBaseline -> Bool
Prelude.Eq, ReadPrec [RegisterDefaultPatchBaseline]
ReadPrec RegisterDefaultPatchBaseline
Int -> ReadS RegisterDefaultPatchBaseline
ReadS [RegisterDefaultPatchBaseline]
(Int -> ReadS RegisterDefaultPatchBaseline)
-> ReadS [RegisterDefaultPatchBaseline]
-> ReadPrec RegisterDefaultPatchBaseline
-> ReadPrec [RegisterDefaultPatchBaseline]
-> Read RegisterDefaultPatchBaseline
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RegisterDefaultPatchBaseline]
$creadListPrec :: ReadPrec [RegisterDefaultPatchBaseline]
readPrec :: ReadPrec RegisterDefaultPatchBaseline
$creadPrec :: ReadPrec RegisterDefaultPatchBaseline
readList :: ReadS [RegisterDefaultPatchBaseline]
$creadList :: ReadS [RegisterDefaultPatchBaseline]
readsPrec :: Int -> ReadS RegisterDefaultPatchBaseline
$creadsPrec :: Int -> ReadS RegisterDefaultPatchBaseline
Prelude.Read, Int -> RegisterDefaultPatchBaseline -> ShowS
[RegisterDefaultPatchBaseline] -> ShowS
RegisterDefaultPatchBaseline -> String
(Int -> RegisterDefaultPatchBaseline -> ShowS)
-> (RegisterDefaultPatchBaseline -> String)
-> ([RegisterDefaultPatchBaseline] -> ShowS)
-> Show RegisterDefaultPatchBaseline
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RegisterDefaultPatchBaseline] -> ShowS
$cshowList :: [RegisterDefaultPatchBaseline] -> ShowS
show :: RegisterDefaultPatchBaseline -> String
$cshow :: RegisterDefaultPatchBaseline -> String
showsPrec :: Int -> RegisterDefaultPatchBaseline -> ShowS
$cshowsPrec :: Int -> RegisterDefaultPatchBaseline -> ShowS
Prelude.Show, (forall x.
 RegisterDefaultPatchBaseline -> Rep RegisterDefaultPatchBaseline x)
-> (forall x.
    Rep RegisterDefaultPatchBaseline x -> RegisterDefaultPatchBaseline)
-> Generic RegisterDefaultPatchBaseline
forall x.
Rep RegisterDefaultPatchBaseline x -> RegisterDefaultPatchBaseline
forall x.
RegisterDefaultPatchBaseline -> Rep RegisterDefaultPatchBaseline x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RegisterDefaultPatchBaseline x -> RegisterDefaultPatchBaseline
$cfrom :: forall x.
RegisterDefaultPatchBaseline -> Rep RegisterDefaultPatchBaseline x
Prelude.Generic)

-- |
-- Create a value of 'RegisterDefaultPatchBaseline' 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:
--
-- 'baselineId', 'registerDefaultPatchBaseline_baselineId' - The ID of the patch baseline that should be the default patch baseline.
newRegisterDefaultPatchBaseline ::
  -- | 'baselineId'
  Prelude.Text ->
  RegisterDefaultPatchBaseline
newRegisterDefaultPatchBaseline :: Text -> RegisterDefaultPatchBaseline
newRegisterDefaultPatchBaseline Text
pBaselineId_ =
  RegisterDefaultPatchBaseline' :: Text -> RegisterDefaultPatchBaseline
RegisterDefaultPatchBaseline'
    { $sel:baselineId:RegisterDefaultPatchBaseline' :: Text
baselineId =
        Text
pBaselineId_
    }

-- | The ID of the patch baseline that should be the default patch baseline.
registerDefaultPatchBaseline_baselineId :: Lens.Lens' RegisterDefaultPatchBaseline Prelude.Text
registerDefaultPatchBaseline_baselineId :: (Text -> f Text)
-> RegisterDefaultPatchBaseline -> f RegisterDefaultPatchBaseline
registerDefaultPatchBaseline_baselineId = (RegisterDefaultPatchBaseline -> Text)
-> (RegisterDefaultPatchBaseline
    -> Text -> RegisterDefaultPatchBaseline)
-> Lens
     RegisterDefaultPatchBaseline RegisterDefaultPatchBaseline Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDefaultPatchBaseline' {Text
baselineId :: Text
$sel:baselineId:RegisterDefaultPatchBaseline' :: RegisterDefaultPatchBaseline -> Text
baselineId} -> Text
baselineId) (\s :: RegisterDefaultPatchBaseline
s@RegisterDefaultPatchBaseline' {} Text
a -> RegisterDefaultPatchBaseline
s {$sel:baselineId:RegisterDefaultPatchBaseline' :: Text
baselineId = Text
a} :: RegisterDefaultPatchBaseline)

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

instance Prelude.NFData RegisterDefaultPatchBaseline

instance Core.ToHeaders RegisterDefaultPatchBaseline where
  toHeaders :: RegisterDefaultPatchBaseline -> ResponseHeaders
toHeaders =
    ResponseHeaders -> RegisterDefaultPatchBaseline -> 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
"AmazonSSM.RegisterDefaultPatchBaseline" ::
                          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 RegisterDefaultPatchBaseline where
  toJSON :: RegisterDefaultPatchBaseline -> Value
toJSON RegisterDefaultPatchBaseline' {Text
baselineId :: Text
$sel:baselineId:RegisterDefaultPatchBaseline' :: RegisterDefaultPatchBaseline -> 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
"BaselineId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
baselineId)]
      )

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

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

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

-- |
-- Create a value of 'RegisterDefaultPatchBaselineResponse' 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:
--
-- 'baselineId', 'registerDefaultPatchBaselineResponse_baselineId' - The ID of the default patch baseline.
--
-- 'httpStatus', 'registerDefaultPatchBaselineResponse_httpStatus' - The response's http status code.
newRegisterDefaultPatchBaselineResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RegisterDefaultPatchBaselineResponse
newRegisterDefaultPatchBaselineResponse :: Int -> RegisterDefaultPatchBaselineResponse
newRegisterDefaultPatchBaselineResponse Int
pHttpStatus_ =
  RegisterDefaultPatchBaselineResponse' :: Maybe Text -> Int -> RegisterDefaultPatchBaselineResponse
RegisterDefaultPatchBaselineResponse'
    { $sel:baselineId:RegisterDefaultPatchBaselineResponse' :: Maybe Text
baselineId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RegisterDefaultPatchBaselineResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The ID of the default patch baseline.
registerDefaultPatchBaselineResponse_baselineId :: Lens.Lens' RegisterDefaultPatchBaselineResponse (Prelude.Maybe Prelude.Text)
registerDefaultPatchBaselineResponse_baselineId :: (Maybe Text -> f (Maybe Text))
-> RegisterDefaultPatchBaselineResponse
-> f RegisterDefaultPatchBaselineResponse
registerDefaultPatchBaselineResponse_baselineId = (RegisterDefaultPatchBaselineResponse -> Maybe Text)
-> (RegisterDefaultPatchBaselineResponse
    -> Maybe Text -> RegisterDefaultPatchBaselineResponse)
-> Lens
     RegisterDefaultPatchBaselineResponse
     RegisterDefaultPatchBaselineResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RegisterDefaultPatchBaselineResponse' {Maybe Text
baselineId :: Maybe Text
$sel:baselineId:RegisterDefaultPatchBaselineResponse' :: RegisterDefaultPatchBaselineResponse -> Maybe Text
baselineId} -> Maybe Text
baselineId) (\s :: RegisterDefaultPatchBaselineResponse
s@RegisterDefaultPatchBaselineResponse' {} Maybe Text
a -> RegisterDefaultPatchBaselineResponse
s {$sel:baselineId:RegisterDefaultPatchBaselineResponse' :: Maybe Text
baselineId = Maybe Text
a} :: RegisterDefaultPatchBaselineResponse)

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

instance
  Prelude.NFData
    RegisterDefaultPatchBaselineResponse