Wednesday, April 17, 2013

Amazon SimpleDB getAttributes example c c++ objc

getAttributes:
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.
NOTE: If GetAttributes is called without being passed any attribute names, all the attributes for the item are returned.
- (SimpleDBGetAttributesResponse *)getAttributes:(SimpleDBGetAttributesRequest *)getAttributesRequest

Parameters

getAttributesRequest
Container for the necessary parameters to execute the GetAttributes service method on AmazonSimpleDB.

Return Value

The response from the GetAttributes service method, as returned by AmazonSimpleDB.
Example
{
     NSString        *domainName = @"domainName";
     NSString        *itemName = @"itemName";
     NSMutableArray  attributes = [NSMutableArray arrayWithObjects:@"attr1", @"attr2", nil];    

    // Construct getAttributes request.
    //
    SimpleDBGetAttributesRequest *gar = [[[SimpleDBGetAttributesRequest alloc] initWithDomainName:domainName   andItemName:itemName] autorelease];

    if( attributes )
    {
        for( NSString *attr in attributes )
            [gar addAttributeName:attr];
    }
    
    // Perform getAttributes() on the AWS SimpleDB
    //
    SimpleDBGetAttributesResponse *response = [[AmazonClientManager sdb] getAttributes:gar];
    if(response.error != nil)
    {
        NSLog(@"Error: %@", response.error);
    }

   for (SimpleDBAttribute *attr in response.attributes )
        NSLog(@"%@ -> %@", attr.name, attr.value);

}