std::vector<std::shared_ptr<SimulatorResource> > SimulatorResourceFactory::createResource(
    const std::string &configPath, unsigned int count)
{
    std::vector<std::shared_ptr<SimulatorResource>> resources;

    // Parse the RAML file
    std::shared_ptr<RAML::RamlParser> ramlParser = std::make_shared<RAML::RamlParser>(configPath);
    RAML::RamlPtr raml = ramlParser->getRamlPtr();

    // Get the first resource model from RAML
    RAML::RamlResourcePtr ramlResource;
    if (0 == raml->getResources().size()
        || nullptr == (ramlResource = raml->getResources().begin()->second))
    {
        OIC_LOG(ERROR, TAG, "Zero resources detected from RAML!");
        return resources;
    }

    while (count--)
    {
        std::shared_ptr<SimulatorResource> resource = buildResource(ramlResource);
        if (!resource)
        {
            OIC_LOG(ERROR, TAG, "Failed to create resource!");
            return resources;
        }

        resources.push_back(resource);
    }

    return resources;
}
示例#2
0
unsigned int KeenClient::addEvent(const char *event_collection,
		     const char *event_body)
{
	buildResource(event_collection);
	setAuthorizationHeader(write_key);
	return post(resource, event_body);
}
示例#3
0
void KeenClient::buildResource(const String &event_collection)
{
	buildResource();
	resource += F("/");
	resource += event_collection;

}
示例#4
0
void KeenClient::buildResource(const __FlashStringHelper *event_collection)
{
	buildResource();
	resource += F("/");
	resource += event_collection;

}
std::shared_ptr<SimulatorResource> SimulatorResourceFactory::createResource(
    const std::string &configPath)
{
    // Parse the RAML file
    std::shared_ptr<RAML::RamlParser> ramlParser = std::make_shared<RAML::RamlParser>(configPath);
    RAML::RamlPtr raml = ramlParser->getRamlPtr();

    // Get the first resource model from RAML
    RAML::RamlResourcePtr ramlResource;
    if (0 == raml->getResources().size()
        || nullptr == (ramlResource = raml->getResources().begin()->second))
    {
        OIC_LOG(ERROR, TAG, "Zero resources detected from RAML!");
        return nullptr;
    }

    return buildResource(ramlResource);
}
示例#6
0
unsigned int KeenClient::addEvents(const char *events)
{
	buildResource();
	setAuthorizationHeader(write_key);
	return post(resource, events);
}