{-# 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.SSM.Types.AttachmentContent
-- 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.SSM.Types.AttachmentContent where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.AttachmentHashType

-- | A structure that includes attributes that describe a document
-- attachment.
--
-- /See:/ 'newAttachmentContent' smart constructor.
data AttachmentContent = AttachmentContent'
  { -- | The cryptographic hash value of the document content.
    AttachmentContent -> Maybe Text
hash :: Prelude.Maybe Prelude.Text,
    -- | The size of an attachment in bytes.
    AttachmentContent -> Maybe Integer
size :: Prelude.Maybe Prelude.Integer,
    -- | The URL location of the attachment content.
    AttachmentContent -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | The name of an attachment.
    AttachmentContent -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The hash algorithm used to calculate the hash value.
    AttachmentContent -> Maybe AttachmentHashType
hashType :: Prelude.Maybe AttachmentHashType
  }
  deriving (AttachmentContent -> AttachmentContent -> Bool
(AttachmentContent -> AttachmentContent -> Bool)
-> (AttachmentContent -> AttachmentContent -> Bool)
-> Eq AttachmentContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttachmentContent -> AttachmentContent -> Bool
$c/= :: AttachmentContent -> AttachmentContent -> Bool
== :: AttachmentContent -> AttachmentContent -> Bool
$c== :: AttachmentContent -> AttachmentContent -> Bool
Prelude.Eq, ReadPrec [AttachmentContent]
ReadPrec AttachmentContent
Int -> ReadS AttachmentContent
ReadS [AttachmentContent]
(Int -> ReadS AttachmentContent)
-> ReadS [AttachmentContent]
-> ReadPrec AttachmentContent
-> ReadPrec [AttachmentContent]
-> Read AttachmentContent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttachmentContent]
$creadListPrec :: ReadPrec [AttachmentContent]
readPrec :: ReadPrec AttachmentContent
$creadPrec :: ReadPrec AttachmentContent
readList :: ReadS [AttachmentContent]
$creadList :: ReadS [AttachmentContent]
readsPrec :: Int -> ReadS AttachmentContent
$creadsPrec :: Int -> ReadS AttachmentContent
Prelude.Read, Int -> AttachmentContent -> ShowS
[AttachmentContent] -> ShowS
AttachmentContent -> String
(Int -> AttachmentContent -> ShowS)
-> (AttachmentContent -> String)
-> ([AttachmentContent] -> ShowS)
-> Show AttachmentContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttachmentContent] -> ShowS
$cshowList :: [AttachmentContent] -> ShowS
show :: AttachmentContent -> String
$cshow :: AttachmentContent -> String
showsPrec :: Int -> AttachmentContent -> ShowS
$cshowsPrec :: Int -> AttachmentContent -> ShowS
Prelude.Show, (forall x. AttachmentContent -> Rep AttachmentContent x)
-> (forall x. Rep AttachmentContent x -> AttachmentContent)
-> Generic AttachmentContent
forall x. Rep AttachmentContent x -> AttachmentContent
forall x. AttachmentContent -> Rep AttachmentContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttachmentContent x -> AttachmentContent
$cfrom :: forall x. AttachmentContent -> Rep AttachmentContent x
Prelude.Generic)

-- |
-- Create a value of 'AttachmentContent' 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:
--
-- 'hash', 'attachmentContent_hash' - The cryptographic hash value of the document content.
--
-- 'size', 'attachmentContent_size' - The size of an attachment in bytes.
--
-- 'url', 'attachmentContent_url' - The URL location of the attachment content.
--
-- 'name', 'attachmentContent_name' - The name of an attachment.
--
-- 'hashType', 'attachmentContent_hashType' - The hash algorithm used to calculate the hash value.
newAttachmentContent ::
  AttachmentContent
newAttachmentContent :: AttachmentContent
newAttachmentContent =
  AttachmentContent' :: Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe AttachmentHashType
-> AttachmentContent
AttachmentContent'
    { $sel:hash:AttachmentContent' :: Maybe Text
hash = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:size:AttachmentContent' :: Maybe Integer
size = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:url:AttachmentContent' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AttachmentContent' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:hashType:AttachmentContent' :: Maybe AttachmentHashType
hashType = Maybe AttachmentHashType
forall a. Maybe a
Prelude.Nothing
    }

-- | The cryptographic hash value of the document content.
attachmentContent_hash :: Lens.Lens' AttachmentContent (Prelude.Maybe Prelude.Text)
attachmentContent_hash :: (Maybe Text -> f (Maybe Text))
-> AttachmentContent -> f AttachmentContent
attachmentContent_hash = (AttachmentContent -> Maybe Text)
-> (AttachmentContent -> Maybe Text -> AttachmentContent)
-> Lens
     AttachmentContent AttachmentContent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentContent' {Maybe Text
hash :: Maybe Text
$sel:hash:AttachmentContent' :: AttachmentContent -> Maybe Text
hash} -> Maybe Text
hash) (\s :: AttachmentContent
s@AttachmentContent' {} Maybe Text
a -> AttachmentContent
s {$sel:hash:AttachmentContent' :: Maybe Text
hash = Maybe Text
a} :: AttachmentContent)

-- | The size of an attachment in bytes.
attachmentContent_size :: Lens.Lens' AttachmentContent (Prelude.Maybe Prelude.Integer)
attachmentContent_size :: (Maybe Integer -> f (Maybe Integer))
-> AttachmentContent -> f AttachmentContent
attachmentContent_size = (AttachmentContent -> Maybe Integer)
-> (AttachmentContent -> Maybe Integer -> AttachmentContent)
-> Lens
     AttachmentContent AttachmentContent (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentContent' {Maybe Integer
size :: Maybe Integer
$sel:size:AttachmentContent' :: AttachmentContent -> Maybe Integer
size} -> Maybe Integer
size) (\s :: AttachmentContent
s@AttachmentContent' {} Maybe Integer
a -> AttachmentContent
s {$sel:size:AttachmentContent' :: Maybe Integer
size = Maybe Integer
a} :: AttachmentContent)

-- | The URL location of the attachment content.
attachmentContent_url :: Lens.Lens' AttachmentContent (Prelude.Maybe Prelude.Text)
attachmentContent_url :: (Maybe Text -> f (Maybe Text))
-> AttachmentContent -> f AttachmentContent
attachmentContent_url = (AttachmentContent -> Maybe Text)
-> (AttachmentContent -> Maybe Text -> AttachmentContent)
-> Lens
     AttachmentContent AttachmentContent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentContent' {Maybe Text
url :: Maybe Text
$sel:url:AttachmentContent' :: AttachmentContent -> Maybe Text
url} -> Maybe Text
url) (\s :: AttachmentContent
s@AttachmentContent' {} Maybe Text
a -> AttachmentContent
s {$sel:url:AttachmentContent' :: Maybe Text
url = Maybe Text
a} :: AttachmentContent)

-- | The name of an attachment.
attachmentContent_name :: Lens.Lens' AttachmentContent (Prelude.Maybe Prelude.Text)
attachmentContent_name :: (Maybe Text -> f (Maybe Text))
-> AttachmentContent -> f AttachmentContent
attachmentContent_name = (AttachmentContent -> Maybe Text)
-> (AttachmentContent -> Maybe Text -> AttachmentContent)
-> Lens
     AttachmentContent AttachmentContent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentContent' {Maybe Text
name :: Maybe Text
$sel:name:AttachmentContent' :: AttachmentContent -> Maybe Text
name} -> Maybe Text
name) (\s :: AttachmentContent
s@AttachmentContent' {} Maybe Text
a -> AttachmentContent
s {$sel:name:AttachmentContent' :: Maybe Text
name = Maybe Text
a} :: AttachmentContent)

-- | The hash algorithm used to calculate the hash value.
attachmentContent_hashType :: Lens.Lens' AttachmentContent (Prelude.Maybe AttachmentHashType)
attachmentContent_hashType :: (Maybe AttachmentHashType -> f (Maybe AttachmentHashType))
-> AttachmentContent -> f AttachmentContent
attachmentContent_hashType = (AttachmentContent -> Maybe AttachmentHashType)
-> (AttachmentContent
    -> Maybe AttachmentHashType -> AttachmentContent)
-> Lens
     AttachmentContent
     AttachmentContent
     (Maybe AttachmentHashType)
     (Maybe AttachmentHashType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttachmentContent' {Maybe AttachmentHashType
hashType :: Maybe AttachmentHashType
$sel:hashType:AttachmentContent' :: AttachmentContent -> Maybe AttachmentHashType
hashType} -> Maybe AttachmentHashType
hashType) (\s :: AttachmentContent
s@AttachmentContent' {} Maybe AttachmentHashType
a -> AttachmentContent
s {$sel:hashType:AttachmentContent' :: Maybe AttachmentHashType
hashType = Maybe AttachmentHashType
a} :: AttachmentContent)

instance Core.FromJSON AttachmentContent where
  parseJSON :: Value -> Parser AttachmentContent
parseJSON =
    String
-> (Object -> Parser AttachmentContent)
-> Value
-> Parser AttachmentContent
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttachmentContent"
      ( \Object
x ->
          Maybe Text
-> Maybe Integer
-> Maybe Text
-> Maybe Text
-> Maybe AttachmentHashType
-> AttachmentContent
AttachmentContent'
            (Maybe Text
 -> Maybe Integer
 -> Maybe Text
 -> Maybe Text
 -> Maybe AttachmentHashType
 -> AttachmentContent)
-> Parser (Maybe Text)
-> Parser
     (Maybe Integer
      -> Maybe Text
      -> Maybe Text
      -> Maybe AttachmentHashType
      -> AttachmentContent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Hash")
            Parser
  (Maybe Integer
   -> Maybe Text
   -> Maybe Text
   -> Maybe AttachmentHashType
   -> AttachmentContent)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe AttachmentHashType -> AttachmentContent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Size")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe AttachmentHashType -> AttachmentContent)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe AttachmentHashType -> AttachmentContent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Url")
            Parser
  (Maybe Text -> Maybe AttachmentHashType -> AttachmentContent)
-> Parser (Maybe Text)
-> Parser (Maybe AttachmentHashType -> AttachmentContent)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe AttachmentHashType -> AttachmentContent)
-> Parser (Maybe AttachmentHashType) -> Parser AttachmentContent
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttachmentHashType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"HashType")
      )

instance Prelude.Hashable AttachmentContent

instance Prelude.NFData AttachmentContent