org.openstack4j.openstack.internal.MicroVersionedOpenStackService Maven / Gradle / Ivy
package org.openstack4j.openstack.internal;
import com.google.common.base.Function;
import org.openstack4j.api.types.ServiceType;
import org.openstack4j.core.transport.HttpMethod;
import org.openstack4j.model.common.ActionResponse;
/**
* Base class for OpenStack services which use micro-versions.
*
* @author Daniel Gonzalez Nothnagel
*/
public abstract class MicroVersionedOpenStackService extends BaseOpenStackService {
private final MicroVersion microVersion;
protected MicroVersionedOpenStackService(MicroVersion microVersion) {
this.microVersion = microVersion;
}
protected MicroVersionedOpenStackService(ServiceType serviceType, MicroVersion microVersion) {
super(serviceType);
this.microVersion = microVersion;
}
protected MicroVersionedOpenStackService(ServiceType serviceType, MicroVersion microVersion,
Function endpointFunc) {
super(serviceType, endpointFunc);
this.microVersion = microVersion;
}
private MicroVersion getMicroVersion() {
return microVersion;
}
protected abstract String getApiVersionHeader();
@Override
protected Invocation get(Class returnType, String... path) {
return super.get(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation post(Class returnType, String... path) {
return super.post(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation put(Class returnType, String... path) {
return super.put(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation patch(Class returnType, String... path) {
return super.patch(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation delete(Class returnType, String... path) {
return super.delete(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation deleteWithResponse(String... path) {
return super.deleteWithResponse(path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation head(Class returnType, String... path) {
return super.head(returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
@Override
protected Invocation request(HttpMethod method, Class returnType, String path) {
return super.request(method, returnType, path).header(getApiVersionHeader(), getMicroVersion().toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy