summaryrefslogtreecommitdiffstats
path: root/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java
blob: 055a5c4d1966a92ee5fc4af087dd69bb18818f5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.woorea.openstack.heat;

/*
 * Modifications copyright (c) 2017 AT&T Intellectual Property
 */

import com.woorea.openstack.base.client.Entity;
import com.woorea.openstack.base.client.HttpMethod;
import com.woorea.openstack.base.client.OpenStackClient;
import com.woorea.openstack.base.client.OpenStackRequest;
import com.woorea.openstack.heat.model.CreateStackParam;
import com.woorea.openstack.heat.model.UpdateStackParam;
import com.woorea.openstack.heat.model.Stack;
import com.woorea.openstack.heat.model.Stacks;

public class StackResource {

    private final OpenStackClient client;

    public StackResource(OpenStackClient client) {
        this.client = client;
    }

    public CreateStack create(CreateStackParam param) {
        return new CreateStack(param);
    }

    public UpdateStack update(String name, UpdateStackParam param) {
        return new UpdateStack(name, param);
    }

    public List list() {
        return new List();
    }

    public GetStack byName(String name) {
        return new GetStack(name);
    }

    public DeleteStack deleteByName(String name) {
        return new DeleteStack(name);
    }

    public class CreateStack extends OpenStackRequest<Stack> {
        public CreateStack(CreateStackParam params) {
            super(client, HttpMethod.POST, "/stacks", Entity.json(params), Stack.class);
        }
    }

    public class UpdateStack extends OpenStackRequest<Void> {
        public UpdateStack(String name, UpdateStackParam params) {
            super(client, HttpMethod.PUT, "/stacks/" + name, Entity.json(params), Void.class);
        }
    }

    public class DeleteStack extends OpenStackRequest<Void> {
        public DeleteStack(String name) {
            super(client, HttpMethod.DELETE, "/stacks/" + name, null, Void.class);
        }
    }


    public class GetStack extends OpenStackRequest<Stack> {
        public GetStack(String name) {
            super(client, HttpMethod.GET, "/stacks/" + name, null, Stack.class);
        }
    }

    public class List extends OpenStackRequest<Stacks> {
        public List() {
            super(client, HttpMethod.GET, "/stacks", null, Stacks.class);
        }
    }


}