Files
ubicloud/model/ai/inference_router_target.rb
Jeremy Evans 14a181620c Add ResourceMethods plugin encrypted_columns argument
This DRYs up setting up encrypted columns for a model. You just
need to specify the column or columns to be encrypted, and the
plugin takes care of setting up the column_encryption plugin.

Other advantages:

* Model.redacted_columns is now an attr_reader, and does not
  need to check for encrypted columns every time it is called.

* Model#before_destroy can look at Model.encrypted_columns (also
  an attr_reader), so it is simplified as well. Simplify the
  method while here by using hash key omission, and make sure
  the constant it uses is frozen.
2025-07-09 05:45:18 +09:00

36 lines
1.8 KiB
Ruby

# frozen_string_literal: true
require_relative "../../model"
class InferenceRouterTarget < Sequel::Model
one_to_one :strand, key: :id
many_to_one :inference_router
many_to_one :inference_router_model
plugin ResourceMethods, encrypted_columns: :api_key
plugin SemaphoreMethods, :destroy
end
# Table: inference_router_target
# Columns:
# id | uuid | PRIMARY KEY
# created_at | timestamp with time zone | NOT NULL DEFAULT CURRENT_TIMESTAMP
# updated_at | timestamp with time zone | NOT NULL DEFAULT CURRENT_TIMESTAMP
# name | text | NOT NULL
# host | text | NOT NULL
# api_key | text | NOT NULL
# inflight_limit | integer | NOT NULL
# priority | integer | NOT NULL
# extra_configs | jsonb | NOT NULL DEFAULT '{}'::jsonb
# enabled | boolean | NOT NULL DEFAULT false
# inference_router_model_id | uuid | NOT NULL
# inference_router_id | uuid | NOT NULL
# type | text | NOT NULL DEFAULT 'manual'::text
# config | jsonb | NOT NULL DEFAULT '{}'::jsonb
# state | jsonb | NOT NULL DEFAULT '{}'::jsonb
# Indexes:
# inference_router_target_pkey | PRIMARY KEY btree (id)
# Foreign key constraints:
# inference_router_target_inference_router_id_fkey | (inference_router_id) REFERENCES inference_router(id)
# inference_router_target_inference_router_model_id_fkey | (inference_router_model_id) REFERENCES inference_router_model(id)