2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.cloudify.v3.client;
23 import org.openecomp.mso.cloudify.v3.model.CancelExecutionParams;
24 import org.openecomp.mso.cloudify.v3.model.Execution;
25 import org.openecomp.mso.cloudify.v3.model.Executions;
26 import org.openecomp.mso.cloudify.v3.model.StartExecutionParams;
27 import org.openecomp.mso.cloudify.v3.model.UpdateExecutionParams;
28 import org.openecomp.mso.cloudify.base.client.Entity;
29 import org.openecomp.mso.cloudify.base.client.HttpMethod;
30 import org.openecomp.mso.cloudify.base.client.CloudifyClient;
31 import org.openecomp.mso.cloudify.base.client.CloudifyRequest;
33 public class ExecutionsResource {
35 private final CloudifyClient client;
37 public ExecutionsResource(CloudifyClient client) {
41 public ListExecutions list() {
42 return new ListExecutions(null);
45 public ListExecutions listSorted (String sortBy) {
46 return new ListExecutions("?_sort=" + sortBy);
49 // Return a filtered list.
50 // The filter parameter should be a query string of filter criteria (without leading "?")
51 public ListExecutions listFiltered (String filter, String sortBy) {
52 String listParams = "?" + filter;
53 if (sortBy != null) listParams += "&_sort=" + sortBy;
54 return new ListExecutions(listParams);
57 public GetExecution byId(String id) {
58 return new GetExecution(id);
61 public StartExecution start(StartExecutionParams params) {
62 return new StartExecution(params);
65 public UpdateExecution updateStatus(String id, String status) {
66 UpdateExecutionParams params = new UpdateExecutionParams();
67 params.setStatus(status);
68 return new UpdateExecution(id, params);
71 public CancelExecution cancel(String executionId, CancelExecutionParams params) {
72 return new CancelExecution(executionId, params);
76 public class GetExecution extends CloudifyRequest<Execution> {
77 public GetExecution (String id) {
78 super(client, HttpMethod.GET, "/api/v3/executions/" + id, null, Execution.class);
82 public class ListExecutions extends CloudifyRequest<Executions> {
83 public ListExecutions(String listParams) {
84 super(client, HttpMethod.GET, "/api/v3/executions" + ((listParams!=null) ? listParams : ""), null, Executions.class);
88 public class StartExecution extends CloudifyRequest<Execution> {
89 public StartExecution(StartExecutionParams body) {
90 super(client, HttpMethod.POST, "/api/v3/executions", Entity.json(body), Execution.class);
94 public class UpdateExecution extends CloudifyRequest<Execution> {
95 public UpdateExecution(String executionId, UpdateExecutionParams body) {
96 super(client, HttpMethod.PATCH, "/api/v3/executions/" + executionId, Entity.json(body), Execution.class);
100 public class CancelExecution extends CloudifyRequest<Execution> {
101 public CancelExecution(String executionId, CancelExecutionParams body) {
102 super(client, HttpMethod.POST, "/api/v3/executions/" + executionId, Entity.json(body), Execution.class);