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)
        :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)
    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', 'prerequisite_branch', IBranch)
patch_collection_return_type(
    IBranch, 'getMergeProposals', IBranchMergeProposal)

patch_collection_return_type(
    IBranchSet, 'getMergeProposals', IBranchMergeProposal)

IBranchMergeProposal['getComment'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = ICodeReviewComment
IBranchMergeProposal['createComment'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['parent'].schema = \
        ICodeReviewComment
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',
                           'prerequisite_branch', IBranch)
patch_collection_return_type(IBranch, 'getMergeProposals',
                             IBranchMergeProposal)

patch_collection_return_type(IBranchSet, 'getMergeProposals',
                             IBranchMergeProposal)

IBranchMergeProposal['getComment'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['return_type'].schema = ICodeReviewComment
IBranchMergeProposal['createComment'].queryTaggedValue(
    LAZR_WEBSERVICE_EXPORTED)['params']['parent'].schema = \
        ICodeReviewComment
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)
Exemple #6
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)