{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.SSM.CreateAssociation
(
createAssociation
, CreateAssociation
, caInstanceId
, caScheduleExpression
, caOutputLocation
, caTargets
, caParameters
, caDocumentVersion
, caAssociationName
, caName
, createAssociationResponse
, CreateAssociationResponse
, crsAssociationDescription
, crsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SSM.Types
import Network.AWS.SSM.Types.Product
data CreateAssociation = CreateAssociation'
{ _caInstanceId :: !(Maybe Text)
, _caScheduleExpression :: !(Maybe Text)
, _caOutputLocation :: !(Maybe InstanceAssociationOutputLocation)
, _caTargets :: !(Maybe [Target])
, _caParameters :: !(Maybe (Map Text [Text]))
, _caDocumentVersion :: !(Maybe Text)
, _caAssociationName :: !(Maybe Text)
, _caName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createAssociation
:: Text
-> CreateAssociation
createAssociation pName_ =
CreateAssociation'
{ _caInstanceId = Nothing
, _caScheduleExpression = Nothing
, _caOutputLocation = Nothing
, _caTargets = Nothing
, _caParameters = Nothing
, _caDocumentVersion = Nothing
, _caAssociationName = Nothing
, _caName = pName_
}
caInstanceId :: Lens' CreateAssociation (Maybe Text)
caInstanceId = lens _caInstanceId (\ s a -> s{_caInstanceId = a})
caScheduleExpression :: Lens' CreateAssociation (Maybe Text)
caScheduleExpression = lens _caScheduleExpression (\ s a -> s{_caScheduleExpression = a})
caOutputLocation :: Lens' CreateAssociation (Maybe InstanceAssociationOutputLocation)
caOutputLocation = lens _caOutputLocation (\ s a -> s{_caOutputLocation = a})
caTargets :: Lens' CreateAssociation [Target]
caTargets = lens _caTargets (\ s a -> s{_caTargets = a}) . _Default . _Coerce
caParameters :: Lens' CreateAssociation (HashMap Text [Text])
caParameters = lens _caParameters (\ s a -> s{_caParameters = a}) . _Default . _Map
caDocumentVersion :: Lens' CreateAssociation (Maybe Text)
caDocumentVersion = lens _caDocumentVersion (\ s a -> s{_caDocumentVersion = a})
caAssociationName :: Lens' CreateAssociation (Maybe Text)
caAssociationName = lens _caAssociationName (\ s a -> s{_caAssociationName = a})
caName :: Lens' CreateAssociation Text
caName = lens _caName (\ s a -> s{_caName = a})
instance AWSRequest CreateAssociation where
type Rs CreateAssociation = CreateAssociationResponse
request = postJSON ssm
response
= receiveJSON
(\ s h x ->
CreateAssociationResponse' <$>
(x .?> "AssociationDescription") <*>
(pure (fromEnum s)))
instance Hashable CreateAssociation where
instance NFData CreateAssociation where
instance ToHeaders CreateAssociation where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonSSM.CreateAssociation" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateAssociation where
toJSON CreateAssociation'{..}
= object
(catMaybes
[("InstanceId" .=) <$> _caInstanceId,
("ScheduleExpression" .=) <$> _caScheduleExpression,
("OutputLocation" .=) <$> _caOutputLocation,
("Targets" .=) <$> _caTargets,
("Parameters" .=) <$> _caParameters,
("DocumentVersion" .=) <$> _caDocumentVersion,
("AssociationName" .=) <$> _caAssociationName,
Just ("Name" .= _caName)])
instance ToPath CreateAssociation where
toPath = const "/"
instance ToQuery CreateAssociation where
toQuery = const mempty
data CreateAssociationResponse = CreateAssociationResponse'
{ _crsAssociationDescription :: !(Maybe AssociationDescription)
, _crsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createAssociationResponse
:: Int
-> CreateAssociationResponse
createAssociationResponse pResponseStatus_ =
CreateAssociationResponse'
{ _crsAssociationDescription = Nothing
, _crsResponseStatus = pResponseStatus_
}
crsAssociationDescription :: Lens' CreateAssociationResponse (Maybe AssociationDescription)
crsAssociationDescription = lens _crsAssociationDescription (\ s a -> s{_crsAssociationDescription = a})
crsResponseStatus :: Lens' CreateAssociationResponse Int
crsResponseStatus = lens _crsResponseStatus (\ s a -> s{_crsResponseStatus = a})
instance NFData CreateAssociationResponse where