function is_api_alive($addon_settings) { $DOToken = $addon_settings["digitalocean_token"]; if (empty($DOToken)) { return false; } try { $adapter = new BuzzAdapter($DOToken); $do = new DigitalOceanV2($adapter); $image = $do->image(); $images = $image->getAll(); return true; } catch (Exception $e) { $GFDO = new GFDigitalOcean(); $GFDO->log_debug("Get all images error: " . print_r($e, true)); return false; } }
public function update_entry_meta($key, $entry, $form) { $form_settings = $this->get_form_settings($form); $GFDO = new GFDigitalOcean(); $GFDO->log_debug("Entry meta update: " . print_r($entry, true)); $GFDO->log_debug("Key meta update: " . print_r($key, true)); $GFDO->log_debug("Form meta update: " . print_r($form, true)); if ($key === "droplet_size") { return empty($form_settings["selectDropletSize"]) ? "None chosen" : droplet_size_id_to_size_name($this->get_plugin_settings(), $form_settings["selectDropletSize"]); } else { if ($key === "droplet_id") { return empty($form_settings["droplet_id"]) ? "NO RESPONSE" : $form_settings["droplet_id"]; } else { if ($key === "droplet_name") { return empty($entry[$form_settings["selectDropletName"]]) ? "None chosen" : $entry[$form_settings["selectDropletName"]]; } else { if ($key === "droplet_region") { return empty($form_settings["selectDropletRegion"]) ? "None chosen" : droplet_region_id_to_region_name($this->get_plugin_settings(), $form_settings["selectDropletRegion"]); } else { if ($key === "droplet_image") { return empty($form_settings["selectDropletImage"]) ? "None chosen" : droplet_image_id_to_image_name($this->get_plugin_settings(), $form_settings["selectDropletImage"]); } else { if ($key === "ssh_keys") { return empty($entry["ssh_keys"]) ? "None selected" : $entry["ssh_keys"]; } else { if ($key === "droplet_private_network") { if (empty($form_settings["privateNetworkEnabled"])) { return "No"; } else { if ($form_settings["privateNetworkEnabled"] == 1) { return "Yes"; } else { return "No"; } } } else { if ($key === "droplet_backups") { if (empty($form_settings["backupsEnabled"])) { return "No"; } else { if ($form_settings["backupsEnabled"] == 1) { return "Yes"; } else { return "No"; } } } else { if ($key === "droplet_creation_success") { return empty($form_settings["droplet_creation_success"]) ? "NO RESPONSE" : $form_settings["droplet_creation_success"]; } } } } } } } } } }