microsoft-dpe/wa-toolkit-ios — pull request #30 by darden88 (2011-11-15 23:35:50+00:00)
Title: Update for storage property fetching/setting

Attached are the updated files for this feature. I'm not super-familiar with github pull requests, so there are three files from the Samples directory that I didn't change, and am not anticipating should be part of this pull request, but I don't know why they are included or how to exclude them.

As I've previously written, I'm using these extensively in iOS for managing storage analytics. However, they should be generic enough to apply to any sort of storage property administration.

Here's a sample of how you'd request properties:
WAAuthenticationCredential *credential = [WAAuthenticationCredential
credentialWithAzureServiceAccount:serviceName
accessKey:serviceKey];

WACloudStorageClient *client = [WACloudStorageClient storageClientWithCredential:credential];

[self.spinner startAnimating];

NSString *service;
service =@"blob"; //or table, queue, etc.

[client fetchSettingsForStorageType:service withCompletionHandler:^(NSString * result, NSError * error){
if (error){
NSLog(@"%@", [error localizedDescription]);
[self.spinner stopAnimating];
}
else
{
NSLog(@"result: %@", result);
}
}];

It's really very similar to using the other existing APIs.

One potential issue is that I have defined the url in the fetch and update selectors, as so:

- (void)fetchSettingsForStorageType:(NSString *)storageType withCompletionHandler:(void (^)(NSString *, NSError *))block
{
NSURL *url = [_credential URLforEndpoint:@"?restype=service&comp=properties" forStorageType:storageType];

...

If you think there could be other/different urls now or in the future, then that could be passed in as data through the selector signature. But for now, Storage Analytics are the only ones I'm familiar with.

My motivation for creating a NSString return type in WAAuthenticationCredential.h is because you currently do all of your xml parsing in private classes. I actually prefer to use the Google GData xml parser for iOS, so getting back data from Azure as NSString allows me to parse it in my own app.

And lastly, you'll note that I made a number of changes to - (WACloudURLRequest *)authenticatedRequestWithEndpoint:(NSString *)endpoint forStorageType:(NSString *)storageType httpMethod:(NSString*)httpMethod

In my opinion, while these changes are *required* for storage analytics, they represent fixes for the current code. Specifically, the "comp=" querystring parameter was being handled incorrectly. See my prev pull request email. Also, the version header needs to be created to table requests as well as blob & queue.

If you have any questions on this code, please let me know.

thanks,

Chris