Search in sources :

Example 6 with ConfigurationParser

use of com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationParser in project azure-iot-sdk-java by Azure.

the class Configuration method toConfigurationParser.

/**
 * Converts this into a ConfigurationParser object. To serialize a Configuration object, it must first be converted
 * to a ConfigurationParser object.
 *
 * @return the ConfigurationParser object that can be serialized.
 */
ConfigurationParser toConfigurationParser() {
    // Codes_SRS_SERVICE_SDK_JAVA_CONFIGURATION_28_004: [This method shall return a new instance of a ConfigurationParser
    // object that is populated using the properties of this.]
    ConfigurationParser configurationParser = new ConfigurationParser();
    configurationParser.setId(this.id);
    configurationParser.setSchemaVersion(this.schemaVersion);
    configurationParser.setLabels(this.labels);
    configurationParser.setTargetCondition(this.targetCondition);
    configurationParser.setCreatedTimeUtc(ParserUtility.getDateTimeUtc(this.createdTimeUtc));
    configurationParser.setLastUpdatedTimeUtc(ParserUtility.getDateTimeUtc(this.lastUpdatedTimeUtc));
    configurationParser.setPriority(this.priority);
    configurationParser.setETag(this.etag);
    if (this.content != null) {
        ConfigurationContentParser parser = new ConfigurationContentParser();
        parser.setDeviceContent(this.content.getDeviceContent());
        parser.setModulesContent(this.content.getModulesContent());
        parser.setModuleContent(this.content.getModuleContent());
        configurationParser.setContent(parser);
    }
    if (this.systemMetrics != null) {
        ConfigurationMetricsParser parser = new ConfigurationMetricsParser();
        parser.setQueries(this.systemMetrics.getQueries());
        parser.setResults(this.systemMetrics.getResults());
        configurationParser.setSystemMetrics(parser);
    }
    if (this.metrics != null) {
        ConfigurationMetricsParser parser = new ConfigurationMetricsParser();
        parser.setQueries(this.metrics.getQueries());
        parser.setResults(this.metrics.getResults());
        configurationParser.setMetrics(parser);
    }
    return configurationParser;
}
Also used : ConfigurationParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationParser) ConfigurationMetricsParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser) ConfigurationContentParser(com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser)

Aggregations

ConfigurationParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationParser)6 HttpRequest (com.microsoft.azure.sdk.iot.service.transport.http.HttpRequest)4 HttpResponse (com.microsoft.azure.sdk.iot.service.transport.http.HttpResponse)4 URL (java.net.URL)4 ConfigurationContentParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationContentParser)1 ConfigurationMetricsParser (com.microsoft.azure.sdk.iot.deps.serializer.ConfigurationMetricsParser)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 JsonArray (javax.json.JsonArray)1 JsonObject (javax.json.JsonObject)1 JsonReader (javax.json.JsonReader)1