Files
ubicloud/model/location_credential.rb
Jeremy Evans 718370f4c9 Convert ResourceMethods to a plugin
Allow plugin to take an etc_type keyword argument for using the
TYPE_ETC ubid type, and remove the separate definitions in every
model that uses the TYPE_ETC ubid type.

This was the cleanest way to DRY things up.  You cannot extend
the models with a module to do this before including ResourceMethods,
because then ResourceMethods::ClassMethods will override it, and
you cannot extend the models with a module to do this after
including ResourceMethods, because the inclusion will not work
correctly due to the eager definition of @ubid_format.

Best reviewed without whitespace differences.
2025-06-04 04:55:45 +09:00

29 lines
725 B
Ruby

# frozen_string_literal: true
require_relative "../model"
require "aws-sdk-ec2"
class LocationCredential < Sequel::Model
plugin ResourceMethods
many_to_one :project
many_to_one :location, key: :id
plugin :column_encryption do |enc|
enc.column :access_key
enc.column :secret_key
end
def client
Aws::EC2::Client.new(access_key_id: access_key, secret_access_key: secret_key, region: location.name)
end
end
# Table: location_credential
# Columns:
# access_key | text | NOT NULL
# secret_key | text | NOT NULL
# id | uuid | PRIMARY KEY
# Indexes:
# location_credential_pkey | PRIMARY KEY btree (id)
# Foreign key constraints:
# location_credential_id_fkey | (id) REFERENCES location(id)