com.huawei.openstack4j.openstack.identity.v3.domain.KeystoneService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openstack4j Show documentation
Show all versions of openstack4j Show documentation
Huawei Cloud Open API SDK for Java
/*******************************************************************************
* Copyright 2016 ContainX and OpenStack4j
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*******************************************************************************/
package com.huawei.openstack4j.openstack.identity.v3.domain;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.huawei.openstack4j.model.identity.v3.Endpoint;
import com.huawei.openstack4j.model.identity.v3.Service;
import com.huawei.openstack4j.model.identity.v3.builder.ServiceBuilder;
import com.huawei.openstack4j.openstack.common.ListResult;
import com.google.common.base.MoreObjects;
/**
* V3 OpenStack service
*
*/
@JsonRootName("service")
@JsonIgnoreProperties(ignoreUnknown = true)
public class KeystoneService implements Service, Comparable {
private static final long serialVersionUID = 1L;
private Integer version;
@JsonProperty
private String id;
@JsonProperty
private String name;
@JsonProperty
private String type;
@JsonProperty
private List endpoints;
private String description;
private Boolean enabled;
private Map links;
@Override
public ServiceBuilder toBuilder() {
return new ServiceConcreteBuilder(this);
}
public static ServiceBuilder builder() {
return new ServiceConcreteBuilder();
}
/**
* {@inheritDoc}
*/
@Override
public Integer getVersion() {
return version;
}
/**
* {@inheritDoc}
*/
@Override
public String getId() {
return id;
}
/**
* {@inheritDoc}
*/
@Override
public String getDescription() {
return description;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return type;
}
/**
* {@inheritDoc}
*/
@Override
public List getEndpoints() {
return endpoints;
}
/**
* @return the enabled status of the service
*/
@Override
public boolean isEnabled() {
return enabled != null && enabled;
}
/**
* set service enabled status
*
* @param enabled the new enabled status
*/
@Override
public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public void setEndpoints(List endpoints) {
this.endpoints = endpoints;
}
/**
* {@inheritDoc}
*/
@Override
public Map getLinks() {
return links;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).omitNullValues()
.add("id", id)
.add("name", name)
.add("description", description)
.add("type", type)
.add("version", version)
.add("enabled", enabled)
.add("links", links)
.add("endpoints", endpoints)
.toString();
}
@Override
public int compareTo(Service s) {
return getVersion().compareTo(s.getVersion());
}
public static class Services extends ListResult {
private static final long serialVersionUID = 1L;
@JsonProperty("services")
private List list;
@Override
protected List value() {
return list;
}
}
public static class Catalog extends ListResult {
private static final long serialVersionUID = 1L;
@JsonProperty("catalog")
private List list;
@Override
protected List value() {
return list;
}
}
public static class ServiceConcreteBuilder implements ServiceBuilder {
private KeystoneService model;
ServiceConcreteBuilder() {
this(new KeystoneService());
}
ServiceConcreteBuilder(KeystoneService model) {
this.model = model;
}
@Override
public Service build() {
return model;
}
@Override
public ServiceBuilder from(Service in) {
model = (KeystoneService) in;
return this;
}
@Override
public ServiceBuilder version(Integer version) {
model.version = version;
return this;
}
@Override
public ServiceBuilder id(String id) {
model.id = id;
return this;
}
@Override
public ServiceBuilder description(String description) {
model.description = description;
return this;
}
@Override
public ServiceBuilder type(String type) {
model.type = type;
return this;
}
@Override
public ServiceBuilder name(String name) {
model.name = name;
return this;
}
@Override
public ServiceBuilder enabled(boolean enabled) {
model.enabled = enabled;
return this;
}
@Override
public ServiceBuilder links(Map links) {
model.links = links;
return this;
}
}
}