1160bee420de448e7d8ac8d91695157751089759
[so.git] / cloudify-client / src / main / java / org / onap / so / cloudify / v3 / client / DeploymentsResource.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.cloudify.v3.client;
22
23 import org.onap.so.cloudify.v3.model.CreateDeploymentParams;
24 import org.onap.so.cloudify.v3.model.Deployment;
25 import org.onap.so.cloudify.v3.model.DeploymentOutputs;
26 import org.onap.so.cloudify.v3.model.Deployments;
27 import org.onap.so.cloudify.base.client.Entity;
28 import org.onap.so.cloudify.base.client.HttpMethod;
29 import org.onap.so.cloudify.base.client.CloudifyClient;
30 import org.onap.so.cloudify.base.client.CloudifyRequest;
31
32 public class DeploymentsResource {
33
34     private final CloudifyClient client;
35
36     public DeploymentsResource(CloudifyClient client) {
37         this.client = client;
38     }
39
40     public CreateDeployment create(String deploymentId, CreateDeploymentParams body) {
41         return new CreateDeployment(deploymentId, body);
42     }
43
44     public ListDeployments list() {
45         return new ListDeployments();
46     }
47
48     public GetDeployment byId(String id) {
49         return new GetDeployment(id);
50     }
51
52     public GetDeploymentOutputs outputsById(String id) {
53         return new GetDeploymentOutputs(id);
54     }
55
56     public DeleteDeployment deleteByName(String name) {
57         return new DeleteDeployment(name);
58     }
59
60     public class CreateDeployment extends CloudifyRequest<Deployment> {
61         public CreateDeployment(String deploymentId, CreateDeploymentParams body) {
62             super(client, HttpMethod.PUT, "/api/v3/deployments/" + deploymentId, Entity.json(body), Deployment.class);
63         }
64     }
65
66     public class DeleteDeployment extends CloudifyRequest<Deployment> {
67         public DeleteDeployment(String deploymentId) {
68             super(client, HttpMethod.DELETE, "/api/v3/deployments/" + deploymentId, null, Deployment.class);
69         }
70     }
71
72     public class GetDeployment extends CloudifyRequest<Deployment> {
73         public GetDeployment(String id) {
74             super(client, HttpMethod.GET, "/api/v3/deployments/" + id, null, Deployment.class);
75         }
76     }
77
78     public class GetDeploymentOutputs extends CloudifyRequest<DeploymentOutputs> {
79         public GetDeploymentOutputs(String id) {
80             super(client, HttpMethod.GET, "/api/v3/deployments/" + id + "/outputs", null, DeploymentOutputs.class);
81         }
82     }
83
84     public class ListDeployments extends CloudifyRequest<Deployments> {
85         public ListDeployments() {
86             super(client, HttpMethod.GET, "/api/v3/deployments", null, Deployments.class);
87        }
88     }
89
90 }