com.aeontronix.enhancedmule.tools.application.api.APIDescriptor Maven / Gradle / Ivy
/*
* Copyright (c) Aeontronix 2020
*/
package com.aeontronix.enhancedmule.tools.application.api;
import com.aeontronix.enhancedmule.tools.anypoint.api.SLATierLimits;
import com.aeontronix.enhancedmule.tools.anypoint.exchange.ExchangeAssetDescriptor;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class APIDescriptor {
private static final Logger logger = LoggerFactory.getLogger(APIDescriptor.class);
private ExchangeAssetDescriptor asset;
private String implementationUrl;
private String consumerUrl;
private Map implementationUrlJson;
private List tags;
private boolean addAutoDiscovery = false;
private String autoDiscoveryFlow = "api-main";
private List policies;
private List accessedBy;
private String label;
private List slaTiers;
private String apiIdProperty;
private boolean injectApiId = true;
public APIDescriptor() {
}
@JsonProperty(defaultValue = "true")
public boolean isInjectApiId() {
return injectApiId;
}
public void setInjectApiId(boolean injectApiId) {
this.injectApiId = injectApiId;
}
public void addPolicy(PolicyDescriptor policy) {
getPolicies().add(policy);
}
@JsonProperty
public synchronized List getPolicies() {
if (policies == null) {
policies = new ArrayList<>();
}
return policies;
}
public void setPolicies(List policies) {
this.policies = policies;
}
@JsonProperty
public List getAccessedBy() {
return accessedBy;
}
public void setAccessedBy(List accessedBy) {
this.accessedBy = accessedBy;
}
public synchronized List getSlaTiers() {
return slaTiers;
}
public synchronized void setSlaTiers(List slaTiers) {
this.slaTiers = slaTiers;
}
public synchronized APIDescriptor addSlaTier(String name, String description, boolean autoApprove, SLATierLimits... limits) {
return addSlaTier(new SLATierDescriptor(name, description, autoApprove, limits));
}
public synchronized APIDescriptor addSlaTier(String name, boolean autoApprove, SLATierLimits... limits) {
return addSlaTier(name, null, autoApprove, limits);
}
public synchronized APIDescriptor addSlaTier(SLATierDescriptor slaTierDescriptor) {
if (slaTiers == null) {
slaTiers = new ArrayList<>();
}
slaTiers.add(slaTierDescriptor);
return this;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public boolean isAddAutoDiscovery() {
return addAutoDiscovery;
}
public void setAddAutoDiscovery(boolean addAutoDiscovery) {
this.addAutoDiscovery = addAutoDiscovery;
}
public String getAutoDiscoveryFlow() {
return autoDiscoveryFlow;
}
public void setAutoDiscoveryFlow(String autoDiscoveryFlow) {
this.autoDiscoveryFlow = autoDiscoveryFlow;
}
public List getTags() {
return tags;
}
public void setTags(List tags) {
this.tags = tags;
}
@JsonProperty
public String getImplementationUrl() {
return implementationUrl;
}
public void setImplementationUrl(String implementationUrl) {
this.implementationUrl = implementationUrl;
}
@JsonProperty
public String getConsumerUrl() {
return consumerUrl;
}
public void setConsumerUrl(String consumerUrl) {
this.consumerUrl = consumerUrl;
}
@JsonProperty
public Map getImplementationUrlJson() {
return implementationUrlJson;
}
public void setImplementationUrlJson(Map implementationUrlJson) {
this.implementationUrlJson = implementationUrlJson;
}
public String getApiIdProperty() {
return apiIdProperty;
}
public void setApiIdProperty(String apiIdProperty) {
this.apiIdProperty = apiIdProperty;
}
@JsonIgnore
public String getAssetVersion() {
return asset != null ? asset.getVersion() : null;
}
@JsonIgnore
public synchronized void setAssetVersion(String version) {
if (asset == null) {
asset = new ExchangeAssetDescriptor();
}
asset.setVersion(version);
}
public ExchangeAssetDescriptor getAsset() {
return asset;
}
public void setAsset(ExchangeAssetDescriptor asset) {
this.asset = asset;
}
}