com.arm.mbed.cloud.sdk.common.AbstractApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mbed-cloud-sdk Show documentation
Show all versions of mbed-cloud-sdk Show documentation
The Pelion Cloud SDK (formerly known as Mbed Cloud SDK) provides a simplified interface to the Pelion Cloud APIs by exposing functionality using conventions and paradigms familiar to Java developers.
package com.arm.mbed.cloud.sdk.common;
import java.util.Map;
import com.arm.mbed.cloud.sdk.annotations.API;
import com.arm.mbed.cloud.sdk.annotations.Internal;
import com.arm.mbed.cloud.sdk.annotations.Preamble;
@Preamble(description = "Generic SDK module definition")
@Internal
public abstract class AbstractApi {
protected final ApiClientWrapper client;
protected final SdkLogger logger;
protected final ApiMetadataCache metadataCache;
/**
* Constructor.
*
* @param options
* connection options @see {@link ConnectionOptions}
*/
public AbstractApi(ConnectionOptions options) {
this(options, null);
}
/**
* Constructor.
*
* @param options
* connection options @see {@link ConnectionOptions}
* @param userAgentExtension
* extension list for the user agent: module name - module version
*/
public AbstractApi(ConnectionOptions options, Map userAgentExtension) {
super();
this.client = new ApiClientWrapper(options, userAgentExtension);
logger = new SdkLogger();
metadataCache = new ApiMetadataCache();
}
protected void checkNotNull(Object arg, String argName) throws MbedCloudException {
clearApiMetadata();
ApiUtils.checkNotNull(logger, arg, argName);
}
protected void checkModelValidity(SdkModel model, String argName) throws MbedCloudException {
clearApiMetadata();
ApiUtils.checkModelValidity(logger, model, argName);
}
/**
* Gets SDK logger.
*
* @see SdkLogger
* @return the logger.
*/
public SdkLogger getLogger() {
return logger;
}
/**
* Gets meta data for the last Arm Mbed Cloud API call.
*
* @see ApiMetadata
* @return metadata
*/
@API
public ApiMetadata getLastApiMetadata() {
return metadataCache.getLastApiMetadata();
}
/**
* Clears API metadata cache.
*
* This is for internal purposes only.
*/
@Internal
public void clearApiMetadata() {
metadataCache.clearMetadata();
}
/**
* Gets the SDK module name.
*
* @return module name.
*/
public abstract String getModuleName();
}