{-# 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.LicenseManager.Types.LicenseSpecification
-- 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.LicenseManager.Types.LicenseSpecification 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

-- | Details for associating a license configuration with a resource.
--
-- /See:/ 'newLicenseSpecification' smart constructor.
data LicenseSpecification = LicenseSpecification'
  { -- | Scope of AMI associations. The possible value is @cross-account@.
    LicenseSpecification -> Maybe Text
amiAssociationScope :: Prelude.Maybe Prelude.Text,
    -- | Amazon Resource Name (ARN) of the license configuration.
    LicenseSpecification -> Text
licenseConfigurationArn :: Prelude.Text
  }
  deriving (LicenseSpecification -> LicenseSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LicenseSpecification -> LicenseSpecification -> Bool
$c/= :: LicenseSpecification -> LicenseSpecification -> Bool
== :: LicenseSpecification -> LicenseSpecification -> Bool
$c== :: LicenseSpecification -> LicenseSpecification -> Bool
Prelude.Eq, ReadPrec [LicenseSpecification]
ReadPrec LicenseSpecification
Int -> ReadS LicenseSpecification
ReadS [LicenseSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LicenseSpecification]
$creadListPrec :: ReadPrec [LicenseSpecification]
readPrec :: ReadPrec LicenseSpecification
$creadPrec :: ReadPrec LicenseSpecification
readList :: ReadS [LicenseSpecification]
$creadList :: ReadS [LicenseSpecification]
readsPrec :: Int -> ReadS LicenseSpecification
$creadsPrec :: Int -> ReadS LicenseSpecification
Prelude.Read, Int -> LicenseSpecification -> ShowS
[LicenseSpecification] -> ShowS
LicenseSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LicenseSpecification] -> ShowS
$cshowList :: [LicenseSpecification] -> ShowS
show :: LicenseSpecification -> String
$cshow :: LicenseSpecification -> String
showsPrec :: Int -> LicenseSpecification -> ShowS
$cshowsPrec :: Int -> LicenseSpecification -> ShowS
Prelude.Show, forall x. Rep LicenseSpecification x -> LicenseSpecification
forall x. LicenseSpecification -> Rep LicenseSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LicenseSpecification x -> LicenseSpecification
$cfrom :: forall x. LicenseSpecification -> Rep LicenseSpecification x
Prelude.Generic)

-- |
-- Create a value of 'LicenseSpecification' 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:
--
-- 'amiAssociationScope', 'licenseSpecification_amiAssociationScope' - Scope of AMI associations. The possible value is @cross-account@.
--
-- 'licenseConfigurationArn', 'licenseSpecification_licenseConfigurationArn' - Amazon Resource Name (ARN) of the license configuration.
newLicenseSpecification ::
  -- | 'licenseConfigurationArn'
  Prelude.Text ->
  LicenseSpecification
newLicenseSpecification :: Text -> LicenseSpecification
newLicenseSpecification Text
pLicenseConfigurationArn_ =
  LicenseSpecification'
    { $sel:amiAssociationScope:LicenseSpecification' :: Maybe Text
amiAssociationScope =
        forall a. Maybe a
Prelude.Nothing,
      $sel:licenseConfigurationArn:LicenseSpecification' :: Text
licenseConfigurationArn = Text
pLicenseConfigurationArn_
    }

-- | Scope of AMI associations. The possible value is @cross-account@.
licenseSpecification_amiAssociationScope :: Lens.Lens' LicenseSpecification (Prelude.Maybe Prelude.Text)
licenseSpecification_amiAssociationScope :: Lens' LicenseSpecification (Maybe Text)
licenseSpecification_amiAssociationScope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LicenseSpecification' {Maybe Text
amiAssociationScope :: Maybe Text
$sel:amiAssociationScope:LicenseSpecification' :: LicenseSpecification -> Maybe Text
amiAssociationScope} -> Maybe Text
amiAssociationScope) (\s :: LicenseSpecification
s@LicenseSpecification' {} Maybe Text
a -> LicenseSpecification
s {$sel:amiAssociationScope:LicenseSpecification' :: Maybe Text
amiAssociationScope = Maybe Text
a} :: LicenseSpecification)

-- | Amazon Resource Name (ARN) of the license configuration.
licenseSpecification_licenseConfigurationArn :: Lens.Lens' LicenseSpecification Prelude.Text
licenseSpecification_licenseConfigurationArn :: Lens' LicenseSpecification Text
licenseSpecification_licenseConfigurationArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LicenseSpecification' {Text
licenseConfigurationArn :: Text
$sel:licenseConfigurationArn:LicenseSpecification' :: LicenseSpecification -> Text
licenseConfigurationArn} -> Text
licenseConfigurationArn) (\s :: LicenseSpecification
s@LicenseSpecification' {} Text
a -> LicenseSpecification
s {$sel:licenseConfigurationArn:LicenseSpecification' :: Text
licenseConfigurationArn = Text
a} :: LicenseSpecification)

instance Data.FromJSON LicenseSpecification where
  parseJSON :: Value -> Parser LicenseSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"LicenseSpecification"
      ( \Object
x ->
          Maybe Text -> Text -> LicenseSpecification
LicenseSpecification'
            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
"AmiAssociationScope")
            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
"LicenseConfigurationArn")
      )

instance Prelude.Hashable LicenseSpecification where
  hashWithSalt :: Int -> LicenseSpecification -> Int
hashWithSalt Int
_salt LicenseSpecification' {Maybe Text
Text
licenseConfigurationArn :: Text
amiAssociationScope :: Maybe Text
$sel:licenseConfigurationArn:LicenseSpecification' :: LicenseSpecification -> Text
$sel:amiAssociationScope:LicenseSpecification' :: LicenseSpecification -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
amiAssociationScope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
licenseConfigurationArn

instance Prelude.NFData LicenseSpecification where
  rnf :: LicenseSpecification -> ()
rnf LicenseSpecification' {Maybe Text
Text
licenseConfigurationArn :: Text
amiAssociationScope :: Maybe Text
$sel:licenseConfigurationArn:LicenseSpecification' :: LicenseSpecification -> Text
$sel:amiAssociationScope:LicenseSpecification' :: LicenseSpecification -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
amiAssociationScope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
licenseConfigurationArn

instance Data.ToJSON LicenseSpecification where
  toJSON :: LicenseSpecification -> Value
toJSON LicenseSpecification' {Maybe Text
Text
licenseConfigurationArn :: Text
amiAssociationScope :: Maybe Text
$sel:licenseConfigurationArn:LicenseSpecification' :: LicenseSpecification -> Text
$sel:amiAssociationScope:LicenseSpecification' :: LicenseSpecification -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AmiAssociationScope" 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
amiAssociationScope,
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"LicenseConfigurationArn"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
licenseConfigurationArn
              )
          ]
      )