{-# 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.GameLift.Types.S3Location
-- 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.GameLift.Types.S3Location 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

-- | The location in Amazon S3 where build or script files are stored for
-- access by Amazon GameLift.
--
-- /See:/ 'newS3Location' smart constructor.
data S3Location = S3Location'
  { -- | An Amazon S3 bucket identifier. Thename of the S3 bucket.
    --
    -- GameLift doesn\'t support uploading from Amazon S3 buckets with names
    -- that contain a dot (.).
    S3Location -> Maybe Text
bucket :: Prelude.Maybe Prelude.Text,
    -- | The name of the zip file that contains the build files or script files.
    S3Location -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The version of the file, if object versioning is turned on for the
    -- bucket. Amazon GameLift uses this information when retrieving files from
    -- an S3 bucket that you own. Use this parameter to specify a specific
    -- version of the file. If not set, the latest version of the file is
    -- retrieved.
    S3Location -> Maybe Text
objectVersion :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
    -- for an IAM role that allows Amazon GameLift to access the S3 bucket.
    S3Location -> Maybe Text
roleArn :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Location -> S3Location -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Location -> S3Location -> Bool
$c/= :: S3Location -> S3Location -> Bool
== :: S3Location -> S3Location -> Bool
$c== :: S3Location -> S3Location -> Bool
Prelude.Eq, ReadPrec [S3Location]
ReadPrec S3Location
Int -> ReadS S3Location
ReadS [S3Location]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Location]
$creadListPrec :: ReadPrec [S3Location]
readPrec :: ReadPrec S3Location
$creadPrec :: ReadPrec S3Location
readList :: ReadS [S3Location]
$creadList :: ReadS [S3Location]
readsPrec :: Int -> ReadS S3Location
$creadsPrec :: Int -> ReadS S3Location
Prelude.Read, Int -> S3Location -> ShowS
[S3Location] -> ShowS
S3Location -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Location] -> ShowS
$cshowList :: [S3Location] -> ShowS
show :: S3Location -> String
$cshow :: S3Location -> String
showsPrec :: Int -> S3Location -> ShowS
$cshowsPrec :: Int -> S3Location -> ShowS
Prelude.Show, forall x. Rep S3Location x -> S3Location
forall x. S3Location -> Rep S3Location x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Location x -> S3Location
$cfrom :: forall x. S3Location -> Rep S3Location x
Prelude.Generic)

-- |
-- Create a value of 'S3Location' 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:
--
-- 'bucket', 's3Location_bucket' - An Amazon S3 bucket identifier. Thename of the S3 bucket.
--
-- GameLift doesn\'t support uploading from Amazon S3 buckets with names
-- that contain a dot (.).
--
-- 'key', 's3Location_key' - The name of the zip file that contains the build files or script files.
--
-- 'objectVersion', 's3Location_objectVersion' - The version of the file, if object versioning is turned on for the
-- bucket. Amazon GameLift uses this information when retrieving files from
-- an S3 bucket that you own. Use this parameter to specify a specific
-- version of the file. If not set, the latest version of the file is
-- retrieved.
--
-- 'roleArn', 's3Location_roleArn' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- for an IAM role that allows Amazon GameLift to access the S3 bucket.
newS3Location ::
  S3Location
newS3Location :: S3Location
newS3Location =
  S3Location'
    { $sel:bucket:S3Location' :: Maybe Text
bucket = forall a. Maybe a
Prelude.Nothing,
      $sel:key:S3Location' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:objectVersion:S3Location' :: Maybe Text
objectVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:roleArn:S3Location' :: Maybe Text
roleArn = forall a. Maybe a
Prelude.Nothing
    }

-- | An Amazon S3 bucket identifier. Thename of the S3 bucket.
--
-- GameLift doesn\'t support uploading from Amazon S3 buckets with names
-- that contain a dot (.).
s3Location_bucket :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_bucket :: Lens' S3Location (Maybe Text)
s3Location_bucket = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
bucket :: Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
bucket} -> Maybe Text
bucket) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:bucket:S3Location' :: Maybe Text
bucket = Maybe Text
a} :: S3Location)

-- | The name of the zip file that contains the build files or script files.
s3Location_key :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_key :: Lens' S3Location (Maybe Text)
s3Location_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
key :: Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
key} -> Maybe Text
key) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:key:S3Location' :: Maybe Text
key = Maybe Text
a} :: S3Location)

-- | The version of the file, if object versioning is turned on for the
-- bucket. Amazon GameLift uses this information when retrieving files from
-- an S3 bucket that you own. Use this parameter to specify a specific
-- version of the file. If not set, the latest version of the file is
-- retrieved.
s3Location_objectVersion :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_objectVersion :: Lens' S3Location (Maybe Text)
s3Location_objectVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
objectVersion :: Maybe Text
$sel:objectVersion:S3Location' :: S3Location -> Maybe Text
objectVersion} -> Maybe Text
objectVersion) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:objectVersion:S3Location' :: Maybe Text
objectVersion = Maybe Text
a} :: S3Location)

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- for an IAM role that allows Amazon GameLift to access the S3 bucket.
s3Location_roleArn :: Lens.Lens' S3Location (Prelude.Maybe Prelude.Text)
s3Location_roleArn :: Lens' S3Location (Maybe Text)
s3Location_roleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Location' {Maybe Text
roleArn :: Maybe Text
$sel:roleArn:S3Location' :: S3Location -> Maybe Text
roleArn} -> Maybe Text
roleArn) (\s :: S3Location
s@S3Location' {} Maybe Text
a -> S3Location
s {$sel:roleArn:S3Location' :: Maybe Text
roleArn = Maybe Text
a} :: S3Location)

instance Data.FromJSON S3Location where
  parseJSON :: Value -> Parser S3Location
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Location"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> S3Location
S3Location'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Bucket")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Key")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ObjectVersion")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RoleArn")
      )

instance Prelude.Hashable S3Location where
  hashWithSalt :: Int -> S3Location -> Int
hashWithSalt Int
_salt S3Location' {Maybe Text
roleArn :: Maybe Text
objectVersion :: Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:roleArn:S3Location' :: S3Location -> Maybe Text
$sel:objectVersion:S3Location' :: S3Location -> Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bucket
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
objectVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
roleArn

instance Prelude.NFData S3Location where
  rnf :: S3Location -> ()
rnf S3Location' {Maybe Text
roleArn :: Maybe Text
objectVersion :: Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:roleArn:S3Location' :: S3Location -> Maybe Text
$sel:objectVersion:S3Location' :: S3Location -> Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bucket
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
objectVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
roleArn

instance Data.ToJSON S3Location where
  toJSON :: S3Location -> Value
toJSON S3Location' {Maybe Text
roleArn :: Maybe Text
objectVersion :: Maybe Text
key :: Maybe Text
bucket :: Maybe Text
$sel:roleArn:S3Location' :: S3Location -> Maybe Text
$sel:objectVersion:S3Location' :: S3Location -> Maybe Text
$sel:key:S3Location' :: S3Location -> Maybe Text
$sel:bucket:S3Location' :: S3Location -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Bucket" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
bucket,
            (Key
"Key" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
key,
            (Key
"ObjectVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
objectVersion,
            (Key
"RoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
roleArn
          ]
      )