The iOS SDK allows you to retrieve, create, and delete tags. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with tags.
This example illustrates a call to deleteTags:withCompletionHandler:
API. This API is used to delete the tags for the file or folder under the specified path.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCDeleteTagsAPIParams
class and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the deleteTags:withCompletionHandler:
method.deleteTags:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCDeleteTagsAPIParams *params = [[PCDeleteTagsAPIParams alloc] init];
params.uri = @"uri"; //URI of the resource. This is a URI value obtained from a fullview or metadata response. (required)
[[PCAPISDK sharedInstance] deleteTags:params withCompletionHandler:^(PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeNoContent:
NSLog(@"Tag deleted successfully");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Delete tags API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
This example illustrates a call to getTags:withCompletionHandler:
API. This API call is used to retrieve the tags for the file or folder under the specified path.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCGetTagsAPIParams
class and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the getTags:withCompletionHandler:
method.getTags:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetTagsAPIParams *params = [[PCGetTagsAPIParams alloc] init];
params.path = @"full_Path"; //The path to the file or folder for which tags need to be retrieved. (required)
[[PCAPISDK sharedInstance] getTags:params withCompletionHandler:^(PCTags *tag, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeNoContent:
case PCAPIResponseCodeOK:
NSLog(@"Tag retrieved successfully");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Get tags API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
This example illustrates a call to setTags:withCompletionHandler:
API. This API call is used to update the tags for the file or folder under the specified path.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCSetTagsAPIParams
class and and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException
exception.PCAPISDK
object and call the setTags:withCompletionHandler:
method.setTags:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCSetTagsAPIParams *params = [[PCSetTagsAPIParams alloc] init];
params.uri = @"uri"; // URI of the resource. This is an URI value obtained from a fullview or metadata response. (required)
params.tags = @"tags"; // A set of Tags. (required)
[[PCAPISDK sharedInstance] setTags:params withCompletionHandler:^(PCTags *tag, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK:
NSLog(@"Tag updated successfully");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Set tags API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.