Commit 29e44561 authored by jan.koester's avatar jan.koester
Browse files

test

parent 9814d756
Loading
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -191,21 +191,27 @@ public:
                    ::uuid::uuid id(gpoid.c_str());

                    try {
                        class Gpo gpo;
                        int ret = -1;

                        // Idempotent: if GPO already exists, just return success
                        if (gpo.exists(_Backend, id, nullptr, ret)) {
                            json_object_object_add(value, id.c_str(), json_object_new_boolean(true));
                        } else {
                            class GpoData gdat(id);
                            gdat.setName(name.c_str());
                            gdat.setDesc(desc.c_str());
                            gdat.setGpoValue(dflt);
                            gdat.setAllowed(members);

                        class Gpo gpo;
                            gpo.create(_Backend, &gdat);

                        int ret = -1;
                            if (gpo.exists(_Backend, id, nullptr, ret)) {
                                json_object_object_add(value, id.c_str(), json_object_new_boolean(true));
                            } else {
                                json_object_object_add(value, id.c_str(), json_object_new_boolean(false));
                            }
                        }
                    } catch (const std::exception &e) {
                        std::cerr << "[api] GPOadd error for '" << name << "': " << e.what() << std::endl;
                        json_object_object_add(value, id.c_str(), json_object_new_boolean(false));