Class TargetController


  • @RestController
    @RequestMapping("/api/1/target")
    public class TargetController
    extends Object
    Main controller for target related operations.
    Author:
    avasquez
    • Method Detail

      • createTarget

        @RequestMapping(value="/create",
                        method=POST)
        public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget​(@RequestBody
                                                                                                        Map<String,​Object> params)
                                                                                                 throws DeployerException,
                                                                                                        org.craftercms.commons.validation.ValidationException
        Creates a Deployer Target.
        Parameters:
        params - the body of the request with the template parameters that will be used to create the target. The body must contain at least a env and site_name parameter. Other required parameters depend on the template used.
        Returns:
        the response entity 201 CREATED status
        Throws:
        DeployerException - if an error occurred during target creation
        org.craftercms.commons.validation.ValidationException - if a required parameter is missing
      • createTargetIfNotExists

        @RequestMapping(value="/create_if_not_exists",
                        method=POST)
        public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTargetIfNotExists​(@RequestBody
                                                                                                                   Map<String,​Object> params)
                                                                                                            throws DeployerException,
                                                                                                                   org.craftercms.commons.validation.ValidationException
        Throws:
        DeployerException
        org.craftercms.commons.validation.ValidationException
      • getTarget

        @RequestMapping(value="/get/{env}/{site_name}",
                        method=GET)
        public org.springframework.http.ResponseEntity<Target> getTarget​(@PathVariable("env")
                                                                         String env,
                                                                         @PathVariable("site_name")
                                                                         String siteName)
                                                                  throws DeployerException
        Returns a Target.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the response entity with the target's properties and 200 OK status
        Throws:
        DeployerException - if an error occurred
      • getAllTargets

        @RequestMapping(value="/get-all",
                        method=GET)
        public org.springframework.http.ResponseEntity<List<Target>> getAllTargets()
                                                                            throws DeployerException
        Returns all current Targets
        Returns:
        the response entity with all the properties of the targets and 200 OK status
        Throws:
        DeployerException - if an error occurred
      • deleteTarget

        @RequestMapping(value="/delete/{env}/{site_name}",
                        method=POST)
        public org.springframework.http.ResponseEntity<Void> deleteTarget​(@PathVariable("env")
                                                                          String env,
                                                                          @PathVariable("site_name")
                                                                          String siteName)
                                                                   throws DeployerException
        Deletes the Target with the specified environment and site name.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the response entity with a 204 NO CONTENT status
        Throws:
        DeployerException - if an error occurred
      • deleteTargetIfExists

        @RequestMapping(value="/delete-if-exists/{env}/{site_name}",
                        method=POST)
        public org.springframework.http.ResponseEntity<Void> deleteTargetIfExists​(@PathVariable("env")
                                                                                  String env,
                                                                                  @PathVariable("site_name")
                                                                                  String siteName)
                                                                           throws DeployerException
        Deletes the Target with the specified environment and site name, does nothing if the target is not found.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the response entity with a 204 NO CONTENT status
        Throws:
        DeployerException - if an error occurred
      • deployTarget

        @RequestMapping(value="/deploy/{env}/{site_name}",
                        method=POST)
        public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> deployTarget​(@PathVariable("env")
                                                                                                        String env,
                                                                                                        @PathVariable("site_name")
                                                                                                        String siteName,
                                                                                                        @RequestBody(required=false)
                                                                                                        Map<String,​Object> params)
                                                                                                 throws DeployerException
        Deploys the Target with the specified environment and site name.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        params - any additional parameters that can be used by the DeploymentProcessors, for example reprocess_all_files
        Returns:
        the response entity with a 200 OK status
        Throws:
        DeployerException - if an error occurred
      • deployAllTargets

        @RequestMapping(value="/deploy-all",
                        method=POST)
        public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> deployAllTargets​(@RequestBody(required=false)
                                                                                                            Map<String,​Object> params)
                                                                                                     throws DeployerException
        Deploys all current Targets.
        Parameters:
        params - any additional parameters that can be used by the DeploymentProcessors, for example reprocess_all_files
        Returns:
        the response entity with a 200 OK status
        Throws:
        DeployerException - if an error occurred
      • getPendingDeployments

        @RequestMapping(value="/deployments/get-pending/{env}/{site_name}",
                        method=GET)
        public org.springframework.http.ResponseEntity<Collection<Deployment>> getPendingDeployments​(@PathVariable("env")
                                                                                                     String env,
                                                                                                     @PathVariable("site_name")
                                                                                                     String siteName)
                                                                                              throws DeployerException
        Gets the pending deployments for a target.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the pending deployments for the target
        Throws:
        DeployerException - if an error occurred
      • getCurrentDeployment

        @RequestMapping(value="/deployments/get-current/{env}/{site_name}",
                        method=GET)
        public org.springframework.http.ResponseEntity<Deployment> getCurrentDeployment​(@PathVariable("env")
                                                                                        String env,
                                                                                        @PathVariable("site_name")
                                                                                        String siteName)
                                                                                 throws DeployerException
        Gets the current deployment for a target.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the pending and current deployments for the target
        Throws:
        DeployerException - if an error occurred
      • getAllDeployments

        @RequestMapping(value="/deployments/get-all/{env}/{site_name}",
                        method=GET)
        public org.springframework.http.ResponseEntity<Collection<Deployment>> getAllDeployments​(@PathVariable("env")
                                                                                                 String env,
                                                                                                 @PathVariable("site_name")
                                                                                                 String siteName)
                                                                                          throws DeployerException
        Gets all deployments for a target (pending and current).
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the pending and current deployments for the target
        Throws:
        DeployerException - if an error occurred
      • recreateIndex

        @RequestMapping(value="/recreate/{env}/{site_name}",
                        method=POST)
        public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> recreateIndex​(@PathVariable("env")
                                                                                                         String env,
                                                                                                         @PathVariable("site_name")
                                                                                                         String siteName,
                                                                                                         @RequestParam
                                                                                                         String token)
                                                                                                  throws DeployerException,
                                                                                                         org.craftercms.commons.exceptions.InvalidManagementTokenException
        Recreates the underlying Elasticsearch index for the Target with the specified environment and site name.
        Parameters:
        env - the target's environment
        siteName - the target's site name
        Returns:
        the response entity with a 200 OK status
        Throws:
        DeployerException - if an error occurred
        org.craftercms.commons.exceptions.InvalidManagementTokenException
      • createTarget

        protected org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget​(Map<String,​Object> params,
                                                                                                           boolean createIfNotExists)
                                                                                                    throws org.craftercms.commons.validation.ValidationException,
                                                                                                           DeployerException
        Throws:
        org.craftercms.commons.validation.ValidationException
        DeployerException
      • createResponseHeaders

        protected org.springframework.http.HttpHeaders createResponseHeaders​(String locationUrlTemplate,
                                                                             Object... variables)
      • validateToken

        protected void validateToken​(String token)
                              throws org.craftercms.commons.exceptions.InvalidManagementTokenException
        Throws:
        org.craftercms.commons.exceptions.InvalidManagementTokenException