{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.RobOMaker.Types.UploadConfiguration
-- 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)
module Amazonka.RobOMaker.Types.UploadConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RobOMaker.Types.UploadBehavior

-- | Provides upload configuration information. Files are uploaded from the
-- simulation job to a location you specify.
--
-- /See:/ 'newUploadConfiguration' smart constructor.
data UploadConfiguration = UploadConfiguration'
  { -- | A prefix that specifies where files will be uploaded in Amazon S3. It is
    -- appended to the simulation output location to determine the final path.
    --
    -- For example, if your simulation output location is @s3:\/\/my-bucket@
    -- and your upload configuration name is @robot-test@, your files will be
    -- uploaded to @s3:\/\/my-bucket\/\<simid>\/\<runid>\/robot-test@.
    UploadConfiguration -> Text
name :: Prelude.Text,
    -- | Specifies the path of the file(s) to upload. Standard Unix glob matching
    -- rules are accepted, with the addition of @**@ as a /super asterisk/. For
    -- example, specifying @\/var\/log\/**.log@ causes all .log files in the
    -- @\/var\/log@ directory tree to be collected. For more examples, see
    -- <https://github.com/gobwas/glob Glob Library>.
    UploadConfiguration -> Text
path :: Prelude.Text,
    -- | Specifies when to upload the files:
    --
    -- [UPLOAD_ON_TERMINATE]
    --     Matching files are uploaded once the simulation enters the
    --     @TERMINATING@ state. Matching files are not uploaded until all of
    --     your code (including tools) have stopped.
    --
    --     If there is a problem uploading a file, the upload is retried. If
    --     problems persist, no further upload attempts will be made.
    --
    -- [UPLOAD_ROLLING_AUTO_REMOVE]
    --     Matching files are uploaded as they are created. They are deleted
    --     after they are uploaded. The specified path is checked every 5
    --     seconds. A final check is made when all of your code (including
    --     tools) have stopped.
    UploadConfiguration -> UploadBehavior
uploadBehavior :: UploadBehavior
  }
  deriving (UploadConfiguration -> UploadConfiguration -> Bool
(UploadConfiguration -> UploadConfiguration -> Bool)
-> (UploadConfiguration -> UploadConfiguration -> Bool)
-> Eq UploadConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UploadConfiguration -> UploadConfiguration -> Bool
$c/= :: UploadConfiguration -> UploadConfiguration -> Bool
== :: UploadConfiguration -> UploadConfiguration -> Bool
$c== :: UploadConfiguration -> UploadConfiguration -> Bool
Prelude.Eq, ReadPrec [UploadConfiguration]
ReadPrec UploadConfiguration
Int -> ReadS UploadConfiguration
ReadS [UploadConfiguration]
(Int -> ReadS UploadConfiguration)
-> ReadS [UploadConfiguration]
-> ReadPrec UploadConfiguration
-> ReadPrec [UploadConfiguration]
-> Read UploadConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UploadConfiguration]
$creadListPrec :: ReadPrec [UploadConfiguration]
readPrec :: ReadPrec UploadConfiguration
$creadPrec :: ReadPrec UploadConfiguration
readList :: ReadS [UploadConfiguration]
$creadList :: ReadS [UploadConfiguration]
readsPrec :: Int -> ReadS UploadConfiguration
$creadsPrec :: Int -> ReadS UploadConfiguration
Prelude.Read, Int -> UploadConfiguration -> ShowS
[UploadConfiguration] -> ShowS
UploadConfiguration -> String
(Int -> UploadConfiguration -> ShowS)
-> (UploadConfiguration -> String)
-> ([UploadConfiguration] -> ShowS)
-> Show UploadConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadConfiguration] -> ShowS
$cshowList :: [UploadConfiguration] -> ShowS
show :: UploadConfiguration -> String
$cshow :: UploadConfiguration -> String
showsPrec :: Int -> UploadConfiguration -> ShowS
$cshowsPrec :: Int -> UploadConfiguration -> ShowS
Prelude.Show, (forall x. UploadConfiguration -> Rep UploadConfiguration x)
-> (forall x. Rep UploadConfiguration x -> UploadConfiguration)
-> Generic UploadConfiguration
forall x. Rep UploadConfiguration x -> UploadConfiguration
forall x. UploadConfiguration -> Rep UploadConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UploadConfiguration x -> UploadConfiguration
$cfrom :: forall x. UploadConfiguration -> Rep UploadConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'UploadConfiguration' 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', 'uploadConfiguration_name' - A prefix that specifies where files will be uploaded in Amazon S3. It is
-- appended to the simulation output location to determine the final path.
--
-- For example, if your simulation output location is @s3:\/\/my-bucket@
-- and your upload configuration name is @robot-test@, your files will be
-- uploaded to @s3:\/\/my-bucket\/\<simid>\/\<runid>\/robot-test@.
--
-- 'path', 'uploadConfiguration_path' - Specifies the path of the file(s) to upload. Standard Unix glob matching
-- rules are accepted, with the addition of @**@ as a /super asterisk/. For
-- example, specifying @\/var\/log\/**.log@ causes all .log files in the
-- @\/var\/log@ directory tree to be collected. For more examples, see
-- <https://github.com/gobwas/glob Glob Library>.
--
-- 'uploadBehavior', 'uploadConfiguration_uploadBehavior' - Specifies when to upload the files:
--
-- [UPLOAD_ON_TERMINATE]
--     Matching files are uploaded once the simulation enters the
--     @TERMINATING@ state. Matching files are not uploaded until all of
--     your code (including tools) have stopped.
--
--     If there is a problem uploading a file, the upload is retried. If
--     problems persist, no further upload attempts will be made.
--
-- [UPLOAD_ROLLING_AUTO_REMOVE]
--     Matching files are uploaded as they are created. They are deleted
--     after they are uploaded. The specified path is checked every 5
--     seconds. A final check is made when all of your code (including
--     tools) have stopped.
newUploadConfiguration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'path'
  Prelude.Text ->
  -- | 'uploadBehavior'
  UploadBehavior ->
  UploadConfiguration
newUploadConfiguration :: Text -> Text -> UploadBehavior -> UploadConfiguration
newUploadConfiguration Text
pName_ Text
pPath_ UploadBehavior
pUploadBehavior_ =
  UploadConfiguration' :: Text -> Text -> UploadBehavior -> UploadConfiguration
UploadConfiguration'
    { $sel:name:UploadConfiguration' :: Text
name = Text
pName_,
      $sel:path:UploadConfiguration' :: Text
path = Text
pPath_,
      $sel:uploadBehavior:UploadConfiguration' :: UploadBehavior
uploadBehavior = UploadBehavior
pUploadBehavior_
    }

-- | A prefix that specifies where files will be uploaded in Amazon S3. It is
-- appended to the simulation output location to determine the final path.
--
-- For example, if your simulation output location is @s3:\/\/my-bucket@
-- and your upload configuration name is @robot-test@, your files will be
-- uploaded to @s3:\/\/my-bucket\/\<simid>\/\<runid>\/robot-test@.
uploadConfiguration_name :: Lens.Lens' UploadConfiguration Prelude.Text
uploadConfiguration_name :: (Text -> f Text) -> UploadConfiguration -> f UploadConfiguration
uploadConfiguration_name = (UploadConfiguration -> Text)
-> (UploadConfiguration -> Text -> UploadConfiguration)
-> Lens UploadConfiguration UploadConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadConfiguration' {Text
name :: Text
$sel:name:UploadConfiguration' :: UploadConfiguration -> Text
name} -> Text
name) (\s :: UploadConfiguration
s@UploadConfiguration' {} Text
a -> UploadConfiguration
s {$sel:name:UploadConfiguration' :: Text
name = Text
a} :: UploadConfiguration)

-- | Specifies the path of the file(s) to upload. Standard Unix glob matching
-- rules are accepted, with the addition of @**@ as a /super asterisk/. For
-- example, specifying @\/var\/log\/**.log@ causes all .log files in the
-- @\/var\/log@ directory tree to be collected. For more examples, see
-- <https://github.com/gobwas/glob Glob Library>.
uploadConfiguration_path :: Lens.Lens' UploadConfiguration Prelude.Text
uploadConfiguration_path :: (Text -> f Text) -> UploadConfiguration -> f UploadConfiguration
uploadConfiguration_path = (UploadConfiguration -> Text)
-> (UploadConfiguration -> Text -> UploadConfiguration)
-> Lens UploadConfiguration UploadConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadConfiguration' {Text
path :: Text
$sel:path:UploadConfiguration' :: UploadConfiguration -> Text
path} -> Text
path) (\s :: UploadConfiguration
s@UploadConfiguration' {} Text
a -> UploadConfiguration
s {$sel:path:UploadConfiguration' :: Text
path = Text
a} :: UploadConfiguration)

-- | Specifies when to upload the files:
--
-- [UPLOAD_ON_TERMINATE]
--     Matching files are uploaded once the simulation enters the
--     @TERMINATING@ state. Matching files are not uploaded until all of
--     your code (including tools) have stopped.
--
--     If there is a problem uploading a file, the upload is retried. If
--     problems persist, no further upload attempts will be made.
--
-- [UPLOAD_ROLLING_AUTO_REMOVE]
--     Matching files are uploaded as they are created. They are deleted
--     after they are uploaded. The specified path is checked every 5
--     seconds. A final check is made when all of your code (including
--     tools) have stopped.
uploadConfiguration_uploadBehavior :: Lens.Lens' UploadConfiguration UploadBehavior
uploadConfiguration_uploadBehavior :: (UploadBehavior -> f UploadBehavior)
-> UploadConfiguration -> f UploadConfiguration
uploadConfiguration_uploadBehavior = (UploadConfiguration -> UploadBehavior)
-> (UploadConfiguration -> UploadBehavior -> UploadConfiguration)
-> Lens
     UploadConfiguration
     UploadConfiguration
     UploadBehavior
     UploadBehavior
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadConfiguration' {UploadBehavior
uploadBehavior :: UploadBehavior
$sel:uploadBehavior:UploadConfiguration' :: UploadConfiguration -> UploadBehavior
uploadBehavior} -> UploadBehavior
uploadBehavior) (\s :: UploadConfiguration
s@UploadConfiguration' {} UploadBehavior
a -> UploadConfiguration
s {$sel:uploadBehavior:UploadConfiguration' :: UploadBehavior
uploadBehavior = UploadBehavior
a} :: UploadConfiguration)

instance Core.FromJSON UploadConfiguration where
  parseJSON :: Value -> Parser UploadConfiguration
parseJSON =
    String
-> (Object -> Parser UploadConfiguration)
-> Value
-> Parser UploadConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"UploadConfiguration"
      ( \Object
x ->
          Text -> Text -> UploadBehavior -> UploadConfiguration
UploadConfiguration'
            (Text -> Text -> UploadBehavior -> UploadConfiguration)
-> Parser Text
-> Parser (Text -> UploadBehavior -> UploadConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"name")
            Parser (Text -> UploadBehavior -> UploadConfiguration)
-> Parser Text -> Parser (UploadBehavior -> UploadConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"path")
            Parser (UploadBehavior -> UploadConfiguration)
-> Parser UploadBehavior -> Parser UploadConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser UploadBehavior
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"uploadBehavior")
      )

instance Prelude.Hashable UploadConfiguration

instance Prelude.NFData UploadConfiguration

instance Core.ToJSON UploadConfiguration where
  toJSON :: UploadConfiguration -> Value
toJSON UploadConfiguration' {Text
UploadBehavior
uploadBehavior :: UploadBehavior
path :: Text
name :: Text
$sel:uploadBehavior:UploadConfiguration' :: UploadConfiguration -> UploadBehavior
$sel:path:UploadConfiguration' :: UploadConfiguration -> Text
$sel:name:UploadConfiguration' :: UploadConfiguration -> 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
"path" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
path),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"uploadBehavior" Text -> UploadBehavior -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= UploadBehavior
uploadBehavior)
          ]
      )