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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(LicenseSpecification -> LicenseSpecification -> Bool)
-> (LicenseSpecification -> LicenseSpecification -> Bool)
-> Eq LicenseSpecification
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]
(Int -> ReadS LicenseSpecification)
-> ReadS [LicenseSpecification]
-> ReadPrec LicenseSpecification
-> ReadPrec [LicenseSpecification]
-> Read 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
(Int -> LicenseSpecification -> ShowS)
-> (LicenseSpecification -> String)
-> ([LicenseSpecification] -> ShowS)
-> Show LicenseSpecification
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. LicenseSpecification -> Rep LicenseSpecification x)
-> (forall x. Rep LicenseSpecification x -> LicenseSpecification)
-> Generic LicenseSpecification
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' :: Maybe Text -> Text -> LicenseSpecification
LicenseSpecification'
    { $sel:amiAssociationScope:LicenseSpecification' :: Maybe Text
amiAssociationScope =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> LicenseSpecification -> f LicenseSpecification
licenseSpecification_amiAssociationScope = (LicenseSpecification -> Maybe Text)
-> (LicenseSpecification -> Maybe Text -> LicenseSpecification)
-> Lens
     LicenseSpecification LicenseSpecification (Maybe Text) (Maybe Text)
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 :: (Text -> f Text) -> LicenseSpecification -> f LicenseSpecification
licenseSpecification_licenseConfigurationArn = (LicenseSpecification -> Text)
-> (LicenseSpecification -> Text -> LicenseSpecification)
-> Lens LicenseSpecification LicenseSpecification Text Text
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 Core.FromJSON LicenseSpecification where
  parseJSON :: Value -> Parser LicenseSpecification
parseJSON =
    String
-> (Object -> Parser LicenseSpecification)
-> Value
-> Parser LicenseSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LicenseSpecification"
      ( \Object
x ->
          Maybe Text -> Text -> LicenseSpecification
LicenseSpecification'
            (Maybe Text -> Text -> LicenseSpecification)
-> Parser (Maybe Text) -> Parser (Text -> LicenseSpecification)
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
"AmiAssociationScope")
            Parser (Text -> LicenseSpecification)
-> Parser Text -> Parser LicenseSpecification
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
"LicenseConfigurationArn")
      )

instance Prelude.Hashable LicenseSpecification

instance Prelude.NFData LicenseSpecification

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AmiAssociationScope" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
amiAssociationScope,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"LicenseConfigurationArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
licenseConfigurationArn
              )
          ]
      )