amazonka-sdb-1.2.0: gen/Network/AWS/SDB/GetAttributes.hs
{-# 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 #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Network.AWS.SDB.GetAttributes
-- Copyright : (c) 2013-2015 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay <brendan.g.hay@gmail.com>
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns all of the attributes associated with the specified item.
-- Optionally, the attributes returned can be limited to one or more
-- attributes by specifying an attribute name parameter.
--
-- If the item does not exist on the replica that was accessed for this
-- operation, an empty set is returned. The system does not return an error
-- as it cannot guarantee the item does not exist on other replicas.
--
-- /See:/ <http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API_GetAttributes.html AWS API Reference> for GetAttributes.
module Network.AWS.SDB.GetAttributes
(
-- * Creating a Request
getAttributes
, GetAttributes
-- * Request Lenses
, gaConsistentRead
, gaAttributeNames
, gaDomainName
, gaItemName
-- * Destructuring the Response
, getAttributesResponse
, GetAttributesResponse
-- * Response Lenses
, garsAttributes
, garsStatus
) where
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.SDB.Types
import Network.AWS.SDB.Types.Product
-- | /See:/ 'getAttributes' smart constructor.
data GetAttributes = GetAttributes'
{ _gaConsistentRead :: !(Maybe Bool)
, _gaAttributeNames :: !(Maybe [Text])
, _gaDomainName :: !Text
, _gaItemName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetAttributes' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'gaConsistentRead'
--
-- * 'gaAttributeNames'
--
-- * 'gaDomainName'
--
-- * 'gaItemName'
getAttributes
:: Text -- ^ 'gaDomainName'
-> Text -- ^ 'gaItemName'
-> GetAttributes
getAttributes pDomainName_ pItemName_ =
GetAttributes'
{ _gaConsistentRead = Nothing
, _gaAttributeNames = Nothing
, _gaDomainName = pDomainName_
, _gaItemName = pItemName_
}
-- | Determines whether or not strong consistency should be enforced when
-- data is read from SimpleDB. If 'true', any data previously written to
-- SimpleDB will be returned. Otherwise, results will be consistent
-- eventually, and the client may not see data that was written immediately
-- before your read.
gaConsistentRead :: Lens' GetAttributes (Maybe Bool)
gaConsistentRead = lens _gaConsistentRead (\ s a -> s{_gaConsistentRead = a});
-- | The names of the attributes.
gaAttributeNames :: Lens' GetAttributes [Text]
gaAttributeNames = lens _gaAttributeNames (\ s a -> s{_gaAttributeNames = a}) . _Default . _Coerce;
-- | The name of the domain in which to perform the operation.
gaDomainName :: Lens' GetAttributes Text
gaDomainName = lens _gaDomainName (\ s a -> s{_gaDomainName = a});
-- | The name of the item.
gaItemName :: Lens' GetAttributes Text
gaItemName = lens _gaItemName (\ s a -> s{_gaItemName = a});
instance AWSRequest GetAttributes where
type Rs GetAttributes = GetAttributesResponse
request = postQuery sDB
response
= receiveXMLWrapper "GetAttributesResult"
(\ s h x ->
GetAttributesResponse' <$>
(may (parseXMLList "Attribute") x) <*>
(pure (fromEnum s)))
instance ToHeaders GetAttributes where
toHeaders = const mempty
instance ToPath GetAttributes where
toPath = const "/"
instance ToQuery GetAttributes where
toQuery GetAttributes'{..}
= mconcat
["Action" =: ("GetAttributes" :: ByteString),
"Version" =: ("2009-04-15" :: ByteString),
"ConsistentRead" =: _gaConsistentRead,
toQuery
(toQueryList "AttributeName" <$> _gaAttributeNames),
"DomainName" =: _gaDomainName,
"ItemName" =: _gaItemName]
-- | /See:/ 'getAttributesResponse' smart constructor.
data GetAttributesResponse = GetAttributesResponse'
{ _garsAttributes :: !(Maybe [Attribute])
, _garsStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
-- | Creates a value of 'GetAttributesResponse' with the minimum fields required to make a request.
--
-- Use one of the following lenses to modify other fields as desired:
--
-- * 'garsAttributes'
--
-- * 'garsStatus'
getAttributesResponse
:: Int -- ^ 'garsStatus'
-> GetAttributesResponse
getAttributesResponse pStatus_ =
GetAttributesResponse'
{ _garsAttributes = Nothing
, _garsStatus = pStatus_
}
-- | The list of attributes returned by the operation.
garsAttributes :: Lens' GetAttributesResponse [Attribute]
garsAttributes = lens _garsAttributes (\ s a -> s{_garsAttributes = a}) . _Default . _Coerce;
-- | The response status code.
garsStatus :: Lens' GetAttributesResponse Int
garsStatus = lens _garsStatus (\ s a -> s{_garsStatus = a});