blob: 259ba55f95d18914076030ae176f52e3f733789b [file] [log] [blame]
Hyunsun Moone0f3e282016-05-13 18:58:35 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
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 */
16package org.onosproject.xosclient.api;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22/**
23 * Object holding OpenStack API access information.
24 */
25// TODO remove this when XOS provides this information
26public class OpenStackAccess {
27
28 private final String endpoint;
29 private final String tenant;
30 private final String user;
31 private final String password;
32
33 /**
34 * Default constructor.
35 *
36 * @param endpoint Keystone endpoint
37 * @param tenant tenant name
38 * @param user user name
39 * @param password password
40 */
41 public OpenStackAccess(String endpoint, String tenant, String user, String password) {
42 this.endpoint = endpoint;
43 this.tenant = tenant;
44 this.user = user;
45 this.password = password;
46 }
47
48 /**
49 * Returns OpenStack API endpoint.
50 *
51 * @return endpoint
52 */
53 public String endpoint() {
54 return this.endpoint;
55 }
56
57 /**
58 * Returns OpenStack tenant name.
59 *
60 * @return tenant name
61 */
62 public String tenant() {
63 return this.tenant;
64 }
65
66 /**
67 * Returns OpenStack user.
68 *
69 * @return user name
70 */
71 public String user() {
72 return this.user;
73 }
74
75 /**
76 * Returns OpenStack password for the user.
77 *
78 * @return password
79 */
80 public String password() {
81 return this.password;
82 }
83
84 @Override
85 public int hashCode() {
86 return Objects.hash(endpoint, tenant, user, password);
87 }
88
89 @Override
90 public boolean equals(Object obj) {
91 if (this == obj) {
92 return true;
93 }
94 if ((obj instanceof OpenStackAccess)) {
95 OpenStackAccess that = (OpenStackAccess) obj;
96 if (Objects.equals(endpoint, that.endpoint) &&
97 Objects.equals(tenant, that.tenant) &&
98 Objects.equals(user, that.user) &&
99 Objects.equals(password, that.password)) {
100 return true;
101 }
102 }
103 return false;
104 }
105
106 @Override
107 public String toString() {
108 return MoreObjects.toStringHelper(getClass())
109 .add("endpoint", endpoint)
110 .add("tenant", tenant)
111 .add("user", user)
112 .add("password", password)
113 .toString();
114 }
115}