packages feed

stratosphere-0.4.3: library-gen/Stratosphere/ResourceProperties/EC2SpotFleetPrivateIpAddressSpecification.hs

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-networkinterfaces-privateipaddresses.html

module Stratosphere.ResourceProperties.EC2SpotFleetPrivateIpAddressSpecification where

import Control.Lens hiding ((.=))
import Data.Aeson
import Data.Maybe (catMaybes)
import Data.Monoid (mempty)
import Data.Text

import Stratosphere.Values


-- | Full data type definition for EC2SpotFleetPrivateIpAddressSpecification.
-- See 'ec2SpotFleetPrivateIpAddressSpecification' for a more convenient
-- constructor.
data EC2SpotFleetPrivateIpAddressSpecification =
  EC2SpotFleetPrivateIpAddressSpecification
  { _eC2SpotFleetPrivateIpAddressSpecificationPrimary :: Maybe (Val Bool')
  , _eC2SpotFleetPrivateIpAddressSpecificationPrivateIpAddress :: Val Text
  } deriving (Show, Eq)

instance ToJSON EC2SpotFleetPrivateIpAddressSpecification where
  toJSON EC2SpotFleetPrivateIpAddressSpecification{..} =
    object $
    catMaybes
    [ ("Primary" .=) <$> _eC2SpotFleetPrivateIpAddressSpecificationPrimary
    , Just ("PrivateIpAddress" .= _eC2SpotFleetPrivateIpAddressSpecificationPrivateIpAddress)
    ]

instance FromJSON EC2SpotFleetPrivateIpAddressSpecification where
  parseJSON (Object obj) =
    EC2SpotFleetPrivateIpAddressSpecification <$>
      obj .:? "Primary" <*>
      obj .: "PrivateIpAddress"
  parseJSON _ = mempty

-- | Constructor for 'EC2SpotFleetPrivateIpAddressSpecification' containing
-- required fields as arguments.
ec2SpotFleetPrivateIpAddressSpecification
  :: Val Text -- ^ 'ecsfpiasPrivateIpAddress'
  -> EC2SpotFleetPrivateIpAddressSpecification
ec2SpotFleetPrivateIpAddressSpecification privateIpAddressarg =
  EC2SpotFleetPrivateIpAddressSpecification
  { _eC2SpotFleetPrivateIpAddressSpecificationPrimary = Nothing
  , _eC2SpotFleetPrivateIpAddressSpecificationPrivateIpAddress = privateIpAddressarg
  }

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-networkinterfaces-privateipaddresses.html#cfn-ec2-spotfleet-privateipaddressspecification-primary
ecsfpiasPrimary :: Lens' EC2SpotFleetPrivateIpAddressSpecification (Maybe (Val Bool'))
ecsfpiasPrimary = lens _eC2SpotFleetPrivateIpAddressSpecificationPrimary (\s a -> s { _eC2SpotFleetPrivateIpAddressSpecificationPrimary = a })

-- | http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-spotfleetrequestconfigdata-launchspecifications-networkinterfaces-privateipaddresses.html#cfn-ec2-spotfleet-privateipaddressspecification-privateipaddress
ecsfpiasPrivateIpAddress :: Lens' EC2SpotFleetPrivateIpAddressSpecification (Val Text)
ecsfpiasPrivateIpAddress = lens _eC2SpotFleetPrivateIpAddressSpecificationPrivateIpAddress (\s a -> s { _eC2SpotFleetPrivateIpAddressSpecificationPrivateIpAddress = a })