From 23474645befba09d8fb999a9623167ade6e809bf Mon Sep 17 00:00:00 2001 From: Madhusudan Ravi Date: Mon, 9 Nov 2026 21:55:42 -0500 Subject: [PATCH 1/2] feat: enable WAF attributes on gem for vhost prov --- lib/aptible/api/operation.rb | 4 ++++ lib/aptible/api/resource.rb | 1 + lib/aptible/api/vhost.rb | 15 +++++++++++++++ lib/aptible/api/waf_config.rb | 14 ++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 lib/aptible/api/waf_config.rb diff --git a/lib/aptible/api/operation.rb b/lib/aptible/api/operation.rb index cfce4bc..7b93a79 100644 --- a/lib/aptible/api/operation.rb +++ b/lib/aptible/api/operation.rb @@ -57,6 +57,10 @@ class Operation < Resource field :enable_backups field :enable_pitr + # vhost:provision WAF request attributes + field :waf_status_request + field :waf_enabled_rulesets + def user auth = Aptible::Auth::User.new(token: token, headers: headers) auth.find_by_url(links['user'].href) diff --git a/lib/aptible/api/resource.rb b/lib/aptible/api/resource.rb index 867f65d..073e8ab 100644 --- a/lib/aptible/api/resource.rb +++ b/lib/aptible/api/resource.rb @@ -42,6 +42,7 @@ def root_url require 'aptible/api/settings' require 'aptible/api/source' require 'aptible/api/vhost' +require 'aptible/api/waf_config' require 'aptible/api/ssh_portal_connection' require 'aptible/api/stack' require 'aptible/api/stack_layer' diff --git a/lib/aptible/api/vhost.rb b/lib/aptible/api/vhost.rb index dc3416f..bb6a340 100644 --- a/lib/aptible/api/vhost.rb +++ b/lib/aptible/api/vhost.rb @@ -6,6 +6,7 @@ class Vhost < Resource belongs_to :current_setting has_many :operations has_many :settings + has_one :waf_config field :id field :virtual_domain @@ -40,6 +41,20 @@ def account def provisioned? status == 'provisioned' end + + # has_many needs a collection link; none exists until a config does. + def create_waf_config!(params) + params = { token: token }.merge(params) + + link = HyperResource::Link.new( + self, + 'href' => "#{href}/waf_configs" + ) + + link.create( + self.class.normalize_params(params) + ) + end end end end diff --git a/lib/aptible/api/waf_config.rb b/lib/aptible/api/waf_config.rb new file mode 100644 index 0000000..4f0c44e --- /dev/null +++ b/lib/aptible/api/waf_config.rb @@ -0,0 +1,14 @@ +module Aptible + module Api + class WafConfig < Resource + belongs_to :vhost + + field :id + field :status + field :enabled_rulesets + field :created_at, type: Time + field :updated_at, type: Time + field :deleted_at, type: Time + end + end +end From 7b8cc0c8e5d7c5f2d93e96ce9a909c7b86992036 Mon Sep 17 00:00:00 2001 From: Madhusudan Ravi Date: Tue, 10 Nov 2026 09:43:14 -0500 Subject: [PATCH 2/2] fix: functioning with link engine, but not really behaving fully as expected --- lib/aptible/api/vhost.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/lib/aptible/api/vhost.rb b/lib/aptible/api/vhost.rb index bb6a340..0cffcfc 100644 --- a/lib/aptible/api/vhost.rb +++ b/lib/aptible/api/vhost.rb @@ -6,7 +6,11 @@ class Vhost < Resource belongs_to :current_setting has_many :operations has_many :settings + + # TODO - is there a better way to allow linking engine to + # enable creation AND retrieval for has_one? has_one :waf_config + has_many :waf_configs field :id field :virtual_domain @@ -41,20 +45,6 @@ def account def provisioned? status == 'provisioned' end - - # has_many needs a collection link; none exists until a config does. - def create_waf_config!(params) - params = { token: token }.merge(params) - - link = HyperResource::Link.new( - self, - 'href' => "#{href}/waf_configs" - ) - - link.create( - self.class.normalize_params(params) - ) - end end end end