class Envoi::Aspera::WatchService::WatchFolder::Subscription

Attributes

attributes[RW]
client[RW]
definition[RW]
snapshots[RW]

Public Class Methods

get_or_create(client, definition, snapshots = { }) click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 133
def self.get_or_create(client, definition, snapshots = { })
  watch_folder_path = definition['path']
  scan_period       = definition['scan_period']
  expire_in         = definition['expire_in']

  subscriptions          = nil
  subscriptions_for_path = client.subscription_find_for_path(path: watch_folder_path, subscriptions: subscriptions)
  subscriptions_for_path.delete_if { |s| s['scan_period']['sec'] != scan_period } if scan_period

  if subscriptions_for_path.empty?
    args_out               = { watch_folder_path: watch_folder_path }
    args_out[:scan_period] = scan_period if scan_period
    args_out[:expire_in]   = expire_in if expire_in
    # Create Subscription
    subscription = client.subscription_create(args_out)
  else
    subscription = subscriptions_for_path.first
  end

  new(subscription, client, definition, snapshots)
end
new(data, client, definition = nil, snapshots = { }) click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 100
def initialize(data, client, definition = nil, snapshots = { })
  @attributes = data
  @client     = client
  @definition = definition
  @snapshots  = {}
end

Public Instance Methods

[](key) click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 111
def [](key)
  attributes[key]
end
id()
Alias for: identifier
identifier() click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 115
def identifier
  attributes['identifier']
end
Also aliased as: id
logger() click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 107
def logger
  client.logger
end
resubscribe() click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 128
def resubscribe
  client.subscription_resubscribe(subscription_id: id)
end
snapshot_create(args = {}) click to toggle source
# File lib/envoi/aspera/watch_service/watch_folder.rb, line 121
def snapshot_create(args = {})
  args_out                   = args.dup
  args_out[:subscription_id] = attributes['identifier']
  snapshot_id                = client.subscription_snapshot_create(args_out)
  snapshots[snapshot_id]     ||= Snapshot.new(self, snapshot_id)
end