integrate enable disable
@@ -43,29 +43,14 @@ func (team *team) ResourceVersions(pipelineName string, resourceName string, pag
}
func (team *team) DisableResourceVersion(pipelineName string, resourceName string, resourceVersionID int) (bool, error) {
- params := rata.Params{
- "pipeline_name": pipelineName,
- "resource_name": resourceName,
- "resource_version_id": strconv.Itoa(resourceVersionID),
- "team_name": team.name,
+ return team.connectionSend(pipelineName, resourceName, resourceVersionID, atc.DisableResourceVersion)
}
- err := team.connection.Send(internal.Request{
- RequestName: atc.DisableResourceVersion,
- Params: params,
- }, nil)
-
- switch err.(type) {
- case nil:
- return true, nil
- case internal.ResourceNotFoundError:
- return false, nil
- default:
- return false, err
- }
+func (team *team) EnableResourceVersion(pipelineName string, resourceName string, resourceVersionID int) (bool, error) {
+ return team.connectionSend(pipelineName, resourceName, resourceVersionID, atc.EnableResourceVersion)
}
-func (team *team) EnableResourceVersion(pipelineName string, resourceName string, resourceVersionID int) (bool, error) {
+func (team *team) connectionSend(pipelineName string, resourceName string, resourceVersionID int, resourceVersionReq string) (bool, error) {
params := rata.Params{
"pipeline_name": pipelineName,
"resource_name": resourceName,
@@ -74,7 +59,7 @@ func (team *team) EnableResourceVersion(pipelineName string, resourceName string
}
err := team.connection.Send(internal.Request{
- RequestName: atc.EnableResourceVersion,
+ RequestName: resourceVersionReq,
Params: params,
}, nil)
