{-# 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-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)
--
-- 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 Amazonka.Glue.Types
import qualified Amazonka.Lens as Lens
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
(PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool)
-> (PutWorkflowRunProperties -> PutWorkflowRunProperties -> Bool)
-> Eq PutWorkflowRunProperties
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]
(Int -> ReadS PutWorkflowRunProperties)
-> ReadS [PutWorkflowRunProperties]
-> ReadPrec PutWorkflowRunProperties
-> ReadPrec [PutWorkflowRunProperties]
-> Read 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
(Int -> PutWorkflowRunProperties -> ShowS)
-> (PutWorkflowRunProperties -> String)
-> ([PutWorkflowRunProperties] -> ShowS)
-> Show PutWorkflowRunProperties
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.
 PutWorkflowRunProperties -> Rep PutWorkflowRunProperties x)
-> (forall x.
    Rep PutWorkflowRunProperties x -> PutWorkflowRunProperties)
-> Generic PutWorkflowRunProperties
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' :: Text -> Text -> HashMap Text Text -> PutWorkflowRunProperties
PutWorkflowRunProperties'
    { $sel:name:PutWorkflowRunProperties' :: Text
name = Text
pName_,
      $sel:runId:PutWorkflowRunProperties' :: Text
runId = Text
pRunId_,
      $sel:runProperties:PutWorkflowRunProperties' :: HashMap Text Text
runProperties = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
    }

-- | Name of the workflow which was run.
putWorkflowRunProperties_name :: Lens.Lens' PutWorkflowRunProperties Prelude.Text
putWorkflowRunProperties_name :: (Text -> f Text)
-> PutWorkflowRunProperties -> f PutWorkflowRunProperties
putWorkflowRunProperties_name = (PutWorkflowRunProperties -> Text)
-> (PutWorkflowRunProperties -> Text -> PutWorkflowRunProperties)
-> Lens PutWorkflowRunProperties PutWorkflowRunProperties Text Text
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 :: (Text -> f Text)
-> PutWorkflowRunProperties -> f PutWorkflowRunProperties
putWorkflowRunProperties_runId = (PutWorkflowRunProperties -> Text)
-> (PutWorkflowRunProperties -> Text -> PutWorkflowRunProperties)
-> Lens PutWorkflowRunProperties PutWorkflowRunProperties Text Text
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 :: (HashMap Text Text -> f (HashMap Text Text))
-> PutWorkflowRunProperties -> f PutWorkflowRunProperties
putWorkflowRunProperties_runProperties = (PutWorkflowRunProperties -> HashMap Text Text)
-> (PutWorkflowRunProperties
    -> HashMap Text Text -> PutWorkflowRunProperties)
-> Lens
     PutWorkflowRunProperties
     PutWorkflowRunProperties
     (HashMap Text Text)
     (HashMap Text Text)
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) ((HashMap Text Text -> f (HashMap Text Text))
 -> PutWorkflowRunProperties -> f PutWorkflowRunProperties)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> PutWorkflowRunProperties
-> f PutWorkflowRunProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
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 :: PutWorkflowRunProperties -> Request PutWorkflowRunProperties
request = Service
-> PutWorkflowRunProperties -> Request PutWorkflowRunProperties
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutWorkflowRunProperties
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutWorkflowRunProperties)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutWorkflowRunProperties))
-> Logger
-> Service
-> Proxy PutWorkflowRunProperties
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutWorkflowRunProperties)))
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 -> PutWorkflowRunPropertiesResponse
PutWorkflowRunPropertiesResponse'
            (Int -> PutWorkflowRunPropertiesResponse)
-> Either String Int
-> Either String PutWorkflowRunPropertiesResponse
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 PutWorkflowRunProperties

instance Prelude.NFData PutWorkflowRunProperties

instance Core.ToHeaders PutWorkflowRunProperties where
  toHeaders :: PutWorkflowRunProperties -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutWorkflowRunProperties -> 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
"AWSGlue.PutWorkflowRunProperties" ::
                          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 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
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
"RunId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
runId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"RunProperties" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
runProperties)
          ]
      )

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

instance Core.ToQuery PutWorkflowRunProperties where
  toQuery :: PutWorkflowRunProperties -> QueryString
toQuery = QueryString -> PutWorkflowRunProperties -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PutWorkflowRunPropertiesResponse
 -> PutWorkflowRunPropertiesResponse -> Bool)
-> (PutWorkflowRunPropertiesResponse
    -> PutWorkflowRunPropertiesResponse -> Bool)
-> Eq PutWorkflowRunPropertiesResponse
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]
(Int -> ReadS PutWorkflowRunPropertiesResponse)
-> ReadS [PutWorkflowRunPropertiesResponse]
-> ReadPrec PutWorkflowRunPropertiesResponse
-> ReadPrec [PutWorkflowRunPropertiesResponse]
-> Read 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
(Int -> PutWorkflowRunPropertiesResponse -> ShowS)
-> (PutWorkflowRunPropertiesResponse -> String)
-> ([PutWorkflowRunPropertiesResponse] -> ShowS)
-> Show PutWorkflowRunPropertiesResponse
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.
 PutWorkflowRunPropertiesResponse
 -> Rep PutWorkflowRunPropertiesResponse x)
-> (forall x.
    Rep PutWorkflowRunPropertiesResponse x
    -> PutWorkflowRunPropertiesResponse)
-> Generic PutWorkflowRunPropertiesResponse
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' :: Int -> PutWorkflowRunPropertiesResponse
PutWorkflowRunPropertiesResponse'
    { $sel:httpStatus:PutWorkflowRunPropertiesResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
putWorkflowRunPropertiesResponse_httpStatus :: Lens.Lens' PutWorkflowRunPropertiesResponse Prelude.Int
putWorkflowRunPropertiesResponse_httpStatus :: (Int -> f Int)
-> PutWorkflowRunPropertiesResponse
-> f PutWorkflowRunPropertiesResponse
putWorkflowRunPropertiesResponse_httpStatus = (PutWorkflowRunPropertiesResponse -> Int)
-> (PutWorkflowRunPropertiesResponse
    -> Int -> PutWorkflowRunPropertiesResponse)
-> Lens
     PutWorkflowRunPropertiesResponse
     PutWorkflowRunPropertiesResponse
     Int
     Int
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