{-# 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.ECR.SetRepositoryPolicy
(
setRepositoryPolicy
, SetRepositoryPolicy
, srpForce
, srpRegistryId
, srpRepositoryName
, srpPolicyText
, setRepositoryPolicyResponse
, SetRepositoryPolicyResponse
, srprsRegistryId
, srprsRepositoryName
, srprsPolicyText
, srprsResponseStatus
) where
import Network.AWS.ECR.Types
import Network.AWS.ECR.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data SetRepositoryPolicy = SetRepositoryPolicy'
{ _srpForce :: !(Maybe Bool)
, _srpRegistryId :: !(Maybe Text)
, _srpRepositoryName :: !Text
, _srpPolicyText :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
setRepositoryPolicy
:: Text
-> Text
-> SetRepositoryPolicy
setRepositoryPolicy pRepositoryName_ pPolicyText_ =
SetRepositoryPolicy'
{ _srpForce = Nothing
, _srpRegistryId = Nothing
, _srpRepositoryName = pRepositoryName_
, _srpPolicyText = pPolicyText_
}
srpForce :: Lens' SetRepositoryPolicy (Maybe Bool)
srpForce = lens _srpForce (\ s a -> s{_srpForce = a});
srpRegistryId :: Lens' SetRepositoryPolicy (Maybe Text)
srpRegistryId = lens _srpRegistryId (\ s a -> s{_srpRegistryId = a});
srpRepositoryName :: Lens' SetRepositoryPolicy Text
srpRepositoryName = lens _srpRepositoryName (\ s a -> s{_srpRepositoryName = a});
srpPolicyText :: Lens' SetRepositoryPolicy Text
srpPolicyText = lens _srpPolicyText (\ s a -> s{_srpPolicyText = a});
instance AWSRequest SetRepositoryPolicy where
type Rs SetRepositoryPolicy =
SetRepositoryPolicyResponse
request = postJSON ecr
response
= receiveJSON
(\ s h x ->
SetRepositoryPolicyResponse' <$>
(x .?> "registryId") <*> (x .?> "repositoryName") <*>
(x .?> "policyText")
<*> (pure (fromEnum s)))
instance Hashable SetRepositoryPolicy
instance NFData SetRepositoryPolicy
instance ToHeaders SetRepositoryPolicy where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonEC2ContainerRegistry_V20150921.SetRepositoryPolicy"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON SetRepositoryPolicy where
toJSON SetRepositoryPolicy'{..}
= object
(catMaybes
[("force" .=) <$> _srpForce,
("registryId" .=) <$> _srpRegistryId,
Just ("repositoryName" .= _srpRepositoryName),
Just ("policyText" .= _srpPolicyText)])
instance ToPath SetRepositoryPolicy where
toPath = const "/"
instance ToQuery SetRepositoryPolicy where
toQuery = const mempty
data SetRepositoryPolicyResponse = SetRepositoryPolicyResponse'
{ _srprsRegistryId :: !(Maybe Text)
, _srprsRepositoryName :: !(Maybe Text)
, _srprsPolicyText :: !(Maybe Text)
, _srprsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
setRepositoryPolicyResponse
:: Int
-> SetRepositoryPolicyResponse
setRepositoryPolicyResponse pResponseStatus_ =
SetRepositoryPolicyResponse'
{ _srprsRegistryId = Nothing
, _srprsRepositoryName = Nothing
, _srprsPolicyText = Nothing
, _srprsResponseStatus = pResponseStatus_
}
srprsRegistryId :: Lens' SetRepositoryPolicyResponse (Maybe Text)
srprsRegistryId = lens _srprsRegistryId (\ s a -> s{_srprsRegistryId = a});
srprsRepositoryName :: Lens' SetRepositoryPolicyResponse (Maybe Text)
srprsRepositoryName = lens _srprsRepositoryName (\ s a -> s{_srprsRepositoryName = a});
srprsPolicyText :: Lens' SetRepositoryPolicyResponse (Maybe Text)
srprsPolicyText = lens _srprsPolicyText (\ s a -> s{_srprsPolicyText = a});
srprsResponseStatus :: Lens' SetRepositoryPolicyResponse Int
srprsResponseStatus = lens _srprsResponseStatus (\ s a -> s{_srprsResponseStatus = a});
instance NFData SetRepositoryPolicyResponse