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