{-# 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.StartAssociationsOnce
-- 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)
--
-- Runs an association immediately and only one time. This operation can be
-- helpful when troubleshooting associations.
module Amazonka.SSM.StartAssociationsOnce
  ( -- * Creating a Request
    StartAssociationsOnce (..),
    newStartAssociationsOnce,

    -- * Request Lenses
    startAssociationsOnce_associationIds,

    -- * Destructuring the Response
    StartAssociationsOnceResponse (..),
    newStartAssociationsOnceResponse,

    -- * Response Lenses
    startAssociationsOnceResponse_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:/ 'newStartAssociationsOnce' smart constructor.
data StartAssociationsOnce = StartAssociationsOnce'
  { -- | The association IDs that you want to run immediately and only one time.
    StartAssociationsOnce -> NonEmpty Text
associationIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (StartAssociationsOnce -> StartAssociationsOnce -> Bool
(StartAssociationsOnce -> StartAssociationsOnce -> Bool)
-> (StartAssociationsOnce -> StartAssociationsOnce -> Bool)
-> Eq StartAssociationsOnce
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartAssociationsOnce -> StartAssociationsOnce -> Bool
$c/= :: StartAssociationsOnce -> StartAssociationsOnce -> Bool
== :: StartAssociationsOnce -> StartAssociationsOnce -> Bool
$c== :: StartAssociationsOnce -> StartAssociationsOnce -> Bool
Prelude.Eq, ReadPrec [StartAssociationsOnce]
ReadPrec StartAssociationsOnce
Int -> ReadS StartAssociationsOnce
ReadS [StartAssociationsOnce]
(Int -> ReadS StartAssociationsOnce)
-> ReadS [StartAssociationsOnce]
-> ReadPrec StartAssociationsOnce
-> ReadPrec [StartAssociationsOnce]
-> Read StartAssociationsOnce
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartAssociationsOnce]
$creadListPrec :: ReadPrec [StartAssociationsOnce]
readPrec :: ReadPrec StartAssociationsOnce
$creadPrec :: ReadPrec StartAssociationsOnce
readList :: ReadS [StartAssociationsOnce]
$creadList :: ReadS [StartAssociationsOnce]
readsPrec :: Int -> ReadS StartAssociationsOnce
$creadsPrec :: Int -> ReadS StartAssociationsOnce
Prelude.Read, Int -> StartAssociationsOnce -> ShowS
[StartAssociationsOnce] -> ShowS
StartAssociationsOnce -> String
(Int -> StartAssociationsOnce -> ShowS)
-> (StartAssociationsOnce -> String)
-> ([StartAssociationsOnce] -> ShowS)
-> Show StartAssociationsOnce
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartAssociationsOnce] -> ShowS
$cshowList :: [StartAssociationsOnce] -> ShowS
show :: StartAssociationsOnce -> String
$cshow :: StartAssociationsOnce -> String
showsPrec :: Int -> StartAssociationsOnce -> ShowS
$cshowsPrec :: Int -> StartAssociationsOnce -> ShowS
Prelude.Show, (forall x. StartAssociationsOnce -> Rep StartAssociationsOnce x)
-> (forall x. Rep StartAssociationsOnce x -> StartAssociationsOnce)
-> Generic StartAssociationsOnce
forall x. Rep StartAssociationsOnce x -> StartAssociationsOnce
forall x. StartAssociationsOnce -> Rep StartAssociationsOnce x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartAssociationsOnce x -> StartAssociationsOnce
$cfrom :: forall x. StartAssociationsOnce -> Rep StartAssociationsOnce x
Prelude.Generic)

-- |
-- Create a value of 'StartAssociationsOnce' 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:
--
-- 'associationIds', 'startAssociationsOnce_associationIds' - The association IDs that you want to run immediately and only one time.
newStartAssociationsOnce ::
  -- | 'associationIds'
  Prelude.NonEmpty Prelude.Text ->
  StartAssociationsOnce
newStartAssociationsOnce :: NonEmpty Text -> StartAssociationsOnce
newStartAssociationsOnce NonEmpty Text
pAssociationIds_ =
  StartAssociationsOnce' :: NonEmpty Text -> StartAssociationsOnce
StartAssociationsOnce'
    { $sel:associationIds:StartAssociationsOnce' :: NonEmpty Text
associationIds =
        Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pAssociationIds_
    }

-- | The association IDs that you want to run immediately and only one time.
startAssociationsOnce_associationIds :: Lens.Lens' StartAssociationsOnce (Prelude.NonEmpty Prelude.Text)
startAssociationsOnce_associationIds :: (NonEmpty Text -> f (NonEmpty Text))
-> StartAssociationsOnce -> f StartAssociationsOnce
startAssociationsOnce_associationIds = (StartAssociationsOnce -> NonEmpty Text)
-> (StartAssociationsOnce
    -> NonEmpty Text -> StartAssociationsOnce)
-> Lens
     StartAssociationsOnce
     StartAssociationsOnce
     (NonEmpty Text)
     (NonEmpty Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartAssociationsOnce' {NonEmpty Text
associationIds :: NonEmpty Text
$sel:associationIds:StartAssociationsOnce' :: StartAssociationsOnce -> NonEmpty Text
associationIds} -> NonEmpty Text
associationIds) (\s :: StartAssociationsOnce
s@StartAssociationsOnce' {} NonEmpty Text
a -> StartAssociationsOnce
s {$sel:associationIds:StartAssociationsOnce' :: NonEmpty Text
associationIds = NonEmpty Text
a} :: StartAssociationsOnce) ((NonEmpty Text -> f (NonEmpty Text))
 -> StartAssociationsOnce -> f StartAssociationsOnce)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> StartAssociationsOnce
-> f StartAssociationsOnce
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest StartAssociationsOnce where
  type
    AWSResponse StartAssociationsOnce =
      StartAssociationsOnceResponse
  request :: StartAssociationsOnce -> Request StartAssociationsOnce
request = Service -> StartAssociationsOnce -> Request StartAssociationsOnce
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartAssociationsOnce
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAssociationsOnce)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartAssociationsOnce))
-> Logger
-> Service
-> Proxy StartAssociationsOnce
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartAssociationsOnce)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartAssociationsOnceResponse
StartAssociationsOnceResponse'
            (Int -> StartAssociationsOnceResponse)
-> Either String Int -> Either String StartAssociationsOnceResponse
forall (f :: * -> *) a b. Functor 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 StartAssociationsOnce

instance Prelude.NFData StartAssociationsOnce

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

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

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

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

-- |
-- Create a value of 'StartAssociationsOnceResponse' 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:
--
-- 'httpStatus', 'startAssociationsOnceResponse_httpStatus' - The response's http status code.
newStartAssociationsOnceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartAssociationsOnceResponse
newStartAssociationsOnceResponse :: Int -> StartAssociationsOnceResponse
newStartAssociationsOnceResponse Int
pHttpStatus_ =
  StartAssociationsOnceResponse' :: Int -> StartAssociationsOnceResponse
StartAssociationsOnceResponse'
    { $sel:httpStatus:StartAssociationsOnceResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData StartAssociationsOnceResponse