Class: Cloud

Version 1.1 - Updated on 11/17/2016

Contents

Introduction

Cloud(client\_key, client\_secret, callback\_url [, access\_token [, refresh\_token [, on\_refreshed ]]]

The Python SDK Personal Cloud Storage class. For most applications, you there is one instance of this class for each user.

  • Parameters:
    • client_key — Key obtained from the ThingSpace portal
    • client_secret — Secret obtained from the ThingSpace portal
    • callback_url — Callback URL obtained from the ThingSpace portal.
    • access_token - Optional OAuth 2.0 access token that allows the SDK to immediately begin making authenticated calls.
    • refresh_token - Optional OAuth 2.0 refresh token.
    • on_refreshed — Callback function you can use to refresh tokens. Passes the Token object as the only argument.
  • Returns: SDK instance

Authentication and Authorization

authorize_url

cloud.authorize_url()

Obtains a URL used to start the OAuth 2.0 authorization flow. The URI prompts the users to log on and grant access to their Personal Cloud Storage content.

  • Returns: A String URL used to start the authentication process.

refresh

cloud.refresh()

Called when an OAuth 2.0 access token expires. Uses a refresh token to obtain a new access token. This call fails if the refresh token has expired.

This method id called internally by the SDK, when an expired access token is detected.

  • Returns: Token object containing the access\_token and the refresh\_token.
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — The user provided a bad or expired refresh token.

token

cloud.token(auth_code)

The second part of the standard OAuth 2.0 authorization flow. Uses an authorization code obtained through the OAuth 2.0 redirect_uri to obtain an access and refresh tokens, used to access an user’s Cloud Storage content.

  • Parameters:
    • auth_code — OAuth 2.0 auth code obtained from the callback.
  • Returns: Token object containing the access\_token and refresh\_token. The SDK may begin making authenticated calls after a successful tokens call.
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — The user provided a bad auth\_code.

Account Information

account

cloud.account()

Retrieves the account information.

  • Returns: An Account object containing a user’s quota usage and id.
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token.

File and Folder Operations

download

cloud.download\_url(file_or_path)

Retrieves a download URL for a CloudFile object

  • Parameters:
    • file_or_path — a CloudFile or the path of the file to be downloaded.
  • Returns: String URL you can use to download the file.

file_metadata

cloud.file_metadata(path)

Retrieves metadata for a file.

  • Parameters:
    • path — Path to the file
  • Returns: A CloudFile containing the metadata of the file
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token
    • NotFoundError - The resource was not found.

fullview

cloud.fullview(etag)

Obtains information on all files and folders in a user’s Personal Cloud Storage account.

Return value contains a property etag. Use etag as an argument to a fullview call to retrieve changes between two subsequent fullview calls.

  • Parameters:
    • etag — Lucene style search query
  • Returns: files, folders
    • files - array of CloudFile objects
    • empty_folders - Array of empty CloudFolder Objects in the user’s cloud
    • etag - Etag used in subsequent fullview calls to retrieve the changes to the content of a user’s Personal Cloud Storage account
    • deleted - Array of paths that have been deleted since the last fullview call
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token
    • OutOfSyncError - Specified etag is too far out of date. Delete cached files and resync by calling fullview without etag.

metadata

cloud.metadata(path)

Retrieves the metadata for a folder. The response includes the metadata for the folder’s contents, including files and subfolders.

  • Parameters:
    • path — Current folder’s path and name. Defaults to the root /.
  • Returns: files, folders
    • files - array of CloudFile objects
    • folders - array of CloudFolder objects
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token
    • NotFoundError - The resource was not found.

cloud.search(query [, sort [, virtualfolder [, page [, count]]]])

Searches for files or folders.

  • Parameters:
    • query — Lucene style search query
    • sort - Optional sort parameter. Syntax is: {field}+{asc or desc}.
    • virtualfolder - Optional virtualfolder to search in. Default is VZMOBILE.
    • page - Optional page number. Default is 1.
    • count - Optional number of results to return. Default is 20, max is 100.
  • Returns: files, folders
    • files - array of CloudFile objects
    • folders - array of CloudFolder objects
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token

upload

cloud.upload(file\_or\_path, upload\_path [, name [, chunked [, chunk_size ]]])

Uploads a file.

  • Parameters:
    • file_or_path — Either a file object or a path from where the file is to be uploaded.
    • upoad_path - Path where the file is to be uploaded to
    • name - Optional. New name of the file, defaults to the current name.
    • chunked - Optional. If set to true, forces smaller files to be uploaded in chunks.
    • chunk_size - Optional chunk size in bytes.
  • Returns: CloudFile object containing metadata of the uploaded file
  • Errors:
    • CloudError — HTTP request failure
    • UnauthorizedError — Unauthorized, bad or expired token

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.