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; }
unsigned int KeenClient::addEvent(const char *event_collection, const char *event_body) { buildResource(event_collection); setAuthorizationHeader(write_key); return post(resource, event_body); }
void KeenClient::buildResource(const String &event_collection) { buildResource(); resource += F("/"); resource += event_collection; }
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); }
unsigned int KeenClient::addEvents(const char *events) { buildResource(); setAuthorizationHeader(write_key); return post(resource, events); }