Class ModuleWebhooks


  • public class ModuleWebhooks
    extends java.lang.Object
    This module is intended to ease communication with the webhooks module from Contentful.

    All methods here are available twice: Once synchronously and asynchronously through async().

    • Constructor Detail

      • ModuleWebhooks

        public ModuleWebhooks​(retrofit2.Retrofit retrofit,
                              java.util.concurrent.Executor callbackExecutor,
                              java.lang.String spaceId,
                              java.lang.String environmentId,
                              boolean environmentIdConfigured)
        Create this module.
        Parameters:
        retrofit - the retrofit instance to be used to create the service.
        callbackExecutor - to tell on which thread it should run.
        spaceId - the space to be used when not given.
        environmentId - the environment to be used when not given.
        environmentIdConfigured - internal helper to see if environment was set.
    • Method Detail

      • createService

        protected com.contentful.java.cma.ServiceWebhooks createService​(retrofit2.Retrofit retrofit)
        Internal method used for creating the service.
        Parameters:
        retrofit - A Retrofit instance to create the service from.
        Returns:
        The service, to be used for calls to the backend.
      • async

        public ModuleWebhooks.Async async()
        Use this method if you require asynchronous requests through retrofit.
        Returns:
        An instance of this classes Async representation.
      • create

        public CMAWebhook create​(java.lang.String spaceId,
                                 CMAWebhook webhook)
        Create a new webhook.

        This will create a new ID and return the newly created webhook as a return value.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - Which space should be used?
        webhook - A representation of the Webhook to be used.
        Returns:
        The webhook returned from the backend, containing created its ID and more.
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if webhook is null.
      • delete

        public java.lang.Integer delete​(CMAWebhook webhook)
        Delete a given Webhook.
        Parameters:
        webhook - actual webhook to be deleted.
        Returns:
        the response code of the request (aka 200 if successful)
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if webhookId is null.
      • fetchAll

        public CMAArray<CMAWebhook> fetchAll​(java.lang.String spaceId,
                                             java.util.Map<java.lang.String,​java.lang.String> query)
        Retrieve specific webhooks matching a query for this space.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - The id of the space to be asked for all of its spaces.
        query - Specifying the criteria on which webhooks to return.
        Returns:
        A CMAArray containing all found webhooks for this space.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
      • fetchOne

        public CMAWebhook fetchOne​(java.lang.String spaceId,
                                   java.lang.String webhookId)
        Retrieve exactly one webhook, whose id you know.

        This method will override the configuration specified through CMAClient.Builder.setSpaceId(String) and will ignore CMAClient.Builder.setEnvironmentId(String).

        Parameters:
        spaceId - The id of the space to be hosting this webhook.
        webhookId - The id of the webhook to be returned.
        Returns:
        The webhook found, or null, if no such webhook is available.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if webhookId is null.
      • update

        public CMAWebhook update​(CMAWebhook webhook)
        Change the content of a webhook.

        This will take the webhooks id and update it on the backend.

        Parameters:
        webhook - The webhook retrieved beforehand to be changed.
        Returns:
        The from the backend returned, changed webhook.
        Throws:
        java.lang.IllegalArgumentException - if webhook is null.
        java.lang.IllegalArgumentException - if webhookId is null.
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if version is null.
      • calls

        public CMAArray<CMAWebhookCall> calls​(CMAWebhook webhook,
                                              java.util.Map<java.lang.String,​java.lang.String> query)
        Get more information about a specific webhook.
        Parameters:
        webhook - webhook to be asked for more detail.
        Returns:
        A detailed object for the given webhook.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if webhook is null.
        See Also:
        CMAWebhookCall
      • callDetails

        public CMAWebhookCallDetail callDetails​(CMAWebhookCall call)
        Get more information about one specific call to one specific webhook, hosted by one specific space.
        Parameters:
        call - A call to be get more information about.
        Returns:
        A Call Detail to be used to gather more information about this call.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if webhook is null.
        java.lang.IllegalArgumentException - if callId is null.
      • health

        public CMAWebhookHealth health​(CMAWebhook webhook)
        Return a general understanding of the health of the webhook.
        Parameters:
        webhook - Which webhook should be asked for its health?
        Returns:
        A health indicator summarizing healthy/total calls to the Webhook.
        Throws:
        java.lang.IllegalArgumentException - if spaceId is null.
        java.lang.IllegalArgumentException - if webhook is null.