HPCSSwiftClient Class Reference
Inherits from | AFHTTPClient |
Declared in | HPCSSwiftClient.h |
Tasks
Other Methods
-
identityClient
The HPCSIdentityClient object used to get access to the HPCSToken.
property
Creating and Initializing HPCSSwift Clients
-
– initWithIdentityClient:
Creates a Swift client
Container Operations
-
– containers:failure:
Returns a list of all containers owned by the authenticated request sender
-
– saveContainer:success:failure:
Creates a new container belonging to the account of the authenticated request sender.
-
– deleteContainer:success:failure:
Deletes the specified container.
-
– headContainer:success:failure:
Gives metadata details about the given container
-
– setContainer:aclList:success:failure:
Set ACL details about a container
Object Operations
-
– objectsForContainer:success:failure:
Lists information about the objects in a container for a user that has read access to the bucket.
-
– deleteObject:success:failure:
Deletes the specified object.
-
– saveObject:success:progress:failure:
Saves the specified object.
-
– setObject:metadata:success:failure:
Sets custom metadata on an object
-
– getObjectMetadata:success:failure:
Gets all metadata on an object, convenience version of headObject:
-
– getObject:success:failure:
Retrieves the specified object.
-
– headObject:success:failure:
Retrieves information about an object for a user with read access without fetching the object.
-
– putObjectWithData:mimeType:destinationPath:parameters:progress:success:failure:
Adds an object to a bucket for a user that has write access to the bucket. A success response indicates the object was successfully stored; if the object already exists, it will be overwritten.
-
– urlForObject:
Returns the full path for an object
-
– metaDataFromResponse:
Returns an NSDictionary of HTTP headers, usually used with a HEAD request to get object metadata
-
– URLEncodedString:
URL encode a string
Properties
identityClient
The HPCSIdentityClient object used to get access to the HPCSToken.
@property (retain) HPCSIdentityClient *identityClient
Declared In
HPCSSwiftClient.h
Instance Methods
URLEncodedString:
URL encode a string
- (NSString *)URLEncodedString:(NSString *)source
Parameters
- source
the string to URLEncode
Declared In
HPCSSwiftClient.h
containers:failure:
Returns a list of all containers owned by the authenticated request sender
- (void)containers:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSArray *records ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- success
A block containing NSHTTPURLResponse from Swift and the NSArray of Containers
- failure
A block containing NSHTTPURLResponse from Swift and the NSError.
Return Value
Calls either the success for failure block depending on HTTPStatus code returned *
Declared In
HPCSSwiftClient.h
deleteContainer:success:failure:
Deletes the specified container.
- (void)deleteContainer:(id)container success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- container
Object that must respond to name
- success
block returning NSHTTURLResponse from Swift
- failure
Block returning NSHTTPURLResponse and NSError
Return Value
Calls either the success for failure block depending on HTTPStatus code returned
Discussion
All objects in the container must be deleted before the bucket itself can be deleted.
HTTP Status Return Codes
204 success
404 container not found
409 container not empty
Declared In
HPCSSwiftClient.h
deleteObject:success:failure:
Deletes the specified object.
- (void)deleteObject:(id)object success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
The object to delete. It must respond to parent, parent.name and name
- success
Block returning NSHTTPURLResponse from Swift
- failure
Block returning NSHTTPURLResponse and NSError
Return Value
Calls either the success for failure block depending on HTTPStatus code returned
Discussion
Once deleted, there is no method to restore or undelete an object.
HTTP Status Codes
204 is passed back if the container is empty or does not exist for the specified account.
404 If an incorrect account is specified.
Declared In
HPCSSwiftClient.h
getObject:success:failure:
Retrieves the specified object.
- (void)getObject:(id)object success:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSData *data ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
The object to save. Must respond to parent, parent.name and name
- success
Block returning NSHTTPURLResponse from Swift
- failure
Block returning NSHTTPURLResponse from Swift and NSError
Declared In
HPCSSwiftClient.h
getObjectMetadata:success:failure:
Gets all metadata on an object, convenience version of headObject:
- (void)getObjectMetadata:(id)object success:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSDictionary *metadata ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
the object which you want the metadata on, must respond to name and parent.name
- success
metadata is the NSDictionary taken from the responseObject headers result
- failure
called if there is an error
@disussion this is really an alias for headObject:success:failure:
Declared In
HPCSSwiftClient.h
headContainer:success:failure:
Gives metadata details about the given container
- (void)headContainer:(id)container success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- container
The container to get metadata about
- success
Block returning an NSHTTPURLResponse with headers that contain the metadata
- failure
Block called if this call fails
Declared In
HPCSSwiftClient.h
headObject:success:failure:
Retrieves information about an object for a user with read access without fetching the object.
- (void)headObject:(id)object success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
The object to save. Must respond to parent,parent.name, name
- success
responseObject with metadata stored in httpresponse.
- failure
Block returning NSHTTPURLResponse from Swift and NSError
Return Value
Calls either the success or failure block depending on HTTPStatus code returned
Declared In
HPCSSwiftClient.h
initWithIdentityClient:
Creates a Swift client
- (id)initWithIdentityClient:(HPCSIdentityClient *)client
Parameters
- client
the HPCSIdentityClient to use as the Identity Service Client
Discussion
This is designated initializer. Typically its called in the following fashion (implicitly) from a singleton instance of HPCSIdentityClient:
HPCSIdentityClient *client = [HPCSIdentityClient sharedClient];
//this calls initWithIdentityClient
HPCSSwiftClient *swiftClient = [client swiftClient];
Declared In
HPCSSwiftClient.h
metaDataFromResponse:
Returns an NSDictionary of HTTP headers, usually used with a HEAD request to get object metadata
- (NSDictionary *)metaDataFromResponse:(NSHTTPURLResponse *)response
Parameters
- response
The response from an Operation
Discussion
This is a helper method to extract information from a header, typically to get a count of objects in the container, or bytes used, as this is more peformant than a full GET request
For containers: X-Container-Bytes-Used,X-Container-Object-Count
For top level container request X-Account-Container-Count
Declared In
HPCSSwiftClient.h
objectsForContainer:success:failure:
Lists information about the objects in a container for a user that has read access to the bucket.
- (void)objectsForContainer:(id)container success:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSArray *records ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- container
Object that must respond to name
- success
Block returning NSHTTPURLResponse from Swift and an NSArray of results
- failure
Block returning NSHTTPURLResponse and NSError
Return Value
Calls either the success for failure block depending on HTTPStatus code returned
HTTP Status Return Codes
Declared In
HPCSSwiftClient.h
putObjectWithData:mimeType:destinationPath:parameters:progress:success:failure:
Adds an object to a bucket for a user that has write access to the bucket. A success response indicates the object was successfully stored; if the object already exists, it will be overwritten.
- (void)putObjectWithData:(NSData *)data mimeType:(NSString *)mimeType destinationPath:(NSString *)destinationPath parameters:(NSDictionary *)parameters progress:(void ( ^ ) ( NSUInteger bytesWritten , long long totalBytesWritten , long long totalBytesExpectedToWrite ))progress success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- data
The NSData to be stored
- mimeType
The mimeType of the resource
- destinationPath
Dont know what this is
- parameters
The HTTP parameters for the POST operation
- progress
Block which takes an parameters for progress bars
- success
Block returning NSHTTPURLResponse from Swift.
- failure
Block returning NSHTTPURLResponse from Swift and NSError
Declared In
HPCSSwiftClient.h
saveContainer:success:failure:
Creates a new container belonging to the account of the authenticated request sender.
- (void)saveContainer:(id)container success:(void ( ^ ) ( NSHTTPURLResponse *))saved failure:(void ( ^ ) ( NSHTTPURLResponse *, NSError *))failure
Parameters
- container
container information, must respond to name
- saved
block returning NSHTTPURLResponse from Swift
- failure
block returning NSHTTPURLResponse from Swift and the NSError
Return Value
Calls either the success for failure block depending on HTTPStatus code returned
HTTP Status Codes
201 successful create
202 if the container already existed
Declared In
HPCSSwiftClient.h
saveObject:success:progress:failure:
Saves the specified object.
- (void)saveObject:(id)object success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success progress:(void ( ^ ) ( NSUInteger bytesWritten , long long totalBytesWritten , long long totalBytesExpectedToWrite ))progress failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
The object to save. Must respond to parent, parent.name and name , mimeTypeForFile, data
- success
Block returning NSHTTPURLResponse from Swift
- progress
Block returning the state of the upload
- failure
Block returning NSHTTPURLResponse from Swift and NSError
Return Value
Calls either the success or failure block depending on HTTPStatus code returned
Declared In
HPCSSwiftClient.h
setContainer:aclList:success:failure:
Set ACL details about a container
- (void)setContainer:(id)container aclList:(NSString *)aclList success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- container
The container to get metadata about (must respond to Name)
- aclList
acl string formatted like see http://docs.openstack.org/developer/swift/misc.html#id5
- success
Block returning an NSHTTPURLResponse with headers that contain the metadata
- failure
Block called if this call fails
Discussion
an example ACL list for granting everybody access would be
Declared In
HPCSSwiftClient.h
setObject:metadata:success:failure:
Sets custom metadata on an object
- (void)setObject:(id)object metadata:(NSDictionary *)metadata success:(void ( ^ ) ( NSHTTPURLResponse *responseObject ))success failure:(void ( ^ ) ( NSHTTPURLResponse *responseObject , NSError *error ))failure
Parameters
- object
the object which you want the metadata on, must respond to name and parent.name
- metadata
NSDictionary of key value pairs with keys of the form “X-Object-Meta-
”
- success
Block returning NSHTTPURLResponse from Swift
- failure
Block returning NSHTTPURLResponse from Swift and NSError
Discussion
You cannot use the POST operation to change any of the following metadata:
- Content-Length
- ETag
- Last-Modified
To set custom metadata on an object use a header name with a prefix of X-Object-Meta-. After this prefix, you can pick any name meaningful to you. For example, X-Object-Meta-Reviewed could be used indicate that the contents of an object had been reviewed.
NSDictionary *meta = @{ @"X-Object-Meta-Reviewed": @"true"}
[client setObject:object metadata:meta success:^(NSHTTPURLResponse *responseObject){
NSLog(@"metadata set");
}
failure:^(NSHTTPURLResponse *responseObject, NSError *error){
NSLog(@"metadata not set");
}
HTTP Return Codes
- Success 202
- Failure 404
Declared In
HPCSSwiftClient.h