Class TargetController

java.lang.Object
org.craftercms.deployer.impl.rest.TargetController

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

  • Constructor Details

  • Method Details

    • createTarget

      @RequestMapping(value="/create", method=POST) public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget(@Valid @RequestBody @Valid CreateTargetRequest params) throws DeployerException
      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
    • createTargetIfNotExists

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

      @RequestMapping(value="/get/{env}/{site_name}", method=GET) public org.springframework.http.ResponseEntity<Target> getTarget(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank 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(@NotBlank @PathVariable("env") @NotBlank String env, @NotBlank @PathVariable("site_name") @NotBlank String siteName, @RequestParam String token) throws DeployerException, org.craftercms.commons.exceptions.InvalidManagementTokenException, org.craftercms.commons.config.ConfigurationException
      Recreates the underlying OpenSearch 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
      org.craftercms.commons.config.ConfigurationException
    • createTarget

      protected org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget(CreateTargetRequest createRequest, boolean createIfNotExists) throws DeployerException
      Throws:
      DeployerException
    • createResponseHeaders

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

      @ResponseStatus(OK) @PostMapping("/unlock/{env}/{site_name}") public void unlockTarget(@PathVariable("env") String env, @PathVariable("site_name") String siteName, @RequestParam String token) throws TargetNotFoundException, TargetServiceException, org.craftercms.commons.exceptions.InvalidManagementTokenException
      Throws:
      TargetNotFoundException
      TargetServiceException
      org.craftercms.commons.exceptions.InvalidManagementTokenException
    • duplicateTarget

      @ResponseStatus(CREATED) @PostMapping("/duplicate/{env}/{site_name}") public org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> duplicateTarget(@NotEmpty @PathVariable("env") @NotEmpty String env, @PathVariable("site_name") String sourceSiteName, @Valid @RequestBody @Valid DuplicateTargetRequest duplicateTargetRequest) throws TargetServiceException, TargetAlreadyExistsException, TargetNotFoundException
      Throws:
      TargetServiceException
      TargetAlreadyExistsException
      TargetNotFoundException
    • validateToken

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