Search in sources :

Example 1 with GitHardcodedCredential

use of org.alien4cloud.git.model.GitHardcodedCredential in project alien4cloud by alien4cloud.

the class ApplicationEnvironmentGitController method getByEnvironmentId.

@ApiOperation(value = "Retrieve information about a git repository using environment Id.")
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<GitLocation> getByEnvironmentId(@ApiParam(value = "Application id", required = true) @PathVariable String applicationId, @ApiParam(value = "Environment id", required = true) @PathVariable String environmentId) {
    checkEnvironmentAuthorization(applicationId, environmentId);
    GitLocation gitLocation = gitLocationDao.findDeploymentSetupLocation(applicationId, environmentId);
    if (gitLocation.isLocal()) {
        gitLocation.setUrl(GitLocation.LOCAL_PREFIX);
    }
    gitLocation.setCredential(new GitHardcodedCredential());
    return RestResponseBuilder.<GitLocation>builder().data(gitLocation).build();
}
Also used : GitLocation(org.alien4cloud.git.model.GitLocation) GitHardcodedCredential(org.alien4cloud.git.model.GitHardcodedCredential) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with GitHardcodedCredential

use of org.alien4cloud.git.model.GitHardcodedCredential in project alien4cloud by alien4cloud.

the class ApplicationVariableGitController method getByEnvironmentId.

@ApiOperation(value = "Retrieve information about a git repository using environment Id.")
@RequestMapping(method = RequestMethod.GET)
@PreAuthorize("isAuthenticated()")
public RestResponse<GitLocation> getByEnvironmentId(@ApiParam(value = "Application id", required = true) @PathVariable String applicationId) {
    applicationService.checkAndGetApplication(applicationId, ApplicationRole.APPLICATION_MANAGER);
    GitLocation gitLocation = gitLocationDao.findApplicationVariablesLocation(applicationId);
    if (gitLocation.isLocal()) {
        gitLocation.setUrl(GitLocation.LOCAL_PREFIX);
    }
    gitLocation.setCredential(new GitHardcodedCredential());
    return RestResponseBuilder.<GitLocation>builder().data(gitLocation).build();
}
Also used : GitLocation(org.alien4cloud.git.model.GitLocation) GitHardcodedCredential(org.alien4cloud.git.model.GitHardcodedCredential) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with GitHardcodedCredential

use of org.alien4cloud.git.model.GitHardcodedCredential in project alien4cloud by alien4cloud.

the class ApplicationVariableGitController method updateToCustomGit.

@ApiOperation(value = "Update the remote git repository parameters for storing application variables.")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> updateToCustomGit(@ApiParam(value = "Application id", required = true) @PathVariable String applicationId, @Valid @RequestBody UpdateGitLocationRequest request) {
    applicationService.checkAndGetApplication(applicationId, ApplicationRole.APPLICATION_MANAGER);
    String id = GitLocation.IdBuilder.forApplicationVariables(applicationId);
    GitLocation gitLocation = GitLocation.builder().id(id).gitType(GitType.ApplicationVariables).branch(request.getBranch()).credential(new GitHardcodedCredential(request.getUsername(), request.getPassword())).path(request.getPath()).url(request.getUrl()).build();
    gitLocationService.updateToRemoteGit(gitLocation);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : GitLocation(org.alien4cloud.git.model.GitLocation) GitHardcodedCredential(org.alien4cloud.git.model.GitHardcodedCredential) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with GitHardcodedCredential

use of org.alien4cloud.git.model.GitHardcodedCredential in project alien4cloud by alien4cloud.

the class ApplicationEnvironmentGitController method updateToCustomGit.

@ApiOperation(value = "Update the remote git repository parameters for storing environment deployment config")
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit
public RestResponse<Void> updateToCustomGit(@ApiParam(value = "Application id", required = true) @PathVariable String applicationId, @ApiParam(value = "Environment id", required = true) @PathVariable String environmentId, @Valid @RequestBody UpdateGitLocationRequest request) {
    checkEnvironmentAuthorization(applicationId, environmentId);
    String id = GitLocation.IdBuilder.forDeploymentSetup(applicationId, environmentId);
    GitLocation gitLocation = GitLocation.builder().id(id).gitType(GitLocation.GitType.DeploymentConfig).branch(request.getBranch()).credential(new GitHardcodedCredential(request.getUsername(), request.getPassword())).path(request.getPath()).url(request.getUrl()).build();
    gitLocationService.updateToRemoteGit(gitLocation);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : GitLocation(org.alien4cloud.git.model.GitLocation) GitHardcodedCredential(org.alien4cloud.git.model.GitHardcodedCredential) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)4 GitHardcodedCredential (org.alien4cloud.git.model.GitHardcodedCredential)4 GitLocation (org.alien4cloud.git.model.GitLocation)4 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 Audit (alien4cloud.audit.annotation.Audit)2