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.onap.so.cloudify.v3.client;
23 import org.onap.so.cloudify.v3.model.CancelExecutionParams;
24 import org.onap.so.cloudify.v3.model.Execution;
25 import org.onap.so.cloudify.v3.model.Executions;
26 import org.onap.so.cloudify.v3.model.StartExecutionParams;
27 import org.onap.so.cloudify.v3.model.UpdateExecutionParams;
28 import org.onap.so.cloudify.base.client.Entity;
29 import org.onap.so.cloudify.base.client.HttpMethod;
30 import org.onap.so.cloudify.base.client.CloudifyClient;
31 import org.onap.so.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;
54 listParams += "&_sort=" + sortBy;
55 return new ListExecutions(listParams);
58 public GetExecution byId(String id) {
59 return new GetExecution(id);
62 public StartExecution start(StartExecutionParams params) {
63 return new StartExecution(params);
66 public UpdateExecution updateStatus(String id, String status) {
67 UpdateExecutionParams params = new UpdateExecutionParams();
68 params.setStatus(status);
69 return new UpdateExecution(id, params);
72 public CancelExecution cancel(String executionId, CancelExecutionParams params) {
73 return new CancelExecution(executionId, params);
77 public class GetExecution extends CloudifyRequest<Execution> {
78 public GetExecution(String id) {
79 super(client, HttpMethod.GET, "/api/v3/executions/" + id, null, Execution.class);
83 public class ListExecutions extends CloudifyRequest<Executions> {
84 public ListExecutions(String listParams) {
85 super(client, HttpMethod.GET, "/api/v3/executions" + ((listParams != null) ? listParams : ""), null,
90 public class StartExecution extends CloudifyRequest<Execution> {
91 public StartExecution(StartExecutionParams body) {
92 super(client, HttpMethod.POST, "/api/v3/executions", Entity.json(body), Execution.class);
96 public class UpdateExecution extends CloudifyRequest<Execution> {
97 public UpdateExecution(String executionId, UpdateExecutionParams body) {
98 super(client, HttpMethod.PATCH, "/api/v3/executions/" + executionId, Entity.json(body), Execution.class);
102 public class CancelExecution extends CloudifyRequest<Execution> {
103 public CancelExecution(String executionId, CancelExecutionParams body) {
104 super(client, HttpMethod.POST, "/api/v3/executions/" + executionId, Entity.json(body), Execution.class);