Sha256: 3d7963281b4db730ee08d3a0fd013bb5767a5fc50be3590dc9c3757882be2b2d

Contents?: true

Size: 1005 Bytes

Versions: 3

Compression:

Stored size: 1005 Bytes

Contents

class Ey::Core::Client::StorageUser < Ey::Core::Model
  extend Ey::Core::Associations

  identity :id

  attribute :username
  attribute :access_id
  attribute :secret_key
  attribute :provisioned_id

  attribute :created_at, type: :time
  attribute :deleted_at, type: :time

  has_one :storage

  attr_accessor :permissions

  def save!
    requires :storage_id, :username

    params = {
        "url"          => self.collection.url,
        "storage"      => self.storage_id,
        "storage_user" => {
          "username"    => self.username,
          "permissions" => self.permissions
        },
    }

    if new_record?
      self.connection.requests.new(self.connection.create_storage_user(params).body["request"])
    else raise NotImplementedError
    end
  end

  def destroy!
    requires :identity

    params = {
      "id" => self.identity,
    }
    connection.requests.new(connection.destroy_storage_user(params).body["request"])
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ey-core-3.6.6 lib/ey-core/models/storage_user.rb
ey-core-3.4.5 lib/ey-core/models/storage_user.rb
ey-core-3.6.5 lib/ey-core/models/storage_user.rb