{-# 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.UpdateAssociationStatus
-- 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)
--
-- Updates the status of the Amazon Web Services Systems Manager document
-- (SSM document) associated with the specified instance.
--
-- @UpdateAssociationStatus@ is primarily used by the Amazon Web Services
-- Systems Manager Agent (SSM Agent) to report status updates about your
-- associations and is only used for associations created with the
-- @InstanceId@ legacy parameter.
module Amazonka.SSM.UpdateAssociationStatus
  ( -- * Creating a Request
    UpdateAssociationStatus (..),
    newUpdateAssociationStatus,

    -- * Request Lenses
    updateAssociationStatus_name,
    updateAssociationStatus_instanceId,
    updateAssociationStatus_associationStatus,

    -- * Destructuring the Response
    UpdateAssociationStatusResponse (..),
    newUpdateAssociationStatusResponse,

    -- * Response Lenses
    updateAssociationStatusResponse_associationDescription,
    updateAssociationStatusResponse_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:/ 'newUpdateAssociationStatus' smart constructor.
data UpdateAssociationStatus = UpdateAssociationStatus'
  { -- | The name of the SSM document.
    UpdateAssociationStatus -> Text
name :: Prelude.Text,
    -- | The instance ID.
    UpdateAssociationStatus -> Text
instanceId :: Prelude.Text,
    -- | The association status.
    UpdateAssociationStatus -> AssociationStatus
associationStatus :: AssociationStatus
  }
  deriving (UpdateAssociationStatus -> UpdateAssociationStatus -> Bool
(UpdateAssociationStatus -> UpdateAssociationStatus -> Bool)
-> (UpdateAssociationStatus -> UpdateAssociationStatus -> Bool)
-> Eq UpdateAssociationStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAssociationStatus -> UpdateAssociationStatus -> Bool
$c/= :: UpdateAssociationStatus -> UpdateAssociationStatus -> Bool
== :: UpdateAssociationStatus -> UpdateAssociationStatus -> Bool
$c== :: UpdateAssociationStatus -> UpdateAssociationStatus -> Bool
Prelude.Eq, ReadPrec [UpdateAssociationStatus]
ReadPrec UpdateAssociationStatus
Int -> ReadS UpdateAssociationStatus
ReadS [UpdateAssociationStatus]
(Int -> ReadS UpdateAssociationStatus)
-> ReadS [UpdateAssociationStatus]
-> ReadPrec UpdateAssociationStatus
-> ReadPrec [UpdateAssociationStatus]
-> Read UpdateAssociationStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAssociationStatus]
$creadListPrec :: ReadPrec [UpdateAssociationStatus]
readPrec :: ReadPrec UpdateAssociationStatus
$creadPrec :: ReadPrec UpdateAssociationStatus
readList :: ReadS [UpdateAssociationStatus]
$creadList :: ReadS [UpdateAssociationStatus]
readsPrec :: Int -> ReadS UpdateAssociationStatus
$creadsPrec :: Int -> ReadS UpdateAssociationStatus
Prelude.Read, Int -> UpdateAssociationStatus -> ShowS
[UpdateAssociationStatus] -> ShowS
UpdateAssociationStatus -> String
(Int -> UpdateAssociationStatus -> ShowS)
-> (UpdateAssociationStatus -> String)
-> ([UpdateAssociationStatus] -> ShowS)
-> Show UpdateAssociationStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAssociationStatus] -> ShowS
$cshowList :: [UpdateAssociationStatus] -> ShowS
show :: UpdateAssociationStatus -> String
$cshow :: UpdateAssociationStatus -> String
showsPrec :: Int -> UpdateAssociationStatus -> ShowS
$cshowsPrec :: Int -> UpdateAssociationStatus -> ShowS
Prelude.Show, (forall x.
 UpdateAssociationStatus -> Rep UpdateAssociationStatus x)
-> (forall x.
    Rep UpdateAssociationStatus x -> UpdateAssociationStatus)
-> Generic UpdateAssociationStatus
forall x. Rep UpdateAssociationStatus x -> UpdateAssociationStatus
forall x. UpdateAssociationStatus -> Rep UpdateAssociationStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAssociationStatus x -> UpdateAssociationStatus
$cfrom :: forall x. UpdateAssociationStatus -> Rep UpdateAssociationStatus x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAssociationStatus' 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:
--
-- 'name', 'updateAssociationStatus_name' - The name of the SSM document.
--
-- 'instanceId', 'updateAssociationStatus_instanceId' - The instance ID.
--
-- 'associationStatus', 'updateAssociationStatus_associationStatus' - The association status.
newUpdateAssociationStatus ::
  -- | 'name'
  Prelude.Text ->
  -- | 'instanceId'
  Prelude.Text ->
  -- | 'associationStatus'
  AssociationStatus ->
  UpdateAssociationStatus
newUpdateAssociationStatus :: Text -> Text -> AssociationStatus -> UpdateAssociationStatus
newUpdateAssociationStatus
  Text
pName_
  Text
pInstanceId_
  AssociationStatus
pAssociationStatus_ =
    UpdateAssociationStatus' :: Text -> Text -> AssociationStatus -> UpdateAssociationStatus
UpdateAssociationStatus'
      { $sel:name:UpdateAssociationStatus' :: Text
name = Text
pName_,
        $sel:instanceId:UpdateAssociationStatus' :: Text
instanceId = Text
pInstanceId_,
        $sel:associationStatus:UpdateAssociationStatus' :: AssociationStatus
associationStatus = AssociationStatus
pAssociationStatus_
      }

-- | The name of the SSM document.
updateAssociationStatus_name :: Lens.Lens' UpdateAssociationStatus Prelude.Text
updateAssociationStatus_name :: (Text -> f Text)
-> UpdateAssociationStatus -> f UpdateAssociationStatus
updateAssociationStatus_name = (UpdateAssociationStatus -> Text)
-> (UpdateAssociationStatus -> Text -> UpdateAssociationStatus)
-> Lens UpdateAssociationStatus UpdateAssociationStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssociationStatus' {Text
name :: Text
$sel:name:UpdateAssociationStatus' :: UpdateAssociationStatus -> Text
name} -> Text
name) (\s :: UpdateAssociationStatus
s@UpdateAssociationStatus' {} Text
a -> UpdateAssociationStatus
s {$sel:name:UpdateAssociationStatus' :: Text
name = Text
a} :: UpdateAssociationStatus)

-- | The instance ID.
updateAssociationStatus_instanceId :: Lens.Lens' UpdateAssociationStatus Prelude.Text
updateAssociationStatus_instanceId :: (Text -> f Text)
-> UpdateAssociationStatus -> f UpdateAssociationStatus
updateAssociationStatus_instanceId = (UpdateAssociationStatus -> Text)
-> (UpdateAssociationStatus -> Text -> UpdateAssociationStatus)
-> Lens UpdateAssociationStatus UpdateAssociationStatus Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssociationStatus' {Text
instanceId :: Text
$sel:instanceId:UpdateAssociationStatus' :: UpdateAssociationStatus -> Text
instanceId} -> Text
instanceId) (\s :: UpdateAssociationStatus
s@UpdateAssociationStatus' {} Text
a -> UpdateAssociationStatus
s {$sel:instanceId:UpdateAssociationStatus' :: Text
instanceId = Text
a} :: UpdateAssociationStatus)

-- | The association status.
updateAssociationStatus_associationStatus :: Lens.Lens' UpdateAssociationStatus AssociationStatus
updateAssociationStatus_associationStatus :: (AssociationStatus -> f AssociationStatus)
-> UpdateAssociationStatus -> f UpdateAssociationStatus
updateAssociationStatus_associationStatus = (UpdateAssociationStatus -> AssociationStatus)
-> (UpdateAssociationStatus
    -> AssociationStatus -> UpdateAssociationStatus)
-> Lens
     UpdateAssociationStatus
     UpdateAssociationStatus
     AssociationStatus
     AssociationStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssociationStatus' {AssociationStatus
associationStatus :: AssociationStatus
$sel:associationStatus:UpdateAssociationStatus' :: UpdateAssociationStatus -> AssociationStatus
associationStatus} -> AssociationStatus
associationStatus) (\s :: UpdateAssociationStatus
s@UpdateAssociationStatus' {} AssociationStatus
a -> UpdateAssociationStatus
s {$sel:associationStatus:UpdateAssociationStatus' :: AssociationStatus
associationStatus = AssociationStatus
a} :: UpdateAssociationStatus)

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

instance Prelude.NFData UpdateAssociationStatus

instance Core.ToHeaders UpdateAssociationStatus where
  toHeaders :: UpdateAssociationStatus -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAssociationStatus -> 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.UpdateAssociationStatus" ::
                          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 UpdateAssociationStatus where
  toJSON :: UpdateAssociationStatus -> Value
toJSON UpdateAssociationStatus' {Text
AssociationStatus
associationStatus :: AssociationStatus
instanceId :: Text
name :: Text
$sel:associationStatus:UpdateAssociationStatus' :: UpdateAssociationStatus -> AssociationStatus
$sel:instanceId:UpdateAssociationStatus' :: UpdateAssociationStatus -> Text
$sel:name:UpdateAssociationStatus' :: UpdateAssociationStatus -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"InstanceId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AssociationStatus" Text -> AssociationStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AssociationStatus
associationStatus)
          ]
      )

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

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

-- | /See:/ 'newUpdateAssociationStatusResponse' smart constructor.
data UpdateAssociationStatusResponse = UpdateAssociationStatusResponse'
  { -- | Information about the association.
    UpdateAssociationStatusResponse -> Maybe AssociationDescription
associationDescription :: Prelude.Maybe AssociationDescription,
    -- | The response's http status code.
    UpdateAssociationStatusResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateAssociationStatusResponse
-> UpdateAssociationStatusResponse -> Bool
(UpdateAssociationStatusResponse
 -> UpdateAssociationStatusResponse -> Bool)
-> (UpdateAssociationStatusResponse
    -> UpdateAssociationStatusResponse -> Bool)
-> Eq UpdateAssociationStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAssociationStatusResponse
-> UpdateAssociationStatusResponse -> Bool
$c/= :: UpdateAssociationStatusResponse
-> UpdateAssociationStatusResponse -> Bool
== :: UpdateAssociationStatusResponse
-> UpdateAssociationStatusResponse -> Bool
$c== :: UpdateAssociationStatusResponse
-> UpdateAssociationStatusResponse -> Bool
Prelude.Eq, ReadPrec [UpdateAssociationStatusResponse]
ReadPrec UpdateAssociationStatusResponse
Int -> ReadS UpdateAssociationStatusResponse
ReadS [UpdateAssociationStatusResponse]
(Int -> ReadS UpdateAssociationStatusResponse)
-> ReadS [UpdateAssociationStatusResponse]
-> ReadPrec UpdateAssociationStatusResponse
-> ReadPrec [UpdateAssociationStatusResponse]
-> Read UpdateAssociationStatusResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAssociationStatusResponse]
$creadListPrec :: ReadPrec [UpdateAssociationStatusResponse]
readPrec :: ReadPrec UpdateAssociationStatusResponse
$creadPrec :: ReadPrec UpdateAssociationStatusResponse
readList :: ReadS [UpdateAssociationStatusResponse]
$creadList :: ReadS [UpdateAssociationStatusResponse]
readsPrec :: Int -> ReadS UpdateAssociationStatusResponse
$creadsPrec :: Int -> ReadS UpdateAssociationStatusResponse
Prelude.Read, Int -> UpdateAssociationStatusResponse -> ShowS
[UpdateAssociationStatusResponse] -> ShowS
UpdateAssociationStatusResponse -> String
(Int -> UpdateAssociationStatusResponse -> ShowS)
-> (UpdateAssociationStatusResponse -> String)
-> ([UpdateAssociationStatusResponse] -> ShowS)
-> Show UpdateAssociationStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAssociationStatusResponse] -> ShowS
$cshowList :: [UpdateAssociationStatusResponse] -> ShowS
show :: UpdateAssociationStatusResponse -> String
$cshow :: UpdateAssociationStatusResponse -> String
showsPrec :: Int -> UpdateAssociationStatusResponse -> ShowS
$cshowsPrec :: Int -> UpdateAssociationStatusResponse -> ShowS
Prelude.Show, (forall x.
 UpdateAssociationStatusResponse
 -> Rep UpdateAssociationStatusResponse x)
-> (forall x.
    Rep UpdateAssociationStatusResponse x
    -> UpdateAssociationStatusResponse)
-> Generic UpdateAssociationStatusResponse
forall x.
Rep UpdateAssociationStatusResponse x
-> UpdateAssociationStatusResponse
forall x.
UpdateAssociationStatusResponse
-> Rep UpdateAssociationStatusResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateAssociationStatusResponse x
-> UpdateAssociationStatusResponse
$cfrom :: forall x.
UpdateAssociationStatusResponse
-> Rep UpdateAssociationStatusResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAssociationStatusResponse' 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:
--
-- 'associationDescription', 'updateAssociationStatusResponse_associationDescription' - Information about the association.
--
-- 'httpStatus', 'updateAssociationStatusResponse_httpStatus' - The response's http status code.
newUpdateAssociationStatusResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateAssociationStatusResponse
newUpdateAssociationStatusResponse :: Int -> UpdateAssociationStatusResponse
newUpdateAssociationStatusResponse Int
pHttpStatus_ =
  UpdateAssociationStatusResponse' :: Maybe AssociationDescription
-> Int -> UpdateAssociationStatusResponse
UpdateAssociationStatusResponse'
    { $sel:associationDescription:UpdateAssociationStatusResponse' :: Maybe AssociationDescription
associationDescription =
        Maybe AssociationDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateAssociationStatusResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the association.
updateAssociationStatusResponse_associationDescription :: Lens.Lens' UpdateAssociationStatusResponse (Prelude.Maybe AssociationDescription)
updateAssociationStatusResponse_associationDescription :: (Maybe AssociationDescription -> f (Maybe AssociationDescription))
-> UpdateAssociationStatusResponse
-> f UpdateAssociationStatusResponse
updateAssociationStatusResponse_associationDescription = (UpdateAssociationStatusResponse -> Maybe AssociationDescription)
-> (UpdateAssociationStatusResponse
    -> Maybe AssociationDescription -> UpdateAssociationStatusResponse)
-> Lens
     UpdateAssociationStatusResponse
     UpdateAssociationStatusResponse
     (Maybe AssociationDescription)
     (Maybe AssociationDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAssociationStatusResponse' {Maybe AssociationDescription
associationDescription :: Maybe AssociationDescription
$sel:associationDescription:UpdateAssociationStatusResponse' :: UpdateAssociationStatusResponse -> Maybe AssociationDescription
associationDescription} -> Maybe AssociationDescription
associationDescription) (\s :: UpdateAssociationStatusResponse
s@UpdateAssociationStatusResponse' {} Maybe AssociationDescription
a -> UpdateAssociationStatusResponse
s {$sel:associationDescription:UpdateAssociationStatusResponse' :: Maybe AssociationDescription
associationDescription = Maybe AssociationDescription
a} :: UpdateAssociationStatusResponse)

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

instance
  Prelude.NFData
    UpdateAssociationStatusResponse