About Tags

About Tags

Contents

Introduction

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.

Examples

deleteTags

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.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCDeleteTagsAPIParams class and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the deleteTags:withCompletionHandler: method.
  5. Perform the deleteTags:withCompletionHandler: API call using the code sample in this example.
  6. Retrieve the results in the completion block.
  7. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

getTags

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.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCGetTagsAPIParams class and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the getTags:withCompletionHandler: method.
  5. Perform the getTags:withCompletionHandler: API call using the code sample in this example.
  6. Retrieve the result in the completion block.
  7. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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]);
    }

setTags

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.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCSetTagsAPIParams class and and provide the required parameters. If the required parameters are not provided, the call results in NSInvalidArgumentException exception.
  4. Initalize the PCAPISDK object and call the setTags:withCompletionHandler: method.
  5. Perform the setTags:withCompletionHandler: API call using the code sample in this example.
  6. Retrieve the results in the completion block.
  7. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call 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.