{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.RobOMaker.Types.UploadConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' UploadConfiguration Text
uploadConfiguration_name = 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 :: Lens' UploadConfiguration Text
uploadConfiguration_path = 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 :: Lens' UploadConfiguration UploadBehavior
uploadConfiguration_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 Data.FromJSON UploadConfiguration where
  parseJSON :: Value -> Parser UploadConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"UploadConfiguration"
      ( \Object
x ->
          Text -> Text -> UploadBehavior -> UploadConfiguration
UploadConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"name")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"path")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"uploadBehavior")
      )

instance Prelude.Hashable UploadConfiguration where
  hashWithSalt :: Int -> UploadConfiguration -> Int
hashWithSalt Int
_salt UploadConfiguration' {Text
UploadBehavior
uploadBehavior :: UploadBehavior
path :: Text
name :: Text
$sel:uploadBehavior:UploadConfiguration' :: UploadConfiguration -> UploadBehavior
$sel:path:UploadConfiguration' :: UploadConfiguration -> Text
$sel:name:UploadConfiguration' :: UploadConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
path
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UploadBehavior
uploadBehavior

instance Prelude.NFData UploadConfiguration where
  rnf :: UploadConfiguration -> ()
rnf UploadConfiguration' {Text
UploadBehavior
uploadBehavior :: UploadBehavior
path :: Text
name :: Text
$sel:uploadBehavior:UploadConfiguration' :: UploadConfiguration -> UploadBehavior
$sel:path:UploadConfiguration' :: UploadConfiguration -> Text
$sel:name:UploadConfiguration' :: UploadConfiguration -> 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
path
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UploadBehavior
uploadBehavior

instance Data.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
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
"path" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
path),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"uploadBehavior" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= UploadBehavior
uploadBehavior)
          ]
      )