Class ModuleWebhooks
- java.lang.Object
-
- com.contentful.java.cma.ModuleWebhooks
-
public class ModuleWebhooks extends java.lang.ObjectThis module is intended to ease communication with the webhooks module from Contentful.All methods here are available twice: Once synchronously and asynchronously through
async().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModuleWebhooks.AsyncAsync module.
-
Constructor Summary
Constructors Constructor Description ModuleWebhooks(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create this module.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModuleWebhooks.Asyncasync()Use this method if you require asynchronous requests through retrofit.CMAWebhookCallDetailcallDetails(CMAWebhookCall call)Get more information about one specific call to one specific webhook, hosted by one specific space.CMAArray<CMAWebhookCall>calls(CMAWebhook webhook)CMAArray<CMAWebhookCall>calls(CMAWebhook webhook, java.util.Map<java.lang.String,java.lang.String> query)Get more information about a specific webhook.CMAWebhookcreate(CMAWebhook webhook)Create a new webhook.CMAWebhookcreate(java.lang.String spaceId, CMAWebhook webhook)Create a new webhook.protected com.contentful.java.cma.ServiceWebhookscreateService(retrofit2.Retrofit retrofit)Internal method used for creating the service.java.lang.Integerdelete(CMAWebhook webhook)Delete a given Webhook.CMAArray<CMAWebhook>fetchAll()Retrieve all the webhooks defined the configured space.CMAArray<CMAWebhook>fetchAll(java.lang.String spaceId)Retrieve all the webhooks defined for this space.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.CMAArray<CMAWebhook>fetchAll(java.util.Map<java.lang.String,java.lang.String> query)Retrieve specific webhooks matching a query for this space.CMAWebhookfetchOne(java.lang.String webhookId)Retrieve exactly one webhook, whose id you know.CMAWebhookfetchOne(java.lang.String spaceId, java.lang.String webhookId)Retrieve exactly one webhook, whose id you know.CMAWebhookHealthhealth(CMAWebhook webhook)Return a general understanding of the health of the webhook.CMAWebhookupdate(CMAWebhook webhook)Change the content of a webhook.
-
-
-
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- ARetrofitinstance 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(CMAWebhook webhook)
Create a new webhook.This will create a new ID and return the newly created webhook as a return value.
- Parameters:
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 configured space id is null.java.lang.IllegalArgumentException- if webhook is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
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 ignoreCMAClient.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()
Retrieve all the webhooks defined the configured space.- Returns:
- An
CMAArraycontaining all found webhooks for this space. - Throws:
java.lang.IllegalArgumentException- if configured spaceId is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
fetchAll
public CMAArray<CMAWebhook> fetchAll(java.util.Map<java.lang.String,java.lang.String> query)
Retrieve specific webhooks matching a query for this space.- Parameters:
query- Specifying the criteria on which webhooks to return.- Returns:
- An
CMAArraycontaining all found webhooks for this space. - Throws:
java.lang.IllegalArgumentException- if configured spaceId is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
fetchAll
public CMAArray<CMAWebhook> fetchAll(java.lang.String spaceId)
Retrieve all the webhooks defined for this space.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- The id of the space to be asked for all of its spaces.- Returns:
- An
CMAArraycontaining all found webhooks for this space. - Throws:
java.lang.IllegalArgumentException- if spaceId 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 ignoreCMAClient.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
CMAArraycontaining all found webhooks for this space. - Throws:
java.lang.IllegalArgumentException- if spaceId is null.
-
fetchOne
public CMAWebhook fetchOne(java.lang.String webhookId)
Retrieve exactly one webhook, whose id you know.- Parameters:
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 configured spaceId is null.java.lang.IllegalArgumentException- if webhookId is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
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 ignoreCMAClient.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)
-
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.
-
-