Github user minifirocks commented on a diff in the pull request: https://github.com/apache/nifi-minifi-cpp/pull/217#discussion_r156161507 --- Diff: libminifi/src/capi/api.cpp --- @@ -0,0 +1,251 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <string> +#include <map> +#include <memory> +#include <utility> +#include "core/Core.h" +#include "capi/api.h" +#include "capi/expect.h" +#include "capi/Instance.h" +#include "capi/Plan.h" +#include "ResourceClaim.h" + +/** + * Creates a NiFi Instance from the url and output port. + * @param url http URL for NiFi instance + * @param port Remote output port. + */ +nifi_instance *create_instance(char *url, nifi_port *port) { + minifi::setDefaultDirectory(DEFAULT_CONTENT_DIRECTORY); + nifi_instance *instance = new nifi_instance; + + instance->instance_ptr = new minifi::Instance(url, port->pord_id); + instance->port.pord_id = port->pord_id; + + return instance; +} + +/** + * Initializes the instance + */ +void initialize_instance(nifi_instance *instance) { + auto minifi_instance_ref = static_cast<minifi::Instance*>(instance->instance_ptr); + minifi_instance_ref->initialize(instance->port.pord_id); --- End diff -- same as above, we need to init instance just once.
---