Notice: Over the next few months, we're reorganizing the App Engine documentation site to make it easier to find content and better align with the rest of Google Cloud products. The same content will be available, but the navigation will now match the rest of the Cloud products. If you have feedback or questions as you navigate the site, click Send Feedback.

Python 2 is no longer supported by the community. We recommend that you migrate Python 2 apps to Python 3.
Stay organized with collections Save and categorize content based on your preferences.

google.appengine.api.capabilities package

Summary

Allows applications to identify API outages and scheduled downtime.

Example:

def StoreUploadedProfileImage(self):
  uploaded_image = self.request.get('img')
  # If the images API is unavailable, we'll just skip the resize.
  if CapabilitySet('images').is_enabled():
    uploaded_image = images.resize(uploaded_image, 64, 64)
  store(uploaded_image)

def RenderHTMLForm(self):
  datastore_readonly = CapabilitySet('datastore_v3', capabilities=['write'])
  if datastore_readonly.is_enabled():
    # ...render form normally...
  else:
    # self.response.out('<p>Not accepting submissions right now: %s</p>' %
                        datastore_readonly.admin_message())
    # ...render form with form elements disabled...

Individual API wrapper modules should expose CapabilitySet objects for users rather than relying on users to create them. They can also create convenience methods that delegate to the relevant CapabilitySet; for example, db.IsReadOnly().

Contents

class google.appengine.api.capabilities.CapabilitySet(package, capabilities=None, methods=None, stub_map=google.appengine.api.apiproxy_stub_map)source

Bases: object

Encapsulates one or more capabilities.

Capabilities can either be named explicitly, or inferred from the list of methods provided. If no capabilities or methods are provided, this will check whether the entire package is enabled.

admin_message()source

Retrieves any administrator notice messages for these capabilities.

Returns

A string containing one or more administrator messages, or an empty string.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

is_enabled()source

Tests whether the capabilities are currently enabled.

Returns

True if API calls that require these capabillities will succeed.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

will_remain_enabled_for(time=60)source

Returns whether a capability will remain enabled.

DEPRECATED: this method was never fully implemented and is considered deprecated. Use is_enabled() instead.

Parameters

time – Number of seconds in the future to look when checking for scheduled downtime.

Returns

True if there is no scheduled downtime for the specified capability within the amount of time specified.

Raises

UnknownCapabilityError – If a specified capability was not recognized.

exception google.appengine.api.capabilities.UnknownCapabilityErrorsource

Bases: exceptions.Exception

An unknown capability was requested.