Exemplo n.º 1
0
    and Products. Each ProjectGroup may be responsible for several Products.
    For example, the Mozilla Project has Firefox, Thunderbird and The
    Mozilla App Suite as Products, among others.
    """

    export_as_webservice_entry('project')

    drivers = Attribute(
        "Presents the drivers of this project as a list. A list is "
        "required because there might be a project driver and also a "
        "driver appointed in the overarching project group.")


# Fix cyclic references.
patch_collection_property(IProjectGroup, 'products', IProduct)
patch_reference_property(IProductRelease, 'product', IProduct)


class IProductSet(Interface):
    export_as_webservice_collection(IProduct)

    title = Attribute("The set of Products registered in the Launchpad")

    people = Attribute(
        "The PersonSet, placed here so we can easily render "
        "the list of latest teams to register on the /projects/ page.")

    def get_users_private_products(user):
        """Get users non-public products.

        :param user: Which user are we searching products for.
Exemplo n.º 2
0
            u"this can lead users to mistake an existing bug as the one "
            u"they want to report. This can happen for example for hardware "
            u"related bugs where the one symptom can be caused by "
            u"completely different hardware and drivers."),
        required=False)

    def createBug(bug_params):
        """Create a new bug on this target.

        bug_params is an instance of `CreateBugParams`.
        """


# We assign the schema for an `IBugTask` attribute here
# in order to avoid circular dependencies.
patch_reference_property(IBugTask, 'target', IBugTarget)
patch_plain_parameter_type(IBugTask, 'transitionToTarget', 'target',
                           IBugTarget)


class IHasOfficialBugTags(Interface):
    """An entity that exposes a set of official bug tags."""

    official_bug_tags = exported(
        List(title=_("Official Bug Tags"),
             description=_("The list of bug tags defined as official."),
             value_type=Tag(),
             readonly=True))

    def getUsedBugTagsWithOpenCounts(user, tag_limit=0, include_tags=None):
        """Return name and bug count of tags having open bugs.
Exemplo n.º 3
0
    ISearchableByQuestionOwner,
    )
from lp.answers.interfaces.questionmessage import IQuestionMessage
from lp.answers.interfaces.questionsperson import IQuestionsPerson
from lp.answers.interfaces.questionsubscription import IQuestionSubscription
from lp.answers.interfaces.questiontarget import IQuestionTarget
from lp.services.webservice.apihelpers import (
    patch_collection_return_type,
    patch_entry_return_type,
    patch_reference_property,
    )


IQuestionSet.queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['collection_entry_schema'] = IQuestion
patch_entry_return_type(IQuestionSet, 'get', IQuestion)
patch_collection_return_type(
    IQuestionTarget, 'findSimilarQuestions', IQuestion)
patch_collection_return_type(
    IQuestionCollection, 'searchQuestions', IQuestion)
patch_collection_return_type(
    ISearchableByQuestionOwner, 'searchQuestions', IQuestion)
patch_reference_property(IQuestionMessage, 'question', IQuestion)
patch_reference_property(IQuestionSubscription, 'question', IQuestion)
patch_collection_return_type(
    IQuestionsPerson, 'getDirectAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'getTeamAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'searchQuestions', IQuestion)
Exemplo n.º 4
0
    @export_read_operation()
    @operation_for_version('devel')
    def getTags():
        """Return the milestone tags in alphabetical order.

        See above the IMilestone.setTags docstring for an explanation of
        why this is not a property.
        """

    def userCanView(user):
        """True if the given user has access to this product."""


# Avoid circular imports
patch_reference_property(IBugTask, 'milestone', IMilestone)
patch_collection_property(IBugTaskSearchBase, 'milestone', IMilestone)
patch_plain_parameter_type(IBugTask, 'transitionToMilestone', 'new_milestone',
                           IMilestone)


class IMilestoneSet(Interface):
    """An set provides access `IMilestone`s."""
    def __iter__():
        """Return an iterator over all the milestones for a thing."""

    def get(milestoneid):
        """Get a milestone by its id.

        If the milestone with that ID is not found, a
        NotFoundError will be raised.
IBranch['dependent_branches'].value_type.schema = IBranchMergeProposal
IBranch['getSubscription'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = IBranchSubscription
IBranch['landing_candidates'].value_type.schema = IBranchMergeProposal
IBranch['landing_targets'].value_type.schema = IBranchMergeProposal
IBranch['linkBug'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['bug'].schema = IBug
IBranch['linkSpecification'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['spec'].schema = ISpecification
IBranch['product'].schema = IProduct

patch_plain_parameter_type(
    IBranch, 'setTarget', 'project', IProduct)
patch_plain_parameter_type(
    IBranch, 'setTarget', 'source_package', ISourcePackage)
patch_reference_property(IBranch, 'sourcepackage', ISourcePackage)
patch_reference_property(IBranch, 'code_import', ICodeImport)

IBranch['spec_links'].value_type.schema = ISpecificationBranch
IBranch['subscribe'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = IBranchSubscription
IBranch['subscriptions'].value_type.schema = IBranchSubscription
IBranch['unlinkBug'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['bug'].schema = IBug
IBranch['unlinkSpecification'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['spec'].schema = ISpecification

patch_entry_return_type(IBranch, '_createMergeProposal', IBranchMergeProposal)
patch_plain_parameter_type(
    IBranch, '_createMergeProposal', 'target_branch', IBranch)
patch_plain_parameter_type(
Exemplo n.º 6
0
        :param webhook: The webhook to deliver to.
        """


class IWebhookClient(Interface):
    def deliver(self, url, proxy, user_agent, timeout, secret, delivery_id,
                event_type, payload):
        """Deliver a payload to a webhook endpoint.

        Returns a dict of request and response details. The 'request' key
        and one of either 'response' or 'connection_error' are always
        present.

        An exception will be raised if an internal error has occurred that
        cannot be the fault of the remote endpoint. For example, a 404 will
        return a response, and a DNS error returns a connection_error, but
        the proxy being offline will raise an exception.

        The timeout is just given to the underlying requests library, so
        it only provides connect and inter-read timeouts. A reliable
        overall request timeout will require another mechanism.

        If secret is not None, a PubSubHubbub-compatible X-Hub-Signature
        header will be sent using HMAC-SHA1.
        """


patch_collection_property(IWebhook, 'deliveries', IWebhookDeliveryJob)
patch_entry_return_type(IWebhook, 'ping', IWebhookDeliveryJob)
patch_reference_property(IWebhook, 'target', IWebhookTarget)
Exemplo n.º 7
0
                                      as_of="devel")
    date_created = exported(Datetime(title=_('Date subscribed'),
                                     required=True,
                                     readonly=True),
                            as_of="beta")
    subscribed_by = exported(PersonChoice(
        title=_('Subscribed by'),
        required=True,
        vocabulary='ValidPersonOrTeam',
        readonly=True,
        description=_("The person who created this subscription.")),
                             as_of="beta")

    display_subscribed_by = Attribute("`subscribed_by` formatted for display.")

    display_duplicate_subscribed_by = Attribute(
        "duplicate bug `subscribed_by` formatted for display.")

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("beta")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the bug?"""


# In order to avoid circular dependencies, we only import
# IBug (which itself imports IBugSubscription) here, and assign it as
# the value type for the `bug` reference.
from lp.bugs.interfaces.bug import IBug
patch_reference_property(IBugSubscription, 'bug', IBug)
Exemplo n.º 8
0
            value_type=Reference(schema=IBugTrackerComponent)))
    bug_tracker = exported(
        Reference(title=_('BugTracker'), schema=IBugTracker))

    @operation_parameters(
        component_name=TextLine(
            title=u"The name of the remote software component to be added",
            required=True))
    @export_write_operation()
    def addComponent(component_name):
        """Adds a component to be tracked as part of this component group"""


# Patch in a mutual reference between IBugTrackerComponent and
# IBugTrackerComponentGroup.
patch_reference_property(
    IBugTrackerComponent, "component_group", IBugTrackerComponentGroup)


class IHasExternalBugTracker(Interface):
    """An object that can have an external bugtracker specified."""

    def getExternalBugTracker():
        """Return the external bug tracker used by this bug tracker.

        If the product uses Launchpad, return None.

        If the product doesn't have a bug tracker specified, return the
        project bug tracker instead. If the product doesn't belong to a
        superproject, or if the superproject doesn't have a bug tracker,
        return None.
        """
Exemplo n.º 9
0
            ),
        as_of="devel")
    date_created = exported(
        Datetime(title=_('Date subscribed'), required=True, readonly=True),
        as_of="beta")
    subscribed_by = exported(
        PersonChoice(
            title=_('Subscribed by'), required=True,
            vocabulary='ValidPersonOrTeam', readonly=True,
            description=_("The person who created this subscription.")),
        as_of="beta")

    display_subscribed_by = Attribute(
        "`subscribed_by` formatted for display.")

    display_duplicate_subscribed_by = Attribute(
        "duplicate bug `subscribed_by` formatted for display.")

    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version("beta")
    def canBeUnsubscribedByUser(user):
        """Can the user unsubscribe the subscriber from the bug?"""


# In order to avoid circular dependencies, we only import
# IBug (which itself imports IBugSubscription) here, and assign it as
# the value type for the `bug` reference.
from lp.bugs.interfaces.bug import IBug
patch_reference_property(IBugSubscription, 'bug', IBug)
Exemplo n.º 10
0
                    "message."),
            value_type=Reference(Interface)),
        exported_as='bug_attachments')

    def __iter__():
        """Iterate over all the message chunks."""

    @accessor_for(parent)
    @export_read_operation()
    @operation_for_version('beta')
    def getAPIParent():
        """Return None because messages are not threaded over the API."""


# Fix for self-referential schema.
patch_reference_property(IMessage, 'parent', IMessage)


class IMessageSet(Interface):
    """Set of IMessage"""

    def get(rfc822msgid):
        """Return a list of IMessage's with the given rfc822msgid.

        If no such messages exist, raise NotFoundError.
        """

    def fromText(subject, content, owner=None, datecreated=None,
        rfc822msgid=None):
        """Construct a Message from a text string and return it."""
IBranch['linked_bugs'].value_type.schema = IBug
IBranch['dependent_branches'].value_type.schema = IBranchMergeProposal
IBranch['getSubscription'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = IBranchSubscription
IBranch['landing_candidates'].value_type.schema = IBranchMergeProposal
IBranch['landing_targets'].value_type.schema = IBranchMergeProposal
IBranch['linkBug'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['bug'].schema = IBug
IBranch['linkSpecification'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['spec'].schema = ISpecification
IBranch['product'].schema = IProduct

patch_plain_parameter_type(IBranch, 'setTarget', 'project', IProduct)
patch_plain_parameter_type(IBranch, 'setTarget', 'source_package',
                           ISourcePackage)
patch_reference_property(IBranch, 'sourcepackage', ISourcePackage)
patch_reference_property(IBranch, 'code_import', ICodeImport)

IBranch['spec_links'].value_type.schema = ISpecificationBranch
IBranch['subscribe'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = IBranchSubscription
IBranch['subscriptions'].value_type.schema = IBranchSubscription
IBranch['unlinkBug'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['bug'].schema = IBug
IBranch['unlinkSpecification'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['spec'].schema = ISpecification

patch_entry_return_type(IBranch, '_createMergeProposal', IBranchMergeProposal)
patch_plain_parameter_type(IBranch, '_createMergeProposal', 'target_branch',
                           IBranch)
patch_plain_parameter_type(IBranch, '_createMergeProposal',
Exemplo n.º 12
0
from lp.answers.interfaces.questioncollection import (
    IQuestionSet,
    ISearchableByQuestionOwner,
    )
from lp.answers.interfaces.questionmessage import IQuestionMessage
from lp.answers.interfaces.questionsperson import IQuestionsPerson
from lp.answers.interfaces.questionsubscription import IQuestionSubscription
from lp.answers.interfaces.questiontarget import IQuestionTarget
from lp.services.webservice.apihelpers import (
    patch_collection_return_type,
    patch_entry_return_type,
    patch_reference_property,
    )


IQuestionSet.queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['collection_entry_schema'] = IQuestion
patch_entry_return_type(IQuestionSet, 'get', IQuestion)
patch_collection_return_type(
    IQuestionTarget, 'findSimilarQuestions', IQuestion)
patch_collection_return_type(
    ISearchableByQuestionOwner, 'searchQuestions', IQuestion)
patch_reference_property(IQuestionMessage, 'question', IQuestion)
patch_reference_property(IQuestionSubscription, 'question', IQuestion)
patch_collection_return_type(
    IQuestionsPerson, 'getDirectAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'getTeamAnswerQuestionTargets', IQuestionTarget)
patch_collection_return_type(
    IQuestionsPerson, 'searchQuestions', IQuestion)
Exemplo n.º 13
0
    ISnapView,
)
from lp.snappy.interfaces.snapbase import (
    ISnapBase,
    ISnapBaseSet,
)
from lp.snappy.interfaces.snapbuild import (
    ISnapBuild,
    ISnapFile,
)
from lp.snappy.interfaces.snappyseries import (
    ISnappySeries,
    ISnappySeriesSet,
)

# ISnapFile
patch_reference_property(ISnapFile, 'snapbuild', ISnapBuild)

# ISnapBuildRequest
patch_reference_property(ISnapBuildRequest, 'snap', ISnap)
patch_collection_property(ISnapBuildRequest, 'builds', ISnapBuild)

# ISnapView
patch_entry_return_type(ISnapView, 'requestBuild', ISnapBuild)
patch_collection_property(ISnapView, 'builds', ISnapBuild)
patch_collection_property(ISnapView, 'completed_builds', ISnapBuild)
patch_collection_property(ISnapView, 'pending_builds', ISnapBuild)

# ISnapEdit
patch_collection_return_type(ISnapEdit, 'requestAutoBuilds', ISnapBuild)
Exemplo n.º 14
0
    def hasReleaseFile(name):
        """Does the release have a file that matches the name?"""


class IProductRelease(IProductReleaseEditRestricted, IProductReleaseView,
                      IProductReleasePublic):
    """A specific release (i.e. version) of a product.

    For example: Mozilla 1.7.2 or Apache 2.0.48.
    """

    export_as_webservice_entry('project_release')


# Set the schema for IProductReleaseFile now that IProductRelease is defined.
patch_reference_property(
    IProductReleaseFile, 'productrelease', IProductRelease)


class IProductReleaseFileAddForm(Interface):
    """Schema for adding ProductReleaseFiles to a project."""
    description = Text(title=_("Description"), required=True,
        description=_('A short description of the file contents'))

    filecontent = Bytes(
        title=u"File", required=True,
        constraint=productrelease_file_size_constraint)

    signature = Bytes(
        title=u"GPG signature (recommended)", required=False,
        constraint=productrelease_signature_size_constraint)
Exemplo n.º 15
0
            # Really IBranchMergeProposal, patched in
            # _schema_circular_imports.py.
            value_type=Reference(schema=Interface),
            readonly=True),
        as_of='devel')

    @accessor_for(linked_merge_proposals)
    @call_with(user=REQUEST_USER)
    @export_read_operation()
    @operation_for_version('devel')
    def getVisibleLinkedMergeProposals(user):
        """Return all the MPs linked to the bug that `user` can see."""


# We are forced to define these now to avoid circular import problems.
patch_reference_property(IBugAttachment, 'bug', IBug)
patch_reference_property(IBugWatch, 'bug', IBug)
patch_collection_property(IMessage, 'bugs', IBug)
patch_collection_property(ICve, 'bugs', IBug)

# In order to avoid circular dependencies, we only import
# IBugSubscription (which itself imports IBug) here, and assign it as
# the value type for the `subscriptions` collection.
from lp.bugs.interfaces.bugsubscription import IBugSubscription
patch_collection_property(IBug, 'subscriptions', IBugSubscription)


class IBugDelta(Interface):
    """The quantitative change made to a bug that was edited."""

    bug = Attribute("The IBug, after it's been edited.")