Skip to content

Commit

Permalink
feat(codebuild): Add stopBuild API in AwsCodeBuildController (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaixiang-AWS authored Feb 5, 2020
1 parent 367bb72 commit d933df4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.amazonaws.services.codebuild.model.BatchGetBuildsRequest;
import com.amazonaws.services.codebuild.model.Build;
import com.amazonaws.services.codebuild.model.StartBuildRequest;
import com.amazonaws.services.codebuild.model.StopBuildRequest;
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -59,6 +60,10 @@ public Build getBuild(String buildId) {
return client.batchGetBuilds(new BatchGetBuildsRequest().withIds(buildId)).getBuilds().get(0);
}

public Build stopBuild(String buildId) {
return client.stopBuild(new StopBuildRequest().withId(buildId)).getBuild();
}

private String getRoleArn(String accountId, String assumeRole) {
String assumeRoleValue = Objects.requireNonNull(assumeRole, "assumeRole");
if (!assumeRoleValue.startsWith("arn:")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ Build startBuild(@PathVariable String account, @RequestBody Map<String, Object>
Build getBuild(@PathVariable String account, @PathVariable String buildId) {
return awsCodeBuildAccountRepository.getAccount(account).getBuild(buildId);
}

@RequestMapping(value = "/builds/stop/{account}/{buildId}", method = RequestMethod.POST)
Build stopBuild(@PathVariable String account, @PathVariable String buildId) {
return awsCodeBuildAccountRepository.getAccount(account).stopBuild(buildId);
}
}

0 comments on commit d933df4

Please sign in to comment.