Interface EnvironmentService

  • All Known Implementing Classes:
    EnvironmentServiceImpl

    public interface EnvironmentService
    Provides services and functionality around Environments. All objects returned/inputted are immutable.
    • Method Detail

      • getEnvironmentsForDeploymentProject

        @NotNull
        @NotNull List<Environment> getEnvironmentsForDeploymentProject​(long deploymentProjectId)
        Get all environments for a particular deployment project. Does not validate deployment project actually exists.
        Parameters:
        deploymentProjectId - of the deployment project to get environments for
        Returns:
        List of environments for a single deployment project. Sorted by position, name.
      • getEnvironmentStubsForDeploymentProject

        @NotNull
        @NotNull List<EnvironmentStub> getEnvironmentStubsForDeploymentProject​(long deploymentProjectId)
        Get all environment stubs for a particular deployment project. Does not validate deployment project actually exists. Returns minimum data set required for rendering on deployment project pages.
        Parameters:
        deploymentProjectId - of the deployment project to get environments for
        Returns:
        List of environments for a single deployment project. Sorted by position, name.
      • getPaginatedEnvironmentsForDeploymentProject

        @NotNull
        @NotNull PaginatedEnvironmentsForDashboard getPaginatedEnvironmentsForDeploymentProject​(long deploymentProjectId,
                                                                                                int start,
                                                                                                int limit,
                                                                                                @Nullable
                                                                                                @Nullable String filter)
        Get paginated environments for a particular deployment project ordered by position. Does not validate deployment project actually exists. Filtering requires at least one character. If filter is null or empty then no filtering.
        Parameters:
        deploymentProjectId - of the deployment project to get environments for
        start - start by index
        limit - return no more entries than limit
        filter - filter
        Returns:
        List of environments for a single deployment project. Sorted by position.
        See Also:
        InternalEnvironment.getPosition()
      • getEnvironmentsMatchingCapabilities

        @Deprecated
        @NotNull
        @NotNull PaginatedEnvironmentsForExecutablesView getEnvironmentsMatchingCapabilities​(int start,
                                                                                             int limit,
                                                                                             @Nullable
                                                                                             @Nullable String filter,
                                                                                             @NotNull
                                                                                             @NotNull ReadOnlyCapabilitySet agentCapabilities)
        Deprecated.
        9.2, the method does not take into account the agent's assignments, use getEnvironmentsMatchingCapabilities(int, int, String, ReadOnlyCapabilitySet, Iterable) instead
        Provide a paginated list of minimal information about deployment environments matching agent capabilities.
        Parameters:
        start - start by index
        limit - return no more entries than limit
        filter - filter
        agentCapabilities - capabilities of an agent
        Returns:
        List of ids and name of deployment projects and environments, sorted alphabetically by deployment name and environment position;
      • getEnvironmentsMatchingCapabilities

        @NotNull
        @NotNull PaginatedEnvironmentsForExecutablesView getEnvironmentsMatchingCapabilities​(int start,
                                                                                             int limit,
                                                                                             @Nullable
                                                                                             @Nullable String filter,
                                                                                             @NotNull
                                                                                             @NotNull ReadOnlyCapabilitySet agentCapabilities,
                                                                                             @NotNull
                                                                                             @NotNull Iterable<AgentAssignmentService.AgentAssignmentExecutor> agentAssignmentExecutors)
        Provide a paginated list of minimal information about deployment environments matching agent capabilities.
        Parameters:
        start - start by index
        limit - return no more entries than limit
        filter - filter
        agentCapabilities - capabilities of an agent
        agentAssignmentExecutors - executors of agent assignment
        Returns:
        List of ids and name of deployment projects and environments, sorted alphabetically by deployment name and environment position;
        Since:
        9.2
      • getEnvironment

        @Nullable
        @Nullable Environment getEnvironment​(long environmentId)
                                      throws org.acegisecurity.AccessDeniedException
        Get specific environment by ID.
        Parameters:
        environmentId - ID to search for
        Returns:
        environment with given ID or null if one could not be found.
        Throws:
        org.acegisecurity.AccessDeniedException - when user doesn't have permissions to view environment
      • getEnvironmentUnrestricted

        @Nullable
        @Nullable Environment getEnvironmentUnrestricted​(long environmentId)
        Get specific environment by ID. Does not check permissions.
        Parameters:
        environmentId - ID to search for
        Returns:
        environment with given ID or null if one could not be found.
        Since:
        7.1
      • validateAddEnvironment

        @NotNull
        @NotNull ErrorCollection validateAddEnvironment​(long deploymentProjectId,
                                                        @Nullable
                                                        @Nullable String name,
                                                        @Nullable
                                                        @Nullable String description)
        Validates values to be used for creating a new environment.
        Parameters:
        deploymentProjectId -
        name -
        description -
        Returns:
        errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.
      • addEnvironment

        @NotNull
        default @NotNull Environment addEnvironment​(long deploymentProjectId,
                                                    @Nullable
                                                    @Nullable String name,
                                                    @Nullable
                                                    @Nullable String description)
                                             throws WebValidationException
        Creates a new environment in the specified deployment project.
        Parameters:
        deploymentProjectId - to create environment in
        name - of the environment.
        description - of the environment.
        Throws:
        WebValidationException
      • addEnvironment

        @NotNull
        @NotNull Environment addEnvironment​(long deploymentProjectId,
                                            @Nullable
                                            @Nullable String name,
                                            @Nullable
                                            @Nullable String description,
                                            @Nullable
                                            @Nullable ReleaseApprovalPrerequisite environmentPrerequisites)
                                     throws WebValidationException
        Creates a new environment in the specified deployment project.
        Parameters:
        deploymentProjectId - to create environment in
        name - of the environment.
        description - of the environment.
        environmentPrerequisites - prerequisites needed to be met before launching release is possible
        Throws:
        WebValidationException
        Since:
        9.4
      • cloneEnvironment

        Environment cloneEnvironment​(long deploymentProjectId,
                                     long environmentId,
                                     @Nullable
                                     @Nullable String name,
                                     @Nullable
                                     @Nullable String description)
                              throws WebValidationException
        Create new environment as a clone of existing one
        Parameters:
        environmentId -
        name -
        description -
        Returns:
        Throws:
        WebValidationException - when user has no permission to clone environment with dedicated agents or deployment/environment not found
      • cloneEnvironment

        Environment cloneEnvironment​(long deploymentProjectId,
                                     long environmentId,
                                     @Nullable
                                     @Nullable String name,
                                     @Nullable
                                     @Nullable String description,
                                     @NotNull
                                     @NotNull Map<String,​String> oldAndClonedEnvironmentIds)
                              throws WebValidationException
        Create new environment as a clone of existing one and if necessary update triggers' configuration
        Parameters:
        environmentId -
        name -
        description -
        oldAndClonedEnvironmentIds -
        Returns:
        Throws:
        WebValidationException - when user has no permission to clone environment with dedicated agents or deployment/environment not found
      • validateEditEnvironment

        @NotNull
        @NotNull ErrorCollection validateEditEnvironment​(long environmentId,
                                                         @Nullable
                                                         @Nullable String name,
                                                         @Nullable
                                                         @Nullable String description)
        Validates values to be used when editing existing environment.
        Parameters:
        environmentId - environment to edit
        name - of the environment
        description - of the environment
        Returns:
        errorCollection containing any errors found. If no errors, an empty errorCollection will be returned.
      • editEnvironment

        @NotNull
        @NotNull Environment editEnvironment​(long environmentId,
                                             String name,
                                             String description)
                                      throws WebValidationException
        Edit the details of an existing environment
        Parameters:
        environmentId - environment to edit
        name - of the environment
        description - of the environment
        Returns:
        the updated environment
        Throws:
        WebValidationException
      • editEnvironment

        @NotNull
        @NotNull Environment editEnvironment​(long environmentId,
                                             String name,
                                             String description,
                                             @Nullable
                                             @Nullable ReleaseApprovalPrerequisite environmentPrerequisites)
                                      throws WebValidationException
        Edit the details of an existing environment
        Parameters:
        environmentId - environment to edit
        name - of the environment
        description - of the environment
        environmentPrerequisites - prerequisites needed to be met before launching release is possible
        Returns:
        the updated environment
        Throws:
        WebValidationException
        Since:
        9.3
      • updateEnvironmentConfigurationState

        void updateEnvironmentConfigurationState​(long environmentId,
                                                 @NotNull
                                                 @NotNull ConfigurationState configurationState)
        Update the configurationState of this environment
        Parameters:
        environmentId - of environment to update
        configurationState - new configuration state
      • getEnvironmentRequirementSet

        @Nullable
        @Nullable RequirementSet getEnvironmentRequirementSet​(long environmentId)
        Retrieve Agent Requirement set for environment, if environment with id exists.
        Parameters:
        environmentId - of environment
        Returns:
        all requirements this environment has.
      • getAllEnvironments

        @NotNull
        @NotNull Iterable<Environment> getAllEnvironments()
        Retrieve all Environment defined in the system. The result is filtered by environment permissions and sorted by deployment project id and environment position. Environments belonging to inaccessible projects are not currently filtered out, but their operations show them to be inaccessible.
      • getAllEnvironmentsForDashboard

        @NotNull
        @NotNull Collection<Environment> getAllEnvironmentsForDashboard()
        Retrieve all Environment defined in the system. The result is filtered by environment permissions and sorted by deployment project id and environment position. Environments belonging to inaccessible projects are not currently filtered out, but their operations show them to be inaccessible. Some data inside the object may be unavailable.
      • getAllInternalEnvironmentsNoUserContext

        @NotNull
        @NotNull Iterable<InternalEnvironment> getAllInternalEnvironmentsNoUserContext​(int firstResult,
                                                                                       int maxResults)
        Retrieve all Environment defined in the system without filling in operations permitted for the user.
        Since:
        9.1
      • countAll

        long countAll()
      • getPlanRepositoryDefinitionsForEnvironment

        @NotNull
        @NotNull List<PlanRepositoryDefinition> getPlanRepositoryDefinitionsForEnvironment​(@NotNull
                                                                                           @NotNull InternalEnvironment environment)
        Retrieves all repositories used in environment source checkout tasks
        Parameters:
        environment -
        Returns:
      • getEnvironmentRepositoryLinksForRepository

        List<EnvironmentRepositoryLink> getEnvironmentRepositoryLinksForRepository​(long repositoryId)
        Parameters:
        repositoryId - repository id
        Returns:
        list of Source Repository relationships defined for the given repository
      • getEnvironmentsUsingRepositoryDataEntity

        List<Environment> getEnvironmentsUsingRepositoryDataEntity​(long repositoryId)
        TODO 6.0 rename to getEnvironmentsUsingRepository
        Parameters:
        repositoryId - repository id
        Returns:
        list of immutable Environments that use given repository
      • getNotificationSet

        @Nullable
        @Nullable NotificationSet getNotificationSet​(long environmentId)
        Retrieve notification set for environment, if environment with id exists.
        Parameters:
        environmentId - of environment
      • stopAllTriggers

        void stopAllTriggers​(@NotNull
                             @NotNull Environment environment)
        Stop all automatic triggering on InternalEnvironment
        Parameters:
        environment -
      • startAllTriggers

        void startAllTriggers​(@NotNull
                              @NotNull Environment environment)
        Start all automatic triggering on InternalEnvironment
        Parameters:
        environment -
      • stopAllTriggersForDeploymentProject

        void stopAllTriggersForDeploymentProject​(long deploymentProjectId)
        Stop all automatic triggering on every Environment related to a DeploymentProject
        Parameters:
        deploymentProjectId -
      • startAllTriggersForDeploymentProject

        void startAllTriggersForDeploymentProject​(long deploymentProjectId)
        Start all automatic triggering on every Environment related to a DeploymentProject
        Parameters:
        deploymentProjectId -
      • getEnvironmentCount

        int getEnvironmentCount()
        Returns:
        number of all environments
        Since:
        5.3
      • getEnvironmentCountForProject

        int getEnvironmentCountForProject​(DeploymentProject deploymentProject)
        Parameters:
        deploymentProject -
        Returns:
        number of environments defined for project
        Since:
        5.1
      • updatePlanKey

        void updatePlanKey​(long deploymentProjectId,
                           @NotNull
                           @NotNull PlanKey originalPlanKey,
                           @NotNull
                           @NotNull PlanKey newPlanKey)
        Update planKey in Environment related configuration when plan key has changed (ie after moving plan). This method is called by DeploymentProjectService.updatePlanKey(PlanKey, PlanKey) after DeploymentProject has been updated.
        Parameters:
        deploymentProjectId - id of deployment project which environments have to be checked
        originalPlanKey - original PlanKey
        newPlanKey - new PlanKey
        Since:
        5.2
      • resetTriggersForDeployment

        void resetTriggersForDeployment​(long deploymentProjectId)
        Delete and recreate triggers for all environments for this deployment
        Parameters:
        deploymentProjectId -
        Since:
        5.11
      • getEnvironmentDecorator

        Function<Environment,​DecoratedEnvironment> getEnvironmentDecorator()
        Create environment decorator function object. Instances should be used for a single stream operation and should not live long. The function will return null if the user is not allowed to see the corresponding deployment project.
      • findEnvironmentsByRequirementKey

        @NotNull
        @NotNull Set<RequirementDeploymentMapping> findEnvironmentsByRequirementKey​(@NotNull
                                                                                    @NotNull String requirementKey)
        Find environments which rely on requirementKey
        Parameters:
        requirementKey - on which environments rely
        Returns:
        environments or empty set
        Since:
        5.13
      • createImmutableEnvironment

        @NotNull
        @NotNull Environment createImmutableEnvironment​(@NotNull
                                                        @NotNull MutableEnvironment environment)
        Converts mutable environment to immutable.
        Since:
        6.1
      • findEnvironmentByName

        @Nullable
        @Nullable Environment findEnvironmentByName​(long deploymentProjectId,
                                                    String name)
        Find environment with specified name in a deployment project
        Parameters:
        deploymentProjectId -
        name -
        Since:
        6.8
      • createOperationsAwareImmutableEnvironment

        @NotNull
        @NotNull Environment createOperationsAwareImmutableEnvironment​(@NotNull
                                                                       @NotNull MutableEnvironment environment)
        Create operation aware immutable environment
        Since:
        6.8
        See Also:
        Operations
      • updateEnvironmentPrerequisites

        void updateEnvironmentPrerequisites​(long environmentId,
                                            @NotNull
                                            @NotNull ReleaseApprovalPrerequisite releaseApprovalPrerequisite)
        Updates the prerequisites of the environment with requested ID needed to launch the release.
        Parameters:
        environmentId - id of the environment
        releaseApprovalPrerequisite - new prerequisites
        Since:
        9.4
      • moveEnvironment

        ErrorCollection moveEnvironment​(MoveEnvironmentStrategy moveEnvironmentStrategy,
                                        long deploymentProjectId,
                                        long environmentId,
                                        int currentPosition,
                                        Optional<Long> relatedEnvId)
        Move Environment in given deploymentProject with given strategy. relatedEnvId is optional for most cases. It is only required for strategy MoveEnvironmentStrategy.AFTER or MoveEnvironmentStrategy.BEFORE
        Parameters:
        moveEnvironmentStrategy -
        deploymentProjectId -
        environmentId -
        currentPosition -
        relatedEnvId -
        Returns:
        error collection
        Since:
        6.8