Class: RMC::ExpressProtects

Inherits:
Object
  • Object
show all
Defined in:
lib/rmc/express_protects.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ ExpressProtects

Returns a new instance of ExpressProtects.



7
8
9
# File 'lib/rmc/express_protects.rb', line 7

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



5
6
7
# File 'lib/rmc/express_protects.rb', line 5

def connection
  @connection
end

Instance Method Details

#create_set(data) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/rmc/express_protects.rb', line 42

def create_set(data)
  response = create_set_async(data)

  # Blocks async task
  response = @connection.wait_for_task(response['taskUri'].split('/').last)

  get_set(response['associatedResource']['resourceUri'].split('/').last)
end

#create_set_async(data) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/rmc/express_protects.rb', line 32

def create_set_async(data)
  @connection.request(
      url: "/backup-sets",
      method: :post,
      payload: {
          backupSet: data
      }
  )
end

#get_set(id) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/rmc/express_protects.rb', line 24

def get_set(id)
  response = @connection.request(
      url: "/backup-sets/#{id}",
  )

  RMC::Item::ExpressProtect.new(@connection, response['backupSet'])
end

#list_sets(query = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rmc/express_protects.rb', line 11

def list_sets(query=nil)
  response = @connection.request(
      url: "/backup-sets#{query ? "?query=\"#{query}\"" : ''}"
  )

  backup_sets = []
  response['backupSets'].each do |_data|
    backup_sets << RMC::Item::ExpressProtect.new(@connection, _data)
  end

  backup_sets
end