Class ModuleEnvironments


  • public class ModuleEnvironments
    extends java.lang.Object
    Environments Module.
    • Constructor Detail

      • ModuleEnvironments

        public ModuleEnvironments​(retrofit2.Retrofit retrofit,
                                  java.util.concurrent.Executor callbackExecutor,
                                  java.lang.String spaceId,
                                  java.lang.String environmentId,
                                  boolean environmentIdConfigured)
        Create environments 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.ServiceEnvironments createService​(retrofit2.Retrofit retrofit)
      • create

        public CMAEnvironment create​(java.lang.String spaceId,
                                     CMAEnvironment environment)
        Create an environment using the given space id.

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

        Parameters:
        spaceId - the id of the space to be used
        environment - CMAEnvironment
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if environment is null.
      • clone

        public CMAEnvironment clone​(CMAEnvironment sourceEnvironment,
                                    CMAEnvironment newEnvironment)
        Create an environment based on the content of another environment.

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

        Parameters:
        sourceEnvironment - the environment to be taken as a source of branching
        newEnvironment - the environment to be created, based on the source.
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if sourceEnvironment is null.
        java.lang.IllegalArgumentException - if newEnvironment is null.
        java.lang.IllegalArgumentException - if the space of the source environment is not set.
      • branch

        @Deprecated
        public CMAEnvironment branch​(CMAEnvironment sourceEnvironment,
                                     CMAEnvironment newEnvironment)
        Deprecated.
        This method has been renamed to clone(CMAEnvironment, CMAEnvironment). It will be removed in the next major release.
        Create an environment based on the content of another environment.

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

        Parameters:
        sourceEnvironment - the environment to be taken as a source of branching
        newEnvironment - the environment to be created, based on the source.
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if sourceEnvironment is null.
        java.lang.IllegalArgumentException - if newEnvironment is null.
        java.lang.IllegalArgumentException - if the space of the source environment is not set.
      • delete

        public java.lang.Integer delete​(CMAEnvironment environment)
        Delete an environment.
        Parameters:
        environment - the environment to be deleted
        Returns:
        Integer representing the result (204, or an error code)
        Throws:
        java.lang.IllegalArgumentException - if environment's space id is null.
        java.lang.IllegalArgumentException - if environment's id is null.
        java.lang.IllegalArgumentException - if environment's version is null.
      • fetchAll

        public CMAArray<CMAEnvironment> fetchAll​(java.lang.String spaceId)
        Fetch all environments of the given space.

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

        Parameters:
        spaceId - space ID
        Returns:
        CMAArray result instance
        Throws:
        java.lang.IllegalArgumentException - if environment's space id is null.
      • fetchOne

        public CMAEnvironment fetchOne​(java.lang.String environmentId)
        Fetch an environment with a given environmentId from the configured space.
        Parameters:
        environmentId - environment ID
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if the configured space id is null.
        java.lang.IllegalArgumentException - if environment's id is null.
        See Also:
        CMAClient.Builder.setSpaceId(String)
      • fetchOne

        public CMAEnvironment fetchOne​(java.lang.String spaceId,
                                       java.lang.String environmentId)
        Fetch an environment with a given environmentId and space.

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

        Parameters:
        spaceId - space ID
        environmentId - environment ID
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if space id is null.
        java.lang.IllegalArgumentException - if environment's id is null.
      • update

        public CMAEnvironment update​(CMAEnvironment environment)
        Update an environment.
        Parameters:
        environment - environment
        Returns:
        CMAEnvironment result instance
        Throws:
        java.lang.IllegalArgumentException - if environment is null.
        java.lang.IllegalArgumentException - if environment's name is null.
        java.lang.IllegalArgumentException - if environment's space id is null.
        java.lang.IllegalArgumentException - if environment's environment id is null.
        java.lang.IllegalArgumentException - if environment's version is null.