Package com.contentful.java.cma
Class ModuleSpaceMemberships
- java.lang.Object
-
- com.contentful.java.cma.ModuleSpaceMemberships
-
public class ModuleSpaceMemberships extends java.lang.ObjectThis module contains all the space membership options available to this SDK.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classModuleSpaceMemberships.AsyncHandler for asynchronous requests.
-
Constructor Summary
Constructors Constructor Description ModuleSpaceMemberships(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create a new membership module.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ModuleSpaceMemberships.Asyncasync()Use all functionalities of this module asynchronously.CMASpaceMembershipcreate(CMASpaceMembership membership)Create a new membership.CMASpaceMembershipcreate(java.lang.String spaceId, CMASpaceMembership membership)Create a new membership.protected ServiceSpaceMembershipscreateService(retrofit2.Retrofit retrofit)Initialize retrofit with the current service.intdelete(CMASpaceMembership membership)Delete the given membership instance.CMAArray<CMASpaceMembership>fetchAll()Fetch all memberships of the configured space.CMAArray<CMASpaceMembership>fetchAll(java.lang.String spaceId)Fetch all memberships of the given space.CMAArray<CMASpaceMembership>fetchAll(java.lang.String spaceId, java.util.Map<java.lang.String,java.lang.String> query)Fetch all memberships of this space.CMAArray<CMASpaceMembership>fetchAll(java.util.Map<java.lang.String,java.lang.String> query)Fetch all memberships of the configured space.CMASpaceMembershipfetchOne(java.lang.String membershipId)Fetches one space membership by its id from Contentful.CMASpaceMembershipfetchOne(java.lang.String spaceId, java.lang.String membershipId)Fetches one space membership by its id from Contentful.CMASpaceMembershipupdate(CMASpaceMembership membership)Update the given membership instance on Contentful.
-
-
-
Constructor Detail
-
ModuleSpaceMemberships
public ModuleSpaceMemberships(retrofit2.Retrofit retrofit, java.util.concurrent.Executor callbackExecutor, java.lang.String spaceId, java.lang.String environmentId, boolean environmentIdConfigured)Create a new membership module.- Parameters:
retrofit- the retrofit instance to be used to create the service.callbackExecutor- to tell on which thread it should run.spaceId- the id of the space to be used if not specified in the module call.environmentId- the id of the environment used, if not specified before.environmentIdConfigured- internal helper to see if environment was set.
-
-
Method Detail
-
createService
protected ServiceSpaceMemberships createService(retrofit2.Retrofit retrofit)
Initialize retrofit with the current service.- Parameters:
retrofit- the instance to use the service with.- Returns:
- a populated instance of the service to be used.
-
async
public ModuleSpaceMemberships.Async async()
Use all functionalities of this module asynchronously.- Returns:
- an asynchronous handling instance.
-
fetchAll
public CMAArray<CMASpaceMembership> fetchAll()
Fetch all memberships of the configured space.- Returns:
- the array of memberships.
- 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<CMASpaceMembership> fetchAll(java.lang.String spaceId)
Fetch all memberships of the given space.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- the space identifier identifying the space.- Returns:
- the array of memberships.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.
-
fetchAll
public CMAArray<CMASpaceMembership> fetchAll(java.util.Map<java.lang.String,java.lang.String> query)
Fetch all memberships of the configured space.- Parameters:
query- define which space memberships to return.- Returns:
- the array of memberships.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
fetchAll
public CMAArray<CMASpaceMembership> fetchAll(java.lang.String spaceId, java.util.Map<java.lang.String,java.lang.String> query)
Fetch all memberships of this space.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- the space identifier identifying the space.query- define which space memberships to return.- Returns:
- the array of memberships.
- Throws:
java.lang.IllegalArgumentException- if spaceId is null.
-
fetchOne
public CMASpaceMembership fetchOne(java.lang.String membershipId)
Fetches one space membership by its id from Contentful.- Parameters:
membershipId- the id of the membership to be found.- Returns:
- null if no membership was found, otherwise the found membership.
- Throws:
java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if membership id is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
fetchOne
public CMASpaceMembership fetchOne(java.lang.String spaceId, java.lang.String membershipId)
Fetches one space membership by its id from Contentful.- Parameters:
spaceId- the space this membership is hosted by.membershipId- the id of the membership to be found.- Returns:
- null if no membership was found, otherwise the found membership.
- Throws:
java.lang.IllegalArgumentException- if space id is null.java.lang.IllegalArgumentException- if membership id is null.
-
create
public CMASpaceMembership create(CMASpaceMembership membership)
Create a new membership.- Parameters:
membership- the new membership to be created.- Returns:
- the newly created membership.
- Throws:
java.lang.IllegalArgumentException- if configured space id is null.java.lang.IllegalArgumentException- if membership is null.CMANotWithEnvironmentsException- if environmentId was set usingCMAClient.Builder.setEnvironmentId(String).- See Also:
CMAClient.Builder.setSpaceId(String)
-
create
public CMASpaceMembership create(java.lang.String spaceId, CMASpaceMembership membership)
Create a new membership.This method will override the configuration specified through
CMAClient.Builder.setSpaceId(String)and will ignoreCMAClient.Builder.setEnvironmentId(String).- Parameters:
spaceId- the space id to host the membership.membership- the new membership to be created.- Returns:
- the newly created membership.
- Throws:
java.lang.IllegalArgumentException- if space id is null.java.lang.IllegalArgumentException- if membership is null.
-
update
public CMASpaceMembership update(CMASpaceMembership membership)
Update the given membership instance on Contentful.Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.
- Parameters:
membership- the membership fetched from Contentful, updated by caller, to be updated.- Returns:
- the updated membership.
- Throws:
java.lang.IllegalArgumentException- if space id is null.java.lang.IllegalArgumentException- if membership is null.java.lang.IllegalArgumentException- if membership id is null.java.lang.IllegalArgumentException- if membership does not have a version attached.
-
delete
public int delete(CMASpaceMembership membership)
Delete the given membership instance.Please make sure that the instance provided is fetched from Contentful. Otherwise you will get an exception thrown.
- Parameters:
membership- the membership fetched from Contentful, updated by caller, to be deleted.- Returns:
- the code of the response (204 means success).
- Throws:
java.lang.IllegalArgumentException- if space id is null.java.lang.IllegalArgumentException- if membership id is null.
-
-