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 Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final DeploymentServicestatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final TargetServicestatic final String -
Constructor Summary
ConstructorsConstructorDescriptionTargetController(TargetService targetService, DeploymentService deploymentService) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.HttpHeaderscreateResponseHeaders(String locationUrlTemplate, Object... variables) org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget(@Valid CreateTargetRequest params) Creates a DeployerTarget.protected org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTarget(CreateTargetRequest createRequest, boolean createIfNotExists) org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> createTargetIfNotExists(@Valid CreateTargetRequest params) org.springframework.http.ResponseEntity<Void> deleteTarget(@NotBlank String env, @NotBlank String siteName) Deletes theTargetwith the specified environment and site name.org.springframework.http.ResponseEntity<Void> deleteTargetIfExists(@NotBlank String env, @NotBlank String siteName) Deletes theTargetwith the specified environment and site name, does nothing if the target is not found.org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> deployAllTargets(Map<String, Object> params) Deploys all currentTargets.org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> Deploys theTargetwith the specified environment and site name.org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> duplicateTarget(@NotEmpty String env, String sourceSiteName, @Valid DuplicateTargetRequest duplicateTargetRequest) org.springframework.http.ResponseEntity<Collection<Deployment>> getAllDeployments(@NotBlank String env, @NotBlank String siteName) Gets all deployments for a target (pending and current).Returns all currentTargetsorg.springframework.http.ResponseEntity<Deployment> getCurrentDeployment(@NotBlank String env, @NotBlank String siteName) Gets the current deployment for a target.org.springframework.http.ResponseEntity<Collection<Deployment>> getPendingDeployments(@NotBlank String env, @NotBlank String siteName) Gets the pending deployments for a target.org.springframework.http.ResponseEntity<Target> Returns aTarget.org.springframework.http.ResponseEntity<org.craftercms.commons.rest.Result> recreateIndex(@NotBlank String env, @NotBlank String siteName, String token) Recreates the underlying OpenSearch index for theTargetwith the specified environment and site name.voidunlockTarget(String env, String siteName, String token) protected voidvalidateToken(String token)
-
Field Details
-
BASE_URL
- See Also:
-
CREATE_TARGET_URL
- See Also:
-
CREATE_TARGET_IF_NOT_EXISTS_URL
- See Also:
-
DUPLICATE_TARGET_URL
- See Also:
-
GET_TARGET_URL
- See Also:
-
GET_ALL_TARGETS_URL
- See Also:
-
DELETE_TARGET_URL
- See Also:
-
DELETE_IF_EXIST_TARGET_URL
- See Also:
-
DEPLOY_TARGET_URL
- See Also:
-
DEPLOY_ALL_TARGETS_URL
- See Also:
-
GET_PENDING_DEPLOYMENTS_URL
- See Also:
-
GET_CURRENT_DEPLOYMENT_URL
- See Also:
-
GET_ALL_DEPLOYMENTS_URL
- See Also:
-
UNLOCK_TARGET_URL
- See Also:
-
RECREATE_INDEX_URL
- See Also:
-
REPO_URL_PARAM_NAME
- See Also:
-
REPO_BRANCH_PARAM_NAME
- See Also:
-
REPO_USERNAME_PARAM_NAME
- See Also:
-
SSH_PRIVATE_KEY_PATH_PARAM_NAME
- See Also:
-
ENGINE_URL_PARAM_NAME
- See Also:
-
NOTIFICATION_ADDRESSESS_PARAM_NAME
- See Also:
-
targetService
-
deploymentService
-
managementToken
-
-
Constructor Details
-
TargetController
@Autowired public TargetController(TargetService targetService, DeploymentService deploymentService)
-
-
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 DeployerTarget.- 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 aenvandsite_nameparameter. 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 aTarget.- Parameters:
env- the target's environmentsiteName- 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 DeployerExceptionReturns all currentTargets- 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 theTargetwith the specified environment and site name.- Parameters:
env- the target's environmentsiteName- 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 theTargetwith the specified environment and site name, does nothing if the target is not found.- Parameters:
env- the target's environmentsiteName- 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 DeployerExceptionDeploys theTargetwith the specified environment and site name.- Parameters:
env- the target's environmentsiteName- the target's site nameparams- any additional parameters that can be used by theDeploymentProcessors, for examplereprocess_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 DeployerExceptionDeploys all currentTargets.- Parameters:
params- any additional parameters that can be used by theDeploymentProcessors, for examplereprocess_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 environmentsiteName- 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 environmentsiteName- 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 environmentsiteName- 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 theTargetwith the specified environment and site name.- Parameters:
env- the target's environmentsiteName- the target's site name- Returns:
- the response entity with a 200 OK status
- Throws:
DeployerException- if an error occurredorg.craftercms.commons.exceptions.InvalidManagementTokenExceptionorg.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
-
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:
TargetNotFoundExceptionTargetServiceExceptionorg.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 -
validateToken
protected void validateToken(String token) throws org.craftercms.commons.exceptions.InvalidManagementTokenException - Throws:
org.craftercms.commons.exceptions.InvalidManagementTokenException
-