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