Skip to content

Commit

Permalink
Add ServiceSizingPolicy (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelaossa committed Sep 6, 2024
1 parent 6851ed1 commit 2eb36f3
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/aptible/api/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Account < Resource
has_many :metric_drains
has_many :vhosts
has_many :backup_retention_policies
has_many :service_sizing_policies
embeds_many :log_drains

field :id
Expand Down
1 change: 1 addition & 0 deletions lib/aptible/api/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def root_url
require 'aptible/api/permission'
require 'aptible/api/release'
require 'aptible/api/service'
require 'aptible/api/service_sizing_policy'
require 'aptible/api/source'
require 'aptible/api/vhost'
require 'aptible/api/ssh_portal_connection'
Expand Down
16 changes: 16 additions & 0 deletions lib/aptible/api/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Service < Resource
has_many :operations
has_many :releases
has_many :disk_attachments
has_one :service_sizing_policy

field :id
field :handle
Expand All @@ -21,6 +22,21 @@ class Service < Resource
field :instance_class
field :created_at, type: Time
field :updated_at, type: Time

def create_service_sizing_policy!(params)
params = { token: token }.merge(params)

# First create a link object so we know where to go
link = HyperResource::Link.new(
self,
'href' => "#{href}/service_sizing_policies"
)

# Now create the policy
link.create(
self.class.normalize_params(params)
)
end
end
end
end
33 changes: 33 additions & 0 deletions lib/aptible/api/service_sizing_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Aptible
module Api
class ServiceSizingPolicy < Resource
belongs_to :account
has_many :services

field :id
field :created_at, type: Time
field :updated_at, type: Time

field :scaling_enabled
field :default_policy
field :metric_lookback_seconds
field :percentile
field :post_scale_up_cooldown_seconds
field :post_scale_down_cooldown_seconds
field :post_release_cooldown_seconds
field :mem_cpu_ratio_r_threshold
field :mem_cpu_ratio_c_threshold
field :mem_scale_up_threshold
field :mem_scale_down_threshold
field :minimum_memory
field :disable_recommendations
field :maximum_memory
field :cpu_consideration_threshold
field :autoscaling
field :min_cpu_threshold
field :max_cpu_threshold
field :min_containers
field :max_containers
end
end
end

0 comments on commit 2eb36f3

Please sign in to comment.