heatbridge implementation for openstack-adapter
[so.git] / adapters / mso-openstack-adapters / src / main / java / org / onap / so / heatbridge / openstack / api / OpenstackAccess.java
1 /*-
2  * Copyright (C) 2018 Bell Canada. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.so.heatbridge.openstack.api;
18
19 import org.openstack4j.model.common.Identifier;
20
21 /**
22  * Object handling OpenStack API access information.
23  */
24 public class OpenstackAccess {
25     private final String baseUrl;
26     private final String tenantId;
27     private final String user;
28     private final String password;
29     private final String region;
30     private String domainName;
31     private String projectName;
32
33     public OpenstackAccess(OpenstackAccessBuilder builder) {
34         this.baseUrl = builder.baseUrl;
35         this.tenantId = builder.tenantId;
36         this.user = builder.user;
37         this.password = builder.password;
38         this.region = builder.region;
39         this.domainName = builder.domainName;
40         this.projectName = builder.projectName;
41     }
42
43     public String getUrl() {
44         return baseUrl;
45     }
46
47     public String getTenantId() {
48         return tenantId;
49     }
50
51     public String getUser() {
52         return user;
53     }
54
55     public String getPassword() {
56         return password;
57     }
58
59     public String getRegion() {
60         return region;
61     }
62
63     public Identifier getDomainNameIdentifier() {
64         return Identifier.byName(domainName);
65     }
66
67     public String getProjectName() {
68         return projectName;
69     }
70
71     public static class OpenstackAccessBuilder {
72
73         private String baseUrl;
74         private String tenantId;
75         private String user;
76         private String password;
77         private String region;
78         private String domainName;
79         private String projectName;
80
81         public OpenstackAccessBuilder setBaseUrl(final String baseUrl) {
82             this.baseUrl = baseUrl;
83             return this;
84         }
85
86         public OpenstackAccessBuilder setTenantId(final String tenantId) {
87             this.tenantId = tenantId;
88             return this;
89         }
90
91         public OpenstackAccessBuilder setUser(final String user) {
92             this.user = user;
93             return this;
94         }
95
96         public OpenstackAccessBuilder setPassword(final String password) {
97             this.password = password;
98             return this;
99         }
100
101         public OpenstackAccessBuilder setRegion(final String region) {
102             this.region = region;
103             return this;
104         }
105
106         public OpenstackAccessBuilder setDomainName(final String domainName) {
107             this.domainName = domainName;
108             return this;
109         }
110
111         public OpenstackAccessBuilder setProjectName(final String projectName) {
112             this.projectName = projectName;
113             return this;
114         }
115
116         public OpenstackAccess build() {
117             return new OpenstackAccess(this);
118         }
119     }
120 }