{-# 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.Glue.PutWorkflowRunProperties
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Puts the specified workflow run properties for the given workflow run.
-- If a property already exists for the specified run, then it overrides
-- the value otherwise adds the property to existing properties.
module Amazonka.Glue.PutWorkflowRunProperties
  ( -- * Creating a Request
    PutWorkflowRunProperties (..),
    newPutWorkflowRunProperties,

    -- * Request Lenses
    putWorkflowRunProperties_name,
    putWorkflowRunProperties_runId,
    putWorkflowRunProperties_runProperties,

    -- * Destructuring the Response
    PutWorkflowRunPropertiesResponse (..),
    newPutWorkflowRunPropertiesResponse,

    -- * Response Lenses
    putWorkflowRunPropertiesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPutWorkflowRunProperties' smart constructor.
data PutWorkflowRunProperties = PutWorkflowRunProperties'
  { -- | Name of the workflow which was run.
    PutWorkflowRunProperties -> Text
name :: Prelude.Text,
    -- | The ID of the workflow run for which the run properties should be
    -- updated.
    PutWorkflowRunProperties -> Text
runId :: Prelude.Text,
    -- | The properties to put for the specified run.
    PutWorkflowRunProperties -> HashMap Text Text
runProperties :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool
$c/= :: PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool
== :: PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool
$c== :: PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool
Prelude.Eq, ReadPrec [PutWorkflowRunProperties]
ReadPrec PutWorkflowRunProperties
Int -> ReadS PutWorkflowRunProperties
ReadS [PutWorkflowRunProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutWorkflowRunProperties]
$creadListPrec :: ReadPrec [PutWorkflowRunProperties]
readPrec :: ReadPrec PutWorkflowRunProperties
$creadPrec :: ReadPrec PutWorkflowRunProperties
readList :: ReadS [PutWorkflowRunProperties]
$creadList :: ReadS [PutWorkflowRunProperties]
readsPrec :: Int -> ReadS PutWorkflowRunProperties
$creadsPrec :: Int -> ReadS PutWorkflowRunProperties
Prelude.Read, Int -> PutWorkflowRunProperties -> ShowS
[PutWorkflowRunProperties] -> ShowS
PutWorkflowRunProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutWorkflowRunProperties] -> ShowS
$cshowList :: [PutWorkflowRunProperties] -> ShowS
show :: PutWorkflowRunProperties -> String
$cshow :: PutWorkflowRunProperties -> String
showsPrec :: Int -> PutWorkflowRunProperties -> ShowS
$cshowsPrec :: Int -> PutWorkflowRunProperties -> ShowS
Prelude.Show, forall x.
Rep PutWorkflowRunProperties x -> PutWorkflowRunProperties
forall x.
PutWorkflowRunProperties -> Rep PutWorkflowRunProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutWorkflowRunProperties x -> PutWorkflowRunProperties
$cfrom :: forall x.
PutWorkflowRunProperties -> Rep PutWorkflowRunProperties x
Prelude.Generic)

-- |
-- Create a value of 'PutWorkflowRunProperties' 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', 'putWorkflowRunProperties_name' - Name of the workflow which was run.
--
-- 'runId', 'putWorkflowRunProperties_runId' - The ID of the workflow run for which the run properties should be
-- updated.
--
-- 'runProperties', 'putWorkflowRunProperties_runProperties' - The properties to put for the specified run.
newPutWorkflowRunProperties ::
  -- | 'name'
  Prelude.Text ->
  -- | 'runId'
  Prelude.Text ->
  PutWorkflowRunProperties
newPutWorkflowRunProperties :: Text -> Text -> PutWorkflowRunProperties
newPutWorkflowRunProperties Text
pName_ Text
pRunId_ =
  PutWorkflowRunProperties'
    { $sel:name:PutWorkflowRunProperties' :: Text
name = Text
pName_,
      $sel:runId:PutWorkflowRunProperties' :: Text
runId = Text
pRunId_,
      $sel:runProperties:PutWorkflowRunProperties' :: HashMap Text Text
runProperties = forall a. Monoid a => a
Prelude.mempty
    }

-- | Name of the workflow which was run.
putWorkflowRunProperties_name :: Lens.Lens' PutWorkflowRunProperties Prelude.Text
putWorkflowRunProperties_name :: Lens' PutWorkflowRunProperties Text
putWorkflowRunProperties_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutWorkflowRunProperties' {Text
name :: Text
$sel:name:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
name} -> Text
name) (\s :: PutWorkflowRunProperties
s@PutWorkflowRunProperties' {} Text
a -> PutWorkflowRunProperties
s {$sel:name:PutWorkflowRunProperties' :: Text
name = Text
a} :: PutWorkflowRunProperties)

-- | The ID of the workflow run for which the run properties should be
-- updated.
putWorkflowRunProperties_runId :: Lens.Lens' PutWorkflowRunProperties Prelude.Text
putWorkflowRunProperties_runId :: Lens' PutWorkflowRunProperties Text
putWorkflowRunProperties_runId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutWorkflowRunProperties' {Text
runId :: Text
$sel:runId:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
runId} -> Text
runId) (\s :: PutWorkflowRunProperties
s@PutWorkflowRunProperties' {} Text
a -> PutWorkflowRunProperties
s {$sel:runId:PutWorkflowRunProperties' :: Text
runId = Text
a} :: PutWorkflowRunProperties)

-- | The properties to put for the specified run.
putWorkflowRunProperties_runProperties :: Lens.Lens' PutWorkflowRunProperties (Prelude.HashMap Prelude.Text Prelude.Text)
putWorkflowRunProperties_runProperties :: Lens' PutWorkflowRunProperties (HashMap Text Text)
putWorkflowRunProperties_runProperties = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutWorkflowRunProperties' {HashMap Text Text
runProperties :: HashMap Text Text
$sel:runProperties:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> HashMap Text Text
runProperties} -> HashMap Text Text
runProperties) (\s :: PutWorkflowRunProperties
s@PutWorkflowRunProperties' {} HashMap Text Text
a -> PutWorkflowRunProperties
s {$sel:runProperties:PutWorkflowRunProperties' :: HashMap Text Text
runProperties = HashMap Text Text
a} :: PutWorkflowRunProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest PutWorkflowRunProperties where
  type
    AWSResponse PutWorkflowRunProperties =
      PutWorkflowRunPropertiesResponse
  request :: (Service -> Service)
-> PutWorkflowRunProperties -> Request PutWorkflowRunProperties
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 PutWorkflowRunProperties
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutWorkflowRunProperties)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutWorkflowRunPropertiesResponse
PutWorkflowRunPropertiesResponse'
            forall (f :: * -> *) a b. Functor 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 PutWorkflowRunProperties where
  hashWithSalt :: Int -> PutWorkflowRunProperties -> Int
hashWithSalt Int
_salt PutWorkflowRunProperties' {Text
HashMap Text Text
runProperties :: HashMap Text Text
runId :: Text
name :: Text
$sel:runProperties:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> HashMap Text Text
$sel:runId:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
$sel:name:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
runId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
runProperties

instance Prelude.NFData PutWorkflowRunProperties where
  rnf :: PutWorkflowRunProperties -> ()
rnf PutWorkflowRunProperties' {Text
HashMap Text Text
runProperties :: HashMap Text Text
runId :: Text
name :: Text
$sel:runProperties:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> HashMap Text Text
$sel:runId:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
$sel:name:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
runId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
runProperties

instance Data.ToHeaders PutWorkflowRunProperties where
  toHeaders :: PutWorkflowRunProperties -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSGlue.PutWorkflowRunProperties" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PutWorkflowRunProperties where
  toJSON :: PutWorkflowRunProperties -> Value
toJSON PutWorkflowRunProperties' {Text
HashMap Text Text
runProperties :: HashMap Text Text
runId :: Text
name :: Text
$sel:runProperties:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> HashMap Text Text
$sel:runId:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
$sel:name:PutWorkflowRunProperties' :: PutWorkflowRunProperties -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"RunId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
runId),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"RunProperties" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HashMap Text Text
runProperties)
          ]
      )

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

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

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

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

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

instance
  Prelude.NFData
    PutWorkflowRunPropertiesResponse
  where
  rnf :: PutWorkflowRunPropertiesResponse -> ()
rnf PutWorkflowRunPropertiesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutWorkflowRunPropertiesResponse' :: PutWorkflowRunPropertiesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus