Ejemplo n.º 1
0
class IBaseFactory(Interface):
    init_time = Attribute(
        'Time reference point for all connections made by this factory. '
        'A float, in seconds, as in time.time().')
Ejemplo n.º 2
0
class IDeviceOrganizerInfo(IInfo):
    """
    DeviceClass info
    """
    events = Attribute('A list of (severity, count) tuples for the three most'
                       ' severe event severities')
Ejemplo n.º 3
0
        class INoFields(Interface):
            def method():
                pass

            attr = Attribute('ignoreme')
Ejemplo n.º 4
0
class IFilesystem(Interface):
    """
    A filesystem that is part of a pool.
    """

    size = Attribute("""
    A ``VolumeSize`` instance giving capacity information for this filesystem.
    This value is not necessarily up-to-date but represents information that
    was correct when this ``IFilesystem`` provider was created.
    """)

    def get_path():
        """Retrieve the filesystem's local path.

        E.g. for a ZFS filesystem this would be the path where it is
        mounted.

        :return: The path as a ``FilePath``.
        """

    def snapshots():
        """
        Retrieve the information about the snapshots of this filesystem.

        :return: A ``Deferred`` that fires with a ``list`` of ``Snapshot``
            instances, ordered from oldest to newest, describing the snapshots
            which exist of this filesystem.
        """

    def reader(remote_snapshots=None):
        """
        Context manager that allows reading the contents of the filesystem.

        A blocking API, for now.

        The returned file-like object will be closed by this object.

        :param remote_snapshots: An iterable of the snapshots which are
            available on the writer, ordered from oldest to newest.  An
            incremental data stream may be generated based on one of these if
            possible.  If no value is passed then a complete data stream will
            be generated.

        :return: A file-like object from whom the filesystem's data can be
            read as ``bytes``.
        """

    def writer():
        """Context manager that allows writing new contents to the filesystem.

        This receiver is a blocking API, for now.

        The returned file-like object will be closed by this object.

        The higher-level volume API will ensure that whoever is writing
        the data is the owner of the volume. As such, whatever new data is
        being received will overwrite the filesystem's existing data.

        :param Volume volume: A volume that is being pushed to us.

        :return: A file-like object which when written to with output of
            :meth:`IFilesystem.reader` will populate the volume's
            filesystem.
        """

    def __eq__(other):
        """True if and only if underlying OS filesystem is the same."""

    def __ne__(other):
        """True if and only if underlying OS filesystem is different."""

    def __hash__():
        """Equal objects should have the same hash."""
Ejemplo n.º 5
0
class ILocateTranslation(Interface):
    context = Attribute("context", "The object that is being translated")

    def findLocationForTranslation(language):
        """Find and return a location for a new translation.
class IPASEvent(Interface):
    """An event related to a PAS principal.
    """

    principal = Attribute('The subject of the event.')
Ejemplo n.º 7
0
class IFlickrAdapter(IGalleryAdapter):
    """
    """

    flickr = Attribute("returns a flickrapi object for the api key")

    def get_flickr_user_id(username):
        """
        Returns the actual user id of someone given a username.
        if a username is not given, it will use the one in its
        settings
        """

    def get_flickr_api_key(username):
        """
        Returns the api key  (not sure if this is needed)
        """

    def get_flickr_api_secret(username):
        """
        Returns the api secret (not sure if this is needed)
        """

    def get_flickr_collection_id(self):
        """
        Returns the collection id. Uses value from settings.
        """

    def get_flickr_photoset_id(user_id):
        """
        Returns the photoset id based on the name (or id) in settings.
        User ID must be provided.
        """

    def gen_collection_sets(user_id, collection_id=None):
        """
        Yields all photosets from a collection (as ElementTree objects)
        Available attributes: [id, title, description]
        """

    def gen_photoset_photos(user_id, photoset_id=None):
        """
        Yields all photos from a photoset (as ElementTree objects)
        Available attributes: ['secret', 'title', 'farm', 'isprimary',
                               'id', 'dateupload', 'server']
        """

    def gen_collection_photos(user_id, collection_id=None):
        """
        Yields all photos from given collection,
        sorted by upload date (most recent first)

        Available attributes: same as gen_photoset_photos.
        """

    def get_mini_photo_url(photo):
        """
        takes a photo and creates the thumbnail photo url
        """

    def get_photo_link(photo):
        """
        creates the photo link url
        """

    def get_large_photo_url(photo):
        """
        create the large photo url
        """

    def get_original_image_url(photo):
        """
        Image URL on flickr.com
        """

    def get_original_context_url(photo):
        """
Ejemplo n.º 8
0
class IGrokcoreComponentAPI(
        IBaseClasses,
        IDecorators,
        IDirectives,
        IGrokErrors,
        IMartianAPI,
):
    """grokcore.component's public API.
    """

    getSiteManager = Attribute('Get the site manager for the nearest site.')

    provideAdapter = Attribute('Registers an adapters')

    provideHandler = Attribute('Registers an handler')

    provideInterface = Attribute('Regsiters an interfaces as a utility')

    provideSubscriptionAdapter = Attribute(
        'Registers an subscriptions adapter')

    provideUtility = Attribute('Registers an utility')

    querySubscriptions = Attribute("Function to query subscriptions.")

    queryOrderedSubscriptions = Attribute(
        "Function to query subscription in order.")

    queryMultiSubscriptions = Attribute("Function to query subscriptions.")

    queryOrderedMultiSubscriptions = Attribute(
        "Function to query subscriptions in order.")

    sort_components = Attribute(
        'Sort a list of components using the information provided by '
        '`grok.order`.')
Ejemplo n.º 9
0
class ICommandResult(Interface):
    status = Attribute('Status')
    result = Attribute('Command result. May be a string or an object.')

    def to_dict(self):
        """
Ejemplo n.º 10
0
class IACLModified(IObjectEvent):
    """ May be sent when an object's ACL is modified """
    object = Attribute('The object being modified')
    old_acl = Attribute('The object ACL before the modification')
    new_acl = Attribute('The object ACL after the modification')
Ejemplo n.º 11
0
class ICatalog(Interface):
    """ A collection of indices. """

    objectids = Attribute(
        'a sequence of objectids that are cataloged in this catalog')

    def index_resource(resource, oid=None, action_mode=None):
        """Register the resource in indexes of this catalog using objectid
        ``oid``.  If ``oid`` is not supplied, the ``__oid__`` of the
        ``resource`` will be used.  ``action_mode``, if supplied, should be one
        of ``None``, :attr:`~substanced.interfaces.MODE_IMMEDIATE`,
        :attr:`~substanced.interfaces.MODE_ATCOMMIT` or
        :attr:`~substanced.interfaces.MODE_DEFERRED`."""

    def reindex_resource(resource, oid=None, action_mode=None):
        """Register the resource in indexes of this catalog using objectid
        ``oid``.  If ``oid`` is not supplied, the ``__oid__`` of the
        ``resource`` will be used.  ``action_mode``, if supplied, should be one
        of ``None``, :attr:`~substanced.interfaces.MODE_IMMEDIATE`,
        :attr:`~substanced.interfaces.MODE_ATCOMMIT` or
        :attr:`~substanced.interfaces.MODE_DEFERRED` indicating when the updates
        should take effect.  The ``action_mode`` value will overrule any
        action mode that a member index has been configured with.

        The result of calling this method is logically the same as calling
        ``unindex_resource``, then ``index_resource`` for the same resource/oid
        combination, but calling those two methods in succession is often more
        expensive than calling this single method, as member indexes can choose
        to do smarter things during a reindex than what they would do during an
        unindex then an index.
        """

    def unindex_resource(resource_or_oid, action_mode=None):
        """Deregister the resource in indexes of this catalog using objectid or
        resource ``resource_or_oid``.  If ``resource_or_oid`` is an integer, it
        will be used as the oid; if ``resource_or_oid`` is a resource, its
        ``__oid__`` attribute will be used as the oid.  ``action_mode``, if
        supplied, should be one of ``None``,
        :attr:`~substanced.interfaces.MODE_IMMEDIATE`,
        :attr:`~substanced.interfaces.MODE_ATCOMMIT` or
        :attr:`~substanced.interfaces.MODE_DEFERRED`."""

    def __getitem__(name):
        """ Return the index named ``name``"""

    def reset():
        """ Clear all indexes in this catalog and clear self.objectids. """

    def flush(immediate=True):
        """ Flush any pending indexing actions for all indexes in this catalog.
        If ``immediate`` is ``True``, *all* actions will be immediately
        executed.  If ``immediate`` is ``False``,
        :attr:`~substanced.interfaces.MODE_DEFERRED` actions will be sent to
        the actions processor if one is active, and all other actions will be
        executed immediately."""

    def reindex(dry_run=False,
                commit_interval=200,
                indexes=None,
                path_re=None,
                output=None):
        """\
        Reindex all objects in this collection of indexes.

        If ``dry_run`` is ``True``, do no actual work but send what would be
        changed to the logger.

        ``commit_interval`` controls the number of objects indexed between
        each call to ``transaction.commit()`` (to control memory
        consumption).

        ``indexes``, if not ``None``, should be a list of index names that
        should be reindexed.  If ``indexes`` is ``None``, all indexes are
        reindexed.

        ``path_re``, if it is not ``None`` should be a regular expression
        object that will be matched against each object's path.  If the
        regular expression matches, the object will be reindexed, if it does
        not, it won't.

        ``output``, if passed should be one of ``None``, ``False`` or a
        function.  If it is a function, the function should accept a single
        message argument that will be used to record the actions taken during
        the reindex.  If ``False`` is passed, no output is done.  If ``None``
        is passed (the default), the output will wind up in the
        ``substanced.catalog`` Python logger output at ``info`` level.
        """

    def update_indexes(registry=None,
                       dry_run=False,
                       output=None,
                       replace=False,
                       reindex=False,
                       **kw):
        """ Use the candidate indexes registered via
Ejemplo n.º 12
0
class IObjectModified(IObjectEvent):
    """ May be sent when an object is modified """
    object = Attribute('The object being modified')
Ejemplo n.º 13
0
class IBugWatchSet(Interface):
    """The set of `IBugWatch`es."""

    bug = Int(title=_("Bug id"), readonly=True)
    title = Attribute('Title')

    def __getitem__(key):
        """Get a BugWatch"""

    def __iter__():
        """Iterate through BugWatches for a given bug."""

    def get(id):
        """Get an IBugWatch by its ID.

        Raise a NotFoundError if there is no IBugWatch
        matching the given id.
        """

    def search():
        """Search through all the IBugWatches in the system."""

    def fromText(text, bug, owner):
        """Create one or more BugWatch's by analysing the given text. This
        will look for reference to known or new bug tracking instances and
        create the relevant watches. It returns a (possibly empty) list of
        watches created.
        """

    def fromMessage(message, bug):
        """Create one or more BugWatch's by analysing the given email. The
        owner of the BugWatch's will be the sender of the message.
        It returns a (possibly empty) list of watches created.
        """

    def createBugWatch(bug, owner, bugtracker, remotebug):
        """Create an IBugWatch.

        :bug: The IBug to which the watch is linked.
        :owner: The IPerson who created the IBugWatch.
        :bugtracker: The external IBugTracker.
        :remotebug: A string.
        """

    def extractBugTrackerAndBug(url):
        """Extract the bug tracker and the bug number for the given URL.

        A tuple in the form of (bugtracker, remotebug) is returned,
        where bugtracker is a registered IBugTracer, and remotebug is a
        text string.

        A NoBugTrackerFound exception is raised if the base URL can be
        extracted, but no such bug tracker is registered in Launchpad.

        If no bug tracker type can be guessed, None is returned.
        """

    def getBugWatchesForRemoteBug(remote_bug, bug_watch_ids=None):
        """Returns bug watches referring to the given remote bug.

        Returns a set of those bug watches, optionally limited to
        those with IDs in `bug_watch_ids`, that refer to `remote_bug`.

        :param remote_bug_id: The ID of the remote bug.
        :type remote_bug_id: See `IBugWatch.remotebug`.

        :param bug_watch_ids: A collection of `BugWatch` IDs.
        :type bug_watch_ids: An iterable of `int`s, or `None`.
        """

    # XXX: GavinPanella bug=570277 2010-04-26: In bulkSetError() the
    # last_error_type argument accepts the same values as the result
    # argument to bulkAddActivity(). Using different terms for
    # essentially the same thing is confusing.

    def bulkSetError(references, last_error_type=None):
        """Efficiently update the status of the given bug watches.

        Sets the `last_error_type` field as instructed, updates
        `lastchecked` to now and resets `next_check` to None, all in
        the most efficient way possible.

        :param references: An iterable of `IBugWatch` objects or
            primary keys for the same.
        :param last_error_type: A member of `BugWatchActivityStatus`
            or None.
        """

    def bulkAddActivity(references,
                        result=BugWatchActivityStatus.SYNC_SUCCEEDED,
                        message=None,
                        oops_id=None):
        """Efficiently add activity for the given bug watches.
Ejemplo n.º 14
0
class IBugWatch(IHasBug):
    """A bug on a remote system."""
    export_as_webservice_entry()

    id = Int(title=_('ID'), required=True, readonly=True)

    # Actually refers to Bug; redefined in bug.py.
    bug = exported(
        Reference(title=_('Bug'),
                  schema=Interface,
                  required=True,
                  readonly=True))
    bugtracker = exported(ReferenceChoice(
        title=_('Bug System'),
        required=True,
        schema=IBugTracker,
        vocabulary='BugTracker',
        description=_("You can register new bug trackers from the Launchpad "
                      "Bugs home page.")),
                          exported_as='bug_tracker')
    remotebug = exported(StrippedTextLine(
        title=_('Remote Bug'),
        required=True,
        readonly=False,
        description=_(
            "The bug number of this bug in the remote bug tracker.")),
                         exported_as='remote_bug')
    remotestatus = exported(TextLine(title=_('Remote Status')),
                            exported_as='remote_status')
    remote_importance = exported(TextLine(title=_('Remote Importance')))
    lastchanged = exported(Datetime(title=_('Last Changed')),
                           exported_as='date_last_changed')
    lastchecked = exported(Datetime(title=_('Last Checked')),
                           exported_as='date_last_checked')
    last_error_type = exported(
        Choice(title=_('Last Error Type'), vocabulary=BugWatchActivityStatus))
    datecreated = exported(Datetime(title=_('Date Created'),
                                    required=True,
                                    readonly=True),
                           exported_as='date_created')
    owner = exported(
        Reference(title=_('Owner'),
                  required=True,
                  readonly=True,
                  schema=Interface))
    activity = Attribute('The activity history of this BugWatch.')
    next_check = exported(Datetime(title=_('Next Check')),
                          exported_as='date_next_checked')

    # Useful joins.
    bugtasks = exported(
        CollectionField(
            description=_(
                'The tasks which this watch will affect. '
                'In Launchpad, a bug watch can be linked to one or more '
                'tasks, and if it is linked and we notice a status change '
                'in the watched bug then we will try to update the '
                'Launchpad bug task accordingly.'),
            # value_type is redefined in bugtask.py, to use the right
            # interface.
            value_type=Reference(schema=Interface, )),
        exported_as='bug_tasks')

    # Properties.
    needscheck = Attribute(
        "A True or False indicator of whether or not "
        "this watch needs to be synchronised. The algorithm used considers "
        "the severity of the bug, as well as the activity on the bug, to "
        "ensure that we spend most effort on high-importance and "
        "high-activity bugs.")

    unpushed_comments = Attribute(
        "A set of comments on this BugWatch that need to be pushed to "
        "the remote bug tracker.")

    # Required for Launchpad pages.
    title = exported(Text(title=_('Bug watch title'), readonly=True))

    url = exported(
        Text(title=_('The URL at which to view the remote bug.'),
             readonly=True))

    can_be_rescheduled = Attribute(
        "A True or False indicator of whether or not this watch can be "
        "rescheduled.")

    def updateImportance(remote_importance, malone_importance):
        """Update the importance of the bug watch and any linked bug task.

        The lastchanged attribute gets set to the current time.
        """

    def updateStatus(remote_status, malone_status):
        """Update the status of the bug watch and any linked bug task.

        The lastchanged attribute gets set to the current time.
        """

    def destroySelf():
        """Delete this bug watch."""

    def hasComment(comment_id):
        """Return True if a comment has been imported for the BugWatch.

        If the comment has not been imported, return False.

        :param comment_id: The remote ID of the comment.
        """

    def addComment(comment_id, message):
        """Link and imported comment to the BugWatch.

        :param comment_id: The remote ID of the comment.

        :param message: The imported comment as a Launchpad Message object.
        """

    def getBugMessages(clauses):
        """Return all the `IBugMessage`s that reference this BugWatch.

        :param clauses: A iterable of Storm clauses to limit the messages.
        """

    def getImportedBugMessages():
        """Return all the `IBugMessage`s that have been imported."""

    def addActivity(result=None, message=None, oops_id=None):
        """Add an `IBugWatchActivity` record for this BugWatch."""

    def setNextCheck(next_check):
        """Set the next_check time of the watch.

        :raises: `BugWatchCannotBeRescheduled` if
                 `IBugWatch.can_be_rescheduled` is False.
        """

    def reset():
        """Completely reset the watch.
Ejemplo n.º 15
0
class IPrincipalAddedToGroupEvent(IPASEvent):
    """A principal has been added to a group.
    """
    group_id = Attribute('Group ID to which principal is being added')
Ejemplo n.º 16
0
class INotification(Interface):
    name = Attribute('Notification Name')
    parameters = Attribute('Dictionary of Notification Parameters')

    def to_dict(self):
        """
Ejemplo n.º 17
0
class IPrincipalRemovedFromGroupEvent(IPASEvent):
    """A principal has been removed from a group.
    """
    group_id = Attribute('Group ID from which principal is being removed')
Ejemplo n.º 18
0
    manage = Attribute(""" """)
    manage_menu = Attribute(""" """)
    manage_top_frame = Attribute(""" """)
    manage_page_header = Attribute(""" """)
    manage_page_footer = Attribute(""" """)
    manage_form_title = Attribute("""Add Form""")
    zope_quick_start = Attribute(""" """)
    manage_copyright = Attribute(""" """)
    manage_zmi_prefs = Attribute(""" """)

    def manage_zmi_logout(REQUEST, RESPONSE):
        """Logout current user"""


INavigation.setTaggedValue('manage_page_style.css', Attribute(""" """))


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on App.PersistentExtra.PersistentUtil
class IPersistentExtra(Interface):
    def bobobase_modification_time():
        """
        """


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on App.Undo.UndoSupport
class IUndoSupport(Interface):
Ejemplo n.º 19
0
class IPropertiesUpdatedEvent(IPASEvent):
    """A principals properties have been updated.
    """
    properties = Attribute('List of modified property ids')
Ejemplo n.º 20
0
class IScalingGroup(Interface):
    """
    Scaling group record
    """
    uuid = Attribute("UUID of the scaling group - immutable.")
    tenant_id = Attribute("Rackspace Tenant ID of the owner of this group.")

    def view_manifest(with_policies=True,
                      with_webhooks=False,
                      get_deleting=False):
        """
        The manifest contains everything required to configure this scaling:
        the config, the launch config, and all the scaling policies.

        :param bool with_policies: Should policies information be included?
        :param bool with_webhooks: If policies are included, should webhooks
            information be included?
        :param bool get_deleting: Should group be returned if it is deleting?
            If True, then returned manifest will contain "status" that will be
            one of "ACTIVE", "ERROR" or "DELETING"

        :return: a dictionary corresponding to the JSON schema at
            :data:`otter.json_schema.model_schemas.manifest`
        :rtype: :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def view_config():
        """
        :return: a view of the config, as specified by
            :data:`otter.json_schema.group_schemas.config`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def view_launch_config():
        """
        :return: a view of the launch config, as specified by
            :data:`otter.json_schema.group_schemas.launch_config`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def view_state():
        """
        :return: the state information as a :class:`GroupState`

        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def delete_group():
        """
        Deletes the scaling group if the state is empty.  This method should
        handle its own locking, if required.

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if the scaling group id
            doesn't exist for this tenant id
        :raises GroupNotEmptyError: if the scaling group cannot be
            deleted (e.g. if the state is not empty)
        """

    def update_status(status):
        """
        Updates the status of the group

        :param status: status to update
        :type status: One of the constants from
                      :class:`otter.models.interface.ScalingGroupStatus`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if the scaling group id
            doesn't exist for this tenant id
        """

    def update_error_reasons(reasons):
        """
        Updates the reasons why the group is in ERROR

        :param list reasons: List of string reasons

        :return: a :class:`twisted.internet.defer.Deferred` that fires
            with None

        :raises NoSuchScalingGroupError: if the scaling group id
            doesn't exist for this tenant id
        """

    def update_config(config):
        """
        Update the scaling group configuration paramaters based on the
        attributes in ``config``.  This can update the already-existing values,
        or just overwrite them - it is up to the implementation.

        Enforcing the new min/max constraints should be done elsewhere.

        :param config: Configuration data in JSON format, as specified by
            :data:`otter.json_schema.group_schemas.config`
        :type config: :class:`dict`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def update_launch_config(launch_config):
        """
        Update the scaling group launch configuration parameters based on the
        attributes in ``launch_config``.  This can update the already-existing
        values, or just overwrite them - it is up to the implementation.

        :param launch_config: launch config data in JSON format, as specified
            by :data:`otter.json_schema.group_schemas.launch_config`
        :type launch_config: :class:`dict`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def modify_state(modifier_callable, *args, **kwargs):
        """
        Updates the scaling group state, replacing the whole thing.  This
        takes a callable which produces a state, and then saves it if the
        callable successfully returns it, overwriting the entire previous state.
        This method should handle its own locking, if necessary.  If the
        callback is unsuccessful, does not save.

        :param modifier_callable: a ``callable`` that takes as first two
            arguments the :class:`IScalingGroup`, a :class:`GroupState`, and
            returns a :class:`GroupState`.  Other arguments provided to
            :func:`modify_state` will be passed to the ``callable``.

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def create_policies(data):
        """
        Create a set of new scaling policies.

        :param data: a list of one or more scaling policies in JSON format,
            each of which is defined by
            :data:`otter.json_schema.group_schemas.policy`
        :type data: :class:`list` of :class:`dict`

        :return: list of newly created scaling policies and their ids, as
            specified by :data:`otter.json_schema.model_schemas.policy_list`
        :rtype: :class:`list` of :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        :raises PoliciesOverLimitError: if newly created policies
            breaches maximum policies per group
        """

    def update_policy(policy_id, data):
        """
        Updates an existing policy with the data given.

        :param policy_id: the uuid of the entity to update
        :type policy_id: :class:`bytes`

        :param data: the details of the scaling policy in JSON format
        :type data: :class:`dict`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        :raises NoSuchPolicyError: if the policy id does not exist
        """

    def list_policies(limit=100, marker=None):
        """
        Gets all the policies associated with particular scaling group.

        :param int limit: the maximum number of policies to return
            (for pagination purposes)
        :param bytes marker: the policy ID of the last seen policy (for
            pagination purposes - page offsets)

        :return: a list of the policies, as specified by
            :data:`otter.json_schema.model_schemas.policy_list`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`list`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        """

    def get_policy(policy_id, version=None):
        """
        Gets the specified policy on this particular scaling group.

        :param policy_id: the uuid of the policy
        :type policy_id: :class:`bytes`

        :param version: version of policy to check as Type-1 UUID
        :type version: ``UUID``

        :return: a policy, as specified by
            :data:`otter.json_schema.group_schemas.policy`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`dict`

        :raises NoSuchPolicyError: if the policy id does not exist
        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist - this error is optional - a
            :class:`NoSuchPolicyError` can be raised instead
        """

    def delete_policy(policy_id):
        """
        Delete the specified policy on this particular scaling group, and all
        of its associated webhooks as well.

        :param policy_id: the uuid of the policy to be deleted
        :type policy_id: :class:`bytes`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        :raises NoSuchPolicyError: if the policy id does not exist
        """

    def list_webhooks(policy_id, limit=100, marker=None):
        """
        Gets all the capability URLs created for one particular scaling policy

        :param int limit: the maximum number of policies to return
            (for pagination purposes)
        :param bytes marker: the policy ID of the last seen policy (for
            pagination purposes - page offsets)

        :param policy_id: the uuid of the policy to be deleted
        :type policy_id: :class:`bytes`

        :return: a list of the webhooks, as specified by
            :data:`otter.json_schema.model_schemas.webhook_list`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchPolicyError: if the policy id does not exist
        """

    def create_webhooks(policy_id, data):
        """
        Creates a new webhook for a scaling policy.

        The return value will contain both the webhook identifier (the
        identifier for the webhook resource itself, which allows an
        authenticated user to access and modify the webhook) as well as the
        capability hash (the unguessable identifier for a webhook which allows
        the referenced policy to be executed without further authentication).
        The REST layer turns these identifiers into URLs for the user.

        :param policy_id: The UUID of the policy for which to create a
            new webhook.
        :type policy_id: :class:`bytes`

        :param data: A list of details for each webhook, as specified by
            :data:`otter.json_schema.group_schemas.webhook`
        :type data: :class:`list` of :class:`dict`

        :return: A list of the created webhooks with their unique ids.
        :rtype: :class:`twisted.internet.defer.Deferred` :class:`list` as
            specified by :data:`otter.json_schema.model_schemas.webhook_list`

        :raises NoSuchPolicyError: if the policy id does not exist
        :raises WebhooksOverLimitError: if creating all the specified
            webhooks would put the user over their limit of webhooks per policy
        """

    def get_webhook(policy_id, webhook_id):
        """
        Gets the specified webhook for the specified policy on this particular
        scaling group.

        :param policy_id: the uuid of the policy
        :type policy_id: :class:`bytes`

        :param webhook_id: the uuid of the webhook
        :type webhook_id: :class:`bytes`

        :return: a webhook, as specified by
            :data:`otter.json_schema.model_schemas.webhook`
        :rtype: a :class:`twisted.internet.defer.Deferred` that fires with
            :class:`dict`

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        :raises NoSuchPolicyError: if the policy id does not exist
        :raises NoSuchWebhookError: if the webhook id does not exist
        """

    def update_webhook(policy_id, webhook_id, data):
        """
        Update the specified webhook for the specified policy on this particular
        scaling group.

        :param policy_id: the uuid of the policy
        :type policy_id: :class:`bytes`

        :param webhook_id: the uuid of the webhook
        :type webhook_id: :class:`bytes`

        :param data: the details of the scaling policy in JSON format
        :type data: :class:`dict`

        :return: a :class:`twisted.internet.defer.Deferred` that fires with None

        :raises NoSuchScalingGroupError: if this scaling group (one
            with this uuid) does not exist
        :raises NoSuchPolicyError: if the policy id does not exist
        :raises NoSuchWebhookError: if the webhook id does not exist
        """

    def delete_webhook(policy_id, webhook_id):
        """
Ejemplo n.º 21
0
class IListManager(Interface):
    """The interface of the global list manager.

    The list manager manages `IMailingList` objects.  You can add and remove
    `IMailingList` objects from the list manager, and you can retrieve them
    from the manager via their fully qualified list name, e.g.:
    `[email protected]`.
    """
    def create(fqdn_listname):
        """Create a mailing list with the given name.

        :param fqdn_listname: The fully qualified name of the mailing list,
            e.g. `[email protected]`.
        :type fqdn_listname: Unicode
        :return: The newly created `IMailingList`.
        :raise `ListAlreadyExistsError` if the named list already exists.
        """

    def get(fqdn_listname):
        """Return the mailing list with the given name, if it exists.

        :param fqdn_listname: The fully qualified name of the mailing list.
        :type fqdn_listname: Unicode.
        :return: the matching `IMailingList` or None if the named list does
            not exist.
        """

    def get_by_list_id(list_id):
        """Return the mailing list with the given list id, if it exists.

        :param fqdn_listname: The fully qualified name of the mailing list.
        :type fqdn_listname: Unicode.
        :return: the matching `IMailingList` or None if the named list does
            not exist.
        """

    def delete(mlist):
        """Remove the mailing list from the database.

        :param mlist: The mailing list to delete.
        :type mlist: `IMailingList`
        """

    mailing_lists = Attribute("""An iterator over all the mailing list objects.

        The mailing lists are returned in order sorted by `list_id`.
        """)

    def __iter__():
        """An iterator over all the mailing lists.

        :return: iterator over `IMailingList`.
        """

    names = Attribute(
        """An iterator over the fully qualified list names of all mailing
        lists managed by this list manager.""")

    list_ids = Attribute(
        """An iterator over the list ids of all mailing lists managed by this
        list manager.""")

    name_components = Attribute(
        """An iterator over the 2-tuple of (list_name, mail_host) for all
        mailing lists managed by this list manager.""")

    def find(*, advertised=None, mail_host=None):
        """Search for mailing lists matching some criteria.
Ejemplo n.º 22
0
class IObjectAddedToOrganizerEvent(IObjectEvent):
    """
    An event that is fired when an object is added to an organizer. For instance
    Groups, System, Locations and Dynamic Services
    """
    organizer = Attribute("Organizer the object is added to")
Ejemplo n.º 23
0
class ISFTPServer(Interface):
    """
    SFTP subsystem for server-side communication.

    Each method should check to verify that the user has permission for
    their actions.
    """

    avatar = Attribute("""
        The avatar returned by the Realm that we are authenticated with,
        and represents the logged-in user.
        """)

    def gotVersion(otherVersion, extData):
        """
        Called when the client sends their version info.

        otherVersion is an integer representing the version of the SFTP
        protocol they are claiming.
        extData is a dictionary of extended_name : extended_data items.
        These items are sent by the client to indicate additional features.

        This method should return a dictionary of extended_name : extended_data
        items.  These items are the additional features (if any) supported
        by the server.
        """
        return {}

    def openFile(filename, flags, attrs):
        """
        Called when the clients asks to open a file.

        @param filename: a string representing the file to open.

        @param flags: an integer of the flags to open the file with, ORed
        together.  The flags and their values are listed at the bottom of
        L{twisted.conch.ssh.filetransfer} as FXF_*.

        @param attrs: a list of attributes to open the file with.  It is a
        dictionary, consisting of 0 or more keys.  The possible keys are::

            size: the size of the file in bytes
            uid: the user ID of the file as an integer
            gid: the group ID of the file as an integer
            permissions: the permissions of the file with as an integer.
            the bit representation of this field is defined by POSIX.
            atime: the access time of the file as seconds since the epoch.
            mtime: the modification time of the file as seconds since the epoch.
            ext_*: extended attributes.  The server is not required to
            understand this, but it may.

        NOTE: there is no way to indicate text or binary files.  it is up
        to the SFTP client to deal with this.

        This method returns an object that meets the ISFTPFile interface.
        Alternatively, it can return a L{Deferred} that will be called back
        with the object.
        """

    def removeFile(filename):
        """
        Remove the given file.

        This method returns when the remove succeeds, or a Deferred that is
        called back when it succeeds.

        @param filename: the name of the file as a string.
        """

    def renameFile(oldpath, newpath):
        """
        Rename the given file.

        This method returns when the rename succeeds, or a L{Deferred} that is
        called back when it succeeds. If the rename fails, C{renameFile} will
        raise an implementation-dependent exception.

        @param oldpath: the current location of the file.
        @param newpath: the new file name.
        """

    def makeDirectory(path, attrs):
        """
        Make a directory.

        This method returns when the directory is created, or a Deferred that
        is called back when it is created.

        @param path: the name of the directory to create as a string.
        @param attrs: a dictionary of attributes to create the directory with.
        Its meaning is the same as the attrs in the L{openFile} method.
        """

    def removeDirectory(path):
        """
        Remove a directory (non-recursively)

        It is an error to remove a directory that has files or directories in
        it.

        This method returns when the directory is removed, or a Deferred that
        is called back when it is removed.

        @param path: the directory to remove.
        """

    def openDirectory(path):
        """
        Open a directory for scanning.

        This method returns an iterable object that has a close() method,
        or a Deferred that is called back with same.

        The close() method is called when the client is finished reading
        from the directory.  At this point, the iterable will no longer
        be used.

        The iterable should return triples of the form (filename,
        longname, attrs) or Deferreds that return the same.  The
        sequence must support __getitem__, but otherwise may be any
        'sequence-like' object.

        filename is the name of the file relative to the directory.
        logname is an expanded format of the filename.  The recommended format
        is:
        -rwxr-xr-x   1 mjos     staff      348911 Mar 25 14:29 t-filexfer
        1234567890 123 12345678 12345678 12345678 123456789012

        The first line is sample output, the second is the length of the field.
        The fields are: permissions, link count, user owner, group owner,
        size in bytes, modification time.

        attrs is a dictionary in the format of the attrs argument to openFile.

        @param path: the directory to open.
        """

    def getAttrs(path, followLinks):
        """
        Return the attributes for the given path.

        This method returns a dictionary in the same format as the attrs
        argument to openFile or a Deferred that is called back with same.

        @param path: the path to return attributes for as a string.
        @param followLinks: a boolean.  If it is True, follow symbolic links
        and return attributes for the real path at the base.  If it is False,
        return attributes for the specified path.
        """

    def setAttrs(path, attrs):
        """
        Set the attributes for the path.

        This method returns when the attributes are set or a Deferred that is
        called back when they are.

        @param path: the path to set attributes for as a string.
        @param attrs: a dictionary in the same format as the attrs argument to
        L{openFile}.
        """

    def readLink(path):
        """
        Find the root of a set of symbolic links.

        This method returns the target of the link, or a Deferred that
        returns the same.

        @param path: the path of the symlink to read.
        """

    def makeLink(linkPath, targetPath):
        """
        Create a symbolic link.

        This method returns when the link is made, or a Deferred that
        returns the same.

        @param linkPath: the pathname of the symlink as a string.
        @param targetPath: the path of the target of the link as a string.
        """

    def realPath(path):
        """
        Convert any path to an absolute path.

        This method returns the absolute path as a string, or a Deferred
        that returns the same.

        @param path: the path to convert as a string.
        """

    def extendedRequest(extendedName, extendedData):
        """
Ejemplo n.º 24
0
class IObjectRemovedFromOrganizerEvent(IObjectEvent):
    """
    An event that is fired when an object is removed from an organizer
    """
    organizer = Attribute("Organizer the object is removed from")
Ejemplo n.º 25
0
class ITranslationFactory(Interface):
    context = Attribute("context", "The object that is being translated")

    def createTranslation(container, language, *args, **kwargs):
        """Create and return a translation.
Ejemplo n.º 26
0
class IDeviceClassMoveEvent(IObjectEvent):
    """
    An event that is fired when an object is removed from an organizer
    """
    fromOrganizer = Attribute("Organizer the object is moved from")
    toOrganizer =  Attribute("Organizer the object is moved to")
Ejemplo n.º 27
0
class IHost(Interface):
    """
    For inspecting Control Center hosts.
    """

    id = Attribute("Globally unique host identifier")
    name = Attribute("Name of the host")
    poolId = Attribute("Name of the pool on which the host is running")
    ipAddr = Attribute("IP Address of the host")
    cores = Attribute("Number of processor cores")
    memory = Attribute("Memory (bytes) available on the host")
    privateNetwork = Attribute("Private network of the host")
    createdAt = Attribute("Time host was added")
    updatedAt = Attribute("Time the host was updated")
    kernelVersion = Attribute("Kernel version of the host OS")
    kernelRelease = Attribute("Kernel release number of the host OS")
Ejemplo n.º 28
0
class IMessagePrePublishingEvent(Interface):
    """
    Fired just before a batch of ModelChangeList messages is published to
    Rabbit.
    """
    msgs = Attribute("list of ModelChanges")
Ejemplo n.º 29
0
class IBouserSite(Interface):
    jinja_env = Attribute('jinja_env', 'Jinja Environment')
Ejemplo n.º 30
0
class IConversionFinishedEvent(IObjectEvent):

    status = Attribute("The status of the conversion")